From 8a0a002cf248f41d2a0ccb33687383eed69f0640 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Mon, 17 Oct 2022 11:08:37 +0800 Subject: [PATCH] import changes from `dev' branch of rmottola/Arctic-Fox: - Bug 1148708: Add missing 'override' annotations in DocAccessibleChild.h. rs=ehsan (d606358545) - Bug 1210408 - make nsMaiInterfaceAction work with proxies, r=tbsaunde (f7c819c6ae) - Bug 1210407 - teach nsMaiInterfaceTable to use proxies, r=tbsaunde (4ca4f10b5f) - bug 1185157 make sure we don't send an event to a destroyed ipc document r=billm (23acf53f75) - bug 1214864 - make SetCarretOffset() async r=davidb (e3079e9b2d) - missing of Bug 1139972 - IPC Proxy for charAt, r=tbsaunde (e9593ed752) - bug 1191598 - Pass MOZ_CURRENT_PROJECT in environment when running post-build automation steps for universal mac builds. r=gps (fc342c6ced) - Bug 1164596 - Add mach android-emulator command; r=ahal (afeb9b27d1) - Bug 1223149 - Add basic usage documentation for mach build; r=glandium (bfb802d175) - Bug 1182301 - Improve 'mach build' notifications. r=gps (2c65a122d1) - Bug 1184696 - Add clobber targets to |mach clobber|; Ability to clobber compiled python files, r=gps (35d8be292e) - Bug 1117958 - Allow any debugging options to the run or gtest mach subcommands to automatically enable debugging. r=gps (32f986af4b) - Bug 1180081 - Properly rebuild gtest/libxul before running gtests. r=gps (80db9a3d49) - Bug 1171647, part 1 - Define a new function to convert the mode to a string. r=njn (61ad16f5ba) - Bug 1171647, part 2 - Remove redundant assertion for dark matter mode. r=njn (b5ac9519f3) - Bug 1058178, part 1 - Implement DMD heap scanning mode. r=njn (60e1079536) - Bug 1058178, part 2 - Implement address clamping analysis for DMD scan logs. r=njn (45c0326b93) - Bug 1102388 - Fix DMD static constructor ordering dependency. r=mccr8 (59b87897a1) - Bug 1128705 - Don't redefine PAGE_SIZE in DMD if it's already defined. r=erahm (49216348ee) - Bug 1179042 - Add a script for analyzing memory blocks using a heap scan DMD log. r=njn DONTBUILD (1c08d2d66e) - Bug 1207245 - part 6 - rename nsRefPtr to RefPtr; r=ehsan; a=Tomcat (1c999d139b) - Bug 1158772 - fix non-idiomatic memset call in nsDeque.cpp; r=erahm (de6b555245) - Bug 1199400 - Part 1: Use CheckedInt when growing nsDeque capacity. r=froydnj (dfdf6814a3) - Bug 1199400 - Part 0: Remove unused nsDequeIterator. r=froydnj (38d69d7f47) - Bug 1199400 - Part 2: Add tests for possible nsDeque corner cases. r=froydnj (931baff195) - Bug 1201997 - Part 1 - Converted compiled test to gtest for nsDeque class. Added tests to test untested methods. r=froydn (e893916651) - Bug 1201997 - Part 2 - Removing unused methods from the nsDeque class. r=froydn (41595a90ac) - Bug 1201997 - Part 3 - Make internally used methods private. r=froydn (8cd3afd96f) - Bug 1201997 - Part 4 - Change size and offset variables to size_t.r=froydn (73eabc8d60) - Bug 1215140 P1 Add an nsIConsoleReportCollector interface to support navigation channel logging. r=bz (8a41535e2b) - Bug 1215140 P2 Make HttpBaseChannel implement nsIConsoleReportCollector. r=bz (75fca301f2) - Bug 1197679 - If nsUnknownDecoder is involved in e10s DivertToParent can break. r=jduell (5d94a12504) - Bug 1178991 - smartptr for http converter r=hurley (8e7fbc8443) - bug 366559 - patch 2, fix nsHTTPCompressConv indentation r=bagder (ba762da587) - bug 366559 - patch 3, fix nsHTTPCompressConv bracing style r=bagder (54195ab451) - bits of bug 366559 - patch 7, content-encoding brotli for http (f0b4051022) - Bug 1205112 - Make PushEvent.data nullable. r=mt,smaug (775db32856) - Bug 1193414 - SharedWorkers thread should be kept alive also when the SharedWorker object is CCed, r=khuey (b77ea8125c) - Bug 1206520: Add about:config prefs to enable throwing on asm.js validation failures; r=bz (c42126665d) - Bug 1193414 - Telemetry for SharedWorker spawning. r=bkelly (77984b7bcc) - Bug 1205676 - Enable WPT service-worker/unregister-then-register-new-script.https.html in e10s, r=nsm (ec24939cf6) - Bug 1193133 - Throw when calling postMessage from a Service Worker dom object with no global. r=bkelly (526dcacfab) - Bug 1181871 P1 Only enforce Cache Context shared data destruction on target thread after init. r=ehsan (cdbf3ed3a8) - Bug 1181871 P2 Fix ServiceWorkerManager usage of stack-based ErrorResult. r=ehsan (c449195d90) - minor cleanup and missing bit of 1198230 (02f459db05) - Bug 1143717 - Implement the ServiceWorkerMessageEvent interface. r=baku (027b3465f2) - fix misspatch (708eee4e84) - Bug 1188545 - Disentangle service workers from shared workers and refactor event dispatching code into a separate class. r=nsm,mrbkap (fb5b5341c9) - Bug 1205228 - Change PackagedAppVerifier to notify the verification result asynchronously. r=valentin. (9edda0fa00) - Bug 1178518 - Packaged App Utils. r=valentin (f60f3b7a93) - Bug 1213150 - Part 1: Add a nsContentUtils::IsNonSubresourceRequest helper; r=jdm (b509cc3cc9) - Bug 1213150 - Part 2: Rework ShouldPrepareForIntercept() in terms of subresource requests; r=jdm (2e92fe8780) - Bug 1213150 - Part 3: Remove nsIInterceptedChannel.isNavigation; r=jdm (becf1cc12f) - Bug 1213150 follow-up: fix build bustage (8d73d6ca73) - Bug 1198394 - Part 1: Allow interception of HSTS upgraded connections in non-e10s mode; r=mcmanus (f504c5be08) - Bug 1198394 - Part 2: Add a test for interception of HSTS upgraded connections; r=jdm (054e984eef) - Bug 1187011 - Don't allow response body with null body status. r=bkelly (b1860741d1) - missing bit of 1140788 (29d319712e) - Bug 1213436 - Reject core dumps with node IDs that don't fit in an IEEE 754 double; r=sfink (3c1f6fdda0) - Bug 1211006 - Add Debugger.Source.prototype.canonicalId; r=ejpbruel (eef7b79fce) - Bug 1199218 - Implement JS::ubi::Node::size for js::LazyScript referents; r=sfink (098a48d240) - Bug 1220031 - Add JS::ubi::Node::scriptFilename; r=sfink (6b824ae680) - Bug 1143575. Remove unused MediaQueue::Empty. r=cpearce (de737f3433) - Bug 1209933 - Make sure all parent runtime pointers are the topmost parent, r=billm. (fe824d967d) - Bug 1197012 - Fix ThrowTypeError in Notification. r=mccr8 (0b1a097526) - Bug 1197893 - Check the number of arguments for ThrowTypeError() and ThrowRangeError() at compile time. r=peterv (d98c7d78a0) - Bug 1142083 - Add test for IDN Unicode domain redirect. r=mcmanus (0c8961fe17) - Bug 1187159 - Add mochitest for loading packaged apps (iframe+fetch+mozapp) r=jduell (ce90ea561b) - Bug 1186290 - Notify TabParent to switch process when loading a signed package. r=honzab, r=kanru. (c58a14554a) - fix (15e2df75eb) - Bug 1206124 P1 Fix "same-origin" CORS credentials in FetchDriver. r=ehsan (fae1bb6ab3) - Bug 1206124 P2 Test fetch() with credentials and redirects. r=ehsan (ffc6254112) - Bug 1211751: Remove nsIChannelEventSink-forwarding from EventSource and FetchDriver. It's never needed. r=smaug (adafe5737a) - Bug 1212433 Fail fetch() calls that require preflight and also redirect. r=sicking a=abillings (c0d6742b9e) - Bug 1193128 - Fix base64 decoding when fetching data URIs. r=baku (80bafa291a) - Bug 1195167 part 1: Let necko handle all protocols. r=bkelly (bb932b0ada) - Bug 1195167 part 2: Remove redundant aCORSFlag argument and instead use mCORSFlagEverSet. r=bkelly (beadafcad0) - Bug 1195167 part 3: Remove more scheme-specific handling from FetchDriver. r=bkelly (d00b38db9e) - Bug 1195167 part 4: Remove FetchDriver::BasicFetch since it is empty. r=bkelly (c5ed097267) - Bug 1210413 P2 Test CORS credentials on cross-origin redirects. r=sicking a=dveditz (b4eeb8aac0) - Bug 1210413 P1 Propagate new channel load flags from child to parent on redirect. r=jduell a=dveditz (8b329af4fa) - Bug 1195167 part 5: Make FetchDriver use AsyncOpen2. r=bkelly (cc217c4cc1) - Bug 1195167 part 6: Some code simplification since necko handles fetch recursion. r=bkelly (f3b6da2262) - Bug 1195167: Followup to fix test which I forgot to change (81e7439a2e) - Bug 1215746: Remove RequestMode::Cors_with_forced_preflight. r=bkelly (0336e812b6) - Bug 1211000: Move CORS preflight logic from nsCORSListenerProxy to nsCORSPreflightListener. r=ehsan (bf2f71cf22) - missing bit of Bug 1211443 - Drop scheduled update if decoder initialization isn't done yet. r=jya (f6bc074e33) - Bug 1182571: Fix nsILoadInfo->GetContentPolicyType API to be less ambigious. Audit and fix all users of it. r=ckerschb (5af6fa7442) - fix (e40c8e7625) - Bug 1173811 - Part 1: Propagate the response URL to intercepted channels when necessary (non-e10s). r=mayhemer,bkelly (26f4f13c28) - Bug 1173811 - Part 2: Propagate the response URL to intercepted channels when necessary (e10s). r=mayhemer,bkelly (a603fe1df2) - Bug 1154309 - Add New Resource Timing Fields r=bz,hurley (1d14eb6bef) - Bug 1175685 - add OriginAttribute to LoadInfo. r=jonas, r=ckerschb, r=michal (a5d18bb637) - Bug 1175685 - add OriginAttribute to LoadInfo. r=jonas, r=ckerschb, r=michal (fb07d2c8aa) - Bug 1212904 P1 Add a LoadTainting enumeration. r=jduell (a1db8a3e99) - Bug 1212904 P2 Add LoadTainting information to nsILoadInfo. r=jduell (2482e5e334) - Bug 1221151 - use [infallible] in nsILoadInfo.idl instead of manual %{C++ blocks; r=jduell (aae73129b6) - Bug 1045891 - CSP 2 child-src implementation r=ckerschb (792920aeb9) - Bug 1219931 - CSP: Don't allow removing a policy (r=sicking) (9daaab4186) - Bug 1208661 - Dump client-side layer textures. r=BenWa (1f2d17d515) --- accessible/atk/AccessibleWrap.cpp | 117 ++ accessible/atk/AccessibleWrap.h | 6 + accessible/atk/nsMaiInterfaceAction.cpp | 91 +- accessible/atk/nsMaiInterfaceTable.cpp | 273 +-- accessible/atk/nsMaiInterfaceText.cpp | 5 +- accessible/base/AccEvent.h | 18 +- accessible/base/AccIterator.cpp | 2 +- accessible/base/AccIterator.h | 2 +- accessible/base/DocManager.cpp | 2 +- accessible/base/EventQueue.cpp | 4 +- accessible/base/EventQueue.h | 2 +- accessible/base/FocusManager.cpp | 10 +- accessible/base/FocusManager.h | 4 +- accessible/base/NotificationController.cpp | 8 +- accessible/base/NotificationController.h | 14 +- accessible/base/SelectionManager.cpp | 8 +- accessible/base/StyleInfo.h | 2 +- accessible/base/TextAttrs.cpp | 4 +- accessible/base/TextRange.h | 6 +- accessible/base/TextUpdater.cpp | 8 +- accessible/base/TextUpdater.h | 10 +- accessible/base/nsAccCache.h | 4 +- accessible/base/nsAccessibilityService.cpp | 26 +- accessible/base/nsAccessiblePivot.cpp | 6 +- accessible/base/nsAccessiblePivot.h | 6 +- accessible/base/nsCoreUtils.cpp | 4 +- accessible/base/nsEventShell.cpp | 2 +- accessible/base/nsEventShell.h | 2 +- accessible/generic/Accessible.cpp | 83 +- accessible/generic/Accessible.h | 4 +- accessible/generic/DocAccessible-inl.h | 4 +- accessible/generic/DocAccessible.cpp | 68 +- accessible/generic/DocAccessible.h | 8 +- accessible/generic/HyperTextAccessible-inl.h | 4 +- accessible/generic/HyperTextAccessible.cpp | 14 +- accessible/generic/RootAccessible.cpp | 12 +- accessible/html/HTMLElementAccessibles.cpp | 2 +- accessible/html/HTMLFormControlAccessible.cpp | 4 +- accessible/html/HTMLImageMapAccessible.cpp | 8 +- accessible/html/HTMLListAccessible.cpp | 6 +- accessible/html/HTMLListAccessible.h | 2 +- accessible/html/HTMLSelectAccessible.cpp | 2 +- accessible/html/HTMLSelectAccessible.h | 2 +- accessible/html/HTMLTableAccessible.cpp | 4 +- accessible/ipc/DocAccessibleChild.cpp | 89 +- accessible/ipc/DocAccessibleChild.h | 42 +- accessible/ipc/PDocAccessible.ipdl | 7 +- accessible/ipc/ProxyAccessible.cpp | 46 +- accessible/ipc/ProxyAccessible.h | 5 +- accessible/windows/ia2/ia2Accessible.cpp | 12 +- .../windows/ia2/ia2AccessibleRelation.h | 4 +- accessible/windows/ia2/ia2AccessibleText.cpp | 3 +- accessible/windows/msaa/AccessibleWrap.cpp | 2 +- accessible/windows/msaa/EnumVariant.h | 2 +- .../windows/msaa/HTMLWin32ObjectAccessible.h | 2 +- accessible/windows/msaa/ServiceProvider.h | 2 +- accessible/windows/sdn/sdnDocAccessible.h | 2 +- accessible/windows/sdn/sdnTextAccessible.cpp | 4 +- accessible/windows/sdn/sdnTextAccessible.h | 2 +- accessible/windows/uia/uiaRawElmProvider.h | 2 +- accessible/xpcom/xpcAccessibleDocument.cpp | 2 +- accessible/xpcom/xpcAccessibleHyperLink.cpp | 2 +- accessible/xpcom/xpcAccessibleHyperText.cpp | 6 +- accessible/xpcom/xpcAccessibleTextRange.cpp | 4 +- accessible/xul/XULElementAccessibles.h | 2 +- accessible/xul/XULTreeAccessible.cpp | 14 +- accessible/xul/XULTreeGridAccessible.cpp | 10 +- b2g/installer/package-manifest.in | 2 + .../migration/nsIEHistoryEnumerator.h | 4 +- browser/installer/package-manifest.in | 2 + caps/BasePrincipal.cpp | 4 +- caps/DomainPolicy.h | 8 +- caps/nsNullPrincipal.cpp | 4 +- caps/nsNullPrincipalURI.cpp | 2 +- caps/nsScriptSecurityManager.cpp | 6 +- chrome/nsChromeProtocolHandler.cpp | 2 +- chrome/nsChromeRegistry.cpp | 10 +- docshell/base/nsAboutRedirector.cpp | 2 +- docshell/base/nsDSURIContentListener.cpp | 4 +- docshell/base/nsDefaultURIFixup.cpp | 4 +- docshell/base/nsDocShell.cpp | 84 +- docshell/base/nsDocShell.h | 10 +- .../base/timeline/AutoGlobalTimelineMarker.h | 2 +- docshell/base/timeline/AutoTimelineMarker.h | 4 +- docshell/base/timeline/ObservedDocShell.h | 4 +- docshell/base/timeline/TimelineConsumers.cpp | 8 +- docshell/base/timeline/TimelineConsumers.h | 4 +- docshell/shistory/src/nsSHEntry.h | 2 +- docshell/shistory/src/nsSHEntryShared.cpp | 4 +- docshell/shistory/src/nsSHistory.cpp | 2 +- dom/activities/Activity.h | 2 +- dom/alarm/AlarmHalService.cpp | 2 +- dom/animation/Animation.cpp | 8 +- dom/animation/Animation.h | 10 +- dom/animation/AnimationTimeline.cpp | 2 +- dom/animation/AnimationTimeline.h | 2 +- dom/animation/DocumentTimeline.cpp | 6 +- dom/animation/KeyframeEffect.cpp | 2 +- dom/animation/KeyframeEffect.h | 2 +- dom/archivereader/ArchiveEvent.cpp | 6 +- dom/archivereader/ArchiveEvent.h | 2 +- dom/archivereader/ArchiveReader.cpp | 16 +- dom/archivereader/ArchiveReader.h | 8 +- dom/archivereader/ArchiveRequest.cpp | 20 +- dom/archivereader/ArchiveRequest.h | 10 +- dom/archivereader/ArchiveZipEvent.cpp | 2 +- dom/archivereader/ArchiveZipFile.cpp | 4 +- dom/archivereader/ArchiveZipFile.h | 2 +- dom/asmjscache/AsmJSCache.cpp | 14 +- dom/audiochannel/AudioChannelAgent.cpp | 6 +- dom/audiochannel/AudioChannelService.cpp | 10 +- dom/base/Attr.cpp | 4 +- dom/base/BarProps.h | 2 +- dom/base/BlobSet.h | 8 +- dom/base/Comment.cpp | 2 +- dom/base/Console.cpp | 30 +- dom/base/Console.h | 2 +- dom/base/ConsoleReportCollector.cpp | 83 + dom/base/ConsoleReportCollector.h | 73 + dom/base/Crypto.h | 2 +- dom/base/DOMError.cpp | 2 +- dom/base/DOMException.cpp | 6 +- dom/base/DOMImplementation.cpp | 4 +- dom/base/DOMMatrix.cpp | 40 +- dom/base/DOMParser.cpp | 4 +- dom/base/DOMPoint.cpp | 4 +- dom/base/DOMQuad.cpp | 6 +- dom/base/DOMQuad.h | 4 +- dom/base/DOMRect.cpp | 4 +- dom/base/DOMRect.h | 2 +- dom/base/DOMRequest.cpp | 8 +- dom/base/DOMRequest.h | 4 +- dom/base/DocumentType.cpp | 4 +- dom/base/Element.cpp | 44 +- dom/base/Element.h | 12 +- dom/base/EventSource.cpp | 133 +- dom/base/EventSource.h | 14 - dom/base/File.cpp | 72 +- dom/base/File.h | 12 +- dom/base/FileIOObject.cpp | 2 +- dom/base/FileIOObject.h | 2 +- dom/base/FileList.h | 2 +- dom/base/FragmentOrElement.cpp | 12 +- dom/base/FragmentOrElement.h | 18 +- dom/base/ImageEncoder.cpp | 14 +- dom/base/ImportManager.cpp | 8 +- dom/base/ImportManager.h | 2 +- dom/base/Link.h | 2 +- dom/base/MultipartBlobImpl.cpp | 14 +- dom/base/MultipartBlobImpl.h | 8 +- dom/base/Navigator.cpp | 44 +- dom/base/Navigator.h | 56 +- dom/base/NodeInfo.cpp | 2 +- dom/base/NodeInfo.h | 2 +- dom/base/PerformanceObserver.cpp | 6 +- dom/base/PerformanceObserver.h | 8 +- dom/base/PerformanceObserverEntryList.cpp | 12 +- dom/base/PerformanceObserverEntryList.h | 10 +- dom/base/PerformanceResourceTiming.cpp | 5 +- dom/base/PerformanceResourceTiming.h | 46 +- dom/base/PostMessageEvent.cpp | 8 +- dom/base/PostMessageEvent.h | 6 +- dom/base/ProcessGlobal.h | 2 +- dom/base/ScreenOrientation.cpp | 9 +- dom/base/ScreenOrientation.h | 6 +- dom/base/ScriptSettings.cpp | 4 +- dom/base/ShadowRoot.h | 10 +- dom/base/StructuredCloneHolder.cpp | 40 +- dom/base/StructuredCloneHolder.h | 12 +- dom/base/SubtleCrypto.cpp | 4 +- dom/base/TextInputProcessor.cpp | 28 +- dom/base/TextInputProcessor.h | 4 +- dom/base/URL.cpp | 8 +- dom/base/URL.h | 2 +- dom/base/URLSearchParams.cpp | 4 +- dom/base/URLSearchParams.h | 2 +- dom/base/WebSocket.cpp | 48 +- dom/base/WindowNamedPropertiesHandler.cpp | 2 +- dom/base/moz.build | 3 + dom/base/nsAttrAndChildArray.cpp | 10 +- dom/base/nsAttrValue.cpp | 4 +- dom/base/nsContentAreaDragDrop.cpp | 4 +- dom/base/nsContentIterator.cpp | 2 +- dom/base/nsContentList.cpp | 4 +- dom/base/nsContentPermissionHelper.cpp | 10 +- dom/base/nsContentPermissionHelper.h | 6 +- dom/base/nsContentPolicy.cpp | 2 +- dom/base/nsContentSink.cpp | 2 +- dom/base/nsContentSink.h | 8 +- dom/base/nsContentUtils.cpp | 39 +- dom/base/nsContentUtils.h | 2 +- dom/base/nsCopySupport.cpp | 4 +- dom/base/nsDOMAttributeMap.cpp | 38 +- dom/base/nsDOMCaretPosition.cpp | 4 +- dom/base/nsDOMClassInfo.cpp | 6 +- dom/base/nsDOMDataChannel.cpp | 6 +- dom/base/nsDOMDataChannel.h | 2 +- dom/base/nsDOMFileReader.cpp | 12 +- dom/base/nsDOMFileReader.h | 2 +- dom/base/nsDOMMutationObserver.cpp | 40 +- dom/base/nsDOMMutationObserver.h | 24 +- dom/base/nsDOMSerializer.h | 2 +- dom/base/nsDOMWindowUtils.cpp | 32 +- dom/base/nsDataDocumentContentPolicy.cpp | 2 +- dom/base/nsDocument.cpp | 170 +- dom/base/nsDocument.h | 44 +- dom/base/nsDocumentEncoder.cpp | 2 +- dom/base/nsFocusManager.cpp | 18 +- dom/base/nsFormData.cpp | 10 +- dom/base/nsFormData.h | 2 +- dom/base/nsFrameLoader.cpp | 52 +- dom/base/nsFrameLoader.h | 12 +- dom/base/nsFrameMessageManager.cpp | 36 +- dom/base/nsFrameMessageManager.h | 2 +- dom/base/nsGenericDOMDataNode.h | 2 +- dom/base/nsGlobalWindow.cpp | 168 +- dom/base/nsGlobalWindow.h | 66 +- dom/base/nsHTMLContentSerializer.cpp | 2 +- dom/base/nsHostObjectProtocolHandler.cpp | 13 +- dom/base/nsHostObjectURI.cpp | 4 +- dom/base/nsIAttribute.h | 2 +- dom/base/nsIConsoleReportCollector.h | 81 + dom/base/nsIDocument.h | 28 +- dom/base/nsIGlobalObject.cpp | 2 +- dom/base/nsINode.cpp | 12 +- dom/base/nsINode.h | 8 +- dom/base/nsImageLoadingContent.cpp | 14 +- dom/base/nsImageLoadingContent.h | 10 +- dom/base/nsInProcessTabChildGlobal.cpp | 10 +- dom/base/nsJSEnvironment.cpp | 14 +- dom/base/nsJSEnvironment.h | 2 +- dom/base/nsJSTimeoutHandler.cpp | 6 +- dom/base/nsLineBreaker.cpp | 4 +- dom/base/nsMimeTypeArray.cpp | 2 +- dom/base/nsMimeTypeArray.h | 4 +- dom/base/nsNameSpaceManager.cpp | 2 +- dom/base/nsNodeInfoManager.cpp | 12 +- dom/base/nsNodeInfoManager.h | 2 +- dom/base/nsNodeUtils.cpp | 2 +- dom/base/nsObjectLoadingContent.cpp | 52 +- dom/base/nsObjectLoadingContent.h | 6 +- dom/base/nsPIDOMWindow.h | 2 +- dom/base/nsPerformance.cpp | 45 +- dom/base/nsPerformance.h | 22 +- dom/base/nsPlainTextSerializer.cpp | 6 +- dom/base/nsPlainTextSerializer.h | 2 +- dom/base/nsPluginArray.cpp | 20 +- dom/base/nsPluginArray.h | 8 +- dom/base/nsRange.cpp | 30 +- dom/base/nsRange.h | 6 +- dom/base/nsReferencedElement.cpp | 2 +- dom/base/nsReferencedElement.h | 8 +- dom/base/nsScreen.cpp | 2 +- dom/base/nsScreen.h | 2 +- dom/base/nsScriptElement.cpp | 4 +- dom/base/nsScriptLoader.cpp | 44 +- dom/base/nsScriptLoader.h | 8 +- dom/base/nsStyleLinkElement.cpp | 2 +- dom/base/nsStyleLinkElement.h | 2 +- dom/base/nsSyncLoadService.cpp | 4 +- dom/base/nsTextNode.cpp | 4 +- dom/base/nsTreeSanitizer.cpp | 8 +- dom/base/nsWindowMemoryReporter.cpp | 4 +- dom/base/nsWindowRoot.cpp | 4 +- dom/base/nsWindowRoot.h | 2 +- dom/base/nsXHTMLContentSerializer.cpp | 4 +- dom/base/nsXMLContentSerializer.cpp | 2 +- dom/base/nsXMLHttpRequest.cpp | 20 +- dom/base/nsXMLHttpRequest.h | 10 +- dom/bindings/BindingUtils.cpp | 6 +- dom/bindings/BindingUtils.h | 16 +- dom/bindings/CallbackObject.cpp | 2 +- dom/bindings/CallbackObject.h | 4 +- dom/bindings/Codegen.py | 42 +- dom/bindings/ErrorResult.h | 31 +- dom/bindings/Errors.msg | 1 + dom/bindings/Exceptions.cpp | 4 +- dom/bindings/StructuredClone.cpp | 2 +- dom/bindings/ToJSValue.cpp | 2 +- dom/bindings/ToJSValue.h | 2 +- dom/bindings/test/TestBindingHeader.h | 58 +- dom/bindings/test/TestInterfaceMaplike.cpp | 2 +- .../test/TestInterfaceMaplikeObject.cpp | 4 +- dom/bindings/test/TestInterfaceSetlike.cpp | 2 +- .../test/TestInterfaceSetlikeNode.cpp | 2 +- .../bluedroid/BluetoothA2dpManager.cpp | 18 +- .../bluedroid/BluetoothA2dpManager.h | 2 +- .../bluedroid/BluetoothAvrcpManager.cpp | 18 +- .../bluedroid/BluetoothAvrcpManager.h | 2 +- .../BluetoothDaemonA2dpInterface.cpp | 6 +- .../BluetoothDaemonAvrcpInterface.cpp | 6 +- .../BluetoothDaemonCoreInterface.cpp | 2 +- .../BluetoothDaemonGattInterface.cpp | 6 +- .../BluetoothDaemonHandsfreeInterface.cpp | 6 +- .../bluedroid/BluetoothDaemonInterface.cpp | 14 +- .../bluedroid/BluetoothDaemonInterface.h | 8 +- .../BluetoothDaemonSetupInterface.cpp | 2 +- .../BluetoothDaemonSocketInterface.cpp | 2 +- .../bluedroid/BluetoothGattManager.cpp | 174 +- .../bluedroid/BluetoothMapFolder.cpp | 2 +- dom/bluetooth/bluedroid/BluetoothMapFolder.h | 2 +- .../bluedroid/BluetoothMapSmsManager.h | 8 +- .../bluedroid/BluetoothOppManager.cpp | 14 +- dom/bluetooth/bluedroid/BluetoothOppManager.h | 10 +- .../bluedroid/BluetoothPbapManager.cpp | 12 +- .../bluedroid/BluetoothPbapManager.h | 4 +- .../bluedroid/BluetoothServiceBluedroid.cpp | 16 +- .../bluedroid/BluetoothServiceBluedroid.h | 12 +- .../bluedroid/BluetoothSocketMessageWatcher.h | 2 +- .../bluedroid/hfp/BluetoothHfpManager.cpp | 22 +- .../bluedroid/hfp/BluetoothHfpManager.h | 2 +- .../bluetooth2/BluetoothHidManager.cpp | 4 +- .../bluetooth2/BluetoothHidManager.h | 2 +- .../bluetooth2/BluetoothRilListener.h | 6 +- dom/bluetooth/bluez/BluetoothA2dpManager.cpp | 4 +- dom/bluetooth/bluez/BluetoothA2dpManager.h | 2 +- dom/bluetooth/bluez/BluetoothAvrcpManager.cpp | 4 +- dom/bluetooth/bluez/BluetoothAvrcpManager.h | 2 +- dom/bluetooth/bluez/BluetoothDBusService.cpp | 82 +- dom/bluetooth/bluez/BluetoothHfpManager.cpp | 8 +- dom/bluetooth/bluez/BluetoothHfpManager.h | 12 +- dom/bluetooth/bluez/BluetoothOppManager.cpp | 14 +- dom/bluetooth/bluez/BluetoothOppManager.h | 12 +- dom/bluetooth/common/BluetoothHidManager.cpp | 4 +- dom/bluetooth/common/BluetoothHidManager.h | 2 +- .../common/BluetoothProfileController.cpp | 2 +- .../common/BluetoothProfileController.h | 2 +- dom/bluetooth/common/BluetoothReplyRunnable.h | 2 +- dom/bluetooth/common/BluetoothRilListener.h | 6 +- dom/bluetooth/common/BluetoothService.cpp | 6 +- dom/bluetooth/common/BluetoothService.h | 2 +- .../common/webapi/BluetoothAdapter.cpp | 126 +- .../common/webapi/BluetoothAdapter.h | 12 +- .../common/webapi/BluetoothClassOfDevice.cpp | 2 +- .../common/webapi/BluetoothDevice.cpp | 8 +- dom/bluetooth/common/webapi/BluetoothDevice.h | 20 +- .../webapi/BluetoothDiscoveryHandle.cpp | 8 +- dom/bluetooth/common/webapi/BluetoothGatt.cpp | 28 +- dom/bluetooth/common/webapi/BluetoothGatt.h | 4 +- .../webapi/BluetoothGattCharacteristic.cpp | 10 +- .../webapi/BluetoothGattCharacteristic.h | 12 +- .../common/webapi/BluetoothGattDescriptor.cpp | 6 +- .../common/webapi/BluetoothGattDescriptor.h | 2 +- .../common/webapi/BluetoothGattServer.cpp | 6 +- .../common/webapi/BluetoothGattService.cpp | 2 +- .../common/webapi/BluetoothGattService.h | 14 +- .../common/webapi/BluetoothLeDeviceEvent.cpp | 4 +- .../common/webapi/BluetoothLeDeviceEvent.h | 2 +- .../common/webapi/BluetoothManager.cpp | 14 +- .../common/webapi/BluetoothManager.h | 4 +- .../common/webapi/BluetoothPairingHandle.cpp | 8 +- .../webapi/BluetoothPairingListener.cpp | 6 +- .../webapi/BluetoothPbapRequestHandle.cpp | 14 +- dom/bluetooth/ipc/BluetoothChild.cpp | 2 +- dom/bluetooth/ipc/BluetoothChild.h | 2 +- dom/bluetooth/ipc/BluetoothParent.h | 4 +- .../bluedroid/BluetoothA2dpManager.cpp | 22 +- .../bluedroid/BluetoothA2dpManager.h | 2 +- .../BluetoothDaemonA2dpInterface.cpp | 6 +- .../BluetoothDaemonAvrcpInterface.cpp | 6 +- .../BluetoothDaemonHandsfreeInterface.cpp | 6 +- .../bluedroid/BluetoothDaemonInterface.cpp | 12 +- .../bluedroid/BluetoothDaemonInterface.h | 8 +- .../BluetoothDaemonSocketInterface.cpp | 2 +- .../bluedroid/BluetoothHALHelpers.h | 30 +- .../bluedroid/BluetoothOppManager.cpp | 8 +- .../bluedroid/BluetoothOppManager.h | 8 +- .../bluedroid/BluetoothServiceBluedroid.cpp | 24 +- dom/bluetooth2/bluedroid/BluetoothSocket.cpp | 6 +- .../bluedroid/BluetoothSocketMessageWatcher.h | 2 +- .../bluedroid/hfp/BluetoothHfpManager.cpp | 22 +- .../bluedroid/hfp/BluetoothHfpManager.h | 2 +- dom/bluetooth2/bluez/BluetoothA2dpManager.cpp | 4 +- dom/bluetooth2/bluez/BluetoothA2dpManager.h | 2 +- dom/bluetooth2/bluez/BluetoothDBusService.cpp | 82 +- dom/bluetooth2/bluez/BluetoothHfpManager.cpp | 8 +- dom/bluetooth2/bluez/BluetoothHfpManager.h | 12 +- dom/bluetooth2/bluez/BluetoothOppManager.cpp | 8 +- dom/bluetooth2/bluez/BluetoothOppManager.h | 10 +- dom/broadcastchannel/BroadcastChannel.cpp | 24 +- dom/broadcastchannel/BroadcastChannel.h | 6 +- .../BroadcastChannelChild.cpp | 6 +- .../BroadcastChannelParent.cpp | 2 +- dom/broadcastchannel/BroadcastChannelParent.h | 2 +- .../BroadcastChannelService.cpp | 6 +- .../BrowserElementAudioChannel.cpp | 22 +- dom/browser-element/BrowserElementParent.cpp | 16 +- dom/cache/ActorChild.h | 4 +- dom/cache/AutoUtils.cpp | 8 +- dom/cache/Cache.cpp | 66 +- dom/cache/Cache.h | 6 +- dom/cache/CacheChild.cpp | 4 +- dom/cache/CacheOpChild.cpp | 8 +- dom/cache/CacheOpParent.cpp | 2 +- dom/cache/CacheOpParent.h | 4 +- dom/cache/CacheParent.h | 2 +- dom/cache/CachePushStreamChild.h | 2 +- dom/cache/CacheStorage.cpp | 34 +- dom/cache/CacheStorage.h | 2 +- dom/cache/CacheStorageChild.cpp | 4 +- dom/cache/CacheStorageParent.h | 4 +- dom/cache/CacheStreamControlParent.h | 2 +- dom/cache/Context.cpp | 34 +- dom/cache/Context.h | 14 +- dom/cache/DBAction.cpp | 2 +- dom/cache/DBAction.h | 2 +- dom/cache/DBSchema.cpp | 7 +- dom/cache/Feature.cpp | 2 +- dom/cache/FileUtils.cpp | 2 +- dom/cache/Manager.cpp | 74 +- dom/cache/Manager.h | 4 +- dom/cache/ManagerId.cpp | 4 +- dom/cache/PrincipalVerifier.cpp | 6 +- dom/cache/PrincipalVerifier.h | 4 +- dom/cache/QuotaClient.cpp | 2 +- dom/cache/ReadStream.cpp | 12 +- dom/cache/StreamList.h | 6 +- dom/cache/TypeUtils.cpp | 40 +- dom/camera/CameraControlImpl.cpp | 8 +- dom/camera/CameraControlImpl.h | 2 +- dom/camera/CameraPreviewMediaStream.cpp | 10 +- dom/camera/CameraPreviewMediaStream.h | 2 +- dom/camera/DOMCameraCapabilities.cpp | 6 +- dom/camera/DOMCameraCapabilities.h | 14 +- dom/camera/DOMCameraControl.cpp | 52 +- dom/camera/DOMCameraControl.h | 24 +- dom/camera/DOMCameraControlListener.cpp | 4 +- dom/camera/DOMCameraDetectedFace.cpp | 2 +- dom/camera/DOMCameraDetectedFace.h | 8 +- dom/camera/DOMCameraManager.cpp | 18 +- dom/camera/FallbackCameraPlatform.h | 2 +- dom/camera/GonkCameraControl.cpp | 16 +- dom/camera/GonkCameraControl.h | 6 +- dom/camera/GonkCameraManager.cpp | 2 +- dom/camera/GonkRecorderProfiles.cpp | 12 +- dom/camera/GonkRecorderProfiles.h | 2 +- dom/camera/ICameraControl.h | 2 +- dom/camera/TestGonkCameraHardware.cpp | 12 +- dom/camera/TestGonkCameraHardware.h | 2 +- dom/canvas/CanvasGradient.h | 4 +- dom/canvas/CanvasImageCache.cpp | 6 +- dom/canvas/CanvasPattern.h | 2 +- dom/canvas/CanvasRenderingContext2D.cpp | 74 +- dom/canvas/CanvasRenderingContext2D.h | 26 +- dom/canvas/DocumentRendererChild.cpp | 4 +- dom/canvas/DocumentRendererParent.h | 2 +- dom/canvas/ImageBitmap.cpp | 68 +- dom/canvas/ImageBitmap.h | 6 +- dom/canvas/ImageData.cpp | 4 +- dom/canvas/WebGL2ContextQueries.cpp | 4 +- dom/canvas/WebGL2ContextSamplers.cpp | 2 +- dom/canvas/WebGL2ContextSync.cpp | 2 +- dom/canvas/WebGL2ContextTransformFeedback.cpp | 2 +- dom/canvas/WebGL2ContextUniforms.cpp | 2 +- dom/canvas/WebGLContext.cpp | 16 +- dom/canvas/WebGLContext.h | 6 +- dom/canvas/WebGLContextBuffers.cpp | 2 +- dom/canvas/WebGLContextGL.cpp | 16 +- dom/canvas/WebGLContextUnchecked.h | 4 +- dom/canvas/WebGLContextVertexArray.cpp | 2 +- .../WebGLExtensionDisjointTimerQuery.cpp | 2 +- dom/canvas/WebGLProgram.cpp | 10 +- dom/canvas/WebGLProgram.h | 2 +- .../nsICanvasRenderingContextInternal.h | 4 +- dom/cellbroadcast/CellBroadcast.cpp | 4 +- dom/cellbroadcast/CellBroadcast.h | 2 +- dom/cellbroadcast/CellBroadcastMessage.cpp | 2 +- dom/cellbroadcast/CellBroadcastMessage.h | 2 +- dom/crypto/CryptoKey.h | 2 +- dom/crypto/WebCryptoTask.cpp | 12 +- dom/crypto/WebCryptoTask.h | 2 +- dom/datastore/DataStore.cpp | 2 +- dom/datastore/DataStore.h | 2 +- dom/datastore/DataStoreCursor.cpp | 2 +- dom/datastore/DataStoreCursor.h | 2 +- dom/datastore/DataStoreDB.cpp | 12 +- dom/datastore/DataStoreDB.h | 10 +- dom/datastore/DataStoreRevision.cpp | 2 +- dom/datastore/DataStoreRevision.h | 4 +- dom/datastore/DataStoreService.cpp | 56 +- dom/devicestorage/DeviceStorage.h | 8 +- .../DeviceStorageAreaListener.cpp | 2 +- dom/devicestorage/DeviceStorageAreaListener.h | 2 +- .../DeviceStorageFileDescriptor.h | 2 +- .../DeviceStorageRequestChild.cpp | 4 +- dom/devicestorage/DeviceStorageRequestChild.h | 2 +- .../DeviceStorageRequestParent.cpp | 60 +- .../DeviceStorageRequestParent.h | 34 +- dom/devicestorage/DeviceStorageStatics.cpp | 26 +- dom/devicestorage/DeviceStorageStatics.h | 2 +- dom/devicestorage/nsDeviceStorage.cpp | 174 +- dom/devicestorage/nsDeviceStorage.h | 20 +- dom/encoding/TextDecoder.cpp | 6 +- dom/encoding/TextEncoder.cpp | 4 +- dom/events/AnimationEvent.cpp | 4 +- dom/events/AsyncEventDispatcher.cpp | 8 +- dom/events/BeforeAfterKeyboardEvent.cpp | 4 +- dom/events/BeforeUnloadEvent.cpp | 2 +- dom/events/ClipboardEvent.cpp | 6 +- dom/events/CommandEvent.cpp | 2 +- dom/events/CompositionEvent.cpp | 2 +- dom/events/ContentEventHandler.cpp | 18 +- dom/events/ContentEventHandler.h | 4 +- dom/events/CustomEvent.cpp | 4 +- dom/events/DOMEventTargetHelper.cpp | 4 +- dom/events/DOMEventTargetHelper.h | 2 +- dom/events/DataContainerEvent.cpp | 2 +- dom/events/DataTransfer.cpp | 16 +- dom/events/DataTransfer.h | 2 +- dom/events/DeviceMotionEvent.cpp | 4 +- dom/events/DeviceMotionEvent.h | 10 +- dom/events/DragEvent.cpp | 4 +- dom/events/Event.cpp | 4 +- dom/events/Event.h | 2 +- dom/events/EventDispatcher.cpp | 4 +- dom/events/EventListenerManager.cpp | 12 +- dom/events/EventListenerService.cpp | 2 +- dom/events/EventListenerService.h | 4 +- dom/events/EventStateManager.cpp | 34 +- dom/events/EventStateManager.h | 6 +- dom/events/FocusEvent.cpp | 4 +- dom/events/IMEContentObserver.cpp | 8 +- dom/events/IMEContentObserver.h | 2 +- dom/events/IMEStateManager.cpp | 22 +- dom/events/InputEvent.cpp | 4 +- dom/events/JSEventHandler.cpp | 6 +- dom/events/KeyboardEvent.cpp | 4 +- dom/events/MessageEvent.cpp | 6 +- dom/events/MessageEvent.h | 6 +- dom/events/MouseEvent.cpp | 4 +- dom/events/MouseScrollEvent.cpp | 2 +- dom/events/MutationEvent.cpp | 2 +- dom/events/NotifyPaintEvent.cpp | 14 +- dom/events/PaintRequest.cpp | 4 +- dom/events/PaintRequest.h | 2 +- dom/events/PointerEvent.cpp | 4 +- dom/events/ScrollAreaEvent.cpp | 2 +- dom/events/ScrollAreaEvent.h | 2 +- dom/events/SimpleGestureEvent.cpp | 2 +- dom/events/SpeechRecognitionError.cpp | 2 +- dom/events/StorageEvent.cpp | 4 +- dom/events/StorageEvent.h | 2 +- dom/events/TextComposition.cpp | 4 +- dom/events/TextComposition.h | 10 +- dom/events/TouchEvent.cpp | 2 +- dom/events/TouchEvent.h | 6 +- dom/events/TransitionEvent.cpp | 4 +- dom/events/UIEvent.cpp | 4 +- dom/events/WheelEvent.cpp | 4 +- dom/events/XULCommandEvent.cpp | 2 +- dom/events/XULCommandEvent.h | 2 +- .../test/test_all_synthetic_events.html | 7 + dom/fetch/Fetch.cpp | 274 +-- dom/fetch/Fetch.h | 2 +- dom/fetch/FetchDriver.cpp | 774 +++----- dom/fetch/FetchDriver.h | 53 +- dom/fetch/FetchUtil.cpp | 181 ++ dom/fetch/FetchUtil.h | 44 + dom/fetch/Headers.cpp | 8 +- dom/fetch/Headers.h | 2 +- dom/fetch/InternalHeaders.cpp | 12 +- dom/fetch/InternalRequest.cpp | 4 +- dom/fetch/InternalRequest.h | 2 +- dom/fetch/InternalResponse.cpp | 12 +- dom/fetch/InternalResponse.h | 6 +- dom/fetch/Request.cpp | 54 +- dom/fetch/Request.h | 7 +- dom/fetch/Response.cpp | 35 +- dom/fetch/Response.h | 4 +- dom/filehandle/ActorsChild.cpp | 14 +- dom/filehandle/ActorsChild.h | 8 +- dom/filehandle/ActorsParent.cpp | 50 +- dom/filehandle/FileHandleBase.cpp | 10 +- dom/filesystem/CreateDirectoryTask.cpp | 6 +- dom/filesystem/CreateDirectoryTask.h | 2 +- dom/filesystem/CreateFileTask.cpp | 8 +- dom/filesystem/CreateFileTask.h | 6 +- dom/filesystem/DeviceStorageFileSystem.cpp | 2 +- dom/filesystem/Directory.cpp | 16 +- dom/filesystem/Directory.h | 2 +- dom/filesystem/FileSystemBase.cpp | 4 +- .../FileSystemPermissionRequest.cpp | 6 +- dom/filesystem/FileSystemPermissionRequest.h | 2 +- dom/filesystem/FileSystemRequestParent.cpp | 2 +- dom/filesystem/FileSystemRequestParent.h | 2 +- dom/filesystem/FileSystemTaskBase.h | 4 +- dom/filesystem/GetDirectoryListingTask.cpp | 4 +- dom/filesystem/GetDirectoryListingTask.h | 4 +- dom/filesystem/GetFileOrDirectoryTask.cpp | 8 +- dom/filesystem/GetFileOrDirectoryTask.h | 4 +- dom/filesystem/RemoveTask.cpp | 6 +- dom/filesystem/RemoveTask.h | 4 +- dom/fmradio/FMRadio.cpp | 16 +- dom/fmradio/FMRadioService.cpp | 8 +- dom/fmradio/FMRadioService.h | 2 +- dom/fmradio/ipc/FMRadioParent.cpp | 2 +- dom/fmradio/ipc/FMRadioRequestChild.h | 2 +- dom/gamepad/Gamepad.cpp | 2 +- dom/gamepad/Gamepad.h | 4 +- dom/gamepad/GamepadFunctions.cpp | 2 +- dom/gamepad/GamepadService.cpp | 46 +- dom/gamepad/GamepadService.h | 2 +- dom/gamepad/GamepadServiceTest.cpp | 2 +- dom/gamepad/GamepadServiceTest.h | 2 +- dom/gamepad/windows/WindowsGamepad.cpp | 2 +- dom/geolocation/nsGeoGridFuzzer.cpp | 2 +- dom/geolocation/nsGeoPosition.h | 6 +- dom/geolocation/nsGeolocation.cpp | 36 +- dom/geolocation/nsGeolocation.h | 10 +- dom/geolocation/nsGeolocationSettings.cpp | 2 +- dom/html/HTMLAllCollection.cpp | 2 +- dom/html/HTMLAllCollection.h | 4 +- dom/html/HTMLAnchorElement.h | 2 +- dom/html/HTMLAreaElement.h | 2 +- dom/html/HTMLAudioElement.cpp | 2 +- dom/html/HTMLBodyElement.h | 2 +- dom/html/HTMLButtonElement.cpp | 2 +- dom/html/HTMLCanvasElement.cpp | 30 +- dom/html/HTMLCanvasElement.h | 10 +- dom/html/HTMLContentElement.cpp | 6 +- dom/html/HTMLContentElement.h | 2 +- dom/html/HTMLDataListElement.h | 2 +- dom/html/HTMLDetailsElement.h | 2 +- dom/html/HTMLExtAppElement.cpp | 4 +- dom/html/HTMLExtAppElement.h | 4 +- dom/html/HTMLFieldSetElement.h | 2 +- dom/html/HTMLFormElement.cpp | 10 +- dom/html/HTMLFormElement.h | 6 +- dom/html/HTMLImageElement.cpp | 8 +- dom/html/HTMLImageElement.h | 2 +- dom/html/HTMLInputElement.cpp | 80 +- dom/html/HTMLInputElement.h | 10 +- dom/html/HTMLLabelElement.cpp | 4 +- dom/html/HTMLLegendElement.cpp | 2 +- dom/html/HTMLLinkElement.cpp | 6 +- dom/html/HTMLLinkElement.h | 6 +- dom/html/HTMLMapElement.h | 2 +- dom/html/HTMLMediaElement.cpp | 78 +- dom/html/HTMLMediaElement.h | 36 +- dom/html/HTMLMenuElement.cpp | 2 +- dom/html/HTMLMenuItemElement.cpp | 4 +- dom/html/HTMLMetaElement.cpp | 2 +- dom/html/HTMLObjectElement.cpp | 2 +- dom/html/HTMLOptionElement.cpp | 4 +- dom/html/HTMLOptionsCollection.cpp | 2 +- dom/html/HTMLOptionsCollection.h | 2 +- dom/html/HTMLOutputElement.h | 2 +- dom/html/HTMLPropertiesCollection.cpp | 2 +- dom/html/HTMLPropertiesCollection.h | 12 +- dom/html/HTMLScriptElement.cpp | 2 +- dom/html/HTMLSelectElement.cpp | 24 +- dom/html/HTMLSelectElement.h | 6 +- dom/html/HTMLShadowElement.cpp | 4 +- dom/html/HTMLShadowElement.h | 2 +- dom/html/HTMLSourceElement.cpp | 2 +- dom/html/HTMLSourceElement.h | 4 +- dom/html/HTMLTableElement.cpp | 30 +- dom/html/HTMLTableElement.h | 4 +- dom/html/HTMLTableRowElement.cpp | 4 +- dom/html/HTMLTableRowElement.h | 2 +- dom/html/HTMLTableSectionElement.cpp | 4 +- dom/html/HTMLTableSectionElement.h | 2 +- dom/html/HTMLTemplateElement.h | 2 +- dom/html/HTMLTextAreaElement.cpp | 4 +- dom/html/HTMLTrackElement.h | 6 +- dom/html/HTMLVideoElement.cpp | 4 +- dom/html/HTMLVideoElement.h | 2 +- dom/html/ImageDocument.cpp | 2 +- dom/html/MediaDocument.cpp | 14 +- dom/html/MediaDocument.h | 2 +- dom/html/MediaError.h | 2 +- dom/html/PluginDocument.cpp | 8 +- dom/html/TextTrackManager.cpp | 4 +- dom/html/TextTrackManager.h | 8 +- dom/html/UndoManager.cpp | 34 +- dom/html/UndoManager.h | 2 +- dom/html/VideoDocument.cpp | 6 +- dom/html/nsBrowserElement.cpp | 10 +- dom/html/nsBrowserElement.h | 6 +- dom/html/nsDOMStringMap.h | 2 +- dom/html/nsGenericHTMLElement.cpp | 30 +- dom/html/nsGenericHTMLElement.h | 2 +- dom/html/nsGenericHTMLFrameElement.cpp | 4 +- dom/html/nsGenericHTMLFrameElement.h | 2 +- dom/html/nsHTMLContentSink.cpp | 18 +- dom/html/nsHTMLDocument.cpp | 12 +- dom/html/nsHTMLDocument.h | 18 +- dom/html/nsIConstraintValidation.h | 2 +- dom/html/nsRadioVisitor.cpp | 4 +- dom/html/nsTextEditorState.cpp | 22 +- dom/html/nsTextEditorState.h | 6 +- dom/icc/Icc.cpp | 34 +- dom/icc/IccCallback.cpp | 12 +- dom/icc/IccCallback.h | 4 +- dom/icc/IccCardLockError.cpp | 2 +- dom/icc/IccListener.h | 4 +- dom/icc/IccManager.cpp | 14 +- dom/icc/IccManager.h | 2 +- dom/icc/ipc/IccChild.cpp | 2 +- dom/icc/ipc/IccChild.h | 2 +- dom/icc/ipc/IccIPCService.cpp | 2 +- dom/icc/ipc/IccIPCService.h | 2 +- dom/indexedDB/ActorsChild.cpp | 64 +- dom/indexedDB/ActorsChild.h | 16 +- dom/indexedDB/ActorsParent.cpp | 454 ++--- dom/indexedDB/FileInfo.cpp | 6 +- dom/indexedDB/FileInfo.h | 2 +- dom/indexedDB/FileSnapshot.cpp | 14 +- dom/indexedDB/FileSnapshot.h | 4 +- dom/indexedDB/IDBCursor.cpp | 14 +- dom/indexedDB/IDBCursor.h | 6 +- dom/indexedDB/IDBDatabase.cpp | 30 +- dom/indexedDB/IDBDatabase.h | 4 +- dom/indexedDB/IDBEvents.cpp | 4 +- dom/indexedDB/IDBFactory.cpp | 18 +- dom/indexedDB/IDBFactory.h | 2 +- dom/indexedDB/IDBFileHandle.cpp | 6 +- dom/indexedDB/IDBFileHandle.h | 2 +- dom/indexedDB/IDBFileRequest.cpp | 4 +- dom/indexedDB/IDBFileRequest.h | 2 +- dom/indexedDB/IDBIndex.cpp | 20 +- dom/indexedDB/IDBIndex.h | 2 +- dom/indexedDB/IDBKeyRange.cpp | 14 +- dom/indexedDB/IDBMutableFile.cpp | 14 +- dom/indexedDB/IDBMutableFile.h | 2 +- dom/indexedDB/IDBObjectStore.cpp | 46 +- dom/indexedDB/IDBObjectStore.h | 4 +- dom/indexedDB/IDBRequest.cpp | 10 +- dom/indexedDB/IDBRequest.h | 12 +- dom/indexedDB/IDBTransaction.cpp | 26 +- dom/indexedDB/IDBTransaction.h | 8 +- dom/indexedDB/IndexedDatabase.h | 6 +- dom/indexedDB/IndexedDatabaseManager.cpp | 52 +- dom/inputport/AVInputPort.cpp | 2 +- dom/inputport/DisplayPortInputPort.cpp | 2 +- dom/inputport/FakeInputPortService.cpp | 2 +- dom/inputport/HDMIInputPort.cpp | 2 +- dom/inputport/InputPort.cpp | 2 +- dom/inputport/InputPort.h | 4 +- dom/inputport/InputPortListeners.h | 2 +- dom/inputport/InputPortManager.cpp | 10 +- dom/inputport/InputPortManager.h | 6 +- dom/inputport/InputPortServiceFactory.cpp | 2 +- .../base/nsIServiceWorkerManager.idl | 17 +- .../security/nsIContentSecurityPolicy.idl | 8 +- dom/ipc/Blob.cpp | 106 +- dom/ipc/BlobParent.h | 2 +- dom/ipc/ColorPickerParent.h | 2 +- dom/ipc/ContentBridgeChild.cpp | 2 +- dom/ipc/ContentBridgeChild.h | 2 +- dom/ipc/ContentBridgeParent.cpp | 2 +- dom/ipc/ContentBridgeParent.h | 2 +- dom/ipc/ContentChild.cpp | 40 +- dom/ipc/ContentChild.h | 4 +- dom/ipc/ContentParent.cpp | 122 +- dom/ipc/ContentParent.h | 8 +- dom/ipc/ContentProcessManager.cpp | 2 +- dom/ipc/FilePickerParent.cpp | 10 +- dom/ipc/FilePickerParent.h | 10 +- dom/ipc/NuwaChild.cpp | 2 +- dom/ipc/NuwaParent.cpp | 14 +- dom/ipc/NuwaParent.h | 4 +- dom/ipc/PreallocatedProcessManager.cpp | 10 +- dom/ipc/ProcessHangMonitor.cpp | 12 +- dom/ipc/ProcessPriorityManager.cpp | 16 +- dom/ipc/ScreenManagerParent.cpp | 2 +- dom/ipc/StructuredCloneData.h | 4 +- dom/ipc/TabChild.cpp | 46 +- dom/ipc/TabChild.h | 10 +- dom/ipc/TabParent.cpp | 156 +- dom/ipc/TabParent.h | 19 +- dom/ipc/nsIContentChild.cpp | 6 +- dom/ipc/nsIContentParent.cpp | 8 +- dom/ipc/nsIContentParent.h | 2 +- dom/json/nsJSON.cpp | 2 +- dom/jsurl/nsJSProtocolHandler.cpp | 8 +- .../en-US/chrome/security/csp.properties | 3 + dom/media/ADTSDecoder.cpp | 2 +- dom/media/ADTSDemuxer.cpp | 20 +- dom/media/ADTSDemuxer.h | 12 +- dom/media/AbstractMediaDecoder.h | 2 +- dom/media/AudioSegment.h | 2 +- dom/media/CanvasCaptureMediaStream.cpp | 14 +- dom/media/CanvasCaptureMediaStream.h | 10 +- dom/media/DOMMediaStream.cpp | 46 +- dom/media/DOMMediaStream.h | 16 +- dom/media/DecoderTraits.cpp | 4 +- dom/media/EncodedBufferCache.cpp | 2 +- dom/media/FileBlockCache.cpp | 4 +- dom/media/FileBlockCache.h | 6 +- dom/media/GraphDriver.cpp | 14 +- dom/media/GraphDriver.h | 10 +- dom/media/MP3Decoder.cpp | 8 +- dom/media/MP3Demuxer.cpp | 22 +- dom/media/MP3Demuxer.h | 14 +- dom/media/MediaCache.cpp | 2 +- dom/media/MediaData.cpp | 22 +- dom/media/MediaData.h | 12 +- dom/media/MediaDataDemuxer.h | 14 +- dom/media/MediaDecoder.cpp | 6 +- dom/media/MediaDecoder.h | 14 +- dom/media/MediaDecoderReader.cpp | 32 +- dom/media/MediaDecoderReader.h | 26 +- dom/media/MediaDecoderStateMachine.cpp | 50 +- dom/media/MediaDecoderStateMachine.h | 42 +- dom/media/MediaDevices.cpp | 26 +- dom/media/MediaEventSource.h | 12 +- dom/media/MediaFormatReader.cpp | 50 +- dom/media/MediaFormatReader.h | 32 +- dom/media/MediaInfo.h | 10 +- dom/media/MediaManager.cpp | 160 +- dom/media/MediaManager.h | 30 +- dom/media/MediaPermissionGonk.cpp | 24 +- dom/media/MediaPermissionGonk.h | 2 +- dom/media/MediaQueue.h | 31 +- dom/media/MediaRecorder.cpp | 46 +- dom/media/MediaRecorder.h | 10 +- dom/media/MediaResource.cpp | 14 +- dom/media/MediaResource.h | 10 +- dom/media/MediaStreamError.h | 4 +- dom/media/MediaStreamGraph.cpp | 36 +- dom/media/MediaStreamGraph.h | 8 +- dom/media/MediaStreamGraphImpl.h | 12 +- dom/media/MediaStreamTrack.h | 2 +- dom/media/MediaTimer.cpp | 4 +- dom/media/MediaTimer.h | 10 +- dom/media/MediaTrack.h | 2 +- dom/media/MediaTrackList.cpp | 16 +- dom/media/MediaTrackList.h | 6 +- dom/media/RtspMediaResource.h | 4 +- dom/media/SharedBuffer.h | 2 +- dom/media/StateMirroring.h | 12 +- dom/media/StateWatching.h | 12 +- dom/media/TextTrack.cpp | 4 +- dom/media/TextTrack.h | 10 +- dom/media/TextTrackCue.cpp | 2 +- dom/media/TextTrackCue.h | 12 +- dom/media/TextTrackCueList.cpp | 4 +- dom/media/TextTrackCueList.h | 4 +- dom/media/TextTrackList.cpp | 14 +- dom/media/TextTrackList.h | 6 +- dom/media/TextTrackRegion.cpp | 2 +- dom/media/VideoFrameContainer.h | 2 +- dom/media/VideoPlaybackQuality.h | 2 +- dom/media/VideoSegment.cpp | 4 +- dom/media/VideoSegment.h | 2 +- dom/media/VideoUtils.cpp | 4 +- dom/media/VideoUtils.h | 6 +- dom/media/WebVTTListener.h | 2 +- dom/media/android/AndroidMediaPluginHost.h | 2 +- dom/media/android/AndroidMediaReader.cpp | 16 +- dom/media/android/AndroidMediaReader.h | 8 +- .../android/AndroidMediaResourceServer.cpp | 12 +- .../android/AndroidMediaResourceServer.h | 2 +- dom/media/apple/AppleMP3Reader.cpp | 4 +- dom/media/apple/AppleMP3Reader.h | 2 +- dom/media/directshow/AudioSinkInputPin.cpp | 2 +- dom/media/directshow/DirectShowReader.cpp | 18 +- dom/media/directshow/DirectShowReader.h | 2 +- dom/media/directshow/DirectShowUtils.cpp | 18 +- dom/media/directshow/SourceFilter.cpp | 2 +- dom/media/encoder/EncodedFrameContainer.h | 4 +- dom/media/encoder/MediaEncoder.cpp | 4 +- dom/media/encoder/OmxTrackEncoder.cpp | 10 +- dom/media/encoder/OpusTrackEncoder.cpp | 4 +- dom/media/encoder/TrackEncoder.cpp | 2 +- dom/media/encoder/VP8TrackEncoder.cpp | 6 +- dom/media/encoder/VP8TrackEncoder.h | 2 +- dom/media/encoder/VorbisTrackEncoder.cpp | 2 +- dom/media/encoder/fmp4_muxer/AMRBox.h | 2 +- dom/media/encoder/fmp4_muxer/AVCBox.h | 2 +- dom/media/encoder/fmp4_muxer/ISOControl.cpp | 12 +- dom/media/encoder/fmp4_muxer/ISOControl.h | 12 +- .../encoder/fmp4_muxer/ISOMediaBoxes.cpp | 14 +- dom/media/encoder/fmp4_muxer/ISOMediaBoxes.h | 16 +- .../encoder/fmp4_muxer/ISOMediaWriter.cpp | 2 +- dom/media/encoder/fmp4_muxer/MP4ESDS.cpp | 2 +- dom/media/encoder/fmp4_muxer/MP4ESDS.h | 6 +- dom/media/encoder/fmp4_muxer/MuxerOperation.h | 2 +- dom/media/fmp4/MP4Decoder.cpp | 76 +- dom/media/fmp4/MP4Demuxer.cpp | 36 +- dom/media/fmp4/MP4Demuxer.h | 10 +- dom/media/gmp/GMPAudioDecoderParent.cpp | 2 +- dom/media/gmp/GMPAudioDecoderParent.h | 2 +- dom/media/gmp/GMPChild.h | 4 +- dom/media/gmp/GMPContentParent.cpp | 6 +- dom/media/gmp/GMPContentParent.h | 10 +- dom/media/gmp/GMPDecryptorParent.cpp | 2 +- dom/media/gmp/GMPDecryptorParent.h | 2 +- dom/media/gmp/GMPParent.cpp | 16 +- dom/media/gmp/GMPParent.h | 8 +- dom/media/gmp/GMPPlatform.cpp | 6 +- dom/media/gmp/GMPService.cpp | 20 +- dom/media/gmp/GMPService.h | 4 +- dom/media/gmp/GMPServiceChild.cpp | 12 +- dom/media/gmp/GMPServiceParent.cpp | 26 +- dom/media/gmp/GMPServiceParent.h | 10 +- dom/media/gmp/GMPStorageChild.cpp | 12 +- dom/media/gmp/GMPStorageParent.h | 2 +- dom/media/gmp/GMPTimerParent.h | 2 +- dom/media/gmp/GMPVideoDecoderParent.cpp | 2 +- dom/media/gmp/GMPVideoDecoderParent.h | 2 +- dom/media/gmp/GMPVideoEncoderParent.cpp | 2 +- dom/media/gmp/GMPVideoEncoderParent.h | 2 +- dom/media/gstreamer/GStreamerAllocator.cpp | 2 +- dom/media/gstreamer/GStreamerAllocator.h | 2 +- dom/media/gstreamer/GStreamerMozVideoBuffer.h | 2 +- dom/media/gstreamer/GStreamerReader-0.10.cpp | 12 +- dom/media/gstreamer/GStreamerReader.cpp | 16 +- dom/media/gstreamer/GStreamerReader.h | 10 +- dom/media/gtest/TestGMPCrossOrigin.cpp | 64 +- dom/media/gtest/TestGMPRemoveAndDelete.cpp | 12 +- dom/media/gtest/TestIntervalSet.cpp | 10 +- dom/media/gtest/TestMP3Demuxer.cpp | 18 +- dom/media/gtest/TestMP4Demuxer.cpp | 42 +- dom/media/gtest/TestMP4Reader.cpp | 18 +- dom/media/gtest/TestMediaEventSource.cpp | 20 +- dom/media/gtest/TestMozPromise.cpp | 40 +- dom/media/gtest/TestVideoSegment.cpp | 4 +- dom/media/gtest/TestVideoTrackEncoder.cpp | 12 +- dom/media/gtest/TestVorbisTrackEncoder.cpp | 6 +- dom/media/gtest/TestWebMWriter.cpp | 6 +- dom/media/imagecapture/CaptureTask.cpp | 22 +- dom/media/imagecapture/CaptureTask.h | 2 +- dom/media/imagecapture/ImageCapture.cpp | 22 +- dom/media/imagecapture/ImageCapture.h | 2 +- dom/media/mediasink/AudioSink.h | 4 +- dom/media/mediasink/AudioSinkWrapper.cpp | 2 +- dom/media/mediasink/AudioSinkWrapper.h | 10 +- dom/media/mediasink/DecodedAudioDataSink.cpp | 18 +- dom/media/mediasink/DecodedAudioDataSink.h | 4 +- dom/media/mediasink/DecodedStream.cpp | 20 +- dom/media/mediasink/DecodedStream.h | 16 +- dom/media/mediasink/MediaSink.h | 4 +- dom/media/mediasource/AsyncEventRunner.h | 2 +- dom/media/mediasource/ContainerParser.cpp | 2 +- dom/media/mediasource/ContainerParser.h | 6 +- dom/media/mediasource/MediaSource.cpp | 4 +- dom/media/mediasource/MediaSource.h | 10 +- dom/media/mediasource/MediaSourceDecoder.cpp | 4 +- dom/media/mediasource/MediaSourceDecoder.h | 2 +- dom/media/mediasource/MediaSourceDemuxer.cpp | 36 +- dom/media/mediasource/MediaSourceDemuxer.h | 28 +- dom/media/mediasource/MediaSourceResource.h | 4 +- dom/media/mediasource/ResourceQueue.cpp | 2 +- dom/media/mediasource/ResourceQueue.h | 2 +- dom/media/mediasource/SourceBuffer.cpp | 12 +- dom/media/mediasource/SourceBuffer.h | 6 +- .../SourceBufferContentManager.cpp | 2 +- .../mediasource/SourceBufferContentManager.h | 4 +- dom/media/mediasource/SourceBufferList.h | 4 +- dom/media/mediasource/TrackBuffersManager.cpp | 46 +- dom/media/mediasource/TrackBuffersManager.h | 34 +- dom/media/ogg/OggReader.cpp | 6 +- dom/media/ogg/OggReader.h | 2 +- dom/media/ogg/OggWriter.h | 2 +- dom/media/omx/AudioOffloadPlayer.cpp | 6 +- dom/media/omx/AudioOffloadPlayer.h | 4 +- dom/media/omx/AudioOffloadPlayerBase.h | 2 +- dom/media/omx/MPAPI.h | 2 +- dom/media/omx/MediaCodecProxy.h | 4 +- dom/media/omx/MediaCodecReader.cpp | 44 +- dom/media/omx/MediaCodecReader.h | 30 +- dom/media/omx/MediaOmxCommonDecoder.cpp | 2 +- dom/media/omx/MediaOmxReader.cpp | 34 +- dom/media/omx/MediaOmxReader.h | 6 +- dom/media/omx/OMXCodecProxy.h | 4 +- dom/media/omx/OMXCodecWrapper.cpp | 2 +- dom/media/omx/OMXCodecWrapper.h | 4 +- dom/media/omx/OmxDecoder.cpp | 6 +- dom/media/omx/OmxDecoder.h | 2 +- dom/media/omx/RtspExtractor.cpp | 2 +- dom/media/omx/RtspExtractor.h | 2 +- dom/media/omx/RtspMediaCodecDecoder.cpp | 2 +- dom/media/omx/RtspMediaCodecReader.cpp | 10 +- dom/media/omx/RtspMediaCodecReader.h | 8 +- dom/media/omx/RtspOmxDecoder.cpp | 2 +- dom/media/omx/RtspOmxReader.cpp | 6 +- dom/media/omx/RtspOmxReader.h | 4 +- dom/media/platforms/PDMFactory.cpp | 16 +- dom/media/platforms/PDMFactory.h | 4 +- dom/media/platforms/PlatformDecoderModule.h | 2 +- .../agnostic/AgnosticDecoderModule.cpp | 4 +- .../platforms/agnostic/BlankDecoderModule.cpp | 12 +- dom/media/platforms/agnostic/OpusDecoder.cpp | 6 +- dom/media/platforms/agnostic/OpusDecoder.h | 2 +- dom/media/platforms/agnostic/VPXDecoder.cpp | 8 +- dom/media/platforms/agnostic/VPXDecoder.h | 4 +- .../platforms/agnostic/VorbisDecoder.cpp | 6 +- dom/media/platforms/agnostic/VorbisDecoder.h | 2 +- .../agnostic/gmp/GMPAudioDecoder.cpp | 8 +- .../platforms/agnostic/gmp/GMPAudioDecoder.h | 6 +- .../agnostic/gmp/GMPDecoderModule.cpp | 6 +- .../agnostic/gmp/GMPVideoDecoder.cpp | 8 +- .../platforms/agnostic/gmp/GMPVideoDecoder.h | 8 +- .../agnostic/gmp/MediaDataDecoderProxy.cpp | 4 +- .../agnostic/gmp/MediaDataDecoderProxy.h | 14 +- .../android/AndroidDecoderModule.cpp | 18 +- .../platforms/android/AndroidDecoderModule.h | 4 +- dom/media/platforms/apple/AppleATDecoder.cpp | 10 +- dom/media/platforms/apple/AppleATDecoder.h | 6 +- .../platforms/apple/AppleDecoderModule.cpp | 4 +- dom/media/platforms/apple/AppleVDADecoder.cpp | 14 +- dom/media/platforms/apple/AppleVDADecoder.h | 8 +- dom/media/platforms/apple/AppleVTDecoder.cpp | 4 +- dom/media/platforms/apple/AppleVTDecoder.h | 2 +- dom/media/platforms/apple/ReorderQueue.h | 2 +- .../platforms/ffmpeg/FFmpegAudioDecoder.cpp | 8 +- .../platforms/ffmpeg/FFmpegAudioDecoder.h | 2 +- .../platforms/ffmpeg/FFmpegDataDecoder.h | 6 +- .../platforms/ffmpeg/FFmpegDecoderModule.h | 6 +- .../platforms/ffmpeg/FFmpegH264Decoder.cpp | 10 +- .../platforms/ffmpeg/FFmpegH264Decoder.h | 4 +- .../platforms/ffmpeg/FFmpegRuntimeLinker.cpp | 2 +- .../gonk/GonkAudioDecoderManager.cpp | 14 +- .../platforms/gonk/GonkAudioDecoderManager.h | 6 +- .../platforms/gonk/GonkDecoderModule.cpp | 4 +- .../platforms/gonk/GonkMediaDataDecoder.cpp | 8 +- .../platforms/gonk/GonkMediaDataDecoder.h | 6 +- .../gonk/GonkVideoDecoderManager.cpp | 16 +- .../platforms/gonk/GonkVideoDecoderManager.h | 12 +- dom/media/platforms/wmf/DXVA2Manager.cpp | 44 +- dom/media/platforms/wmf/MFTDecoder.cpp | 16 +- .../platforms/wmf/WMFAudioMFTManager.cpp | 8 +- dom/media/platforms/wmf/WMFAudioMFTManager.h | 2 +- dom/media/platforms/wmf/WMFDecoderModule.cpp | 8 +- .../platforms/wmf/WMFMediaDataDecoder.cpp | 8 +- dom/media/platforms/wmf/WMFMediaDataDecoder.h | 4 +- .../platforms/wmf/WMFVideoMFTManager.cpp | 22 +- dom/media/platforms/wmf/WMFVideoMFTManager.h | 2 +- .../platforms/wrappers/FuzzingWrapper.cpp | 8 +- dom/media/platforms/wrappers/FuzzingWrapper.h | 12 +- .../platforms/wrappers/H264Converter.cpp | 8 +- dom/media/platforms/wrappers/H264Converter.h | 12 +- dom/media/raw/RawReader.cpp | 10 +- dom/media/raw/RawReader.h | 2 +- dom/media/systemservices/CamerasChild.cpp | 14 +- dom/media/systemservices/CamerasParent.cpp | 56 +- dom/media/systemservices/CamerasUtils.h | 2 +- dom/media/systemservices/LoadManager.cpp | 2 +- dom/media/systemservices/LoadManager.h | 2 +- dom/media/systemservices/LoadMonitor.cpp | 20 +- dom/media/systemservices/LoadMonitor.h | 2 +- dom/media/systemservices/MediaChild.cpp | 8 +- dom/media/systemservices/MediaParent.cpp | 14 +- dom/media/systemservices/MediaParent.h | 2 +- .../MediaSystemResourceClient.h | 4 +- .../MediaSystemResourceManagerParent.h | 2 +- dom/media/systemservices/MediaUtils.h | 24 +- dom/media/wave/WaveReader.cpp | 2 +- dom/media/wave/WaveReader.h | 2 +- dom/media/webaudio/AnalyserNode.cpp | 6 +- dom/media/webaudio/AudioBuffer.cpp | 4 +- dom/media/webaudio/AudioBuffer.h | 4 +- dom/media/webaudio/AudioBufferSourceNode.cpp | 6 +- dom/media/webaudio/AudioBufferSourceNode.h | 6 +- dom/media/webaudio/AudioContext.cpp | 62 +- dom/media/webaudio/AudioContext.h | 20 +- dom/media/webaudio/AudioDestinationNode.cpp | 18 +- dom/media/webaudio/AudioDestinationNode.h | 4 +- dom/media/webaudio/AudioListener.h | 2 +- dom/media/webaudio/AudioNode.cpp | 14 +- dom/media/webaudio/AudioNode.h | 14 +- dom/media/webaudio/AudioNodeEngine.cpp | 2 +- .../webaudio/AudioNodeExternalInputStream.cpp | 2 +- dom/media/webaudio/AudioNodeStream.cpp | 4 +- dom/media/webaudio/AudioParam.cpp | 6 +- dom/media/webaudio/AudioParam.h | 4 +- dom/media/webaudio/AudioParamTimeline.h | 2 +- dom/media/webaudio/AudioProcessingEvent.cpp | 2 +- dom/media/webaudio/AudioProcessingEvent.h | 6 +- dom/media/webaudio/BiquadFilterNode.cpp | 4 +- dom/media/webaudio/BiquadFilterNode.h | 8 +- dom/media/webaudio/BufferDecoder.h | 4 +- dom/media/webaudio/ConvolverNode.cpp | 10 +- dom/media/webaudio/ConvolverNode.h | 2 +- dom/media/webaudio/DelayNode.cpp | 4 +- dom/media/webaudio/DelayNode.h | 2 +- dom/media/webaudio/DynamicsCompressorNode.cpp | 4 +- dom/media/webaudio/DynamicsCompressorNode.h | 10 +- dom/media/webaudio/GainNode.h | 2 +- dom/media/webaudio/MediaBufferDecoder.cpp | 10 +- dom/media/webaudio/MediaBufferDecoder.h | 10 +- .../webaudio/MediaElementAudioSourceNode.cpp | 2 +- .../MediaStreamAudioDestinationNode.h | 4 +- .../webaudio/MediaStreamAudioSourceNode.cpp | 2 +- .../webaudio/MediaStreamAudioSourceNode.h | 4 +- .../webaudio/OfflineAudioCompletionEvent.h | 2 +- dom/media/webaudio/OscillatorNode.cpp | 10 +- dom/media/webaudio/OscillatorNode.h | 6 +- dom/media/webaudio/PannerNode.cpp | 4 +- dom/media/webaudio/PeriodicWave.h | 4 +- dom/media/webaudio/PlayingRefChangeHandler.h | 4 +- dom/media/webaudio/ScriptProcessorNode.cpp | 10 +- dom/media/webaudio/StereoPannerNode.h | 2 +- .../webaudio/blink/HRTFDatabaseLoader.cpp | 2 +- dom/media/webaudio/blink/HRTFPanner.h | 2 +- dom/media/webm/AudioDecoder.cpp | 4 +- dom/media/webm/NesteggPacketHolder.h | 4 +- dom/media/webm/SoftwareWebMVideoDecoder.cpp | 6 +- dom/media/webm/SoftwareWebMVideoDecoder.h | 2 +- dom/media/webm/WebMBufferedParser.cpp | 2 +- dom/media/webm/WebMDecoder.cpp | 2 +- dom/media/webm/WebMDemuxer.cpp | 42 +- dom/media/webm/WebMDemuxer.h | 32 +- dom/media/webm/WebMReader.cpp | 30 +- dom/media/webm/WebMReader.h | 12 +- dom/media/webrtc/MediaEngine.h | 4 +- .../webrtc/MediaEngineCameraVideoSource.cpp | 2 +- .../webrtc/MediaEngineCameraVideoSource.h | 6 +- dom/media/webrtc/MediaEngineDefault.cpp | 18 +- dom/media/webrtc/MediaEngineDefault.h | 12 +- .../webrtc/MediaEngineGonkVideoSource.cpp | 28 +- dom/media/webrtc/MediaEngineGonkVideoSource.h | 6 +- .../webrtc/MediaEngineRemoteVideoSource.cpp | 2 +- .../webrtc/MediaEngineTabVideoSource.cpp | 10 +- dom/media/webrtc/MediaEngineTabVideoSource.h | 8 +- dom/media/webrtc/MediaEngineWebRTC.cpp | 12 +- dom/media/webrtc/MediaEngineWebRTC.h | 6 +- dom/media/webrtc/MediaEngineWebRTCAudio.cpp | 2 +- dom/media/webrtc/RTCCertificate.cpp | 6 +- dom/media/webrtc/RTCCertificate.h | 2 +- .../webrtc/RTCIdentityProviderRegistrar.cpp | 2 +- .../webrtc/RTCIdentityProviderRegistrar.h | 4 +- .../PocketSphinxSpeechRecognitionService.cpp | 4 +- .../webspeech/recognition/SpeechGrammar.cpp | 2 +- .../recognition/SpeechGrammarList.cpp | 4 +- .../webspeech/recognition/SpeechGrammarList.h | 2 +- .../recognition/SpeechRecognition.cpp | 32 +- .../webspeech/recognition/SpeechRecognition.h | 20 +- .../SpeechRecognitionAlternative.h | 2 +- .../recognition/SpeechRecognitionResult.cpp | 2 +- .../recognition/SpeechRecognitionResult.h | 4 +- .../SpeechRecognitionResultList.cpp | 2 +- .../recognition/SpeechRecognitionResultList.h | 4 +- .../recognition/SpeechStreamListener.cpp | 2 +- .../recognition/SpeechStreamListener.h | 2 +- .../test/FakeSpeechRecognitionService.cpp | 2 +- dom/media/webspeech/synth/SpeechSynthesis.cpp | 4 +- dom/media/webspeech/synth/SpeechSynthesis.h | 6 +- .../synth/SpeechSynthesisUtterance.cpp | 4 +- .../synth/SpeechSynthesisUtterance.h | 2 +- .../synth/ipc/SpeechSynthesisChild.h | 2 +- .../synth/ipc/SpeechSynthesisParent.cpp | 2 +- .../synth/ipc/SpeechSynthesisParent.h | 2 +- dom/media/webspeech/synth/nsSpeechTask.cpp | 12 +- dom/media/webspeech/synth/nsSpeechTask.h | 10 +- .../webspeech/synth/nsSynthVoiceRegistry.cpp | 18 +- .../webspeech/synth/nsSynthVoiceRegistry.h | 8 +- .../webspeech/synth/pico/nsPicoService.cpp | 14 +- .../synth/test/nsFakeSynthServices.cpp | 6 +- .../webspeech/synth/windows/SapiService.cpp | 22 +- .../webspeech/synth/windows/SapiService.h | 4 +- dom/messagechannel/MessageChannel.cpp | 4 +- dom/messagechannel/MessageChannel.h | 4 +- dom/messagechannel/MessagePort.cpp | 32 +- dom/messagechannel/MessagePort.h | 10 +- dom/messagechannel/MessagePortList.h | 4 +- dom/messagechannel/MessagePortParent.cpp | 6 +- dom/messagechannel/MessagePortParent.h | 2 +- dom/messagechannel/MessagePortService.cpp | 6 +- dom/messagechannel/MessagePortService.h | 4 +- .../SharedMessagePortMessage.cpp | 20 +- dom/messagechannel/SharedMessagePortMessage.h | 8 +- dom/mobileconnection/MobileConnection.cpp | 92 +- dom/mobileconnection/MobileConnection.h | 6 +- dom/mobileconnection/MobileConnectionArray.h | 2 +- .../MobileConnectionCallback.cpp | 4 +- .../MobileConnectionCallback.h | 2 +- dom/mobileconnection/MobileConnectionInfo.h | 4 +- .../ipc/MobileConnectionChild.cpp | 4 +- .../ipc/MobileConnectionChild.h | 4 +- .../ipc/MobileConnectionIPCService.cpp | 4 +- .../ipc/MobileConnectionIPCService.h | 2 +- dom/mobilemessage/MmsMessage.cpp | 8 +- dom/mobilemessage/MmsMessage.h | 2 +- dom/mobilemessage/MobileMessageCallback.cpp | 2 +- dom/mobilemessage/MobileMessageCallback.h | 4 +- .../MobileMessageCursorCallback.cpp | 4 +- .../MobileMessageCursorCallback.h | 2 +- dom/mobilemessage/MobileMessageManager.cpp | 36 +- dom/mobilemessage/MobileMessageManager.h | 2 +- dom/mobilemessage/ipc/SmsIPCService.cpp | 6 +- dom/mobilemessage/ipc/SmsParent.cpp | 6 +- dom/network/TCPServerSocket.cpp | 10 +- dom/network/TCPServerSocket.h | 4 +- dom/network/TCPServerSocketChild.cpp | 2 +- dom/network/TCPServerSocketChild.h | 2 +- dom/network/TCPServerSocketParent.cpp | 4 +- dom/network/TCPServerSocketParent.h | 2 +- dom/network/TCPSocket.cpp | 14 +- dom/network/TCPSocket.h | 4 +- dom/network/TCPSocketParent.h | 4 +- dom/network/UDPSocket.cpp | 10 +- dom/network/UDPSocket.h | 6 +- dom/network/UDPSocketParent.h | 2 +- dom/nfc/MozIsoDepTech.cpp | 4 +- dom/nfc/MozIsoDepTech.h | 4 +- dom/nfc/MozNDEFRecord.cpp | 4 +- dom/nfc/MozNDEFRecord.h | 2 +- dom/nfc/gonk/NfcService.cpp | 6 +- dom/nfc/gonk/NfcService.h | 4 +- dom/notification/DesktopNotification.cpp | 8 +- dom/notification/DesktopNotification.h | 2 +- dom/notification/Notification.cpp | 79 +- dom/notification/NotificationEvent.h | 6 +- dom/offline/nsDOMOfflineResourceList.cpp | 6 +- dom/permission/Permissions.cpp | 2 +- dom/plugins/base/android/ANPAudio.cpp | 2 +- dom/plugins/base/android/ANPWindow.cpp | 4 +- dom/plugins/base/nsJSNPRuntime.cpp | 2 +- dom/plugins/base/nsNPAPIPlugin.cpp | 16 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 16 +- dom/plugins/base/nsNPAPIPluginInstance.h | 12 +- .../base/nsNPAPIPluginStreamListener.cpp | 2 +- .../base/nsNPAPIPluginStreamListener.h | 4 +- dom/plugins/base/nsPluginHost.cpp | 114 +- dom/plugins/base/nsPluginHost.h | 22 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 22 +- dom/plugins/base/nsPluginInstanceOwner.h | 10 +- dom/plugins/base/nsPluginNativeWindow.h | 6 +- dom/plugins/base/nsPluginNativeWindowGtk.cpp | 2 +- dom/plugins/base/nsPluginNativeWindowGtk.h | 2 +- dom/plugins/base/nsPluginNativeWindowQt.cpp | 4 +- dom/plugins/base/nsPluginNativeWindowWin.cpp | 12 +- .../base/nsPluginStreamListenerPeer.cpp | 14 +- dom/plugins/base/nsPluginStreamListenerPeer.h | 6 +- dom/plugins/base/nsPluginTags.cpp | 4 +- dom/plugins/base/nsPluginTags.h | 4 +- dom/plugins/ipc/BrowserStreamParent.cpp | 2 +- dom/plugins/ipc/BrowserStreamParent.h | 2 +- dom/plugins/ipc/PluginAsyncSurrogate.cpp | 4 +- dom/plugins/ipc/PluginAsyncSurrogate.h | 2 +- dom/plugins/ipc/PluginBackgroundDestroyer.h | 2 +- dom/plugins/ipc/PluginInstanceChild.cpp | 16 +- dom/plugins/ipc/PluginInstanceChild.h | 10 +- dom/plugins/ipc/PluginInstanceParent.cpp | 10 +- dom/plugins/ipc/PluginInstanceParent.h | 8 +- dom/plugins/ipc/PluginModuleParent.cpp | 22 +- dom/plugins/ipc/PluginModuleParent.h | 8 +- dom/plugins/ipc/PluginScriptableObjectChild.h | 4 +- dom/plugins/ipc/PluginSurfaceParent.h | 2 +- dom/power/PowerManager.cpp | 2 +- dom/power/PowerManagerService.cpp | 8 +- dom/presentation/Presentation.cpp | 12 +- dom/presentation/Presentation.h | 6 +- dom/presentation/PresentationAvailability.cpp | 2 +- dom/presentation/PresentationCallbacks.cpp | 2 +- dom/presentation/PresentationCallbacks.h | 6 +- .../PresentationDeviceManager.cpp | 2 +- dom/presentation/PresentationRequest.cpp | 10 +- dom/presentation/PresentationRequest.h | 2 +- dom/presentation/PresentationService.cpp | 20 +- dom/presentation/PresentationService.h | 2 +- dom/presentation/PresentationSession.cpp | 8 +- dom/presentation/PresentationSessionInfo.cpp | 4 +- dom/presentation/PresentationSessionInfo.h | 6 +- .../PresentationSessionTransport.cpp | 4 +- .../PresentationSessionTransport.h | 2 +- dom/presentation/ipc/PresentationChild.h | 2 +- dom/presentation/ipc/PresentationIPCService.h | 2 +- dom/presentation/ipc/PresentationParent.cpp | 4 +- .../provider/MulticastDNSDeviceProvider.h | 4 +- dom/promise/AbortablePromise.cpp | 4 +- dom/promise/Promise.cpp | 104 +- dom/promise/Promise.h | 12 +- dom/promise/PromiseCallback.h | 10 +- dom/promise/PromiseDebugging.cpp | 6 +- dom/promise/PromiseDebugging.h | 4 +- dom/promise/PromiseWorkerProxy.h | 10 +- dom/push/PushManager.cpp | 66 +- dom/push/PushManager.h | 4 +- dom/push/PushService.jsm | 18 +- dom/push/PushServiceChildPreload.jsm | 8 +- dom/push/test/frame.html | 3 +- dom/push/test/mochitest.ini | 1 + dom/push/test/push-server.sjs | 30 +- dom/push/test/webpush.js | 206 +++ dom/push/test/worker.js | 47 +- dom/quota/FileStreams.cpp | 6 +- dom/quota/FileStreams.h | 2 +- dom/quota/QuotaManager.cpp | 122 +- dom/quota/QuotaManager.h | 10 +- dom/quota/QuotaObject.h | 2 +- dom/requestsync/RequestSyncWifiService.cpp | 4 +- dom/security/nsCSPContext.cpp | 21 +- dom/security/nsCSPParser.cpp | 23 + dom/security/nsCSPParser.h | 9 + dom/security/nsCSPService.cpp | 18 +- dom/security/nsCSPUtils.cpp | 55 + dom/security/nsCSPUtils.h | 68 +- dom/security/nsContentSecurityManager.cpp | 23 +- .../test/cors/file_CrossSiteXHR_server.sjs | 29 +- dom/security/test/cors/test_CrossSiteXHR.html | 96 + dom/smil/TimeEvent.cpp | 2 +- dom/smil/nsSMILAnimationController.cpp | 2 +- dom/smil/nsSMILCSSProperty.cpp | 2 +- dom/smil/nsSMILCompositor.cpp | 2 +- dom/smil/nsSMILInstanceTime.cpp | 6 +- dom/smil/nsSMILInterval.cpp | 2 +- dom/smil/nsSMILInterval.h | 6 +- dom/smil/nsSMILMappedAttribute.cpp | 6 +- dom/smil/nsSMILParserUtils.cpp | 2 +- dom/smil/nsSMILTargetIdentifier.h | 4 +- dom/smil/nsSMILTimeContainer.h | 4 +- dom/smil/nsSMILTimeValueSpec.cpp | 6 +- dom/smil/nsSMILTimeValueSpec.h | 4 +- dom/smil/nsSMILTimeValueSpecParams.h | 4 +- dom/smil/nsSMILTimedElement.cpp | 14 +- dom/smil/nsSMILTimedElement.h | 2 +- dom/speakermanager/SpeakerManager.cpp | 6 +- dom/speakermanager/SpeakerManagerService.cpp | 6 +- dom/speakermanager/SpeakerManagerService.h | 2 +- .../SpeakerManagerServiceChild.cpp | 6 +- dom/storage/DOMStorage.cpp | 4 +- dom/storage/DOMStorage.h | 4 +- dom/storage/DOMStorageCache.cpp | 12 +- dom/storage/DOMStorageCache.h | 4 +- dom/storage/DOMStorageDBThread.cpp | 2 +- dom/storage/DOMStorageDBThread.h | 6 +- dom/storage/DOMStorageIPC.cpp | 20 +- dom/storage/DOMStorageIPC.h | 6 +- dom/storage/DOMStorageManager.cpp | 12 +- dom/storage/DOMStorageManager.h | 4 +- dom/svg/DOMSVGAnimatedLengthList.cpp | 8 +- dom/svg/DOMSVGAnimatedLengthList.h | 2 +- dom/svg/DOMSVGAnimatedNumberList.cpp | 8 +- dom/svg/DOMSVGAnimatedNumberList.h | 2 +- dom/svg/DOMSVGLength.cpp | 2 +- dom/svg/DOMSVGLength.h | 4 +- dom/svg/DOMSVGLengthList.cpp | 14 +- dom/svg/DOMSVGLengthList.h | 2 +- dom/svg/DOMSVGNumber.cpp | 4 +- dom/svg/DOMSVGNumber.h | 2 +- dom/svg/DOMSVGNumberList.cpp | 16 +- dom/svg/DOMSVGNumberList.h | 2 +- dom/svg/DOMSVGPathSeg.h | 2 +- dom/svg/DOMSVGPathSegList.cpp | 18 +- dom/svg/DOMSVGPathSegList.h | 2 +- dom/svg/DOMSVGPointList.cpp | 12 +- dom/svg/DOMSVGPointList.h | 2 +- dom/svg/DOMSVGStringList.cpp | 2 +- dom/svg/DOMSVGStringList.h | 2 +- dom/svg/DOMSVGTransformList.cpp | 20 +- dom/svg/DOMSVGTransformList.h | 2 +- dom/svg/SVGAngle.h | 2 +- dom/svg/SVGAnimatedAngle.h | 2 +- dom/svg/SVGAnimatedBoolean.h | 2 +- dom/svg/SVGAnimatedEnumeration.h | 2 +- dom/svg/SVGAnimatedInteger.h | 2 +- dom/svg/SVGAnimatedLength.cpp | 4 +- dom/svg/SVGAnimatedLength.h | 2 +- dom/svg/SVGAnimatedNumber.h | 2 +- dom/svg/SVGAnimatedPreserveAspectRatio.cpp | 6 +- dom/svg/SVGAnimatedPreserveAspectRatio.h | 2 +- dom/svg/SVGAnimatedRect.h | 2 +- dom/svg/SVGAnimatedString.h | 2 +- dom/svg/SVGAnimatedTransformList.cpp | 8 +- dom/svg/SVGAnimatedTransformList.h | 2 +- dom/svg/SVGContentUtils.cpp | 10 +- dom/svg/SVGDocument.cpp | 6 +- dom/svg/SVGElementFactory.cpp | 2 +- dom/svg/SVGFEBlendElement.h | 2 +- dom/svg/SVGFEColorMatrixElement.h | 2 +- dom/svg/SVGFEComponentTransferElement.cpp | 4 +- dom/svg/SVGFEComponentTransferElement.h | 2 +- dom/svg/SVGFECompositeElement.h | 2 +- dom/svg/SVGFEConvolveMatrixElement.h | 2 +- dom/svg/SVGFEDiffuseLightingElement.h | 2 +- dom/svg/SVGFEDisplacementMapElement.h | 2 +- dom/svg/SVGFEDropShadowElement.h | 2 +- dom/svg/SVGFEFloodElement.h | 2 +- dom/svg/SVGFEGaussianBlurElement.h | 2 +- dom/svg/SVGFEImageElement.h | 2 +- dom/svg/SVGFEMergeElement.h | 2 +- dom/svg/SVGFEMorphologyElement.h | 2 +- dom/svg/SVGFEOffsetElement.h | 2 +- dom/svg/SVGFESpecularLightingElement.h | 2 +- dom/svg/SVGFETileElement.h | 2 +- dom/svg/SVGFETurbulenceElement.h | 2 +- dom/svg/SVGMarkerElement.cpp | 2 +- dom/svg/SVGMatrix.cpp | 20 +- dom/svg/SVGMatrix.h | 2 +- dom/svg/SVGPathElement.cpp | 40 +- dom/svg/SVGPreserveAspectRatio.h | 2 +- dom/svg/SVGRect.cpp | 2 +- dom/svg/SVGSVGElement.cpp | 16 +- dom/svg/SVGSVGElement.h | 4 +- dom/svg/SVGScriptElement.cpp | 2 +- dom/svg/SVGTextContentElement.cpp | 2 +- dom/svg/SVGTransform.cpp | 4 +- dom/svg/SVGTransform.h | 2 +- dom/svg/SVGTransformableElement.cpp | 12 +- dom/svg/SVGUseElement.cpp | 4 +- dom/svg/SVGViewElement.cpp | 2 +- dom/svg/SVGZoomEvent.cpp | 2 +- dom/svg/SVGZoomEvent.h | 4 +- dom/svg/nsISVGPoint.h | 2 +- dom/svg/nsSVGAngle.cpp | 6 +- dom/svg/nsSVGBoolean.cpp | 2 +- dom/svg/nsSVGClass.cpp | 2 +- dom/svg/nsSVGElement.cpp | 6 +- dom/svg/nsSVGElement.h | 8 +- dom/svg/nsSVGEnum.cpp | 2 +- dom/svg/nsSVGFilters.h | 2 +- dom/svg/nsSVGInteger.cpp | 2 +- dom/svg/nsSVGIntegerPair.cpp | 2 +- dom/svg/nsSVGLength2.cpp | 6 +- dom/svg/nsSVGNumber2.cpp | 2 +- dom/svg/nsSVGNumberPair.cpp | 2 +- dom/svg/nsSVGPathGeometryElement.cpp | 2 +- dom/svg/nsSVGPathGeometryElement.h | 2 +- dom/svg/nsSVGPolyElement.cpp | 4 +- dom/svg/nsSVGString.cpp | 2 +- dom/svg/nsSVGViewBox.cpp | 6 +- dom/svg/nsSVGViewBox.h | 4 +- dom/system/OSFileConstants.cpp | 2 +- dom/system/gonk/AudioChannelManager.cpp | 4 +- dom/system/gonk/AudioChannelManager.h | 2 +- dom/system/gonk/AudioManager.cpp | 20 +- dom/system/gonk/AutoMounter.cpp | 2 +- .../gonk/GonkGPSGeolocationProvider.cpp | 20 +- dom/system/gonk/MozMtpDatabase.cpp | 6 +- dom/system/gonk/MozMtpDatabase.h | 6 +- dom/system/gonk/MozMtpServer.cpp | 26 +- dom/system/gonk/MozMtpServer.h | 4 +- dom/system/gonk/MozMtpStorage.cpp | 8 +- dom/system/gonk/MozMtpStorage.h | 4 +- dom/system/gonk/NetworkWorker.cpp | 2 +- dom/system/gonk/SystemWorkerManager.cpp | 2 +- dom/system/gonk/SystemWorkerManager.h | 2 +- dom/system/gonk/nsVolume.h | 2 +- dom/system/gonk/nsVolumeMountLock.cpp | 4 +- dom/system/gonk/nsVolumeMountLock.h | 2 +- dom/system/gonk/nsVolumeService.cpp | 36 +- dom/system/mac/CoreLocationLocationProvider.h | 2 +- dom/system/nsDeviceSensors.cpp | 8 +- dom/system/qt/QTMLocationProvider.cpp | 2 +- .../windows/WindowsLocationProvider.cpp | 8 +- dom/system/windows/WindowsLocationProvider.h | 2 +- dom/telephony/CallsList.cpp | 4 +- dom/telephony/CallsList.h | 4 +- dom/telephony/MMICall.cpp | 4 +- dom/telephony/MMICall.h | 2 +- dom/telephony/Telephony.cpp | 50 +- dom/telephony/Telephony.h | 12 +- dom/telephony/TelephonyCall.cpp | 24 +- dom/telephony/TelephonyCall.h | 10 +- dom/telephony/TelephonyCallGroup.cpp | 30 +- dom/telephony/TelephonyCallGroup.h | 8 +- dom/telephony/TelephonyCallback.h | 2 +- dom/telephony/TelephonyDialCallback.cpp | 4 +- dom/telephony/TelephonyDialCallback.h | 4 +- dom/telephony/USSDSession.cpp | 8 +- dom/telephony/ipc/TelephonyChild.h | 2 +- .../beacon/test_beaconPreflightFailure.html | 2 +- dom/tests/mochitest/fetch/test_fetch_basic.js | 44 +- dom/tests/mochitest/fetch/test_fetch_cors.js | 121 +- dom/tests/mochitest/fetch/test_response.js | 48 +- dom/time/TimeService.cpp | 2 +- dom/tv/FakeTVService.cpp | 4 +- dom/tv/TVChannel.cpp | 12 +- dom/tv/TVChannel.h | 2 +- dom/tv/TVListeners.cpp | 12 +- dom/tv/TVListeners.h | 2 +- dom/tv/TVManager.cpp | 6 +- dom/tv/TVManager.h | 6 +- dom/tv/TVProgram.cpp | 2 +- dom/tv/TVProgram.h | 2 +- dom/tv/TVServiceCallbacks.cpp | 14 +- dom/tv/TVServiceCallbacks.h | 22 +- dom/tv/TVServiceFactory.cpp | 2 +- dom/tv/TVSource.cpp | 20 +- dom/tv/TVSource.h | 4 +- dom/tv/TVTuner.cpp | 14 +- dom/tv/TVTuner.h | 6 +- dom/voicemail/Voicemail.cpp | 6 +- dom/voicemail/Voicemail.h | 4 +- dom/voicemail/ipc/VoicemailIPCService.cpp | 4 +- dom/vr/VRDevice.cpp | 16 +- dom/vr/VRDevice.h | 28 +- dom/webidl/CSPDictionaries.webidl | 1 + dom/webidl/PerformanceResourceTiming.webidl | 5 + dom/webidl/PushEvent.webidl | 8 +- dom/webidl/PushMessageData.webidl | 13 +- dom/webidl/Request.webidl | 8 +- dom/webidl/ServiceWorkerMessageEvent.webidl | 48 + dom/webidl/moz.build | 1 + dom/wifi/WifiCertService.cpp | 6 +- dom/wifi/WifiProxyService.cpp | 2 +- dom/workers/DataStore.cpp | 62 +- dom/workers/DataStore.h | 4 +- dom/workers/DataStoreCursor.cpp | 12 +- dom/workers/DataStoreCursor.h | 2 +- dom/workers/FileReaderSync.cpp | 2 +- dom/workers/Location.cpp | 2 +- dom/workers/Navigator.cpp | 18 +- dom/workers/RuntimeService.cpp | 158 +- dom/workers/RuntimeService.h | 25 +- dom/workers/ScriptLoader.cpp | 40 +- dom/workers/ServiceWorker.cpp | 37 +- dom/workers/ServiceWorker.h | 17 +- dom/workers/ServiceWorkerClient.cpp | 44 +- dom/workers/ServiceWorkerClients.cpp | 36 +- dom/workers/ServiceWorkerClients.h | 2 +- dom/workers/ServiceWorkerContainer.cpp | 15 +- dom/workers/ServiceWorkerContainer.h | 4 +- dom/workers/ServiceWorkerEvents.cpp | 273 ++- dom/workers/ServiceWorkerEvents.h | 72 +- dom/workers/ServiceWorkerManager.cpp | 1593 +++-------------- dom/workers/ServiceWorkerManager.h | 67 +- dom/workers/ServiceWorkerManagerChild.cpp | 10 +- dom/workers/ServiceWorkerManagerParent.cpp | 22 +- dom/workers/ServiceWorkerManagerParent.h | 2 +- dom/workers/ServiceWorkerManagerService.cpp | 8 +- dom/workers/ServiceWorkerMessageEvent.cpp | 187 ++ dom/workers/ServiceWorkerMessageEvent.h | 86 + dom/workers/ServiceWorkerPeriodicUpdater.cpp | 2 +- dom/workers/ServiceWorkerPrivate.cpp | 1088 +++++++++++ dom/workers/ServiceWorkerPrivate.h | 129 ++ dom/workers/ServiceWorkerRegistrar.cpp | 10 +- dom/workers/ServiceWorkerRegistration.cpp | 98 +- dom/workers/ServiceWorkerRegistration.h | 12 +- dom/workers/ServiceWorkerScriptCache.cpp | 32 +- dom/workers/ServiceWorkerWindowClient.cpp | 16 +- dom/workers/SharedWorker.cpp | 29 +- dom/workers/SharedWorker.h | 8 +- dom/workers/URL.cpp | 76 +- dom/workers/URL.h | 4 +- dom/workers/WorkerDebuggerManager.cpp | 8 +- dom/workers/WorkerDebuggerManager.h | 6 +- dom/workers/WorkerPrivate.cpp | 241 +-- dom/workers/WorkerPrivate.h | 45 +- dom/workers/WorkerRunnable.cpp | 14 +- dom/workers/WorkerScope.cpp | 26 +- dom/workers/WorkerScope.h | 16 +- dom/workers/WorkerThread.cpp | 4 +- dom/workers/WorkerThread.h | 4 +- dom/workers/Workers.h | 2 +- dom/workers/XMLHttpRequest.cpp | 70 +- dom/workers/XMLHttpRequest.h | 4 +- dom/workers/XMLHttpRequestUpload.cpp | 2 +- dom/workers/XMLHttpRequestUpload.h | 2 +- dom/workers/moz.build | 3 + dom/workers/test/gtest/TestReadWrite.cpp | 16 +- dom/workers/test/mochitest.ini | 2 + .../serviceworkers/fetch/hsts/embedder.html | 7 + .../serviceworkers/fetch/hsts/hsts_test.js | 11 + .../serviceworkers/fetch/hsts/image-20px.png | Bin 0 -> 87 bytes .../serviceworkers/fetch/hsts/image-40px.png | Bin 0 -> 123 bytes .../test/serviceworkers/fetch/hsts/image.html | 13 + .../serviceworkers/fetch/hsts/realindex.html | 4 + .../serviceworkers/fetch/hsts/register.html | 14 + .../fetch/hsts/register.html^headers^ | 2 + .../serviceworkers/fetch/hsts/unregister.html | 12 + dom/workers/test/serviceworkers/mochitest.ini | 11 + .../test_hsts_upgrade_intercept.html | 66 + dom/workers/test/sharedWorker_lifetime.js | 5 + .../test/test_sharedWorker_lifetime.html | 32 + dom/xbl/nsBindingManager.cpp | 10 +- dom/xbl/nsBindingManager.h | 4 +- dom/xbl/nsXBLBinding.cpp | 2 +- dom/xbl/nsXBLBinding.h | 8 +- dom/xbl/nsXBLContentSink.cpp | 8 +- dom/xbl/nsXBLDocumentInfo.cpp | 2 +- dom/xbl/nsXBLEventHandler.cpp | 2 +- dom/xbl/nsXBLPrototypeBinding.cpp | 12 +- dom/xbl/nsXBLPrototypeHandler.cpp | 4 +- dom/xbl/nsXBLPrototypeHandler.h | 2 +- dom/xbl/nsXBLPrototypeResources.cpp | 4 +- dom/xbl/nsXBLPrototypeResources.h | 6 +- dom/xbl/nsXBLResourceLoader.cpp | 4 +- dom/xbl/nsXBLService.cpp | 12 +- dom/xbl/nsXBLWindowKeyHandler.cpp | 6 +- dom/xml/CDATASection.cpp | 2 +- dom/xml/ProcessingInstruction.cpp | 8 +- dom/xml/XMLDocument.cpp | 6 +- .../XMLStylesheetProcessingInstruction.cpp | 2 +- dom/xml/nsXMLContentSink.cpp | 16 +- dom/xml/nsXMLFragmentContentSink.cpp | 4 +- dom/xml/nsXMLPrettyPrinter.cpp | 4 +- dom/xslt/xpath/XPathEvaluator.cpp | 4 +- dom/xslt/xpath/XPathEvaluator.h | 2 +- dom/xslt/xpath/XPathExpression.cpp | 6 +- dom/xslt/xpath/XPathExpression.h | 2 +- dom/xslt/xpath/XPathResult.cpp | 2 +- dom/xslt/xpath/XPathResult.h | 2 +- dom/xslt/xpath/txCoreFunctionCall.cpp | 18 +- dom/xslt/xpath/txExpr.cpp | 4 +- dom/xslt/xpath/txExpr.h | 2 +- dom/xslt/xpath/txExprResult.h | 2 +- dom/xslt/xpath/txFilterExpr.cpp | 6 +- dom/xslt/xpath/txForwardContext.h | 2 +- dom/xslt/xpath/txFunctionCall.cpp | 4 +- dom/xslt/xpath/txLocationStep.cpp | 2 +- dom/xslt/xpath/txNamedAttributeStep.cpp | 2 +- dom/xslt/xpath/txNodeSetContext.h | 2 +- dom/xslt/xpath/txNumberExpr.cpp | 2 +- dom/xslt/xpath/txPathExpr.cpp | 16 +- dom/xslt/xpath/txPredicateList.cpp | 2 +- dom/xslt/xpath/txPredicatedNodeTest.cpp | 2 +- dom/xslt/xpath/txRelationalExpr.cpp | 8 +- dom/xslt/xpath/txResultRecycler.cpp | 2 +- dom/xslt/xpath/txResultRecycler.h | 6 +- dom/xslt/xpath/txUnaryExpr.cpp | 2 +- dom/xslt/xpath/txUnionExpr.cpp | 6 +- dom/xslt/xpath/txXPCOMExtensionFunction.cpp | 4 +- dom/xslt/xpath/txXPathObjectAdaptor.h | 2 +- dom/xslt/xpath/txXPathOptimizer.cpp | 4 +- dom/xslt/xslt/txDocumentFunctionCall.cpp | 6 +- dom/xslt/xslt/txEXSLTFunctions.cpp | 44 +- dom/xslt/xslt/txExecutionState.h | 6 +- dom/xslt/xslt/txGenerateIdFunctionCall.cpp | 2 +- dom/xslt/xslt/txInstructions.cpp | 16 +- dom/xslt/xslt/txInstructions.h | 4 +- dom/xslt/xslt/txKey.h | 4 +- dom/xslt/xslt/txKeyFunctionCall.cpp | 8 +- dom/xslt/xslt/txMozillaStylesheetCompiler.cpp | 16 +- dom/xslt/xslt/txMozillaTextOutput.cpp | 2 +- dom/xslt/xslt/txMozillaXMLOutput.cpp | 8 +- dom/xslt/xslt/txMozillaXMLOutput.h | 4 +- dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 16 +- dom/xslt/xslt/txMozillaXSLTProcessor.h | 4 +- dom/xslt/xslt/txNodeSorter.cpp | 2 +- dom/xslt/xslt/txStylesheetCompiler.cpp | 6 +- dom/xslt/xslt/txStylesheetCompiler.h | 6 +- dom/xslt/xslt/txXPathResultComparator.cpp | 2 +- dom/xslt/xslt/txXSLTFunctions.h | 6 +- dom/xslt/xslt/txXSLTNumber.cpp | 2 +- dom/xslt/xslt/txXSLTPatterns.cpp | 10 +- dom/xul/XULDocument.cpp | 30 +- dom/xul/XULDocument.h | 16 +- dom/xul/nsXULContentSink.cpp | 14 +- dom/xul/nsXULContentSink.h | 8 +- dom/xul/nsXULElement.cpp | 60 +- dom/xul/nsXULElement.h | 26 +- dom/xul/nsXULPopupListener.cpp | 2 +- dom/xul/nsXULPrototypeCache.cpp | 14 +- dom/xul/nsXULPrototypeDocument.cpp | 16 +- dom/xul/nsXULPrototypeDocument.h | 10 +- dom/xul/templates/nsInstantiationNode.cpp | 2 +- dom/xul/templates/nsRDFBinding.h | 2 +- dom/xul/templates/nsXMLBinding.h | 4 +- dom/xul/templates/nsXULContentBuilder.cpp | 6 +- dom/xul/templates/nsXULTemplateBuilder.cpp | 4 +- .../nsXULTemplateQueryProcessorRDF.cpp | 6 +- .../nsXULTemplateQueryProcessorRDF.h | 2 +- .../nsXULTemplateQueryProcessorXML.cpp | 10 +- .../nsXULTemplateQueryProcessorXML.h | 8 +- .../templates/nsXULTemplateResultSetRDF.cpp | 2 +- .../templates/nsXULTemplateResultStorage.h | 2 +- editor/composer/nsComposerCommandsUpdater.cpp | 2 +- .../composer/nsComposerDocumentCommands.cpp | 4 +- editor/composer/nsEditingSession.cpp | 2 +- editor/composer/nsEditingSession.h | 2 +- editor/composer/nsEditorSpellCheck.cpp | 18 +- editor/libeditor/CreateElementTxn.cpp | 2 +- editor/libeditor/DeleteRangeTxn.cpp | 14 +- editor/libeditor/DeleteRangeTxn.h | 2 +- editor/libeditor/DeleteTextTxn.cpp | 2 +- editor/libeditor/DeleteTextTxn.h | 2 +- editor/libeditor/EditAggregateTxn.cpp | 2 +- editor/libeditor/EditAggregateTxn.h | 2 +- editor/libeditor/IMETextTxn.cpp | 8 +- editor/libeditor/IMETextTxn.h | 4 +- editor/libeditor/InsertNodeTxn.cpp | 2 +- editor/libeditor/InsertTextTxn.cpp | 4 +- editor/libeditor/InsertTextTxn.h | 2 +- editor/libeditor/PlaceholderTxn.cpp | 8 +- editor/libeditor/SplitNodeTxn.cpp | 2 +- editor/libeditor/TypeInState.cpp | 2 +- editor/libeditor/nsEditor.cpp | 158 +- editor/libeditor/nsEditor.h | 6 +- editor/libeditor/nsEditorEventListener.cpp | 8 +- editor/libeditor/nsEditorEventListener.h | 2 +- editor/libeditor/nsEditorUtils.h | 2 +- editor/libeditor/nsHTMLAbsPosition.cpp | 12 +- editor/libeditor/nsHTMLAnonymousUtils.cpp | 2 +- editor/libeditor/nsHTMLCSSUtils.cpp | 12 +- editor/libeditor/nsHTMLDataTransfer.cpp | 22 +- editor/libeditor/nsHTMLEditRules.cpp | 64 +- editor/libeditor/nsHTMLEditRules.h | 10 +- editor/libeditor/nsHTMLEditor.cpp | 110 +- editor/libeditor/nsHTMLEditor.h | 4 +- .../libeditor/nsHTMLEditorEventListener.cpp | 4 +- editor/libeditor/nsHTMLEditorStyle.cpp | 18 +- editor/libeditor/nsHTMLURIRefObject.cpp | 2 +- editor/libeditor/nsPlaintextDataTransfer.cpp | 6 +- editor/libeditor/nsPlaintextEditor.cpp | 28 +- editor/libeditor/nsSelectionState.cpp | 10 +- editor/libeditor/nsSelectionState.h | 6 +- editor/libeditor/nsStyleSheetTxns.h | 4 +- editor/libeditor/nsTableEditor.cpp | 46 +- editor/libeditor/nsTextEditRules.cpp | 14 +- editor/libeditor/nsTextEditRulesBidi.cpp | 4 +- editor/libeditor/nsWSRunObject.cpp | 38 +- editor/libeditor/nsWSRunObject.h | 8 +- editor/txmgr/nsTransactionItem.cpp | 8 +- editor/txmgr/nsTransactionList.cpp | 10 +- editor/txmgr/nsTransactionList.h | 2 +- editor/txmgr/nsTransactionManager.cpp | 26 +- editor/txmgr/nsTransactionStack.cpp | 10 +- editor/txmgr/nsTransactionStack.h | 2 +- editor/txtsvc/nsFilteredContentIterator.h | 2 +- editor/txtsvc/nsTextServicesDocument.cpp | 20 +- editor/txtsvc/nsTextServicesDocument.h | 2 +- embedding/browser/nsContextMenuInfo.cpp | 8 +- embedding/browser/nsDocShellTreeOwner.cpp | 2 +- embedding/browser/nsDocShellTreeOwner.h | 4 +- embedding/browser/nsWebBrowser.cpp | 2 +- embedding/browser/nsWebBrowser.h | 4 +- .../commandhandler/nsCommandGroup.cpp | 4 +- embedding/components/find/nsFind.cpp | 2 +- embedding/components/find/nsFind.h | 2 +- .../printingui/ipc/nsPrintingProxy.cpp | 6 +- .../webbrowserpersist/nsWebBrowserPersist.cpp | 4 +- .../windowwatcher/nsAutoWindowStateHelper.cpp | 2 +- extensions/auth/nsAuthFactory.cpp | 2 +- extensions/cookie/nsPermissionManager.cpp | 12 +- extensions/gio/nsGIOProtocolHandler.cpp | 2 +- .../spellcheck/src/mozInlineSpellChecker.cpp | 20 +- .../spellcheck/src/mozInlineSpellChecker.h | 10 +- .../spellcheck/src/mozInlineSpellWordUtil.cpp | 2 +- .../spellcheck/src/mozPersonalDictionary.cpp | 4 +- extensions/spellcheck/src/mozSpellChecker.cpp | 2 +- gfx/2d/DrawTargetD2D.cpp | 130 +- gfx/2d/DrawTargetD2D1.cpp | 76 +- gfx/2d/Factory.cpp | 2 +- gfx/2d/FilterNodeD2D1.cpp | 14 +- gfx/2d/HelpersD2D.h | 18 +- gfx/2d/JobScheduler.h | 3 +- gfx/2d/JobScheduler_posix.h | 1 + gfx/2d/PathD2D.cpp | 4 +- gfx/2d/QuartzSupport.h | 2 +- gfx/2d/QuartzSupport.mm | 4 +- gfx/2d/RadialGradientEffectD2D1.cpp | 4 +- gfx/2d/ScaledFontDWrite.cpp | 10 +- gfx/2d/SourceSurfaceD2D.cpp | 16 +- gfx/2d/SourceSurfaceD2D1.cpp | 10 +- gfx/2d/SourceSurfaceD2DTarget.cpp | 16 +- gfx/2d/unittest/TestDrawTargetBase.h | 4 +- gfx/2d/unittest/TestDrawTargetD2D.h | 2 +- gfx/gl/GLContextEGL.h | 2 +- gfx/gl/GLContextGLX.h | 2 +- gfx/gl/GLContextProviderCGL.mm | 8 +- gfx/gl/GLContextProviderEGL.cpp | 8 +- gfx/gl/GLContextProviderGLX.cpp | 6 +- gfx/gl/GLContextProviderWGL.cpp | 12 +- gfx/gl/GLTextureImage.cpp | 4 +- gfx/gl/GLTextureImage.h | 4 +- gfx/gl/SharedSurfaceANGLE.cpp | 4 +- gfx/gl/SharedSurfaceEGL.h | 2 +- gfx/gl/TextureImageCGL.mm | 4 +- gfx/gl/TextureImageEGL.cpp | 4 +- gfx/layers/AtomicRefCountedWithFinalize.h | 8 +- gfx/layers/CopyableCanvasLayer.h | 2 +- gfx/layers/D3D11ShareHandleImage.cpp | 8 +- gfx/layers/D3D9SurfaceImage.cpp | 8 +- gfx/layers/Effects.h | 2 +- gfx/layers/GLImages.cpp | 2 +- gfx/layers/GrallocImages.h | 2 +- gfx/layers/IMFYCbCrImage.cpp | 26 +- gfx/layers/ImageContainer.cpp | 4 +- gfx/layers/ImageContainer.h | 8 +- gfx/layers/ImageLayers.h | 2 +- gfx/layers/LayerScope.cpp | 12 +- gfx/layers/LayerTreeInvalidation.cpp | 6 +- gfx/layers/Layers.cpp | 31 +- gfx/layers/Layers.h | 12 +- gfx/layers/ReadbackProcessor.cpp | 2 +- gfx/layers/TextureDIB.cpp | 4 +- gfx/layers/TextureDIB.h | 4 +- gfx/layers/apz/src/APZCTreeManager.cpp | 78 +- gfx/layers/apz/src/APZCTreeManager.h | 16 +- gfx/layers/apz/src/AsyncPanZoomController.cpp | 60 +- gfx/layers/apz/src/AsyncPanZoomController.h | 34 +- gfx/layers/apz/src/GestureEventListener.h | 2 +- gfx/layers/apz/src/HitTestingTreeNode.h | 10 +- gfx/layers/apz/src/InputBlockState.cpp | 40 +- gfx/layers/apz/src/InputBlockState.h | 28 +- gfx/layers/apz/src/InputQueue.cpp | 26 +- gfx/layers/apz/src/InputQueue.h | 20 +- gfx/layers/apz/src/OverscrollHandoffState.cpp | 8 +- gfx/layers/apz/src/OverscrollHandoffState.h | 10 +- gfx/layers/apz/src/TaskThrottler.cpp | 2 +- .../test/gtest/TestAsyncPanZoomController.cpp | 108 +- gfx/layers/apz/util/APZCCallbackHelper.cpp | 2 +- gfx/layers/apz/util/APZEventState.cpp | 2 +- gfx/layers/apz/util/APZEventState.h | 4 +- gfx/layers/apz/util/ChromeProcessController.h | 4 +- gfx/layers/basic/BasicCanvasLayer.cpp | 2 +- gfx/layers/basic/BasicColorLayer.cpp | 2 +- gfx/layers/basic/BasicContainerLayer.cpp | 2 +- gfx/layers/basic/BasicImageLayer.cpp | 4 +- gfx/layers/basic/BasicImages.cpp | 2 +- gfx/layers/basic/BasicLayerManager.cpp | 16 +- gfx/layers/basic/BasicLayers.h | 6 +- gfx/layers/basic/BasicLayersImpl.h | 2 +- gfx/layers/basic/BasicPaintedLayer.cpp | 8 +- gfx/layers/basic/TextureClientX11.cpp | 2 +- gfx/layers/basic/X11BasicCompositor.cpp | 2 +- gfx/layers/client/ClientCanvasLayer.cpp | 2 +- gfx/layers/client/ClientColorLayer.cpp | 2 +- gfx/layers/client/ClientContainerLayer.cpp | 4 +- gfx/layers/client/ClientImageLayer.cpp | 2 +- gfx/layers/client/ClientLayerManager.cpp | 4 +- gfx/layers/client/ClientLayerManager.h | 8 +- gfx/layers/client/ClientPaintedLayer.cpp | 6 +- gfx/layers/client/ContentClient.cpp | 2 +- gfx/layers/client/ImageClient.cpp | 4 +- .../client/SingleTiledContentClient.cpp | 2 +- gfx/layers/client/SingleTiledContentClient.h | 2 +- gfx/layers/client/TextureClient.cpp | 2 +- gfx/layers/client/TextureClient.h | 2 +- gfx/layers/client/TextureClientPool.h | 2 +- .../client/TextureClientRecycleAllocator.cpp | 2 +- gfx/layers/client/TiledContentClient.cpp | 2 +- gfx/layers/client/TiledContentClient.h | 2 +- .../composite/AsyncCompositionManager.h | 4 +- gfx/layers/composite/CanvasLayerComposite.cpp | 2 +- gfx/layers/composite/CompositableHost.cpp | 2 +- .../composite/ContainerLayerComposite.cpp | 6 +- .../composite/ContainerLayerComposite.h | 2 +- gfx/layers/composite/ImageLayerComposite.cpp | 2 +- .../composite/LayerManagerComposite.cpp | 26 +- gfx/layers/composite/LayerManagerComposite.h | 2 +- .../composite/PaintedLayerComposite.cpp | 2 +- gfx/layers/composite/TextureHost.cpp | 4 +- gfx/layers/composite/TiledContentHost.cpp | 2 +- gfx/layers/composite/X11TextureHost.cpp | 2 +- gfx/layers/d3d11/CompositorD3D11.cpp | 70 +- gfx/layers/d3d11/ReadbackManagerD3D11.cpp | 2 +- gfx/layers/d3d11/TextureD3D11.cpp | 58 +- gfx/layers/d3d9/CompositorD3D9.cpp | 16 +- gfx/layers/d3d9/CompositorD3D9.h | 4 +- gfx/layers/d3d9/DeviceManagerD3D9.cpp | 8 +- gfx/layers/d3d9/DeviceManagerD3D9.h | 48 +- gfx/layers/d3d9/Nv3DVUtils.h | 2 +- gfx/layers/d3d9/TextureD3D9.cpp | 22 +- gfx/layers/d3d9/TextureD3D9.h | 4 +- gfx/layers/ipc/CompositorChild.cpp | 16 +- gfx/layers/ipc/CompositorChild.h | 6 +- gfx/layers/ipc/CompositorParent.cpp | 20 +- gfx/layers/ipc/CompositorParent.h | 22 +- gfx/layers/ipc/FenceUtils.cpp | 6 +- gfx/layers/ipc/FenceUtils.h | 2 +- gfx/layers/ipc/ImageBridgeChild.cpp | 2 +- gfx/layers/ipc/ImageBridgeParent.cpp | 2 +- gfx/layers/ipc/ImageBridgeParent.h | 4 +- gfx/layers/ipc/LayerTransactionParent.cpp | 14 +- gfx/layers/ipc/LayerTransactionParent.h | 4 +- gfx/layers/ipc/ShadowLayerParent.h | 2 +- gfx/layers/ipc/ShadowLayerUtilsX11.cpp | 2 +- gfx/layers/ipc/SharedRGBImage.cpp | 4 +- gfx/layers/opengl/CompositorOGL.cpp | 6 +- gfx/layers/opengl/CompositorOGL.h | 2 +- gfx/layers/opengl/GrallocTextureClient.cpp | 4 +- gfx/layers/opengl/GrallocTextureHost.cpp | 2 +- gfx/layers/opengl/OGLShaderProgram.cpp | 2 +- gfx/layers/opengl/TextureHostOGL.h | 2 +- gfx/layers/opengl/X11TextureSourceOGL.h | 2 +- gfx/src/gfxCrashReporterUtils.cpp | 2 +- gfx/src/nsDeviceContext.cpp | 4 +- gfx/src/nsDeviceContext.h | 4 +- gfx/src/nsFont.h | 2 +- gfx/src/nsFontMetrics.h | 2 +- gfx/src/nsRenderingContext.h | 4 +- .../gtest/TestAsyncPanZoomController.cpp | 126 +- gfx/tests/gtest/TestCompositor.cpp | 16 +- gfx/tests/gtest/TestLayers.cpp | 44 +- gfx/tests/gtest/TestLayers.h | 4 +- gfx/tests/gtest/TestTextures.cpp | 2 +- gfx/tests/gtest/TestVsync.cpp | 16 +- gfx/tests/gtest/gfxFontSelectionTest.cpp | 6 +- gfx/tests/gtest/gfxSurfaceRefCountTest.cpp | 4 +- gfx/tests/gtest/gfxTextRunPerfTest.cpp | 6 +- gfx/tests/gtest/gfxWordCacheTest.cpp | 6 +- gfx/thebes/SoftwareVsyncSource.h | 2 +- gfx/thebes/VsyncSource.cpp | 4 +- gfx/thebes/VsyncSource.h | 10 +- gfx/thebes/gfxASurface.cpp | 8 +- gfx/thebes/gfxAndroidPlatform.cpp | 4 +- gfx/thebes/gfxBaseSharedMemorySurface.h | 4 +- gfx/thebes/gfxBlur.cpp | 4 +- gfx/thebes/gfxBlur.h | 2 +- gfx/thebes/gfxContext.cpp | 6 +- gfx/thebes/gfxContext.h | 22 +- gfx/thebes/gfxDWriteFontList.cpp | 56 +- gfx/thebes/gfxDWriteFontList.h | 20 +- gfx/thebes/gfxDWriteFonts.cpp | 2 +- gfx/thebes/gfxDWriteFonts.h | 2 +- gfx/thebes/gfxDrawable.cpp | 12 +- gfx/thebes/gfxDrawable.h | 8 +- gfx/thebes/gfxFT2FontList.cpp | 30 +- gfx/thebes/gfxFT2FontList.h | 2 +- gfx/thebes/gfxFT2Utils.h | 2 +- gfx/thebes/gfxFcPlatformFontList.cpp | 6 +- gfx/thebes/gfxFcPlatformFontList.h | 4 +- gfx/thebes/gfxFont.cpp | 10 +- gfx/thebes/gfxFont.h | 18 +- gfx/thebes/gfxFontEntry.cpp | 6 +- gfx/thebes/gfxFontEntry.h | 12 +- gfx/thebes/gfxFontInfoLoader.cpp | 6 +- gfx/thebes/gfxFontInfoLoader.h | 6 +- gfx/thebes/gfxFontconfigFonts.cpp | 32 +- gfx/thebes/gfxFontconfigFonts.h | 2 +- gfx/thebes/gfxGDIFontList.cpp | 10 +- gfx/thebes/gfxImageSurface.cpp | 8 +- gfx/thebes/gfxImageSurface.h | 2 +- gfx/thebes/gfxMacPlatformFontList.mm | 6 +- gfx/thebes/gfxPattern.h | 4 +- gfx/thebes/gfxPlatform.cpp | 10 +- gfx/thebes/gfxPlatform.h | 10 +- gfx/thebes/gfxPlatformFontList.cpp | 24 +- gfx/thebes/gfxPlatformFontList.h | 14 +- gfx/thebes/gfxPlatformGtk.cpp | 2 +- gfx/thebes/gfxPlatformMac.cpp | 6 +- gfx/thebes/gfxQPainterSurface.cpp | 2 +- gfx/thebes/gfxQtNativeRenderer.cpp | 2 +- gfx/thebes/gfxQtPlatform.cpp | 2 +- gfx/thebes/gfxQuartzImageSurface.cpp | 4 +- gfx/thebes/gfxQuartzNativeDrawing.h | 4 +- gfx/thebes/gfxQuartzSurface.cpp | 4 +- gfx/thebes/gfxReusableImageSurfaceWrapper.h | 2 +- .../gfxReusableSharedImageSurfaceWrapper.cpp | 6 +- .../gfxReusableSharedImageSurfaceWrapper.h | 4 +- gfx/thebes/gfxSVGGlyphs.h | 8 +- gfx/thebes/gfxTeeSurface.cpp | 6 +- gfx/thebes/gfxTeeSurface.h | 2 +- gfx/thebes/gfxTextRun.cpp | 50 +- gfx/thebes/gfxTextRun.h | 12 +- gfx/thebes/gfxUserFontSet.cpp | 6 +- gfx/thebes/gfxUserFontSet.h | 6 +- gfx/thebes/gfxUtils.cpp | 16 +- gfx/thebes/gfxWindowsNativeDrawing.cpp | 10 +- gfx/thebes/gfxWindowsNativeDrawing.h | 6 +- gfx/thebes/gfxWindowsPlatform.cpp | 54 +- gfx/thebes/gfxWindowsPlatform.h | 20 +- gfx/thebes/gfxWindowsSurface.cpp | 4 +- gfx/thebes/gfxXlibNativeRenderer.cpp | 8 +- gfx/thebes/gfxXlibSurface.cpp | 6 +- gfx/vr/gfxVR.cpp | 4 +- gfx/vr/gfxVR.h | 12 +- gfx/vr/gfxVRCardboard.cpp | 4 +- gfx/vr/gfxVRCardboard.h | 4 +- gfx/vr/gfxVROculus.cpp | 14 +- gfx/vr/gfxVROculus.h | 6 +- gfx/vr/gfxVROculus050.cpp | 6 +- gfx/vr/gfxVROculus050.h | 6 +- hal/gonk/GonkHal.cpp | 8 +- hal/windows/WindowsSensor.cpp | 16 +- image/ClippedImage.cpp | 12 +- image/CopyOnWrite.h | 18 +- image/DecodePool.cpp | 16 +- image/DecodePool.h | 2 +- image/Decoder.cpp | 2 +- image/Decoder.h | 2 +- image/DecoderFactory.cpp | 12 +- image/DynamicImage.cpp | 2 +- image/DynamicImage.h | 2 +- image/FrameAnimator.cpp | 4 +- image/Image.cpp | 2 +- image/Image.h | 6 +- image/ImageCacheKey.cpp | 2 +- image/ImageCacheKey.h | 2 +- image/ImageFactory.cpp | 12 +- image/ImageOps.cpp | 10 +- image/ImageWrapper.h | 2 +- image/MultipartImage.cpp | 24 +- image/MultipartImage.h | 6 +- image/OrientedImage.cpp | 4 +- image/ProgressTracker.cpp | 30 +- image/ProgressTracker.h | 2 +- image/RasterImage.cpp | 24 +- image/RasterImage.h | 6 +- image/SourceBuffer.h | 6 +- image/SurfaceCache.cpp | 40 +- image/VectorImage.cpp | 20 +- image/VectorImage.h | 8 +- image/decoders/nsICODecoder.cpp | 10 +- image/decoders/nsICODecoder.h | 2 +- image/imgFrame.cpp | 4 +- image/imgFrame.h | 6 +- image/imgLoader.cpp | 90 +- image/imgLoader.h | 18 +- image/imgRequest.cpp | 40 +- image/imgRequest.h | 8 +- image/imgRequestProxy.cpp | 50 +- image/imgRequestProxy.h | 4 +- image/imgTools.cpp | 4 +- image/test/gtest/Common.cpp | 4 +- image/test/gtest/TestDecodeToSurface.cpp | 6 +- image/test/gtest/TestDecoders.cpp | 14 +- image/test/gtest/TestMetadata.cpp | 12 +- intl/hyphenation/nsHyphenationManager.cpp | 4 +- intl/locale/nsLocaleService.cpp | 4 +- intl/strres/nsStringBundle.cpp | 4 +- ipc/chromium/src/base/message_loop.cc | 2 +- ipc/chromium/src/base/message_loop.h | 2 +- ipc/chromium/src/base/revocable_store.h | 4 +- ipc/chromium/src/base/waitable_event.h | 2 +- .../src/base/waitable_event_watcher.h | 4 +- .../src/base/waitable_event_watcher_posix.cc | 4 +- .../src/chrome/common/ipc_channel_posix.h | 2 +- .../src/chrome/common/ipc_channel_proxy.h | 4 +- ipc/chromium/src/chrome/common/ipc_message.h | 2 +- .../src/chrome/common/ipc_sync_channel.cc | 6 +- .../src/chrome/common/ipc_sync_channel.h | 2 +- ipc/dbus/DBusUtils.cpp | 2 +- ipc/glue/BackgroundChildImpl.cpp | 20 +- ipc/glue/BackgroundImpl.cpp | 54 +- ipc/glue/BackgroundParentImpl.cpp | 26 +- ipc/glue/BackgroundUtils.cpp | 20 +- ipc/glue/CrossProcessMutex.h | 2 +- ipc/glue/InputStreamUtils.cpp | 2 +- ipc/glue/MessageChannel.h | 8 +- ipc/glue/MessagePump.h | 2 +- ipc/glue/Shmem.cpp | 12 +- ipc/hal/DaemonRunnables.h | 50 +- ipc/hal/DaemonSocketPDU.h | 2 +- ipc/ipdl/ipdl/builtin.py | 2 +- ipc/ipdl/ipdl/lower.py | 4 +- ipc/keystore/KeyStore.h | 4 +- ipc/netd/Netd.cpp | 4 +- ipc/ril/Ril.cpp | 6 +- ipc/ril/Ril.h | 4 +- ipc/ril/RilSocket.cpp | 4 +- ipc/ril/RilSocket.h | 2 +- ipc/testshell/XPCShellEnvironment.cpp | 2 +- js/public/UbiNode.h | 25 +- js/public/Value.h | 11 +- js/src/doc/Debugger/Debugger.Source.md | 11 + .../tests/debug/Source-canonicalId.js | 32 + js/src/jit/IonCode.h | 1 + js/src/jsapi-tests/testUbiNode.cpp | 34 + js/src/jsapi.cpp | 14 +- js/src/jsapi.h | 6 +- js/src/jsscript.cpp | 28 + js/src/jsscript.h | 2 + js/src/vm/Debugger.cpp | 27 + js/src/vm/Interpreter.cpp | 6 +- js/src/vm/Runtime.cpp | 6 +- js/src/vm/Runtime.h | 2 +- js/xpconnect/idl/nsIXPCScriptable.idl | 2 +- js/xpconnect/loader/mozJSComponentLoader.cpp | 2 +- js/xpconnect/loader/mozJSSubScriptLoader.cpp | 24 +- js/xpconnect/src/ExportHelpers.cpp | 8 +- js/xpconnect/src/Sandbox.cpp | 4 +- js/xpconnect/src/XPCComponents.cpp | 22 +- js/xpconnect/src/XPCConvert.cpp | 12 +- js/xpconnect/src/XPCJSID.cpp | 8 +- js/xpconnect/src/XPCJSRuntime.cpp | 7 +- js/xpconnect/src/XPCJSWeakReference.cpp | 2 +- js/xpconnect/src/XPCMaps.cpp | 2 +- js/xpconnect/src/XPCRuntimeService.cpp | 2 +- js/xpconnect/src/XPCShellImpl.cpp | 2 +- js/xpconnect/src/XPCVariant.cpp | 2 +- js/xpconnect/src/XPCWrappedJS.cpp | 10 +- js/xpconnect/src/XPCWrappedJSClass.cpp | 4 +- js/xpconnect/src/XPCWrappedNative.cpp | 14 +- js/xpconnect/src/nsXPConnect.cpp | 8 +- js/xpconnect/src/qsObjectHelper.h | 2 +- js/xpconnect/src/xpcObjectHelper.h | 2 +- js/xpconnect/src/xpcprivate.h | 32 +- js/xpconnect/wrappers/XrayWrapper.cpp | 2 +- layout/base/AccessibleCaret.h | 6 +- layout/base/AccessibleCaretEventHub.cpp | 2 +- layout/base/AccessibleCaretEventHub.h | 2 +- layout/base/AccessibleCaretManager.cpp | 30 +- layout/base/AccessibleCaretManager.h | 2 +- layout/base/ArenaRefPtr.h | 8 +- layout/base/FrameLayerBuilder.cpp | 64 +- layout/base/FrameLayerBuilder.h | 10 +- layout/base/GeometryUtils.cpp | 12 +- layout/base/GeometryUtils.h | 2 +- layout/base/MaskLayerImageCache.h | 2 +- layout/base/PositionedEventTargeting.cpp | 2 +- layout/base/RestyleManager.cpp | 36 +- layout/base/RestyleManager.h | 24 +- layout/base/RestyleTracker.cpp | 10 +- layout/base/RestyleTracker.h | 6 +- layout/base/SelectionCarets.cpp | 52 +- layout/base/TouchCaret.cpp | 24 +- layout/base/TouchManager.cpp | 8 +- layout/base/TouchManager.h | 2 +- .../gtest/TestAccessibleCaretEventHub.cpp | 4 +- layout/base/nsCSSFrameConstructor.cpp | 104 +- layout/base/nsCSSFrameConstructor.h | 6 +- layout/base/nsCSSRendering.cpp | 12 +- layout/base/nsCSSRendering.h | 4 +- layout/base/nsCaret.cpp | 2 +- layout/base/nsCounterManager.h | 4 +- layout/base/nsDisplayList.cpp | 38 +- layout/base/nsDisplayList.h | 8 +- layout/base/nsDocumentViewer.cpp | 44 +- layout/base/nsFrameManager.h | 2 +- layout/base/nsGenConList.h | 2 +- layout/base/nsIPresShell.h | 6 +- layout/base/nsLayoutHistoryState.cpp | 2 +- layout/base/nsLayoutUtils.cpp | 10 +- layout/base/nsLayoutUtils.h | 14 +- layout/base/nsPresContext.cpp | 20 +- layout/base/nsPresContext.h | 14 +- layout/base/nsPresShell.cpp | 84 +- layout/base/nsPresShell.h | 18 +- layout/base/nsRefreshDriver.cpp | 24 +- layout/base/nsRefreshDriver.h | 2 +- layout/base/nsStyleSheetService.cpp | 8 +- layout/build/nsContentDLF.cpp | 4 +- layout/forms/nsButtonFrameRenderer.h | 4 +- layout/forms/nsColorControlFrame.cpp | 2 +- layout/forms/nsComboboxControlFrame.cpp | 10 +- layout/forms/nsFileControlFrame.cpp | 12 +- layout/forms/nsFileControlFrame.h | 2 +- layout/forms/nsGfxButtonControlFrame.cpp | 2 +- layout/forms/nsListControlFrame.cpp | 28 +- layout/forms/nsListControlFrame.h | 2 +- layout/forms/nsMeterFrame.cpp | 6 +- layout/forms/nsNumberControlFrame.cpp | 10 +- layout/forms/nsProgressFrame.cpp | 4 +- layout/forms/nsRangeFrame.cpp | 4 +- layout/forms/nsRangeFrame.h | 4 +- layout/forms/nsTextControlFrame.cpp | 14 +- layout/generic/DetailsFrame.cpp | 2 +- layout/generic/MathMLTextRunFactory.cpp | 8 +- layout/generic/ScrollbarActivity.h | 2 +- layout/generic/Selection.h | 16 +- layout/generic/TextOverflow.cpp | 8 +- layout/generic/nsBRFrame.cpp | 2 +- layout/generic/nsBlockFrame.cpp | 8 +- layout/generic/nsBulletFrame.cpp | 8 +- layout/generic/nsBulletFrame.h | 4 +- layout/generic/nsCanvasFrame.cpp | 8 +- layout/generic/nsCanvasFrame.h | 2 +- layout/generic/nsContainerFrame.cpp | 2 +- layout/generic/nsFirstLetterFrame.cpp | 6 +- layout/generic/nsFrame.cpp | 14 +- layout/generic/nsFrameSelection.h | 4 +- layout/generic/nsFrameSetFrame.cpp | 8 +- layout/generic/nsGfxScrollFrame.cpp | 14 +- layout/generic/nsGfxScrollFrame.h | 6 +- layout/generic/nsHTMLCanvasFrame.cpp | 2 +- layout/generic/nsHTMLReflowState.cpp | 2 +- layout/generic/nsIAnonymousContentCreator.h | 2 +- layout/generic/nsImageFrame.cpp | 10 +- layout/generic/nsImageFrame.h | 4 +- layout/generic/nsInlineFrame.cpp | 2 +- layout/generic/nsLineLayout.cpp | 2 +- layout/generic/nsPageFrame.cpp | 2 +- layout/generic/nsPluginFrame.cpp | 24 +- layout/generic/nsPluginFrame.h | 2 +- layout/generic/nsSelection.cpp | 82 +- layout/generic/nsSimplePageSequenceFrame.cpp | 10 +- layout/generic/nsSimplePageSequenceFrame.h | 2 +- layout/generic/nsSubDocumentFrame.cpp | 16 +- layout/generic/nsSubDocumentFrame.h | 2 +- layout/generic/nsTextFrame.cpp | 18 +- layout/generic/nsTextRunTransformations.cpp | 12 +- layout/generic/nsTextRunTransformations.h | 14 +- layout/generic/nsVideoFrame.cpp | 10 +- layout/inspector/inCSSValueSearch.cpp | 4 +- layout/inspector/inDOMUtils.cpp | 18 +- layout/inspector/nsFontFace.h | 4 +- layout/inspector/nsFontFaceList.cpp | 2 +- layout/ipc/RenderFrameParent.cpp | 10 +- layout/ipc/RenderFrameParent.h | 8 +- layout/ipc/VsyncChild.h | 4 +- layout/ipc/VsyncParent.cpp | 4 +- layout/ipc/VsyncParent.h | 4 +- layout/mathml/nsMathMLChar.cpp | 22 +- layout/mathml/nsMathMLChar.h | 2 +- layout/mathml/nsMathMLContainerFrame.cpp | 4 +- layout/mathml/nsMathMLFrame.cpp | 4 +- layout/mathml/nsMathMLFrame.h | 4 +- layout/mathml/nsMathMLTokenFrame.cpp | 2 +- layout/mathml/nsMathMLmactionFrame.h | 2 +- layout/mathml/nsMathMLmencloseFrame.cpp | 2 +- layout/mathml/nsMathMLmfencedFrame.cpp | 4 +- layout/mathml/nsMathMLmfracFrame.cpp | 2 +- layout/mathml/nsMathMLmmultiscriptsFrame.cpp | 2 +- layout/mathml/nsMathMLmoFrame.cpp | 4 +- layout/mathml/nsMathMLmrootFrame.cpp | 4 +- layout/mathml/nsMathMLmtableFrame.cpp | 4 +- layout/mathml/nsMathMLmunderoverFrame.cpp | 2 +- layout/printing/nsPrintData.h | 2 +- layout/printing/nsPrintEngine.cpp | 24 +- layout/printing/nsPrintObject.h | 4 +- layout/style/AnimationCommon.h | 4 +- layout/style/CSSStyleSheet.cpp | 42 +- layout/style/CSSStyleSheet.h | 10 +- layout/style/CounterStyleManager.cpp | 6 +- layout/style/FontFace.cpp | 10 +- layout/style/FontFace.h | 8 +- layout/style/FontFaceSet.cpp | 36 +- layout/style/FontFaceSet.h | 10 +- layout/style/FontFaceSetIterator.h | 2 +- layout/style/GroupRule.h | 4 +- layout/style/ImageLoader.cpp | 6 +- layout/style/ImportRule.h | 4 +- layout/style/Loader.cpp | 32 +- layout/style/Loader.h | 4 +- layout/style/MediaQueryList.h | 8 +- layout/style/RuleProcessorCache.h | 2 +- layout/style/StyleAnimationValue.cpp | 44 +- layout/style/StyleRule.cpp | 6 +- layout/style/StyleRule.h | 4 +- layout/style/nsAnimationManager.cpp | 14 +- layout/style/nsAnimationManager.h | 2 +- layout/style/nsCSSParser.cpp | 90 +- layout/style/nsCSSProps.h | 2 +- layout/style/nsCSSRuleProcessor.cpp | 2 +- layout/style/nsCSSRuleProcessor.h | 4 +- layout/style/nsCSSRules.cpp | 30 +- layout/style/nsCSSRules.h | 10 +- layout/style/nsCSSValue.cpp | 6 +- layout/style/nsComputedDOMStyle.cpp | 30 +- layout/style/nsComputedDOMStyle.h | 2 +- layout/style/nsDOMCSSAttrDeclaration.cpp | 4 +- layout/style/nsDOMCSSAttrDeclaration.h | 2 +- layout/style/nsDOMCSSDeclaration.cpp | 2 +- layout/style/nsDOMCSSRGBColor.h | 8 +- layout/style/nsDOMCSSRect.h | 8 +- layout/style/nsDOMCSSValueList.h | 2 +- layout/style/nsFontFaceLoader.h | 4 +- layout/style/nsFontFaceUtils.cpp | 2 +- layout/style/nsHTMLStyleSheet.cpp | 6 +- layout/style/nsHTMLStyleSheet.h | 12 +- layout/style/nsICSSDeclaration.h | 2 +- layout/style/nsLayoutStylesheetCache.cpp | 10 +- layout/style/nsLayoutStylesheetCache.h | 46 +- layout/style/nsMediaFeatures.cpp | 2 +- layout/style/nsRuleNode.cpp | 18 +- layout/style/nsRuleWalker.h | 2 +- layout/style/nsStyleContext.cpp | 8 +- layout/style/nsStyleContext.h | 2 +- layout/style/nsStyleSet.cpp | 34 +- layout/style/nsStyleSet.h | 10 +- layout/style/nsStyleStruct.h | 14 +- layout/style/nsTransitionManager.cpp | 8 +- layout/style/nsTransitionManager.h | 2 +- layout/style/test/ParseCSS.cpp | 4 +- layout/svg/SVGTextFrame.cpp | 12 +- layout/svg/SVGTextFrame.h | 2 +- layout/svg/nsFilterInstance.cpp | 6 +- layout/svg/nsFilterInstance.h | 8 +- layout/svg/nsSVGEffects.cpp | 2 +- layout/svg/nsSVGEffects.h | 2 +- layout/svg/nsSVGFilterFrame.cpp | 2 +- layout/svg/nsSVGFilterInstance.cpp | 6 +- layout/svg/nsSVGFilterInstance.h | 2 +- layout/svg/nsSVGGradientFrame.cpp | 10 +- layout/svg/nsSVGIntegrationUtils.cpp | 8 +- layout/svg/nsSVGMaskFrame.cpp | 2 +- layout/svg/nsSVGPathGeometryFrame.cpp | 2 +- layout/svg/nsSVGPatternFrame.cpp | 6 +- layout/svg/nsSVGUseFrame.cpp | 2 +- layout/svg/nsSVGUtils.cpp | 8 +- layout/tables/nsCellMap.h | 2 +- layout/tables/nsTableCellFrame.cpp | 2 +- layout/tables/nsTableFrame.cpp | 4 +- .../src/nsLayoutDebuggingTools.cpp | 4 +- layout/xul/PopupBoxObject.cpp | 2 +- layout/xul/grid/nsGridRowGroupLayout.cpp | 2 +- layout/xul/grid/nsGridRowLeafLayout.cpp | 2 +- layout/xul/nsBoxLayoutState.h | 2 +- layout/xul/nsDocElementBoxFrame.cpp | 2 +- layout/xul/nsImageBoxFrame.cpp | 4 +- layout/xul/nsImageBoxFrame.h | 2 +- layout/xul/nsListBoxBodyFrame.cpp | 12 +- layout/xul/nsListBoxBodyFrame.h | 2 +- layout/xul/nsListBoxLayout.cpp | 2 +- layout/xul/nsMenuFrame.cpp | 4 +- layout/xul/nsMenuFrame.h | 4 +- layout/xul/nsMenuPopupFrame.cpp | 2 +- layout/xul/nsMenuPopupFrame.h | 4 +- layout/xul/nsSliderFrame.h | 2 +- layout/xul/nsSplitterFrame.cpp | 4 +- layout/xul/nsTextBoxFrame.cpp | 10 +- layout/xul/nsXULPopupManager.cpp | 10 +- layout/xul/nsXULTooltipListener.cpp | 2 +- layout/xul/tree/TreeBoxObject.cpp | 2 +- layout/xul/tree/nsTreeBodyFrame.cpp | 36 +- layout/xul/tree/nsTreeBodyFrame.h | 6 +- layout/xul/tree/nsTreeColumns.h | 2 +- layout/xul/tree/nsTreeContentView.cpp | 2 +- layout/xul/tree/nsTreeSelection.cpp | 6 +- layout/xul/tree/nsTreeStyleCache.cpp | 2 +- .../gmp-clearkey/0.1/ClearKeySessionManager.h | 2 +- media/libstagefright/binding/AnnexB.cpp | 6 +- media/libstagefright/binding/H264.cpp | 6 +- media/libstagefright/binding/Index.cpp | 4 +- media/libstagefright/binding/MP4Metadata.cpp | 2 +- media/libstagefright/binding/MoofParser.cpp | 10 +- .../binding/include/mp4_demuxer/Box.h | 2 +- .../include/mp4_demuxer/BufferStream.h | 2 +- .../binding/include/mp4_demuxer/DecoderData.h | 2 +- .../binding/include/mp4_demuxer/Index.h | 2 +- .../binding/include/mp4_demuxer/MP4Metadata.h | 2 +- .../binding/include/mp4_demuxer/MoofParser.h | 2 +- .../include/mp4_demuxer/ResourceStream.h | 4 +- media/mtransport/nr_socket_prsock.cpp | 14 +- media/mtransport/nr_socket_prsock.h | 6 +- media/mtransport/nriceresolver.cpp | 2 +- media/mtransport/runnable_utils.h | 2 +- media/mtransport/test/TestSyncRunnable.cpp | 6 +- .../test/buffered_stun_socket_unittest.cpp | 4 +- media/mtransport/test/ice_unittest.cpp | 12 +- .../test/multi_tcp_socket_unittest.cpp | 2 +- .../test/proxy_tunnel_socket_unittest.cpp | 6 +- media/mtransport/test/sctp_unittest.cpp | 6 +- media/mtransport/test/stunserver.h | 2 +- .../test/test_nr_socket_unittest.cpp | 46 +- media/mtransport/test/transport_unittests.cpp | 14 +- media/mtransport/test_nr_socket.cpp | 14 +- media/mtransport/test_nr_socket.h | 16 +- media/mtransport/transportlayerloopback.h | 2 +- media/mtransport/transportlayerprsock.h | 2 +- .../src/media-conduit/AudioConduit.cpp | 6 +- .../src/media-conduit/AudioConduit.h | 8 +- .../src/media-conduit/MediaConduitInterface.h | 2 +- .../src/media-conduit/VideoConduit.cpp | 8 +- .../src/media-conduit/VideoConduit.h | 14 +- .../src/media-conduit/WebrtcGmpVideoCodec.cpp | 6 +- .../src/media-conduit/WebrtcGmpVideoCodec.h | 6 +- .../src/media/CSFAudioControlWrapper.h | 2 +- .../src/mediapipeline/MediaPipeline.cpp | 14 +- .../src/mediapipeline/MediaPipeline.h | 6 +- .../signaling/src/mediapipeline/SrtpFlow.h | 2 +- .../peerconnection/MediaPipelineFactory.cpp | 10 +- .../src/peerconnection/MediaStreamList.h | 2 +- .../src/peerconnection/PeerConnectionCtx.cpp | 2 +- .../src/peerconnection/PeerConnectionImpl.cpp | 82 +- .../src/peerconnection/PeerConnectionImpl.h | 26 +- .../peerconnection/PeerConnectionMedia.cpp | 18 +- .../src/peerconnection/PeerConnectionMedia.h | 12 +- .../webrtc/signaling/test/FakeMediaStreams.h | 22 +- .../signaling/test/FakeMediaStreamsImpl.h | 4 +- .../signaling/test/mediaconduit_unittests.cpp | 44 +- .../signaling/test/mediapipeline_unittest.cpp | 8 +- .../signaling/test/signaling_unittests.cpp | 34 +- memory/replace/dmd/DMD.cpp | 111 +- memory/replace/dmd/DMD.h | 11 +- memory/replace/dmd/block_analyzer.py | 265 +++ memory/replace/dmd/dmd.py | 205 +++ memory/replace/dmd/test/SmokeDMD.cpp | 23 + .../dmd/test/basic-scan-32-expected.txt | 26 + .../dmd/test/basic-scan-64-expected.txt | 26 + memory/replace/dmd/test/scan-test.py | 87 + memory/replace/dmd/test/test_dmd.js | 28 + memory/replace/dmd/test/xpcshell.ini | 3 + mfbt/AlreadyAddRefed.h | 4 +- mfbt/RefCounted.h | 8 +- mfbt/RefPtr.h | 669 +++++-- mfbt/moz.build | 1 - mfbt/nsRefPtr.h | 613 ------- mfbt/tests/TestRefPtr.cpp | 2 +- modules/libjar/InterceptedJARChannel.cpp | 19 +- modules/libjar/InterceptedJARChannel.h | 8 +- modules/libjar/nsJAR.cpp | 32 +- modules/libjar/nsJAR.h | 2 +- modules/libjar/nsJARChannel.cpp | 20 +- modules/libjar/nsJARChannel.h | 2 +- modules/libjar/nsJARInputStream.h | 4 +- modules/libjar/nsJARProtocolHandler.cpp | 2 +- modules/libjar/nsJARURI.cpp | 4 +- modules/libjar/nsZipArchive.cpp | 8 +- modules/libjar/nsZipArchive.h | 6 +- modules/libjar/zipwriter/nsZipDataStream.h | 4 +- modules/libjar/zipwriter/nsZipWriter.cpp | 10 +- modules/libpref/Preferences.cpp | 14 +- modules/libpref/init/all.js | 1 + mozglue/linker/BaseElf.h | 2 +- mozglue/linker/CustomElf.cpp | 2 +- mozglue/linker/CustomElf.h | 2 +- mozglue/linker/ElfLoader.cpp | 2 +- mozglue/linker/ElfLoader.h | 6 +- mozglue/linker/Mappable.h | 4 +- mozglue/linker/Zip.cpp | 4 +- mozglue/linker/tests/TestZip.cpp | 2 +- netwerk/base/BackgroundFileSaver.cpp | 4 +- netwerk/base/ChannelDiverterParent.h | 2 +- netwerk/base/ClosingService.cpp | 2 +- netwerk/base/Dashboard.cpp | 54 +- netwerk/base/EventTokenBucket.cpp | 6 +- netwerk/base/LoadInfo.cpp | 92 +- netwerk/base/LoadInfo.h | 7 + netwerk/base/LoadTainting.h | 43 + netwerk/base/MemoryDownloader.cpp | 2 +- netwerk/base/MemoryDownloader.h | 2 +- netwerk/base/OfflineObserver.h | 2 +- netwerk/base/Predictor.cpp | 22 +- netwerk/base/Predictor.h | 10 +- netwerk/base/ProxyAutoConfig.cpp | 2 +- netwerk/base/SchedulingContextService.cpp | 2 +- netwerk/base/StreamingProtocolService.cpp | 4 +- netwerk/base/TLSServerSocket.cpp | 8 +- netwerk/base/TLSServerSocket.h | 2 +- netwerk/base/Tickler.cpp | 2 +- netwerk/base/moz.build | 3 + netwerk/base/nsAsyncStreamCopier.cpp | 2 +- netwerk/base/nsBaseChannel.cpp | 8 +- netwerk/base/nsBaseChannel.h | 4 +- netwerk/base/nsDirectoryIndexStream.cpp | 2 +- netwerk/base/nsIDivertableChannel.idl | 20 +- netwerk/base/nsILoadInfo.idl | 160 +- .../base/nsINetworkInterceptController.idl | 17 +- netwerk/base/nsIOService.cpp | 9 +- .../base/nsIPackagedAppChannelListener.idl | 25 + netwerk/base/nsIPackagedAppUtils.idl | 68 + netwerk/base/nsInputStreamPump.cpp | 2 +- netwerk/base/nsNetUtil.cpp | 2 +- netwerk/base/nsNetUtil.inl | 58 +- netwerk/base/nsPACMan.cpp | 32 +- netwerk/base/nsPACMan.h | 2 +- netwerk/base/nsProtocolProxyService.cpp | 6 +- netwerk/base/nsProtocolProxyService.h | 2 +- netwerk/base/nsRequestObserverProxy.cpp | 4 +- netwerk/base/nsSerializationHelper.cpp | 2 +- netwerk/base/nsServerSocket.cpp | 6 +- netwerk/base/nsSimpleURI.cpp | 4 +- netwerk/base/nsSocketTransport2.cpp | 4 +- netwerk/base/nsSocketTransport2.h | 2 +- netwerk/base/nsSocketTransportService2.cpp | 4 +- netwerk/base/nsStandardURL.cpp | 4 +- netwerk/base/nsTemporaryFileInputStream.h | 2 +- netwerk/base/nsTransportUtils.cpp | 4 +- netwerk/base/nsUDPSocket.cpp | 22 +- netwerk/base/nsUDPSocket.h | 4 +- netwerk/cache/nsApplicationCache.h | 2 +- netwerk/cache/nsApplicationCacheService.cpp | 22 +- netwerk/cache/nsApplicationCacheService.h | 2 +- netwerk/cache/nsCacheEntry.cpp | 2 +- netwerk/cache/nsCacheEntry.h | 2 +- netwerk/cache/nsCacheEntryDescriptor.cpp | 14 +- netwerk/cache/nsCacheService.cpp | 14 +- netwerk/cache/nsCacheService.h | 2 +- netwerk/cache/nsCacheUtils.cpp | 4 +- netwerk/cache/nsDiskCacheDeviceSQL.cpp | 10 +- netwerk/cache/nsDiskCacheDeviceSQL.h | 2 +- netwerk/cache2/AppCacheStorage.cpp | 8 +- netwerk/cache2/CacheEntry.cpp | 22 +- netwerk/cache2/CacheEntry.h | 14 +- netwerk/cache2/CacheFile.cpp | 36 +- netwerk/cache2/CacheFile.h | 16 +- netwerk/cache2/CacheFileChunk.cpp | 6 +- netwerk/cache2/CacheFileChunk.h | 2 +- netwerk/cache2/CacheFileContextEvictor.cpp | 4 +- netwerk/cache2/CacheFileContextEvictor.h | 2 +- netwerk/cache2/CacheFileIOManager.cpp | 162 +- netwerk/cache2/CacheFileIOManager.h | 12 +- netwerk/cache2/CacheFileInputStream.h | 4 +- netwerk/cache2/CacheFileMetadata.h | 2 +- netwerk/cache2/CacheFileOutputStream.cpp | 2 +- netwerk/cache2/CacheFileOutputStream.h | 6 +- netwerk/cache2/CacheFileUtils.cpp | 4 +- netwerk/cache2/CacheIndex.cpp | 58 +- netwerk/cache2/CacheIndex.h | 20 +- netwerk/cache2/CacheIndexIterator.h | 2 +- netwerk/cache2/CacheObserver.cpp | 12 +- netwerk/cache2/CacheStorage.cpp | 6 +- netwerk/cache2/CacheStorage.h | 2 +- netwerk/cache2/CacheStorageService.cpp | 56 +- netwerk/cache2/CacheStorageService.h | 6 +- netwerk/cache2/OldWrappers.cpp | 14 +- netwerk/cookie/CookieServiceParent.h | 2 +- netwerk/cookie/nsCookie.cpp | 2 +- netwerk/cookie/nsCookieService.cpp | 16 +- netwerk/cookie/nsCookieService.h | 8 +- netwerk/dns/ChildDNSService.cpp | 10 +- netwerk/dns/ChildDNSService.h | 2 +- netwerk/dns/DNSListenerProxy.cpp | 2 +- netwerk/dns/DNSRequestChild.cpp | 4 +- netwerk/dns/GetAddrInfo.cpp | 2 +- .../mdns/libmdns/MDNSResponderOperator.cpp | 4 +- .../dns/mdns/libmdns/MDNSResponderOperator.h | 6 +- netwerk/dns/mdns/libmdns/MDNSResponderReply.h | 4 +- .../mdns/libmdns/nsDNSServiceDiscovery.cpp | 14 +- .../dns/mdns/libmdns/nsDNSServiceDiscovery.h | 2 +- netwerk/dns/nsDNSService2.cpp | 16 +- netwerk/dns/nsDNSService2.h | 2 +- netwerk/dns/nsHostResolver.cpp | 4 +- netwerk/ipc/ChannelEventQueue.cpp | 2 +- netwerk/ipc/ChannelEventQueue.h | 16 +- netwerk/ipc/NeckoChannelParams.ipdlh | 24 +- netwerk/ipc/NeckoChild.cpp | 2 +- netwerk/ipc/NeckoMessageUtils.h | 7 +- netwerk/ipc/NeckoParent.cpp | 12 +- netwerk/ipc/NeckoParent.h | 2 +- netwerk/ipc/RemoteOpenFileChild.cpp | 8 +- netwerk/ipc/RemoteOpenFileChild.h | 2 +- netwerk/protocol/about/nsAboutCacheEntry.cpp | 2 +- .../protocol/about/nsAboutProtocolHandler.cpp | 2 +- netwerk/protocol/app/AppProtocolHandler.cpp | 6 +- netwerk/protocol/data/nsDataHandler.cpp | 2 +- .../device/AndroidCaptureProvider.cpp | 4 +- netwerk/protocol/device/nsDeviceChannel.cpp | 2 +- .../device/nsDeviceProtocolHandler.cpp | 4 +- netwerk/protocol/file/nsFileChannel.cpp | 4 +- netwerk/protocol/ftp/FTPChannelChild.cpp | 101 ++ netwerk/protocol/ftp/FTPChannelChild.h | 15 +- netwerk/protocol/ftp/FTPChannelParent.cpp | 2 +- netwerk/protocol/ftp/FTPChannelParent.h | 4 +- netwerk/protocol/ftp/nsFTPChannel.cpp | 2 +- .../protocol/ftp/nsFtpConnectionThread.cpp | 6 +- netwerk/protocol/ftp/nsFtpConnectionThread.h | 4 +- .../protocol/ftp/nsFtpControlConnection.cpp | 2 +- netwerk/protocol/ftp/nsFtpControlConnection.h | 2 +- netwerk/protocol/ftp/nsFtpProtocolHandler.cpp | 2 +- netwerk/protocol/http/AlternateServices.cpp | 10 +- netwerk/protocol/http/Http2Compression.cpp | 4 +- netwerk/protocol/http/Http2Compression.h | 6 +- netwerk/protocol/http/Http2Push.cpp | 4 +- netwerk/protocol/http/Http2Session.cpp | 30 +- netwerk/protocol/http/Http2Session.h | 2 +- netwerk/protocol/http/Http2Stream.cpp | 10 +- netwerk/protocol/http/Http2Stream.h | 6 +- netwerk/protocol/http/HttpBaseChannel.cpp | 100 +- netwerk/protocol/http/HttpBaseChannel.h | 37 +- netwerk/protocol/http/HttpChannelChild.cpp | 311 +++- netwerk/protocol/http/HttpChannelChild.h | 44 +- netwerk/protocol/http/HttpChannelParent.cpp | 39 +- netwerk/protocol/http/HttpChannelParent.h | 16 +- .../http/HttpChannelParentListener.cpp | 18 + .../protocol/http/HttpChannelParentListener.h | 3 + netwerk/protocol/http/InterceptedChannel.cpp | 86 +- netwerk/protocol/http/InterceptedChannel.h | 22 +- netwerk/protocol/http/NullHttpChannel.cpp | 24 + netwerk/protocol/http/NullHttpTransaction.cpp | 4 +- netwerk/protocol/http/NullHttpTransaction.h | 4 +- netwerk/protocol/http/PHttpChannel.ipdl | 2 +- netwerk/protocol/http/PackagedAppService.cpp | 91 +- netwerk/protocol/http/PackagedAppService.h | 15 +- netwerk/protocol/http/PackagedAppUtils.js | 109 ++ .../protocol/http/PackagedAppUtils.manifest | 3 + netwerk/protocol/http/PackagedAppVerifier.cpp | 149 +- netwerk/protocol/http/PackagedAppVerifier.h | 49 +- netwerk/protocol/http/SpdyPush31.cpp | 2 +- netwerk/protocol/http/SpdySession31.cpp | 30 +- netwerk/protocol/http/SpdySession31.h | 2 +- netwerk/protocol/http/SpdyStream31.cpp | 4 +- netwerk/protocol/http/SpdyStream31.h | 2 +- netwerk/protocol/http/TimingStruct.h | 2 + netwerk/protocol/http/TunnelUtils.cpp | 24 +- netwerk/protocol/http/TunnelUtils.h | 16 +- netwerk/protocol/http/moz.build | 5 + netwerk/protocol/http/nsAHttpTransaction.h | 4 +- netwerk/protocol/http/nsCORSListenerProxy.cpp | 304 ++-- netwerk/protocol/http/nsCORSListenerProxy.h | 11 - netwerk/protocol/http/nsHttp.cpp | 20 + netwerk/protocol/http/nsHttp.h | 3 + netwerk/protocol/http/nsHttpAuthCache.h | 2 +- netwerk/protocol/http/nsHttpChannel.cpp | 111 +- netwerk/protocol/http/nsHttpChannel.h | 20 +- .../http/nsHttpChannelAuthProvider.cpp | 10 +- .../protocol/http/nsHttpChannelAuthProvider.h | 2 +- netwerk/protocol/http/nsHttpConnection.cpp | 6 +- netwerk/protocol/http/nsHttpConnection.h | 12 +- .../protocol/http/nsHttpConnectionInfo.cpp | 4 +- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 66 +- netwerk/protocol/http/nsHttpConnectionMgr.h | 4 +- netwerk/protocol/http/nsHttpHandler.cpp | 9 +- netwerk/protocol/http/nsHttpHandler.h | 4 +- netwerk/protocol/http/nsHttpPipeline.cpp | 8 +- netwerk/protocol/http/nsHttpPipeline.h | 2 +- netwerk/protocol/http/nsHttpTransaction.cpp | 12 +- netwerk/protocol/http/nsHttpTransaction.h | 12 +- netwerk/protocol/http/nsIHttpChannel.idl | 27 +- .../protocol/http/nsIHttpChannelInternal.idl | 11 +- .../res/SubstitutingProtocolHandler.cpp | 2 +- netwerk/protocol/rtsp/RtspChannelChild.cpp | 12 +- netwerk/protocol/rtsp/RtspHandler.cpp | 4 +- .../rtsp/controller/RtspController.cpp | 10 +- .../rtsp/controller/RtspControllerChild.cpp | 6 +- .../rtsp/controller/RtspControllerParent.cpp | 2 +- netwerk/protocol/rtsp/rtsp/RTSPSource.cpp | 8 +- .../viewsource/nsViewSourceChannel.cpp | 24 + .../viewsource/nsViewSourceHandler.cpp | 2 +- .../websocket/BaseWebSocketChannel.cpp | 2 +- .../protocol/websocket/BaseWebSocketChannel.h | 2 +- .../protocol/websocket/WebSocketChannel.cpp | 28 +- .../websocket/WebSocketChannelChild.cpp | 16 +- .../websocket/WebSocketChannelChild.h | 2 +- .../websocket/WebSocketChannelParent.cpp | 2 +- .../websocket/WebSocketChannelParent.h | 2 +- .../protocol/wyciwyg/WyciwygChannelChild.h | 2 +- netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp | 4 +- netwerk/sctp/datachannel/DataChannel.cpp | 40 +- netwerk/sctp/datachannel/DataChannel.h | 12 +- netwerk/streamconv/converters/moz.build | 6 + .../converters/nsHTTPCompressConv.cpp | 916 +++++----- .../converters/nsHTTPCompressConv.h | 95 +- .../converters/nsICompressConvStats.idl | 17 + .../streamconv/converters/nsMultiMixedConv.h | 2 +- .../converters/nsUnknownDecoder.cpp | 34 +- netwerk/system/win32/nsNotifyAddrListener.cpp | 10 +- netwerk/test/TestBind.cpp | 4 +- netwerk/test/TestUDPSocket.cpp | 6 +- netwerk/test/mochitests/empty.html | 16 + netwerk/test/mochitests/mochitest.ini | 9 + netwerk/test/mochitests/redirect_idn.html | 0 .../mochitests/redirect_idn.html^headers^ | 3 + .../mochitests/signed_web_packaged_app.sjs | 37 + .../test/mochitests/test_idn_redirect.html | 36 + .../test_signed_web_packaged_app.html | 70 + .../mochitests/test_web_packaged_app.html | 210 +++ netwerk/test/mochitests/web_packaged_app.sjs | 35 + .../test/unit/test_packaged_app_service.js | 238 +++ netwerk/test/unit/test_packaged_app_utils.js | 135 ++ .../test/unit/test_synthesized_response.js | 10 +- netwerk/test/unit/xpcshell.ini | 1 + netwerk/wifi/nsWifiMonitorGonk.cpp | 2 +- netwerk/wifi/nsWifiScannerDBus.cpp | 2 +- parser/html/nsHtml5Atom.cpp | 2 +- parser/html/nsHtml5DependentUTF16Buffer.cpp | 2 +- parser/html/nsHtml5OwningUTF16Buffer.cpp | 6 +- parser/html/nsHtml5OwningUTF16Buffer.h | 2 +- parser/html/nsHtml5Parser.cpp | 14 +- parser/html/nsHtml5Parser.h | 6 +- parser/html/nsHtml5SVGLoadDispatcher.cpp | 2 +- parser/html/nsHtml5Speculation.h | 2 +- parser/html/nsHtml5StreamParser.cpp | 10 +- parser/html/nsHtml5StreamParser.h | 4 +- parser/html/nsHtml5StringParser.h | 2 +- parser/html/nsHtml5TreeOpExecutor.cpp | 12 +- parser/html/nsHtml5TreeOperation.cpp | 20 +- parser/html/nsParserUtils.cpp | 2 +- parser/htmlparser/nsParser.cpp | 2 +- parser/xml/nsSAXXMLReader.cpp | 2 +- profile/dirserviceprovider/nsProfileLock.cpp | 2 +- python/lldbutils/lldbutils/utils.py | 4 +- python/mozbuild/mozbuild/mach_commands.py | 104 +- rdf/base/nsRDFService.cpp | 2 +- rdf/datasource/nsFileSystemDataSource.cpp | 2 +- security/manager/ssl/DataStorage.cpp | 10 +- .../manager/ssl/TransportSecurityInfo.cpp | 2 +- security/manager/ssl/TransportSecurityInfo.h | 2 +- security/manager/ssl/nsCertPicker.cpp | 2 +- security/manager/ssl/nsCertTree.h | 8 +- security/manager/ssl/nsNSSCallbacks.cpp | 4 +- security/manager/ssl/nsNSSCallbacks.h | 2 +- security/manager/ssl/nsNSSCertificate.cpp | 2 +- security/manager/ssl/nsNSSCertificateDB.cpp | 2 +- security/manager/ssl/nsNSSComponent.cpp | 2 +- security/manager/ssl/nsNSSComponent.h | 2 +- .../manager/ssl/nsProtectedAuthThread.cpp | 4 +- security/manager/ssl/nsSiteSecurityService.h | 2 +- .../ssl/tests/gtest/DataStorageTest.cpp | 2 +- startupcache/StartupCache.cpp | 2 +- startupcache/StartupCache.h | 4 +- storage/StorageBaseStatementInternal.cpp | 8 +- storage/StorageBaseStatementInternal.h | 2 +- storage/TelemetryVFS.cpp | 4 +- storage/VacuumManager.cpp | 4 +- storage/mozStorageAsyncStatement.cpp | 2 +- storage/mozStorageAsyncStatement.h | 2 +- storage/mozStorageAsyncStatementExecution.cpp | 14 +- storage/mozStorageAsyncStatementExecution.h | 4 +- storage/mozStorageAsyncStatementJSHelper.cpp | 2 +- storage/mozStorageBindingParams.cpp | 6 +- storage/mozStorageBindingParams.h | 2 +- storage/mozStorageConnection.cpp | 24 +- storage/mozStorageConnection.h | 6 +- storage/mozStoragePrivateHelpers.cpp | 2 +- storage/mozStorageService.cpp | 36 +- storage/mozStorageService.h | 4 +- storage/mozStorageStatement.cpp | 4 +- storage/mozStorageStatement.h | 2 +- storage/mozStorageStatementData.h | 2 +- storage/mozStorageStatementJSHelper.cpp | 4 +- storage/test/storage_test_harness.h | 4 +- storage/test/test_AsXXX_helpers.cpp | 2 +- ...st_asyncStatementExecution_transaction.cpp | 2 +- storage/test/test_transaction_helper.cpp | 2 +- storage/test/test_true_async.cpp | 6 +- storage/test/test_unlock_notify.cpp | 6 +- testing/cppunittest.ini | 5 +- testing/mochitest/mach_commands.py | 8 + .../mozrunner/devices/android_device.py | 522 ++++++ .../web-platform/mozilla/meta/MANIFEST.json | 6 + .../worker-interception-iframe.https.html.ini | 3 + .../fetch-canvas-tainting-cache.https.html | 38 + .../fetch-event-redirect.https.html | 3 +- .../fetch-canvas-tainting-iframe.html | 21 +- .../fetch-event-redirect-iframe.html | 7 + .../resources/fetch-rewrite-worker.js | 20 +- testing/xpcshell/mach_commands.py | 2 + .../addoncompat/RemoteAddonsChild.jsm | 2 +- toolkit/components/alerts/nsXULAlerts.cpp | 2 +- .../diskspacewatcher/DiskSpaceWatcher.cpp | 2 +- .../downloads/ApplicationReputation.cpp | 8 +- toolkit/components/downloads/SQLFunctions.cpp | 2 +- .../downloads/nsDownloadManager.cpp | 34 +- .../downloads/nsDownloadScanner.cpp | 6 +- .../components/downloads/nsDownloadScanner.h | 2 +- toolkit/components/filepicker/nsFileView.cpp | 2 +- .../filewatcher/NativeFileWatcherWin.cpp | 8 +- .../FinalizationWitnessService.cpp | 6 +- .../jsdownloads/src/DownloadPlatform.cpp | 2 +- .../osfile/NativeOSFileInternals.cpp | 26 +- .../nsParentalControlsServiceWin.cpp | 10 +- .../perfmonitoring/nsPerformanceStats.cpp | 2 +- .../components/places/AsyncFaviconHelpers.cpp | 32 +- .../components/places/AsyncFaviconHelpers.h | 2 +- toolkit/components/places/Database.cpp | 8 +- toolkit/components/places/Helpers.cpp | 2 +- toolkit/components/places/History.cpp | 26 +- toolkit/components/places/History.h | 4 +- toolkit/components/places/SQLFunctions.cpp | 16 +- .../components/places/nsAnnotationService.h | 2 +- .../components/places/nsFaviconService.cpp | 2 +- toolkit/components/places/nsFaviconService.h | 2 +- toolkit/components/places/nsNavBookmarks.cpp | 12 +- toolkit/components/places/nsNavBookmarks.h | 2 +- toolkit/components/places/nsNavHistory.cpp | 32 +- toolkit/components/places/nsNavHistory.h | 2 +- .../components/places/nsNavHistoryQuery.cpp | 4 +- .../components/places/nsNavHistoryResult.cpp | 26 +- .../components/places/nsNavHistoryResult.h | 12 +- toolkit/components/places/nsPlacesMacros.h | 4 +- .../components/places/tests/cpp/mock_Link.h | 2 +- .../places/tests/cpp/places_test_harness.h | 4 +- .../tests/cpp/places_test_harness_tail.h | 2 +- .../places/tests/cpp/test_IHistory.cpp | 38 +- toolkit/components/startup/nsAppStartup.cpp | 2 +- toolkit/components/startup/nsAppStartup.h | 8 +- toolkit/components/telemetry/Telemetry.cpp | 2 +- .../typeaheadfind/nsTypeAheadFind.cpp | 6 +- .../nsUrlClassifierDBService.cpp | 4 +- toolkit/devtools/server/HeapSnapshot.cpp | 4 +- .../devtools/webconsole/network-monitor.js | 13 +- toolkit/library/Makefile.in | 2 +- toolkit/modules/addons/WebRequest.jsm | 26 +- toolkit/profile/nsToolkitProfileService.cpp | 12 +- toolkit/system/dbus/nsDBusService.cpp | 2 +- toolkit/system/gnome/nsGIOService.cpp | 2 +- .../system/gnome/nsSystemAlertsService.cpp | 2 +- toolkit/xre/nsAppRunner.cpp | 10 +- toolkit/xre/nsEmbedFunctions.cpp | 2 +- tools/profiler/core/GeckoSampler.cpp | 2 +- tools/profiler/core/GeckoSampler.h | 4 +- tools/profiler/core/ThreadProfile.h | 2 +- tools/profiler/gecko/ThreadResponsiveness.h | 2 +- tools/profiler/gecko/nsProfiler.cpp | 2 +- tools/profiler/public/ProfileGatherer.h | 2 +- tools/profiler/public/ProfilerMarkers.h | 2 +- .../tests/gtest/ThreadProfileTest.cpp | 8 +- uriloader/base/nsDocLoader.cpp | 6 +- uriloader/base/nsDocLoader.h | 2 +- uriloader/base/nsURILoader.cpp | 8 +- uriloader/exthandler/ExternalHelperAppChild.h | 2 +- .../exthandler/android/nsMIMEInfoAndroid.cpp | 2 +- .../android/nsOSHelperAppService.cpp | 2 +- .../exthandler/gonk/nsOSHelperAppService.cpp | 2 +- .../exthandler/mac/nsOSHelperAppService.mm | 2 +- .../exthandler/nsExternalHelperAppService.cpp | 8 +- .../exthandler/nsExternalHelperAppService.h | 2 +- uriloader/exthandler/unix/nsGNOMERegistry.cpp | 4 +- uriloader/exthandler/unix/nsMIMEInfoUnix.cpp | 2 +- .../exthandler/unix/nsOSHelperAppService.cpp | 12 +- .../exthandler/win/nsOSHelperAppService.cpp | 6 +- .../prefetch/OfflineCacheUpdateChild.cpp | 2 +- uriloader/prefetch/OfflineCacheUpdateGlue.h | 2 +- .../prefetch/OfflineCacheUpdateParent.cpp | 2 +- uriloader/prefetch/nsOfflineCacheUpdate.cpp | 14 +- uriloader/prefetch/nsOfflineCacheUpdate.h | 10 +- .../prefetch/nsOfflineCacheUpdateService.cpp | 8 +- uriloader/prefetch/nsPrefetchService.cpp | 10 +- uriloader/prefetch/nsPrefetchService.h | 4 +- view/nsView.cpp | 12 +- view/nsViewManager.cpp | 6 +- view/nsViewManager.h | 4 +- widget/ContentCache.cpp | 2 +- widget/InputData.cpp | 2 +- widget/PuppetWidget.cpp | 4 +- widget/PuppetWidget.h | 6 +- widget/ScreenProxy.h | 2 +- widget/TextEventDispatcher.cpp | 6 +- widget/TextEventDispatcher.h | 2 +- widget/TextEvents.h | 2 +- widget/TouchEvents.h | 4 +- widget/VsyncDispatcher.h | 8 +- widget/cocoa/OSXNotificationCenter.h | 4 +- widget/cocoa/OSXNotificationCenter.mm | 4 +- widget/cocoa/SwipeTracker.h | 4 +- widget/cocoa/SwipeTracker.mm | 2 +- widget/cocoa/TextInputHandler.h | 2 +- widget/cocoa/TextInputHandler.mm | 32 +- widget/cocoa/nsChildView.h | 4 +- widget/cocoa/nsChildView.mm | 14 +- widget/cocoa/nsClipboard.mm | 1 - widget/cocoa/nsCocoaUtils.mm | 2 +- widget/cocoa/nsCocoaWindow.h | 2 +- widget/cocoa/nsCocoaWindow.mm | 2 +- widget/cocoa/nsDeviceContextSpecX.mm | 4 +- widget/cocoa/nsIdleServiceX.h | 2 +- widget/cocoa/nsMacDockSupport.h | 2 +- widget/cocoa/nsMenuBarX.mm | 2 +- widget/cocoa/nsMenuItemIconX.h | 2 +- widget/cocoa/nsMenuItemIconX.mm | 4 +- widget/cocoa/nsMenuItemX.h | 2 +- widget/cocoa/nsMenuUtilsX.mm | 2 +- widget/cocoa/nsMenuX.h | 2 +- widget/cocoa/nsPrintDialogX.mm | 4 +- widget/cocoa/nsPrintOptionsX.mm | 8 +- widget/cocoa/nsScreenManagerCocoa.h | 2 +- widget/cocoa/nsScreenManagerCocoa.mm | 2 +- widget/cocoa/nsSystemStatusBarCocoa.h | 2 +- widget/cocoa/nsSystemStatusBarCocoa.mm | 2 +- widget/gonk/GeckoTouchDispatcher.h | 4 +- widget/gonk/GonkMemoryPressureMonitoring.cpp | 2 +- widget/gonk/GonkPermission.cpp | 4 +- widget/gonk/HwcComposer2D.cpp | 6 +- widget/gonk/nativewindow/GonkBufferQueueJB.h | 2 +- widget/gonk/nativewindow/GonkBufferQueueKK.h | 2 +- .../GonkBufferQueueLL/GonkBufferSlot.h | 2 +- .../gonk/nativewindow/GonkNativeWindowICS.h | 2 +- .../gonk/nativewindow/GonkNativeWindowJB.cpp | 2 +- .../gonk/nativewindow/GonkNativeWindowKK.cpp | 2 +- .../gonk/nativewindow/GonkNativeWindowLL.cpp | 2 +- widget/gonk/nsAppShell.cpp | 6 +- widget/gonk/nsClipboard.cpp | 8 +- widget/gonk/nsIdleServiceGonk.h | 2 +- widget/gonk/nsScreenManagerGonk.cpp | 14 +- widget/gonk/nsScreenManagerGonk.h | 12 +- widget/gonk/nsWindow.cpp | 6 +- widget/gonk/nsWindow.h | 6 +- widget/gtk/IMContextWrapper.cpp | 12 +- widget/gtk/nsClipboard.h | 2 +- widget/gtk/nsDeviceContextSpecG.cpp | 2 +- widget/gtk/nsDragService.cpp | 6 +- widget/gtk/nsDragService.h | 4 +- widget/gtk/nsIdleServiceGTK.h | 2 +- widget/gtk/nsImageToPixbuf.cpp | 1 - widget/gtk/nsScreenManagerGtk.cpp | 4 +- widget/gtk/nsWindow.cpp | 62 +- widget/gtk/nsWindow.h | 6 +- widget/nsBaseClipboard.h | 2 +- widget/nsBaseDragService.cpp | 4 +- widget/nsBaseDragService.h | 6 +- widget/nsBaseFilePicker.cpp | 8 +- widget/nsBaseWidget.cpp | 12 +- widget/nsBaseWidget.h | 20 +- widget/nsDragServiceProxy.cpp | 4 +- widget/nsFilePickerProxy.cpp | 10 +- widget/nsFilePickerProxy.h | 2 +- widget/nsIWidget.h | 2 +- widget/nsIdleService.cpp | 2 +- widget/nsIdleService.h | 2 +- widget/nsPrintOptionsImpl.cpp | 2 +- widget/nsPrintSettingsImpl.cpp | 2 +- widget/nsScreenManagerProxy.cpp | 4 +- widget/nsScreenManagerProxy.h | 6 +- widget/nsShmImage.cpp | 4 +- widget/nsShmImage.h | 4 +- widget/qt/nsDeviceContextSpecQt.cpp | 2 +- widget/qt/nsIdleServiceQt.h | 2 +- widget/tests/TestWinTSF.cpp | 40 +- widget/uikit/nsWindow.mm | 6 +- widget/windows/AudioSession.cpp | 12 +- widget/windows/IMMHandler.cpp | 4 +- widget/windows/InkCollector.cpp | 2 +- widget/windows/InkCollector.h | 6 +- widget/windows/JumpListBuilder.cpp | 18 +- widget/windows/JumpListBuilder.h | 2 +- widget/windows/JumpListItem.cpp | 6 +- widget/windows/JumpListItem.h | 6 +- widget/windows/KeyboardLayout.h | 4 +- widget/windows/TSFTextStore.cpp | 88 +- widget/windows/TSFTextStore.h | 16 +- widget/windows/TaskbarPreview.cpp | 2 +- widget/windows/TaskbarPreview.h | 2 +- widget/windows/TaskbarPreviewButton.h | 2 +- widget/windows/TaskbarTabPreview.cpp | 2 +- widget/windows/TaskbarWindowPreview.cpp | 2 +- widget/windows/WidgetTraceEvent.cpp | 2 +- widget/windows/WinMouseScrollHandler.cpp | 2 +- widget/windows/WinTaskbar.cpp | 4 +- widget/windows/nsDataObjCollection.h | 4 +- widget/windows/nsDeviceContextSpecWin.cpp | 4 +- widget/windows/nsDragService.cpp | 8 +- widget/windows/nsFilePicker.cpp | 28 +- widget/windows/nsIdleServiceWin.h | 2 +- widget/windows/nsNativeDragTarget.cpp | 2 +- widget/windows/nsNativeThemeWin.cpp | 4 +- widget/windows/nsPrintSettingsWin.cpp | 2 +- widget/windows/nsWindow.cpp | 8 +- widget/windows/nsWindow.h | 4 +- widget/windows/nsWindowGfx.cpp | 8 +- widget/windows/tests/TestWinDND.cpp | 14 +- xpcom/base/AvailableMemoryTracker.cpp | 2 +- xpcom/base/CycleCollectedJSRuntime.h | 2 +- xpcom/base/DebuggerOnGCRunnable.cpp | 2 +- xpcom/base/OwningNonNull.h | 12 +- xpcom/base/nsAutoPtr.h | 2 +- xpcom/base/nsConsoleService.cpp | 8 +- xpcom/base/nsCycleCollector.cpp | 20 +- xpcom/base/nsErrorService.cpp | 2 +- xpcom/base/nsMemoryInfoDumper.cpp | 18 +- xpcom/base/nsMemoryReporterManager.cpp | 8 +- xpcom/base/nsMemoryReporterManager.h | 2 +- xpcom/base/nsMessageLoop.cpp | 2 +- xpcom/base/nsQueryObject.h | 4 +- xpcom/base/nsStatusReporterManager.cpp | 2 +- xpcom/build/FileLocation.cpp | 8 +- xpcom/build/FileLocation.h | 4 +- xpcom/build/Omnijar.cpp | 4 +- xpcom/build/Omnijar.h | 2 +- xpcom/build/XPCOMInit.cpp | 2 +- xpcom/build/perfprobe.cpp | 4 +- xpcom/build/perfprobe.h | 4 +- xpcom/components/nsCategoryManager.cpp | 2 +- xpcom/components/nsComponentManager.cpp | 4 +- xpcom/components/nsNativeModuleLoader.cpp | 4 +- xpcom/ds/nsAtomTable.cpp | 8 +- xpcom/ds/nsExpirationTracker.h | 2 +- xpcom/ds/nsINIParserImpl.cpp | 2 +- xpcom/ds/nsObserverList.cpp | 2 +- xpcom/ds/nsObserverService.cpp | 4 +- xpcom/ds/nsPersistentProperties.cpp | 6 +- xpcom/ds/nsWindowsRegKey.cpp | 2 +- xpcom/glue/nsArrayEnumerator.cpp | 6 +- xpcom/glue/nsCOMPtr.h | 8 +- xpcom/glue/nsCategoryCache.h | 2 +- xpcom/glue/nsDeque.cpp | 390 +--- xpcom/glue/nsDeque.h | 218 +-- xpcom/glue/nsEnumeratorUtils.cpp | 4 +- xpcom/glue/nsHashKeys.h | 2 +- xpcom/glue/nsISupportsUtils.h | 4 +- xpcom/glue/nsProxyRelease.h | 8 +- xpcom/glue/nsRefPtrHashtable.h | 50 +- xpcom/glue/nsTArray.h | 2 +- xpcom/glue/nsTObserverArray.h | 2 +- xpcom/glue/nsTWeakRef.h | 2 +- xpcom/glue/nsThreadUtils.h | 16 +- xpcom/glue/tests/gtest/TestNsDeque.cpp | 341 ++++ xpcom/glue/tests/gtest/TestThreadUtils.cpp | 14 +- xpcom/glue/tests/gtest/moz.build | 1 + xpcom/io/SpecialSystemDirectory.cpp | 4 +- xpcom/io/nsAnonymousTemporaryFile.cpp | 2 +- xpcom/io/nsDirectoryService.cpp | 4 +- xpcom/io/nsInputStreamTee.cpp | 2 +- xpcom/io/nsLocalFileUnix.cpp | 10 +- xpcom/io/nsLocalFileWin.cpp | 16 +- xpcom/io/nsMultiplexInputStream.cpp | 4 +- xpcom/io/nsPipe3.cpp | 10 +- xpcom/io/nsScriptableInputStream.cpp | 2 +- xpcom/io/nsStorageStream.cpp | 6 +- xpcom/io/nsStreamUtils.cpp | 4 +- xpcom/io/nsStringStream.cpp | 8 +- xpcom/io/nsUnicharInputStream.cpp | 4 +- xpcom/libxpcomrt/XPCOMRTInit.cpp | 2 +- xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp | 2 +- xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp | 10 +- .../xptinfo/xptiInterfaceInfoManager.cpp | 2 +- xpcom/reflect/xptinfo/xptiprivate.h | 2 +- xpcom/tests/TestAutoPtr.cpp | 64 +- xpcom/tests/TestBase64.cpp | 2 +- xpcom/tests/TestCallTemplates.cpp | 2 +- xpcom/tests/TestDeque.cpp | 240 --- xpcom/tests/TestNsRefPtr.cpp | 84 +- xpcom/tests/TestRacingServiceManager.cpp | 2 +- xpcom/tests/TestTArray.cpp | 2 +- xpcom/tests/TestThreadUtils.cpp | 14 +- xpcom/tests/TestTimers.cpp | 4 +- xpcom/tests/gtest/TestPipes.cpp | 20 +- xpcom/tests/gtest/TestStrings.cpp | 4 +- xpcom/tests/moz.build | 1 - xpcom/threads/AbstractThread.cpp | 4 +- xpcom/threads/AbstractThread.h | 2 +- xpcom/threads/MozPromise.h | 86 +- xpcom/threads/SyncRunnable.h | 4 +- xpcom/threads/TaskDispatcher.h | 4 +- xpcom/threads/TaskQueue.cpp | 8 +- xpcom/threads/TaskQueue.h | 8 +- xpcom/threads/TimerThread.cpp | 10 +- xpcom/threads/nsProcessCommon.cpp | 2 +- xpcom/threads/nsThread.cpp | 10 +- xpcom/threads/nsThread.h | 4 +- xpcom/threads/nsThreadManager.cpp | 10 +- xpcom/threads/nsThreadManager.h | 2 +- xpcom/threads/nsThreadPool.cpp | 2 +- xpfe/appshell/nsAppShellService.cpp | 8 +- xpfe/appshell/nsAppShellService.h | 4 +- xpfe/appshell/nsContentTreeOwner.cpp | 2 +- xpfe/appshell/nsWebShellWindow.cpp | 8 +- xpfe/appshell/nsWindowMediator.cpp | 8 +- xpfe/appshell/nsXULWindow.cpp | 6 +- 2987 files changed, 24310 insertions(+), 19152 deletions(-) create mode 100644 dom/base/ConsoleReportCollector.cpp create mode 100644 dom/base/ConsoleReportCollector.h create mode 100644 dom/base/nsIConsoleReportCollector.h create mode 100644 dom/push/test/webpush.js create mode 100644 dom/webidl/ServiceWorkerMessageEvent.webidl create mode 100644 dom/workers/ServiceWorkerMessageEvent.cpp create mode 100644 dom/workers/ServiceWorkerMessageEvent.h create mode 100644 dom/workers/ServiceWorkerPrivate.cpp create mode 100644 dom/workers/ServiceWorkerPrivate.h create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/embedder.html create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/hsts_test.js create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/image-20px.png create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/image-40px.png create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/image.html create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/realindex.html create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/register.html create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/register.html^headers^ create mode 100644 dom/workers/test/serviceworkers/fetch/hsts/unregister.html create mode 100644 dom/workers/test/serviceworkers/test_hsts_upgrade_intercept.html create mode 100644 dom/workers/test/sharedWorker_lifetime.js create mode 100644 dom/workers/test/test_sharedWorker_lifetime.html create mode 100644 js/src/jit-test/tests/debug/Source-canonicalId.js create mode 100644 memory/replace/dmd/block_analyzer.py create mode 100644 memory/replace/dmd/test/basic-scan-32-expected.txt create mode 100644 memory/replace/dmd/test/basic-scan-64-expected.txt create mode 100644 memory/replace/dmd/test/scan-test.py delete mode 100644 mfbt/nsRefPtr.h create mode 100644 netwerk/base/LoadTainting.h create mode 100644 netwerk/base/nsIPackagedAppChannelListener.idl create mode 100644 netwerk/base/nsIPackagedAppUtils.idl create mode 100644 netwerk/protocol/http/PackagedAppUtils.js create mode 100644 netwerk/protocol/http/PackagedAppUtils.manifest create mode 100644 netwerk/streamconv/converters/nsICompressConvStats.idl create mode 100644 netwerk/test/mochitests/empty.html create mode 100644 netwerk/test/mochitests/redirect_idn.html create mode 100644 netwerk/test/mochitests/redirect_idn.html^headers^ create mode 100644 netwerk/test/mochitests/signed_web_packaged_app.sjs create mode 100644 netwerk/test/mochitests/test_idn_redirect.html create mode 100644 netwerk/test/mochitests/test_signed_web_packaged_app.html create mode 100644 netwerk/test/mochitests/test_web_packaged_app.html create mode 100644 netwerk/test/mochitests/web_packaged_app.sjs create mode 100644 netwerk/test/unit/test_packaged_app_utils.js create mode 100644 testing/mozbase/mozrunner/mozrunner/devices/android_device.py create mode 100644 testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini create mode 100644 testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html create mode 100644 xpcom/glue/tests/gtest/TestNsDeque.cpp delete mode 100644 xpcom/tests/TestDeque.cpp diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index 8f2a7be0b8..fde0986a20 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -14,6 +14,8 @@ #include "OuterDocAccessible.h" #include "ProxyAccessible.h" #include "RootAccessible.h" +#include "TableAccessible.h" +#include "TableCellAccessible.h" #include "nsMai.h" #include "nsMaiHyperlink.h" #include "nsString.h" @@ -1524,3 +1526,118 @@ AccessibleWrap::FireAtkShowHideEvent(AccEvent* aEvent, return NS_OK; } + +// static +void +AccessibleWrap::GetKeyBinding(Accessible* aAccessible, nsAString& aResult) +{ + // Return all key bindings including access key and keyboard shortcut. + + // Get access key. + nsAutoString keyBindingsStr; + KeyBinding keyBinding = aAccessible->AccessKey(); + if (!keyBinding.IsEmpty()) { + keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat); + + Accessible* parent = aAccessible->Parent(); + roles::Role role = parent ? parent->Role() : roles::NOTHING; + if (role == roles::PARENT_MENUITEM || role == roles::MENUITEM || + role == roles::RADIO_MENU_ITEM || role == roles::CHECK_MENU_ITEM) { + // It is submenu, expose keyboard shortcuts from menu hierarchy like + // "s;f:s" + nsAutoString keysInHierarchyStr = keyBindingsStr; + do { + KeyBinding parentKeyBinding = parent->AccessKey(); + if (!parentKeyBinding.IsEmpty()) { + nsAutoString str; + parentKeyBinding.ToString(str, KeyBinding::eAtkFormat); + str.Append(':'); + + keysInHierarchyStr.Insert(str, 0); + } + } while ((parent = parent->Parent()) && parent->Role() != roles::MENUBAR); + + keyBindingsStr.Append(';'); + keyBindingsStr.Append(keysInHierarchyStr); + } + } else { + // No access key, add ';' to point this. + keyBindingsStr.Append(';'); + } + + // Get keyboard shortcut. + keyBindingsStr.Append(';'); + keyBinding = aAccessible->KeyboardShortcut(); + if (!keyBinding.IsEmpty()) { + keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat); + } + aResult = keyBindingsStr; +} + +// static +Accessible* +AccessibleWrap::GetColumnHeader(TableAccessible* aAccessible, int32_t aColIdx) +{ + if (!aAccessible) { + return nullptr; + } + + Accessible* cell = aAccessible->CellAt(0, aColIdx); + if (!cell) { + return nullptr; + } + + // If the cell at the first row is column header then assume it is column + // header for all rows, + if (cell->Role() == roles::COLUMNHEADER) { + return cell; + } + + // otherwise get column header for the data cell at the first row. + TableCellAccessible* tableCell = cell->AsTableCell(); + if (!tableCell) { + return nullptr; + } + + nsAutoTArray headerCells; + tableCell->ColHeaderCells(&headerCells); + if (headerCells.IsEmpty()) { + return nullptr; + } + + return headerCells[0]; +} + +// static +Accessible* +AccessibleWrap::GetRowHeader(TableAccessible* aAccessible, int32_t aRowIdx) +{ + if (!aAccessible) { + return nullptr; + } + + Accessible* cell = aAccessible->CellAt(aRowIdx, 0); + if (!cell) { + return nullptr; + } + + // If the cell at the first column is row header then assume it is row + // header for all columns, + if (cell->Role() == roles::ROWHEADER) { + return cell; + } + + // otherwise get row header for the data cell at the first column. + TableCellAccessible* tableCell = cell->AsTableCell(); + if (!tableCell) { + return nullptr; + } + + nsAutoTArray headerCells; + tableCell->RowHeaderCells(&headerCells); + if (headerCells.IsEmpty()) { + return nullptr; + } + + return headerCells[0]; +} diff --git a/accessible/atk/AccessibleWrap.h b/accessible/atk/AccessibleWrap.h index 2f88e9b9e5..9761c6f863 100644 --- a/accessible/atk/AccessibleWrap.h +++ b/accessible/atk/AccessibleWrap.h @@ -69,6 +69,12 @@ public: return returnedString.get(); } + static void GetKeyBinding(Accessible* aAccessible, nsAString& aResult); + + static Accessible* GetColumnHeader(TableAccessible* aAccessible, + int32_t aColIdx); + static Accessible* GetRowHeader(TableAccessible* aAccessible, + int32_t aRowIdx); protected: nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject *aObject); diff --git a/accessible/atk/nsMaiInterfaceAction.cpp b/accessible/atk/nsMaiInterfaceAction.cpp index e254938121..9ba1216658 100644 --- a/accessible/atk/nsMaiInterfaceAction.cpp +++ b/accessible/atk/nsMaiInterfaceAction.cpp @@ -10,7 +10,7 @@ #include "nsMai.h" #include "Role.h" #include "mozilla/Likely.h" - +#include "ProxyAccessible.h" #include "nsString.h" using namespace mozilla::a11y; @@ -21,86 +21,69 @@ static gboolean doActionCB(AtkAction *aAction, gint aActionIndex) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); - return accWrap && accWrap->DoAction(aActionIndex); + if (accWrap) { + return accWrap->DoAction(aActionIndex); + } + + ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction)); + return proxy && proxy->DoAction(aActionIndex); } static gint getActionCountCB(AtkAction *aAction) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); - return accWrap ? accWrap->ActionCount() : 0; + if (accWrap) { + return accWrap->ActionCount(); + } + + ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction)); + return proxy ? proxy->ActionCount() : 0; } static const gchar* getActionDescriptionCB(AtkAction *aAction, gint aActionIndex) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); - if (!accWrap) - return nullptr; - nsAutoString description; - accWrap->ActionDescriptionAt(aActionIndex, description); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); + if (accWrap) { + accWrap->ActionDescriptionAt(aActionIndex, description); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) { + proxy->ActionDescriptionAt(aActionIndex, description); + } else { + return nullptr; + } + return AccessibleWrap::ReturnString(description); } static const gchar* getActionNameCB(AtkAction *aAction, gint aActionIndex) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); - if (!accWrap) - return nullptr; - nsAutoString autoStr; - accWrap->ActionNameAt(aActionIndex, autoStr); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); + if (accWrap) { + accWrap->ActionNameAt(aActionIndex, autoStr); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) { + proxy->ActionNameAt(aActionIndex, autoStr); + } else { + return nullptr; + } + return AccessibleWrap::ReturnString(autoStr); } static const gchar* getKeyBindingCB(AtkAction *aAction, gint aActionIndex) { - AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction)); - if (!acc) - return nullptr; - - // Return all key bindings including access key and keyboard shortcut. nsAutoString keyBindingsStr; - - // Get access key. - KeyBinding keyBinding = acc->AccessKey(); - if (!keyBinding.IsEmpty()) { - keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat); - - Accessible* parent = acc->Parent(); - roles::Role role = parent ? parent->Role() : roles::NOTHING; - if (role == roles::PARENT_MENUITEM || role == roles::MENUITEM || - role == roles::RADIO_MENU_ITEM || role == roles::CHECK_MENU_ITEM) { - // It is submenu, expose keyboard shortcuts from menu hierarchy like - // "s;f:s" - nsAutoString keysInHierarchyStr = keyBindingsStr; - do { - KeyBinding parentKeyBinding = parent->AccessKey(); - if (!parentKeyBinding.IsEmpty()) { - nsAutoString str; - parentKeyBinding.ToString(str, KeyBinding::eAtkFormat); - str.Append(':'); - - keysInHierarchyStr.Insert(str, 0); - } - } while ((parent = parent->Parent()) && parent->Role() != roles::MENUBAR); - - keyBindingsStr.Append(';'); - keyBindingsStr.Append(keysInHierarchyStr); - } + AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction)); + if (acc) { + AccessibleWrap::GetKeyBinding(acc, keyBindingsStr); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) { + proxy->AtkKeyBinding(keyBindingsStr); } else { - // No access key, add ';' to point this. - keyBindingsStr.Append(';'); - } - - // Get keyboard shortcut. - keyBindingsStr.Append(';'); - keyBinding = acc->KeyboardShortcut(); - if (!keyBinding.IsEmpty()) { - keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat); + return nullptr; } return AccessibleWrap::ReturnString(keyBindingsStr); diff --git a/accessible/atk/nsMaiInterfaceTable.cpp b/accessible/atk/nsMaiInterfaceTable.cpp index 28db194196..1795f8e12b 100644 --- a/accessible/atk/nsMaiInterfaceTable.cpp +++ b/accessible/atk/nsMaiInterfaceTable.cpp @@ -12,7 +12,7 @@ #include "TableAccessible.h" #include "TableCellAccessible.h" #include "nsMai.h" - +#include "ProxyAccessible.h" #include "nsArrayUtils.h" #include "mozilla/Likely.h" @@ -23,17 +23,31 @@ extern "C" { static AtkObject* refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) { + if (aRowIdx < 0 || aColIdx < 0) { + return nullptr; + } + + AtkObject* cellAtkObj = nullptr; AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap || aRowIdx < 0 || aColIdx < 0) - return nullptr; + if (accWrap) { + Accessible* cell = accWrap->AsTable()->CellAt(aRowIdx, aColIdx); + if (!cell) { + return nullptr; + } - Accessible* cell = accWrap->AsTable()->CellAt(aRowIdx, aColIdx); - if (!cell) - return nullptr; + cellAtkObj = AccessibleWrap::GetAtkObject(cell); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + ProxyAccessible* cell = proxy->TableCellAt(aRowIdx, aColIdx); + if (!cell) { + return nullptr; + } - AtkObject* cellAtkObj = AccessibleWrap::GetAtkObject(cell); - if (cellAtkObj) + cellAtkObj = GetWrapperFor(cell); + } + + if (cellAtkObj) { g_object_ref(cellAtkObj); + } return cellAtkObj; } @@ -41,93 +55,153 @@ refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) static gint getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap || aRowIdx < 0 || aColIdx < 0) + if (aRowIdx < 0 || aColIdx < 0) { return -1; + } - return static_cast(accWrap->AsTable()->CellIndexAt(aRowIdx, aColIdx)); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { + return static_cast(accWrap->AsTable()->CellIndexAt(aRowIdx, aColIdx)); + } + + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableCellIndexAt(aRowIdx, aColIdx)); + } + + return -1; } static gint getColumnAtIndexCB(AtkTable *aTable, gint aIdx) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap || aIdx < 0) + if (aIdx < 0) { return -1; + } + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { return static_cast(accWrap->AsTable()->ColIndexAt(aIdx)); + } + + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableColumnIndexAt(aIdx)); + } + + return -1; } static gint getRowAtIndexCB(AtkTable *aTable, gint aIdx) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap || aIdx < 0) + if (aIdx < 0) { return -1; + } + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { return static_cast(accWrap->AsTable()->RowIndexAt(aIdx)); + } + + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableRowIndexAt(aIdx)); + } + + return -1; } static gint getColumnCountCB(AtkTable *aTable) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return -1; - + if (accWrap) { return static_cast(accWrap->AsTable()->ColCount()); + } + + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableColumnCount()); + } + + return -1; } static gint getRowCountCB(AtkTable *aTable) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return -1; - + if (accWrap) { return static_cast(accWrap->AsTable()->RowCount()); + } + + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableRowCount()); + } + + return -1; } static gint getColumnExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap || aRowIdx < 0 || aColIdx < 0) + if (aRowIdx < 0 || aColIdx < 0) { return -1; + } + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { return static_cast(accWrap->AsTable()->ColExtentAt(aRowIdx, aColIdx)); + } + + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableColumnExtentAt(aRowIdx, aColIdx)); + } + + return -1; } static gint getRowExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return -1; + if (accWrap) { + return static_cast(accWrap->AsTable()->RowExtentAt(aRowIdx, aColIdx)); + } - return static_cast(accWrap->AsTable()->RowExtentAt(aRowIdx, aColIdx)); + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableRowExtentAt(aRowIdx, aColIdx)); + } + + return -1; } static AtkObject* getCaptionCB(AtkTable* aTable) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return nullptr; + if (accWrap) { + Accessible* caption = accWrap->AsTable()->Caption(); + return caption ? AccessibleWrap::GetAtkObject(caption) : nullptr; + } - Accessible* caption = accWrap->AsTable()->Caption(); - return caption ? AccessibleWrap::GetAtkObject(caption) : nullptr; + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + ProxyAccessible* caption = proxy->TableCaption(); + return caption ? GetWrapperFor(caption) : nullptr; + } + + return nullptr; } static const gchar* getColumnDescriptionCB(AtkTable *aTable, gint aColumn) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return nullptr; - nsAutoString autoStr; - accWrap->AsTable()->ColDescription(aColumn, autoStr); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { + accWrap->AsTable()->ColDescription(aColumn, autoStr); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + proxy->TableColumnDescription(aColumn, autoStr); + } else { + return nullptr; + } return AccessibleWrap::ReturnString(autoStr); } @@ -136,40 +210,32 @@ static AtkObject* getColumnHeaderCB(AtkTable *aTable, gint aColIdx) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return nullptr; + if (accWrap) { + Accessible* header = + AccessibleWrap::GetColumnHeader(accWrap->AsTable(), aColIdx); + return header ? AccessibleWrap::GetAtkObject(header) : nullptr; + } - Accessible* cell = accWrap->AsTable()->CellAt(0, aColIdx); - if (!cell) - return nullptr; + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + ProxyAccessible* header = proxy->AtkTableColumnHeader(aColIdx); + return header ? GetWrapperFor(header) : nullptr; + } - // If the cell at the first row is column header then assume it is column - // header for all rows, - if (cell->Role() == roles::COLUMNHEADER) - return AccessibleWrap::GetAtkObject(cell); - - // otherwise get column header for the data cell at the first row. - TableCellAccessible* tableCell = cell->AsTableCell(); - if (!tableCell) - return nullptr; - - nsAutoTArray headerCells; - tableCell->ColHeaderCells(&headerCells); - if (headerCells.IsEmpty()) - return nullptr; - - return AccessibleWrap::GetAtkObject(headerCells[0]); + return nullptr; } static const gchar* getRowDescriptionCB(AtkTable *aTable, gint aRow) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return nullptr; - nsAutoString autoStr; - accWrap->AsTable()->RowDescription(aRow, autoStr); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { + accWrap->AsTable()->RowDescription(aRow, autoStr); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + proxy->TableRowDescription(aRow, autoStr); + } else { + return nullptr; + } return AccessibleWrap::ReturnString(autoStr); } @@ -178,29 +244,18 @@ static AtkObject* getRowHeaderCB(AtkTable *aTable, gint aRowIdx) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return nullptr; + if (accWrap) { + Accessible* header = + AccessibleWrap::GetRowHeader(accWrap->AsTable(), aRowIdx); + return header ? AccessibleWrap::GetAtkObject(header) : nullptr; + } - Accessible* cell = accWrap->AsTable()->CellAt(aRowIdx, 0); - if (!cell) - return nullptr; + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + ProxyAccessible* header = proxy->AtkTableRowHeader(aRowIdx); + return header ? GetWrapperFor(header) : nullptr; + } - // If the cell at the first column is row header then assume it is row - // header for all columns, - if (cell->Role() == roles::ROWHEADER) - return AccessibleWrap::GetAtkObject(cell); - - // otherwise get row header for the data cell at the first column. - TableCellAccessible* tableCell = cell->AsTableCell(); - if (!tableCell) - return nullptr; - - nsAutoTArray headerCells; - tableCell->RowHeaderCells(&headerCells); - if (headerCells.IsEmpty()) - return nullptr; - - return AccessibleWrap::GetAtkObject(headerCells[0]); + return nullptr; } static AtkObject* @@ -218,12 +273,16 @@ getSelectedColumnsCB(AtkTable *aTable, gint** aSelected) { *aSelected = nullptr; - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return 0; - nsAutoTArray cols; - accWrap->AsTable()->SelectedColIndices(&cols); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { + accWrap->AsTable()->SelectedColIndices(&cols); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + proxy->TableSelectedColumnIndices(&cols); + } else { + return 0; + } + if (cols.IsEmpty()) return 0; @@ -241,12 +300,15 @@ getSelectedColumnsCB(AtkTable *aTable, gint** aSelected) static gint getSelectedRowsCB(AtkTable *aTable, gint **aSelected) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return 0; - nsAutoTArray rows; - accWrap->AsTable()->SelectedRowIndices(&rows); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); + if (accWrap) { + accWrap->AsTable()->SelectedRowIndices(&rows); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + proxy->TableSelectedRowIndices(&rows); + } else { + return 0; + } gint* atkRows = g_new(gint, rows.Length()); if (!atkRows) { @@ -263,31 +325,40 @@ static gboolean isColumnSelectedCB(AtkTable *aTable, gint aColIdx) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return FALSE; + if (accWrap) { + return static_cast(accWrap->AsTable()->IsColSelected(aColIdx)); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableColumnSelected(aColIdx)); + } - return static_cast(accWrap->AsTable()->IsColSelected(aColIdx)); + return FALSE; } static gboolean isRowSelectedCB(AtkTable *aTable, gint aRowIdx) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return FALSE; + if (accWrap) { + return static_cast(accWrap->AsTable()->IsRowSelected(aRowIdx)); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableRowSelected(aRowIdx)); + } - return static_cast(accWrap->AsTable()->IsRowSelected(aRowIdx)); + return FALSE; } static gboolean isCellSelectedCB(AtkTable *aTable, gint aRowIdx, gint aColIdx) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable)); - if (!accWrap) - return FALSE; - + if (accWrap) { return static_cast(accWrap->AsTable()-> IsCellSelected(aRowIdx, aColIdx)); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) { + return static_cast(proxy->TableCellSelected(aRowIdx, aColIdx)); + } + + return FALSE; } } diff --git a/accessible/atk/nsMaiInterfaceText.cpp b/accessible/atk/nsMaiInterfaceText.cpp index b291c499e8..e408ff8eb3 100644 --- a/accessible/atk/nsMaiInterfaceText.cpp +++ b/accessible/atk/nsMaiInterfaceText.cpp @@ -576,9 +576,8 @@ setCaretOffsetCB(AtkText *aText, gint aOffset) } if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { - if (proxy->SetCaretOffset(aOffset)) { - return TRUE; - } + proxy->SetCaretOffset(aOffset); + return TRUE; } return FALSE; diff --git a/accessible/base/AccEvent.h b/accessible/base/AccEvent.h index 7e2c4821ef..f15c254fba 100644 --- a/accessible/base/AccEvent.h +++ b/accessible/base/AccEvent.h @@ -127,7 +127,7 @@ protected: bool mIsFromUserInput; uint32_t mEventType; EEventRule mEventRule; - nsRefPtr mAccessible; + RefPtr mAccessible; friend class EventQueue; friend class AccReorderEvent; @@ -237,8 +237,8 @@ public: protected: nsCOMPtr mNode; - nsRefPtr mParent; - nsRefPtr mTextChangeEvent; + RefPtr mParent; + RefPtr mTextChangeEvent; friend class EventQueue; }; @@ -268,8 +268,8 @@ public: protected: bool mNeedsShutdown; - nsRefPtr mNextSibling; - nsRefPtr mPrevSibling; + RefPtr mNextSibling; + RefPtr mPrevSibling; friend class EventQueue; }; @@ -397,7 +397,7 @@ public: bool IsCaretMoveOnly() const; private: - nsRefPtr mSel; + RefPtr mSel; int32_t mReason; friend class EventQueue; @@ -432,8 +432,8 @@ public: Accessible* Widget() const { return mWidget; } private: - nsRefPtr mWidget; - nsRefPtr mItem; + RefPtr mWidget; + RefPtr mItem; SelChangeType mSelChangeType; uint32_t mPreceedingCount; AccSelChangeEvent* mPackedEvent; @@ -495,7 +495,7 @@ public: int32_t Reason() const { return mReason; } private: - nsRefPtr mOldAccessible; + RefPtr mOldAccessible; int32_t mOldStart; int32_t mOldEnd; int16_t mReason; diff --git a/accessible/base/AccIterator.cpp b/accessible/base/AccIterator.cpp index dedbca7557..2859953c1d 100644 --- a/accessible/base/AccIterator.cpp +++ b/accessible/base/AccIterator.cpp @@ -394,7 +394,7 @@ ARIAOwnsIterator::Next() Accessible* SingleAccIterator::Next() { - nsRefPtr nextAcc; + RefPtr nextAcc; mAcc.swap(nextAcc); if (!nextAcc || nextAcc->IsDefunct()) { return nullptr; diff --git a/accessible/base/AccIterator.h b/accessible/base/AccIterator.h index 17c988ccd9..62aca0d491 100644 --- a/accessible/base/AccIterator.h +++ b/accessible/base/AccIterator.h @@ -306,7 +306,7 @@ private: SingleAccIterator(const SingleAccIterator&); SingleAccIterator& operator = (const SingleAccIterator&); - nsRefPtr mAcc; + RefPtr mAcc; }; diff --git a/accessible/base/DocManager.cpp b/accessible/base/DocManager.cpp index d5df31b088..3dfcd58736 100644 --- a/accessible/base/DocManager.cpp +++ b/accessible/base/DocManager.cpp @@ -427,7 +427,7 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument) // We only create root accessibles for the true root, otherwise create a // doc accessible. nsIContent *rootElm = nsCoreUtils::GetRoleContent(aDocument); - nsRefPtr docAcc = isRootDoc ? + RefPtr docAcc = isRootDoc ? new RootAccessibleWrap(aDocument, rootElm, presShell) : new DocAccessibleWrap(aDocument, rootElm, presShell); diff --git a/accessible/base/EventQueue.cpp b/accessible/base/EventQueue.cpp index 96bb9e3801..d123c210ff 100644 --- a/accessible/base/EventQueue.cpp +++ b/accessible/base/EventQueue.cpp @@ -61,7 +61,7 @@ EventQueue::PushEvent(AccEvent* aEvent) ENameValueFlag nameFlag = parent->Name(name); // If name is obtained from subtree, fire name change event. if (nameFlag == eNameFromSubtree) { - nsRefPtr nameChangeEvent = + RefPtr nameChangeEvent = new AccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, parent); PushEvent(nameChangeEvent); } @@ -482,7 +482,7 @@ void EventQueue::ProcessEventQueue() { // Process only currently queued events. - nsTArray > events; + nsTArray > events; events.SwapElements(mEvents); uint32_t eventCount = events.Length(); diff --git a/accessible/base/EventQueue.h b/accessible/base/EventQueue.h index 31082f293b..01384b844f 100644 --- a/accessible/base/EventQueue.h +++ b/accessible/base/EventQueue.h @@ -79,7 +79,7 @@ protected: * Pending events array. Don't make this an nsAutoTArray; we use * SwapElements() on it. */ - nsTArray > mEvents; + nsTArray > mEvents; }; } // namespace a11y diff --git a/accessible/base/FocusManager.cpp b/accessible/base/FocusManager.cpp index 57269b9a46..fee8b60bef 100644 --- a/accessible/base/FocusManager.cpp +++ b/accessible/base/FocusManager.cpp @@ -218,7 +218,7 @@ FocusManager::DispatchFocusEvent(DocAccessible* aDocument, { NS_PRECONDITION(aDocument, "No document for focused accessible!"); if (aDocument) { - nsRefPtr event = + RefPtr event = new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget, eAutoDetect, AccEvent::eCoalesceOfSameType); aDocument->FireDelayedEvent(event); @@ -331,7 +331,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent) if (ARIAMenubar != mActiveARIAMenubar) { // Leaving ARIA menu. Fire menu_end event on current menubar. if (mActiveARIAMenubar) { - nsRefPtr menuEndEvent = + RefPtr menuEndEvent = new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar, aEvent->FromUserInput()); nsEventShell::FireEvent(menuEndEvent); @@ -341,7 +341,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent) // Entering ARIA menu. Fire menu_start event. if (mActiveARIAMenubar) { - nsRefPtr menuStartEvent = + RefPtr menuStartEvent = new AccEvent(nsIAccessibleEvent::EVENT_MENU_START, mActiveARIAMenubar, aEvent->FromUserInput()); nsEventShell::FireEvent(menuStartEvent); @@ -349,7 +349,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent) } } else if (mActiveARIAMenubar) { // Focus left a menu. Fire menu_end event. - nsRefPtr menuEndEvent = + RefPtr menuEndEvent = new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar, aEvent->FromUserInput()); nsEventShell::FireEvent(menuEndEvent); @@ -367,7 +367,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent) // offset before the caret move event is handled. SelectionMgr()->ResetCaretOffset(); - nsRefPtr focusEvent = + RefPtr focusEvent = new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, target, aEvent->FromUserInput()); nsEventShell::FireEvent(focusEvent); diff --git a/accessible/base/FocusManager.h b/accessible/base/FocusManager.h index ccbbd9e9ee..6638cafc78 100644 --- a/accessible/base/FocusManager.h +++ b/accessible/base/FocusManager.h @@ -124,8 +124,8 @@ private: nsIDocument* FocusedDOMDocument() const; private: - nsRefPtr mActiveItem; - nsRefPtr mActiveARIAMenubar; + RefPtr mActiveItem; + RefPtr mActiveARIAMenubar; }; } // namespace a11y diff --git a/accessible/base/NotificationController.cpp b/accessible/base/NotificationController.cpp index aa47a922cf..83d3062ef0 100644 --- a/accessible/base/NotificationController.cpp +++ b/accessible/base/NotificationController.cpp @@ -101,7 +101,7 @@ NotificationController::ScheduleContentInsertion(Accessible* aContainer, nsIContent* aStartChildNode, nsIContent* aEndChildNode) { - nsRefPtr insertion = new ContentInsertion(mDocument, + RefPtr insertion = new ContentInsertion(mDocument, aContainer); if (insertion && insertion->InitChildList(aStartChildNode, aEndChildNode) && mContentInsertions.AppendElement(insertion)) { @@ -193,7 +193,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime) // document accessible. // Process only currently queued content inserted notifications. - nsTArray > contentInsertions; + nsTArray > contentInsertions; contentInsertions.SwapElements(mContentInsertions); uint32_t insertionCount = contentInsertions.Length(); @@ -290,7 +290,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime) // Bind hanging child documents. uint32_t hangingDocCnt = mHangingChildDocuments.Length(); - nsTArray> newChildDocs; + nsTArray> newChildDocs; for (uint32_t idx = 0; idx < hangingDocCnt; idx++) { DocAccessible* childDoc = mHangingChildDocuments[idx]; if (childDoc->IsDefunct()) @@ -336,7 +336,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime) } // Process only currently queued generic notifications. - nsTArray < nsRefPtr > notifications; + nsTArray < RefPtr > notifications; notifications.SwapElements(mNotifications); uint32_t notificationCount = notifications.Length(); diff --git a/accessible/base/NotificationController.h b/accessible/base/NotificationController.h index fb4208413f..81533c2fc4 100644 --- a/accessible/base/NotificationController.h +++ b/accessible/base/NotificationController.h @@ -81,7 +81,7 @@ private: Class* mInstance; Callback mCallback; - Tuple ...> mArgs; + Tuple ...> mArgs; }; /** @@ -161,7 +161,7 @@ public: return; } - nsRefPtr notification = + RefPtr notification = new TNotification(aInstance, aMethod, aArg); if (notification && mNotifications.AppendElement(notification)) ScheduleProcessing(); @@ -177,7 +177,7 @@ public: inline void ScheduleNotification(Class* aInstance, typename TNotification::Callback aMethod) { - nsRefPtr notification = + RefPtr notification = new TNotification(aInstance, aMethod); if (notification && mNotifications.AppendElement(notification)) ScheduleProcessing(); @@ -227,7 +227,7 @@ private: /** * Child documents that needs to be bound to the tree. */ - nsTArray > mHangingChildDocuments; + nsTArray > mHangingChildDocuments; /** * Storage for content inserted notification information. @@ -257,7 +257,7 @@ private: DocAccessible* mDocument; // The container accessible that content insertion occurs within. - nsRefPtr mContainer; + RefPtr mContainer; // Array of inserted contents. nsTArray > mInsertedContent; @@ -267,7 +267,7 @@ private: * A pending accessible tree update notifications for content insertions. * Don't make this an nsAutoTArray; we use SwapElements() on it. */ - nsTArray > mContentInsertions; + nsTArray > mContentInsertions; template class nsCOMPtrHashKey : public PLDHashEntryHdr @@ -302,7 +302,7 @@ private: * Other notifications like DOM events. Don't make this an nsAutoTArray; we * use SwapElements() on it. */ - nsTArray > mNotifications; + nsTArray > mNotifications; }; } // namespace a11y diff --git a/accessible/base/SelectionManager.cpp b/accessible/base/SelectionManager.cpp index 607cfd22b4..6cb83ba1b3 100644 --- a/accessible/base/SelectionManager.cpp +++ b/accessible/base/SelectionManager.cpp @@ -29,7 +29,7 @@ struct mozilla::a11y::SelData final SelData(Selection* aSel, int32_t aReason) : mSel(aSel), mReason(aReason) {} - nsRefPtr mSel; + RefPtr mSel; int16_t mReason; NS_INLINE_DECL_REFCOUNTING(SelData) @@ -159,7 +159,7 @@ SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent) selection->FocusOffset()); mAccWithCaret = caretCntr; if (mCaretOffset != -1) { - nsRefPtr caretMoveEvent = + RefPtr caretMoveEvent = new AccCaretMoveEvent(caretCntr, mCaretOffset, aEvent->FromUserInput()); nsEventShell::FireEvent(caretMoveEvent); } @@ -184,7 +184,7 @@ SelectionManager::NotifySelectionChanged(nsIDOMDocument* aDOMDocument, // Selection manager has longer lifetime than any document accessible, // so that we are guaranteed that the notification is processed before // the selection manager is destroyed. - nsRefPtr selData = + RefPtr selData = new SelData(static_cast(aSelection), aReason); document->HandleNotification (this, &SelectionManager::ProcessSelectionChanged, selData); @@ -221,7 +221,7 @@ SelectionManager::ProcessSelectionChanged(SelData* aSelData) } if (selection->GetType() == nsISelectionController::SELECTION_NORMAL) { - nsRefPtr event = + RefPtr event = new AccTextSelChangeEvent(text, selection, aSelData->mReason); text->Document()->FireDelayedEvent(event); diff --git a/accessible/base/StyleInfo.h b/accessible/base/StyleInfo.h index a4326d592b..c8cc033888 100644 --- a/accessible/base/StyleInfo.h +++ b/accessible/base/StyleInfo.h @@ -39,7 +39,7 @@ private: void Margin(Side aSide, nsAString& aValue); dom::Element* mElement; - nsRefPtr mStyleContext; + RefPtr mStyleContext; }; } // namespace a11y diff --git a/accessible/base/TextAttrs.cpp b/accessible/base/TextAttrs.cpp index 1881c1204d..cf108d0c39 100644 --- a/accessible/base/TextAttrs.cpp +++ b/accessible/base/TextAttrs.cpp @@ -460,7 +460,7 @@ bool TextAttrsMgr::FontFamilyTextAttr:: GetFontFamily(nsIFrame* aFrame, nsString& aFamily) { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm)); gfxFontGroup* fontGroup = fm->GetThebesFontGroup(); @@ -618,7 +618,7 @@ TextAttrsMgr::FontWeightTextAttr:: { // nsFont::width isn't suitable here because it's necessary to expose real // value of font weight (used font might not have some font weight values). - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm)); gfxFontGroup *fontGroup = fm->GetThebesFontGroup(); diff --git a/accessible/base/TextRange.h b/accessible/base/TextRange.h index be1077cdad..4f964ff185 100644 --- a/accessible/base/TextRange.h +++ b/accessible/base/TextRange.h @@ -243,9 +243,9 @@ private: HyperTextAccessible* aStopContainer = nullptr, int32_t aStopOffset = 0); - nsRefPtr mRoot; - nsRefPtr mStartContainer; - nsRefPtr mEndContainer; + RefPtr mRoot; + RefPtr mStartContainer; + RefPtr mEndContainer; int32_t mStartOffset; int32_t mEndOffset; }; diff --git a/accessible/base/TextUpdater.cpp b/accessible/base/TextUpdater.cpp index 69ae568aa3..75cbbe7e1d 100644 --- a/accessible/base/TextUpdater.cpp +++ b/accessible/base/TextUpdater.cpp @@ -81,14 +81,14 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText, strLen1 > kMaxStrLen || strLen2 > kMaxStrLen) { if (strLen1 > 0) { // Fire text change event for removal. - nsRefPtr textRemoveEvent = + RefPtr textRemoveEvent = new AccTextChangeEvent(mHyperText, mTextOffset, str1, false); mDocument->FireDelayedEvent(textRemoveEvent); } if (strLen2 > 0) { // Fire text change event for insertion. - nsRefPtr textInsertEvent = + RefPtr textInsertEvent = new AccTextChangeEvent(mHyperText, mTextOffset, str2, true); mDocument->FireDelayedEvent(textInsertEvent); } @@ -129,7 +129,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText, } // Compute events based on the difference. - nsTArray > events; + nsTArray > events; ComputeTextChangeEvents(str1, str2, entries, events); delete [] entries; @@ -148,7 +148,7 @@ void TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1, const nsAString& aStr2, uint32_t* aEntries, - nsTArray >& aEvents) + nsTArray >& aEvents) { int32_t colIdx = aStr1.Length(), rowIdx = aStr2.Length(); diff --git a/accessible/base/TextUpdater.h b/accessible/base/TextUpdater.h index fcaa29d4db..06df3890d9 100644 --- a/accessible/base/TextUpdater.h +++ b/accessible/base/TextUpdater.h @@ -51,15 +51,15 @@ private: void ComputeTextChangeEvents(const nsAString& aStr1, const nsAString& aStr2, uint32_t* aEntries, - nsTArray >& aEvents); + nsTArray >& aEvents); /** * Helper to create text change events for inserted text. */ inline void FireInsertEvent(const nsAString& aText, uint32_t aAddlOffset, - nsTArray >& aEvents) + nsTArray >& aEvents) { - nsRefPtr event = + RefPtr event = new AccTextChangeEvent(mHyperText, mTextOffset + aAddlOffset, aText, true); aEvents.AppendElement(event); @@ -69,9 +69,9 @@ private: * Helper to create text change events for removed text. */ inline void FireDeleteEvent(const nsAString& aText, uint32_t aAddlOffset, - nsTArray >& aEvents) + nsTArray >& aEvents) { - nsRefPtr event = + RefPtr event = new AccTextChangeEvent(mHyperText, mTextOffset + aAddlOffset, aText, false); aEvents.AppendElement(event); diff --git a/accessible/base/nsAccCache.h b/accessible/base/nsAccCache.h index 14b83b76e0..acfedb8e63 100644 --- a/accessible/base/nsAccCache.h +++ b/accessible/base/nsAccCache.h @@ -17,7 +17,7 @@ */ template static PLDHashOperator -ClearCacheEntry(const void* aKey, nsRefPtr& aAccessible, void* aUserArg) +ClearCacheEntry(const void* aKey, RefPtr& aAccessible, void* aUserArg) { NS_ASSERTION(aAccessible, "Calling ClearCacheEntry with a nullptr pointer!"); if (aAccessible && !aAccessible->IsDefunct()) @@ -28,7 +28,7 @@ ClearCacheEntry(const void* aKey, nsRefPtr& aAccessible, void* aUserArg) template static PLDHashOperator -UnbindCacheEntryFromDocument(const void* aKey, nsRefPtr& aAccessible, +UnbindCacheEntryFromDocument(const void* aKey, RefPtr& aAccessible, void* aUserArg) { MOZ_ASSERT(aAccessible && !aAccessible->IsDefunct()); diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index bf02f1f982..a232b897e1 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -456,7 +456,7 @@ nsAccessibilityService::CreatePluginAccessible(nsPluginFrame* aFrame, return nullptr; #if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK) - nsRefPtr pluginInstance; + RefPtr pluginInstance; if (NS_SUCCEEDED(aFrame->GetPluginInstance(getter_AddRefs(pluginInstance))) && pluginInstance) { #ifdef XP_WIN @@ -464,7 +464,7 @@ nsAccessibilityService::CreatePluginAccessible(nsPluginFrame* aFrame, (Preferences::GetBool("accessibility.delay_plugins") || Compatibility::IsJAWS() || Compatibility::IsWE())) { nsCOMPtr timer = do_CreateInstance(NS_TIMER_CONTRACTID); - nsRefPtr cb = new PluginTimerCallBack(aContent); + RefPtr cb = new PluginTimerCallBack(aContent); timer->InitWithCallback(cb, Preferences::GetUint("accessibility.delay_plugin_time"), nsITimer::TYPE_ONE_SHOT); sPluginTimers->AppendElement(timer); @@ -481,7 +481,7 @@ nsAccessibilityService::CreatePluginAccessible(nsPluginFrame* aFrame, HWND pluginPort = nullptr; aFrame->GetPluginPort(&pluginPort); - nsRefPtr accessible = + RefPtr accessible = new HTMLWin32ObjectOwnerAccessible(aContent, aContext->Document(), pluginPort); return accessible.forget(); @@ -496,7 +496,7 @@ nsAccessibilityService::CreatePluginAccessible(nsPluginFrame* aFrame, nsresult rv = pluginInstance->GetValueFromPlugin( NPPVpluginNativeAccessibleAtkPlugId, &plugId); if (NS_SUCCEEDED(rv) && !plugId.IsEmpty()) { - nsRefPtr socketAccessible = + RefPtr socketAccessible = new AtkSocketAccessible(aContent, aContext->Document(), plugId); return socketAccessible.forget(); @@ -787,7 +787,7 @@ NS_IMETHODIMP nsAccessibilityService::GetStringStates(uint32_t aState, uint32_t aExtraState, nsISupports **aStringStates) { - nsRefPtr stringStates = new DOMStringList(); + RefPtr stringStates = new DOMStringList(); uint64_t state = nsAccUtils::To64State(aState, aExtraState); @@ -1087,7 +1087,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode, #endif // Attempt to create an accessible based on what we know. - nsRefPtr newAcc; + RefPtr newAcc; // Create accessible for visible text frames. if (content->IsNodeOfType(nsINode::eTEXT)) { @@ -1423,11 +1423,11 @@ nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent, return nullptr; if (role.EqualsLiteral("outerdoc")) { - nsRefPtr accessible = new OuterDocAccessible(aContent, aDoc); + RefPtr accessible = new OuterDocAccessible(aContent, aDoc); return accessible.forget(); } - nsRefPtr accessible; + RefPtr accessible; #ifdef MOZ_XUL // XUL controls if (role.EqualsLiteral("xul:alert")) { @@ -1599,7 +1599,7 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame, { DocAccessible* document = aContext->Document(); - nsRefPtr newAcc; + RefPtr newAcc; switch (aFrame->AccessibleType()) { case eNoType: return nullptr; @@ -1826,7 +1826,7 @@ NS_GetAccessibilityService(nsIAccessibilityService** aResult) return NS_OK; } - nsRefPtr service = new nsAccessibilityService(); + RefPtr service = new nsAccessibilityService(); NS_ENSURE_TRUE(service, NS_ERROR_OUT_OF_MEMORY); if (!service->Init()) { @@ -1859,19 +1859,19 @@ nsAccessibilityService::CreateAccessibleForXULTree(nsIContent* aContent, if (!treeFrame) return nullptr; - nsRefPtr treeCols = treeFrame->Columns(); + RefPtr treeCols = treeFrame->Columns(); int32_t count = 0; treeCols->GetCount(&count); // Outline of list accessible. if (count == 1) { - nsRefPtr accessible = + RefPtr accessible = new XULTreeAccessible(aContent, aDoc, treeFrame); return accessible.forget(); } // Table or tree table accessible. - nsRefPtr accessible = + RefPtr accessible = new XULTreeGridAccessibleWrap(aContent, aDoc, treeFrame); return accessible.forget(); } diff --git a/accessible/base/nsAccessiblePivot.cpp b/accessible/base/nsAccessiblePivot.cpp index deee601cd1..963dfc4ec3 100644 --- a/accessible/base/nsAccessiblePivot.cpp +++ b/accessible/base/nsAccessiblePivot.cpp @@ -89,7 +89,7 @@ nsAccessiblePivot::GetPosition(nsIAccessible** aPosition) NS_IMETHODIMP nsAccessiblePivot::SetPosition(nsIAccessible* aPosition) { - nsRefPtr position = nullptr; + RefPtr position = nullptr; if (aPosition) { position = aPosition->ToInternalAccessible(); @@ -168,7 +168,7 @@ nsAccessiblePivot::SetTextRange(nsIAccessibleText* aTextAccessible, nsCOMPtr xpcAcc = do_QueryInterface(aTextAccessible); NS_ENSURE_ARG(xpcAcc); - nsRefPtr acc = xpcAcc->ToInternalAccessible(); + RefPtr acc = xpcAcc->ToInternalAccessible(); NS_ENSURE_ARG(acc); HyperTextAccessible* position = acc->AsHyperText(); @@ -643,7 +643,7 @@ nsAccessiblePivot::MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason, bool aIsFromUserInput) { - nsRefPtr oldPosition = mPosition.forget(); + RefPtr oldPosition = mPosition.forget(); mPosition = aPosition; int32_t oldStart = mStartOffset, oldEnd = mEndOffset; mStartOffset = mEndOffset = -1; diff --git a/accessible/base/nsAccessiblePivot.h b/accessible/base/nsAccessiblePivot.h index c47d1f3e81..f6c07daa53 100644 --- a/accessible/base/nsAccessiblePivot.h +++ b/accessible/base/nsAccessiblePivot.h @@ -114,17 +114,17 @@ private: /* * The root accessible. */ - nsRefPtr mRoot; + RefPtr mRoot; /* * The temporary modal root accessible. */ - nsRefPtr mModalRoot; + RefPtr mModalRoot; /* * The current pivot position. */ - nsRefPtr mPosition; + RefPtr mPosition; /* * The text start offset ofthe pivot. diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 017dd017ff..0bd318e7ee 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -102,7 +102,7 @@ nsCoreUtils::DispatchClickEvent(nsITreeBoxObject *aTreeBoxObj, nsIWidget *rootWidget = rootFrame->GetViewExternal()->GetNearestWidget(&offset); - nsRefPtr presContext = presShell->GetPresContext(); + RefPtr presContext = presShell->GetPresContext(); int32_t cnvdX = presContext->CSSPixelsToDevPixels(tcX + x + 1) + presContext->AppUnitsToDevPixels(offset.x); @@ -149,7 +149,7 @@ nsCoreUtils::DispatchTouchEvent(EventMessage aMessage, int32_t aX, int32_t aY, event.time = PR_IntervalNow(); // XXX: Touch has an identifier of -1 to hint that it is synthesized. - nsRefPtr t = new dom::Touch(-1, LayoutDeviceIntPoint(aX, aY), + RefPtr t = new dom::Touch(-1, LayoutDeviceIntPoint(aX, aY), nsIntPoint(1, 1), 0.0f, 1.0f); t->SetTarget(aContent); event.touches.AppendElement(t); diff --git a/accessible/base/nsEventShell.cpp b/accessible/base/nsEventShell.cpp index 8d0a5094d2..b5b1415bad 100644 --- a/accessible/base/nsEventShell.cpp +++ b/accessible/base/nsEventShell.cpp @@ -42,7 +42,7 @@ nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible, { NS_ENSURE_TRUE_VOID(aAccessible); - nsRefPtr event = new AccEvent(aEventType, aAccessible, + RefPtr event = new AccEvent(aEventType, aAccessible, aIsFromUserInput); FireEvent(event); diff --git a/accessible/base/nsEventShell.h b/accessible/base/nsEventShell.h index ee0dce21c9..169af6dad6 100644 --- a/accessible/base/nsEventShell.h +++ b/accessible/base/nsEventShell.h @@ -41,7 +41,7 @@ public: static void FireEvent(mozilla::a11y::Accessible* aTarget, uint64_t aState, bool aIsEnabled, bool aIsFromUserInput) { - nsRefPtr stateChangeEvent = + RefPtr stateChangeEvent = new mozilla::a11y::AccStateChangeEvent(aTarget, aState, aIsEnabled, (aIsFromUserInput ? mozilla::a11y::eFromUserInput : diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 2f70aa8794..703bec6a77 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -835,47 +835,50 @@ Accessible::HandleAccEvent(AccEvent* aEvent) if (IPCAccessibilityActive() && Document()) { DocAccessibleChild* ipcDoc = mDoc->IPCDoc(); - uint64_t id = aEvent->GetAccessible()->IsDoc() ? 0 : - reinterpret_cast(aEvent->GetAccessible()); + MOZ_ASSERT(ipcDoc); + if (ipcDoc) { + uint64_t id = aEvent->GetAccessible()->IsDoc() ? 0 : + reinterpret_cast(aEvent->GetAccessible()); - switch(aEvent->GetEventType()) { - case nsIAccessibleEvent::EVENT_SHOW: - ipcDoc->ShowEvent(downcast_accEvent(aEvent)); - break; + switch(aEvent->GetEventType()) { + case nsIAccessibleEvent::EVENT_SHOW: + ipcDoc->ShowEvent(downcast_accEvent(aEvent)); + break; - case nsIAccessibleEvent::EVENT_HIDE: - ipcDoc->SendHideEvent(id); - break; + case nsIAccessibleEvent::EVENT_HIDE: + ipcDoc->SendHideEvent(id); + break; - case nsIAccessibleEvent::EVENT_REORDER: - // reorder events on the application acc aren't necessary to tell the parent - // about new top level documents. - if (!aEvent->GetAccessible()->IsApplication()) - ipcDoc->SendEvent(id, aEvent->GetEventType()); - break; - case nsIAccessibleEvent::EVENT_STATE_CHANGE: { - AccStateChangeEvent* event = downcast_accEvent(aEvent); - ipcDoc->SendStateChangeEvent(id, event->GetState(), - event->IsStateEnabled()); - break; - } - case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: { - AccCaretMoveEvent* event = downcast_accEvent(aEvent); - ipcDoc->SendEvent(id, event->GetCaretOffset()); - break; - } - case nsIAccessibleEvent::EVENT_TEXT_INSERTED: - case nsIAccessibleEvent::EVENT_TEXT_REMOVED: { - AccTextChangeEvent* event = downcast_accEvent(aEvent); - ipcDoc->SendTextChangeEvent(id, event->ModifiedText(), - event->GetStartOffset(), - event->GetLength(), - event->IsTextInserted(), - event->IsFromUserInput()); - break; - } - default: - ipcDoc->SendEvent(id, aEvent->GetEventType()); + case nsIAccessibleEvent::EVENT_REORDER: + // reorder events on the application acc aren't necessary to tell the parent + // about new top level documents. + if (!aEvent->GetAccessible()->IsApplication()) + ipcDoc->SendEvent(id, aEvent->GetEventType()); + break; + case nsIAccessibleEvent::EVENT_STATE_CHANGE: { + AccStateChangeEvent* event = downcast_accEvent(aEvent); + ipcDoc->SendStateChangeEvent(id, event->GetState(), + event->IsStateEnabled()); + break; + } + case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: { + AccCaretMoveEvent* event = downcast_accEvent(aEvent); + ipcDoc->SendEvent(id, event->GetCaretOffset()); + break; + } + case nsIAccessibleEvent::EVENT_TEXT_INSERTED: + case nsIAccessibleEvent::EVENT_TEXT_REMOVED: { + AccTextChangeEvent* event = downcast_accEvent(aEvent); + ipcDoc->SendTextChangeEvent(id, event->ModifiedText(), + event->GetStartOffset(), + event->GetLength(), + event->IsTextInserted(), + event->IsFromUserInput()); + break; + } + default: + ipcDoc->SendEvent(id, aEvent->GetEventType()); + } } } @@ -1790,7 +1793,7 @@ Accessible::DoCommand(nsIContent *aContent, uint32_t aActionIndex) } private: - nsRefPtr mAcc; + RefPtr mAcc; nsCOMPtr mContent; uint32_t mIdx; }; @@ -1826,7 +1829,7 @@ Accessible::DispatchClickEvent(nsIContent *aContent, uint32_t aActionIndex) nsSize size = frame->GetSize(); - nsRefPtr presContext = presShell->GetPresContext(); + RefPtr presContext = presShell->GetPresContext(); int32_t x = presContext->AppUnitsToDevPixels(point.x + size.width / 2); int32_t y = presContext->AppUnitsToDevPixels(point.y + size.height / 2); diff --git a/accessible/generic/Accessible.h b/accessible/generic/Accessible.h index 0c7065ea05..100c9c0922 100644 --- a/accessible/generic/Accessible.h +++ b/accessible/generic/Accessible.h @@ -1116,8 +1116,8 @@ protected: nsCOMPtr mContent; DocAccessible* mDoc; - nsRefPtr mParent; - nsTArray > mChildren; + RefPtr mParent; + nsTArray > mChildren; int32_t mIndexInParent; static const uint8_t kChildrenFlagsBits = 2; diff --git a/accessible/generic/DocAccessible-inl.h b/accessible/generic/DocAccessible-inl.h index 7cf26775b0..ca9008761d 100644 --- a/accessible/generic/DocAccessible-inl.h +++ b/accessible/generic/DocAccessible-inl.h @@ -45,7 +45,7 @@ DocAccessible::FireDelayedEvent(AccEvent* aEvent) inline void DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget) { - nsRefPtr event = new AccEvent(aEventType, aTarget); + RefPtr event = new AccEvent(aEventType, aTarget); FireDelayedEvent(event); } @@ -113,7 +113,7 @@ DocAccessible::NotifyOfLoad(uint32_t aLoadEventType) // If the document is loaded completely then network activity was presumingly // caused by file loading. Fire busy state change event. if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) { - nsRefPtr stateEvent = + RefPtr stateEvent = new AccStateChangeEvent(this, states::BUSY, false); FireDelayedEvent(stateEvent); } diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index ee9cb71f6a..3a606e9eef 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -654,7 +654,7 @@ DocAccessible::Observe(nsISupports* aSubject, const char* aTopic, // Normally we only fire delayed events created from the node, not an // accessible object. See the AccStateChangeEvent constructor for details // about this exceptional case. - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(this, states::EDITABLE, true); FireDelayedEvent(event); } @@ -672,7 +672,7 @@ DocAccessible::OnPivotChanged(nsIAccessiblePivot* aPivot, PivotMoveReason aReason, bool aIsFromUserInput) { - nsRefPtr event = + RefPtr event = new AccVCChangeEvent( this, (aOldAccessible ? aOldAccessible->ToInternalAccessible() : nullptr), aOldStart, aOldEnd, aReason, @@ -809,11 +809,11 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible, if (aAccessible->Unavailable() == mStateBitWasOn) return; - nsRefPtr enabledChangeEvent = + RefPtr enabledChangeEvent = new AccStateChangeEvent(aAccessible, states::ENABLED, mStateBitWasOn); FireDelayedEvent(enabledChangeEvent); - nsRefPtr sensitiveChangeEvent = + RefPtr sensitiveChangeEvent = new AccStateChangeEvent(aAccessible, states::SENSITIVE, mStateBitWasOn); FireDelayedEvent(sensitiveChangeEvent); return; @@ -872,7 +872,7 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible, if (aAttribute == nsGkAtoms::aria_busy) { bool isOn = elm->AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true, eCaseMatters); - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(aAccessible, states::BUSY, isOn); FireDelayedEvent(event); return; @@ -889,7 +889,7 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible, elm->AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true, eCaseMatters) ? AccSelChangeEvent::eSelectionAdd : AccSelChangeEvent::eSelectionRemove; - nsRefPtr event = + RefPtr event = new AccSelChangeEvent(widget, aAccessible, selChangeType); FireDelayedEvent(event); } @@ -898,7 +898,7 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible, } if (aAttribute == nsGkAtoms::contenteditable) { - nsRefPtr editableChangeEvent = + RefPtr editableChangeEvent = new AccStateChangeEvent(aAccessible, states::EDITABLE); FireDelayedEvent(editableChangeEvent); return; @@ -918,14 +918,14 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute // there is an ARIA role present or not. if (aAttribute == nsGkAtoms::aria_required) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(aAccessible, states::REQUIRED); FireDelayedEvent(event); return; } if (aAttribute == nsGkAtoms::aria_invalid) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(aAccessible, states::INVALID); FireDelayedEvent(event); return; @@ -943,7 +943,7 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute // We treat aria-expanded as a global ARIA state for historical reasons if (aAttribute == nsGkAtoms::aria_expanded) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(aAccessible, states::EXPANDED); FireDelayedEvent(event); return; @@ -953,7 +953,7 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute // change event; at least until native API comes up with a more meaningful event. uint8_t attrFlags = aria::AttrCharacteristicsFor(aAttribute); if (!(attrFlags & ATTR_BYPASSOBJ)) { - nsRefPtr event = + RefPtr event = new AccObjectAttrChangedEvent(aAccessible, aAttribute); FireDelayedEvent(event); } @@ -969,7 +969,7 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute !aAccessible->Parent()->IsARIAHidden()) { aAccessible->SetARIAHidden(isDefined); - nsRefPtr event = + RefPtr event = new AccObjectAttrChangedEvent(aAccessible, aAttribute); FireDelayedEvent(event); } @@ -981,14 +981,14 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute aAttribute == nsGkAtoms::aria_pressed)) { const uint64_t kState = (aAttribute == nsGkAtoms::aria_checked) ? states::CHECKED : states::PRESSED; - nsRefPtr event = new AccStateChangeEvent(aAccessible, kState); + RefPtr event = new AccStateChangeEvent(aAccessible, kState); FireDelayedEvent(event); bool wasMixed = (mARIAAttrOldValue == nsGkAtoms::mixed); bool isMixed = elm->AttrValueIs(kNameSpaceID_None, aAttribute, nsGkAtoms::mixed, eCaseMatters); if (isMixed != wasMixed) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(aAccessible, states::MIXED, isMixed); FireDelayedEvent(event); } @@ -996,7 +996,7 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute } if (aAttribute == nsGkAtoms::aria_readonly) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(aAccessible, states::READONLY); FireDelayedEvent(event); return; @@ -1060,26 +1060,26 @@ DocAccessible::ContentStateChanged(nsIDocument* aDocument, AccSelChangeEvent::SelChangeType selChangeType = aContent->AsElement()->State().HasState(NS_EVENT_STATE_CHECKED) ? AccSelChangeEvent::eSelectionAdd : AccSelChangeEvent::eSelectionRemove; - nsRefPtr event = + RefPtr event = new AccSelChangeEvent(widget, accessible, selChangeType); FireDelayedEvent(event); return; } - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(accessible, states::CHECKED, aContent->AsElement()->State().HasState(NS_EVENT_STATE_CHECKED)); FireDelayedEvent(event); } if (aStateMask.HasState(NS_EVENT_STATE_INVALID)) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(accessible, states::INVALID, true); FireDelayedEvent(event); } if (aStateMask.HasState(NS_EVENT_STATE_VISITED)) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(accessible, states::TRAVERSED, true); FireDelayedEvent(event); } @@ -1349,8 +1349,8 @@ DocAccessible::ProcessInvalidationList() // XXX: update context flags { Accessible* oldParent = child->Parent(); - nsRefPtr reorderEvent = new AccReorderEvent(oldParent); - nsRefPtr hideEvent = + RefPtr reorderEvent = new AccReorderEvent(oldParent); + RefPtr hideEvent = new AccHideEvent(child, child->GetContent(), false); FireDelayedEvent(hideEvent); reorderEvent->AddSubMutationEvent(hideEvent); @@ -1363,8 +1363,8 @@ DocAccessible::ProcessInvalidationList() } { - nsRefPtr reorderEvent = new AccReorderEvent(owner); - nsRefPtr showEvent = + RefPtr reorderEvent = new AccReorderEvent(owner); + RefPtr showEvent = new AccShowEvent(child, child->GetContent()); FireDelayedEvent(showEvent); reorderEvent->AddSubMutationEvent(showEvent); @@ -1453,14 +1453,14 @@ DocAccessible::NotifyOfLoading(bool aIsReloading) // Fire reload and state busy events on existing document accessible while // event from user input flag can be calculated properly and accessible // is alive. When new document gets loaded then this one is destroyed. - nsRefPtr reloadEvent = + RefPtr reloadEvent = new AccEvent(nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD, this); nsEventShell::FireEvent(reloadEvent); } // Fire state busy change event. Use delayed event since we don't care // actually if event isn't delivered when the document goes away like a shot. - nsRefPtr stateEvent = + RefPtr stateEvent = new AccStateChangeEvent(this, states::BUSY, true); FireDelayedEvent(stateEvent); } @@ -1492,14 +1492,14 @@ DocAccessible::DoInitialUpdate() // this document may be fired prior to this reorder event. If this is // a problem then consider to keep event processing per tab document. if (!IsRoot()) { - nsRefPtr reorderEvent = new AccReorderEvent(Parent()); + RefPtr reorderEvent = new AccReorderEvent(Parent()); ParentDocument()->FireDelayedEvent(reorderEvent); } uint32_t childCount = ChildCount(); for (uint32_t i = 0; i < childCount; i++) { Accessible* child = GetChildAt(i); - nsRefPtr event = new AccShowEvent(child, child->GetContent()); + RefPtr event = new AccShowEvent(child, child->GetContent()); FireDelayedEvent(event); } } @@ -1525,14 +1525,14 @@ DocAccessible::ProcessLoad() // Fire complete/load stopped if the load event type is given. if (mLoadEventType) { - nsRefPtr loadEvent = new AccEvent(mLoadEventType, this); + RefPtr loadEvent = new AccEvent(mLoadEventType, this); FireDelayedEvent(loadEvent); mLoadEventType = 0; } // Fire busy state change event. - nsRefPtr stateEvent = + RefPtr stateEvent = new AccStateChangeEvent(this, states::BUSY, false); FireDelayedEvent(stateEvent); } @@ -1683,7 +1683,7 @@ DocAccessible::RemoveDependentIDsFor(Accessible* aRelProvider, nsTArray containers; // Remove ARIA owned elements from where they belonged. - nsRefPtr reorderEvent = new AccReorderEvent(aRelProvider); + RefPtr reorderEvent = new AccReorderEvent(aRelProvider); { AutoTreeMutation mut(aRelProvider); for (uint32_t idx = 0; idx < children->Length(); idx++) { @@ -1691,7 +1691,7 @@ DocAccessible::RemoveDependentIDsFor(Accessible* aRelProvider, Accessible* child = GetAccessible(childEl); if (child && child->IsRepositioned()) { { - nsRefPtr hideEvent = + RefPtr hideEvent = new AccHideEvent(child, childEl, false); FireDelayedEvent(hideEvent); reorderEvent->AddSubMutationEvent(hideEvent); @@ -1842,7 +1842,7 @@ DocAccessible::UpdateTreeOnInsertion(Accessible* aContainer) aContainer->InvalidateChildren(); aContainer->EnsureChildren(); - nsRefPtr reorderEvent = new AccReorderEvent(aContainer); + RefPtr reorderEvent = new AccReorderEvent(aContainer); uint32_t updateFlags = eNoAccessible; for (uint32_t idx = 0; idx < aContainer->ContentChildCount(); idx++) { @@ -1914,7 +1914,7 @@ DocAccessible::UpdateTreeOnRemoval(Accessible* aContainer, nsIContent* aChildNod #endif uint32_t updateFlags = eNoAccessible; - nsRefPtr reorderEvent = new AccReorderEvent(aContainer); + RefPtr reorderEvent = new AccReorderEvent(aContainer); AutoTreeMutation mut(aContainer); if (child) { @@ -1996,7 +1996,7 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert, } // Fire show/hide event. - nsRefPtr event; + RefPtr event; if (aIsInsert) event = new AccShowEvent(aChild, node); else diff --git a/accessible/generic/DocAccessible.h b/accessible/generic/DocAccessible.h index 18aa2cafdd..2727832cf0 100644 --- a/accessible/generic/DocAccessible.h +++ b/accessible/generic/DocAccessible.h @@ -618,12 +618,12 @@ protected: bool mStateBitWasOn; }; - nsTArray > mChildDocuments; + nsTArray > mChildDocuments; /** * The virtual cursor of the document. */ - nsRefPtr mVirtualCursor; + RefPtr mVirtualCursor; /** * A storage class for pairing content with one of its relation attributes. @@ -665,7 +665,7 @@ protected: * * @see ProcessInvalidationList */ - nsTArray> mInvalidationList; + nsTArray> mInvalidationList; /** * Holds a list of aria-owns relations. @@ -689,7 +689,7 @@ protected: /** * Used to process notification from core and accessible events. */ - nsRefPtr mNotificationController; + RefPtr mNotificationController; friend class EventQueue; friend class NotificationController; diff --git a/accessible/generic/HyperTextAccessible-inl.h b/accessible/generic/HyperTextAccessible-inl.h index 5d12b21bac..53e4151250 100644 --- a/accessible/generic/HyperTextAccessible-inl.h +++ b/accessible/generic/HyperTextAccessible-inl.h @@ -142,7 +142,7 @@ HyperTextAccessible::AdjustCaretOffset(uint32_t aOffset) const inline bool HyperTextAccessible::IsCaretAtEndOfLine() const { - nsRefPtr frameSelection = FrameSelection(); + RefPtr frameSelection = FrameSelection(); return frameSelection && frameSelection->GetHint() == CARET_ASSOCIATE_BEFORE; } @@ -157,7 +157,7 @@ HyperTextAccessible::FrameSelection() const inline dom::Selection* HyperTextAccessible::DOMSelection() const { - nsRefPtr frameSelection = FrameSelection(); + RefPtr frameSelection = FrameSelection(); return frameSelection ? frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL) : nullptr; diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index abaadfcad1..b4ec2337f6 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -1221,7 +1221,7 @@ HyperTextAccessible::CaretLineNumber() { // Provide the line number for the caret, relative to the // currently focused node. Use a 1-based index - nsRefPtr frameSelection = FrameSelection(); + RefPtr frameSelection = FrameSelection(); if (!frameSelection) return -1; @@ -1290,7 +1290,7 @@ HyperTextAccessible::GetCaretRect(nsIWidget** aWidget) { *aWidget = nullptr; - nsRefPtr caret = mDoc->PresShell()->GetCaret(); + RefPtr caret = mDoc->PresShell()->GetCaret(); NS_ENSURE_TRUE(caret, nsIntRect()); bool isVisible = caret->IsVisible(); @@ -1332,7 +1332,7 @@ HyperTextAccessible::GetSelectionDOMRanges(int16_t aType, nsTArray* aRanges) { // Ignore selection if it is not visible. - nsRefPtr frameSelection = FrameSelection(); + RefPtr frameSelection = FrameSelection(); if (!frameSelection || frameSelection->GetDisplaySelection() <= nsISelectionController::SELECTION_HIDDEN) return; @@ -1440,7 +1440,7 @@ HyperTextAccessible::SetSelectionBoundsAt(int32_t aSelectionNum, if (!domSel) return false; - nsRefPtr range; + RefPtr range; uint32_t rangeCount = domSel->RangeCount(); if (aSelectionNum == static_cast(rangeCount)) range = new nsRange(mContent); @@ -1480,7 +1480,7 @@ void HyperTextAccessible::ScrollSubstringTo(int32_t aStartOffset, int32_t aEndOffset, uint32_t aScrollType) { - nsRefPtr range = new nsRange(mContent); + RefPtr range = new nsRange(mContent); if (OffsetsToDOMRange(aStartOffset, aEndOffset, range)) nsCoreUtils::ScrollSubstringTo(GetFrame(), range, aScrollType); } @@ -1498,7 +1498,7 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset, nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType, this); - nsRefPtr range = new nsRange(mContent); + RefPtr range = new nsRange(mContent); if (!OffsetsToDOMRange(aStartOffset, aEndOffset, range)) return; @@ -1892,7 +1892,7 @@ HyperTextAccessible::GetSpellTextAttr(nsINode* aNode, uint32_t* aEndOffset, nsIPersistentProperties* aAttributes) { - nsRefPtr fs = FrameSelection(); + RefPtr fs = FrameSelection(); if (!fs) return; diff --git a/accessible/generic/RootAccessible.cpp b/accessible/generic/RootAccessible.cpp index 801e473ce5..ed19478fc5 100644 --- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -310,7 +310,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent) bool isEnabled = (state & (states::CHECKED | states::SELECTED)) != 0; if (accessible->NeedsDOMUIEvent()) { - nsRefPtr accEvent = + RefPtr accEvent = new AccStateChangeEvent(accessible, states::CHECKED, isEnabled); nsEventShell::FireEvent(accEvent); } @@ -331,7 +331,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent) uint64_t state = accessible->State(); bool isEnabled = !!(state & states::CHECKED); - nsRefPtr accEvent = + RefPtr accEvent = new AccStateChangeEvent(accessible, states::CHECKED, isEnabled); nsEventShell::FireEvent(accEvent); } @@ -351,7 +351,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent) uint64_t state = accessible->State(); bool isEnabled = (state & states::EXPANDED) != 0; - nsRefPtr accEvent = + RefPtr accEvent = new AccStateChangeEvent(accessible, states::EXPANDED, isEnabled); nsEventShell::FireEvent(accEvent); return; @@ -377,7 +377,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent) return; } - nsRefPtr selChangeEvent = + RefPtr selChangeEvent = new AccSelChangeEvent(treeAcc, treeItemAcc, AccSelChangeEvent::eSelectionAdd); nsEventShell::FireEvent(selChangeEvent); @@ -536,7 +536,7 @@ RootAccessible::HandlePopupShownEvent(Accessible* aAccessible) roles::Role comboboxRole = combobox->Role(); if (comboboxRole == roles::COMBOBOX || comboboxRole == roles::AUTOCOMPLETE) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(combobox, states::EXPANDED, true); if (event) nsEventShell::FireEvent(event); @@ -645,7 +645,7 @@ RootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode) // Fire expanded state change event. if (notifyOf & kNotifyOfState) { - nsRefPtr event = + RefPtr event = new AccStateChangeEvent(widget, states::EXPANDED, false); document->FireDelayedEvent(event); } diff --git a/accessible/html/HTMLElementAccessibles.cpp b/accessible/html/HTMLElementAccessibles.cpp index 938abc178e..c6e466ef81 100644 --- a/accessible/html/HTMLElementAccessibles.cpp +++ b/accessible/html/HTMLElementAccessibles.cpp @@ -68,7 +68,7 @@ HTMLLabelAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); if (aType == RelationType::LABEL_FOR) { - nsRefPtr label = dom::HTMLLabelElement::FromContent(mContent); + RefPtr label = dom::HTMLLabelElement::FromContent(mContent); rel.AppendTarget(mDoc, label->GetControl()); } diff --git a/accessible/html/HTMLFormControlAccessible.cpp b/accessible/html/HTMLFormControlAccessible.cpp index e7817c4948..628e17763a 100644 --- a/accessible/html/HTMLFormControlAccessible.cpp +++ b/accessible/html/HTMLFormControlAccessible.cpp @@ -134,7 +134,7 @@ HTMLRadioButtonAccessible::GetPositionAndSizeInternal(int32_t* aPosInSet, nsAutoString name; mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name); - nsRefPtr inputElms; + RefPtr inputElms; nsCOMPtr formControlNode(do_QueryInterface(mContent)); dom::Element* formElm = formControlNode->GetFormElement(); @@ -529,7 +529,7 @@ HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent) event->GetState() == states::INVALID)) { Accessible* button = GetChildAt(0); if (button && button->Role() == roles::PUSHBUTTON) { - nsRefPtr childEvent = + RefPtr childEvent = new AccStateChangeEvent(button, event->GetState(), event->IsStateEnabled(), event->FromUserInput()); nsEventShell::FireEvent(childEvent); diff --git a/accessible/html/HTMLImageMapAccessible.cpp b/accessible/html/HTMLImageMapAccessible.cpp index 2f6692b5c3..cae1c366d3 100644 --- a/accessible/html/HTMLImageMapAccessible.cpp +++ b/accessible/html/HTMLImageMapAccessible.cpp @@ -87,7 +87,7 @@ HTMLImageMapAccessible::UpdateChildAreas(bool aDoFireEvents) bool treeChanged = false; AutoTreeMutation mut(this); - nsRefPtr reorderEvent = new AccReorderEvent(this); + RefPtr reorderEvent = new AccReorderEvent(this); // Remove areas that are not a valid part of the image map anymore. for (int32_t childIdx = mChildren.Length() - 1; childIdx >= 0; childIdx--) { @@ -96,7 +96,7 @@ HTMLImageMapAccessible::UpdateChildAreas(bool aDoFireEvents) continue; if (aDoFireEvents) { - nsRefPtr event = new AccHideEvent(area, area->GetContent()); + RefPtr event = new AccHideEvent(area, area->GetContent()); mDoc->FireDelayedEvent(event); reorderEvent->AddSubMutationEvent(event); } @@ -112,7 +112,7 @@ HTMLImageMapAccessible::UpdateChildAreas(bool aDoFireEvents) Accessible* area = mChildren.SafeElementAt(idx); if (!area || area->GetContent() != areaContent) { - nsRefPtr area = new HTMLAreaAccessible(areaContent, mDoc); + RefPtr area = new HTMLAreaAccessible(areaContent, mDoc); mDoc->BindToDocument(area, aria::GetRoleMap(areaContent)); if (!InsertChildAt(idx, area)) { @@ -121,7 +121,7 @@ HTMLImageMapAccessible::UpdateChildAreas(bool aDoFireEvents) } if (aDoFireEvents) { - nsRefPtr event = new AccShowEvent(area, areaContent); + RefPtr event = new AccShowEvent(area, areaContent); mDoc->FireDelayedEvent(event); reorderEvent->AddSubMutationEvent(event); } diff --git a/accessible/html/HTMLListAccessible.cpp b/accessible/html/HTMLListAccessible.cpp index 3cdb485ef7..3ca464cb11 100644 --- a/accessible/html/HTMLListAccessible.cpp +++ b/accessible/html/HTMLListAccessible.cpp @@ -102,7 +102,7 @@ HTMLLIAccessible::UpdateBullet(bool aHasBullet) return; } - nsRefPtr reorderEvent = new AccReorderEvent(this); + RefPtr reorderEvent = new AccReorderEvent(this); AutoTreeMutation mut(this); DocAccessible* document = Document(); @@ -111,11 +111,11 @@ HTMLLIAccessible::UpdateBullet(bool aHasBullet) document->BindToDocument(mBullet, nullptr); InsertChildAt(0, mBullet); - nsRefPtr event = new AccShowEvent(mBullet, mBullet->GetContent()); + RefPtr event = new AccShowEvent(mBullet, mBullet->GetContent()); mDoc->FireDelayedEvent(event); reorderEvent->AddSubMutationEvent(event); } else { - nsRefPtr event = new AccHideEvent(mBullet, mBullet->GetContent()); + RefPtr event = new AccHideEvent(mBullet, mBullet->GetContent()); mDoc->FireDelayedEvent(event); reorderEvent->AddSubMutationEvent(event); diff --git a/accessible/html/HTMLListAccessible.h b/accessible/html/HTMLListAccessible.h index d804dd0c81..c22e028916 100644 --- a/accessible/html/HTMLListAccessible.h +++ b/accessible/html/HTMLListAccessible.h @@ -64,7 +64,7 @@ protected: virtual void CacheChildren() override; private: - nsRefPtr mBullet; + RefPtr mBullet; }; diff --git a/accessible/html/HTMLSelectAccessible.cpp b/accessible/html/HTMLSelectAccessible.cpp index 5a905a373c..cc13a15b99 100644 --- a/accessible/html/HTMLSelectAccessible.cpp +++ b/accessible/html/HTMLSelectAccessible.cpp @@ -134,7 +134,7 @@ HTMLSelectListAccessible::CacheChildren() nsGkAtoms::optgroup)) { // Get an accessible for option or optgroup and cache it. - nsRefPtr accessible = + RefPtr accessible = GetAccService()->GetOrCreateAccessible(childContent, this); if (accessible) AppendChild(accessible); diff --git a/accessible/html/HTMLSelectAccessible.h b/accessible/html/HTMLSelectAccessible.h index 42a80330a3..a7b26a88cb 100644 --- a/accessible/html/HTMLSelectAccessible.h +++ b/accessible/html/HTMLSelectAccessible.h @@ -196,7 +196,7 @@ protected: Accessible* SelectedOption() const; private: - nsRefPtr mListAccessible; + RefPtr mListAccessible; }; /* diff --git a/accessible/html/HTMLTableAccessible.cpp b/accessible/html/HTMLTableAccessible.cpp index ca391899a9..d0f013ddd6 100644 --- a/accessible/html/HTMLTableAccessible.cpp +++ b/accessible/html/HTMLTableAccessible.cpp @@ -812,7 +812,7 @@ HTMLTableAccessible::AddRowOrColumnToSelection(int32_t aIndex, uint32_t aTarget) count = RowCount(); nsIPresShell* presShell(mDoc->PresShell()); - nsRefPtr tableSelection = + RefPtr tableSelection = const_cast(presShell->ConstFrameSelection()); for (uint32_t idx = 0; idx < count; idx++) { @@ -838,7 +838,7 @@ HTMLTableAccessible::RemoveRowsOrColumnsFromSelection(int32_t aIndex, return NS_OK; nsIPresShell* presShell(mDoc->PresShell()); - nsRefPtr tableSelection = + RefPtr tableSelection = const_cast(presShell->ConstFrameSelection()); bool doUnselectRow = (aTarget == nsISelectionPrivate::TABLESELECTION_ROW); diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index 9d43cc642e..45a09ce614 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -17,6 +17,9 @@ #include "nsIPersistentProperties2.h" #include "nsISimpleEnumerator.h" #include "nsAccUtils.h" +#ifdef MOZ_ACCESSIBILITY_ATK +#include "AccessibleWrap.h" +#endif namespace mozilla { namespace a11y { @@ -378,13 +381,10 @@ DocAccessibleChild::RecvCaretOffset(const uint64_t& aID, int32_t* aOffset) bool DocAccessibleChild::RecvSetCaretOffset(const uint64_t& aID, - const int32_t& aOffset, - bool* aRetVal) + const int32_t& aOffset) { HyperTextAccessible* acc = IdToHyperTextAccessible(aID); - *aRetVal = false; if (acc && acc->IsTextRole() && acc->IsValidOffset(aOffset)) { - *aRetVal = true; acc->SetCaretOffset(aOffset); } return true; @@ -476,6 +476,17 @@ DocAccessibleChild::RecvGetTextBeforeOffset(const uint64_t& aID, return true; } +bool +DocAccessibleChild::RecvCharAt(const uint64_t& aID, + const int32_t& aOffset, + uint16_t* aChar) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + *aChar = acc && acc->IsTextRole() ? + static_cast(acc->CharAt(aOffset)) : 0; + return true; +} + bool DocAccessibleChild::RecvTextAttributes(const uint64_t& aID, const bool& aIncludeDefAttrs, @@ -743,17 +754,6 @@ DocAccessibleChild::RecvPasteText(const uint64_t& aID, return true; } -bool -DocAccessibleChild::RecvCharAt(const uint64_t& aID, - const int32_t& aOffset, - uint16_t* aChar) -{ - HyperTextAccessible* acc = IdToHyperTextAccessible(aID); - *aChar = acc && acc->IsTextRole() ? - static_cast(acc->CharAt(aOffset)) : 0; - return true; -} - bool DocAccessibleChild::RecvImagePosition(const uint64_t& aID, const uint32_t& aCoordType, @@ -1444,6 +1444,52 @@ DocAccessibleChild::RecvTableIsProbablyForLayout(const uint64_t& aID, return true; } +bool +DocAccessibleChild::RecvAtkTableColumnHeader(const uint64_t& aID, + const int32_t& aCol, + uint64_t* aHeader, + bool* aOk) +{ + *aHeader = 0; + *aOk = false; + +#ifdef MOZ_ACCESSIBILITY_ATK + TableAccessible* acc = IdToTableAccessible(aID); + if (acc) { + Accessible* header = AccessibleWrap::GetColumnHeader(acc, aCol); + if (header) { + *aHeader = reinterpret_cast(header->UniqueID()); + *aOk = true; + } + } +#endif + + return true; +} + +bool +DocAccessibleChild::RecvAtkTableRowHeader(const uint64_t& aID, + const int32_t& aRow, + uint64_t* aHeader, + bool* aOk) +{ + *aHeader = 0; + *aOk = false; + +#ifdef MOZ_ACCESSIBILITY_ATK + TableAccessible* acc = IdToTableAccessible(aID); + if (acc) { + Accessible* header = AccessibleWrap::GetRowHeader(acc, aRow); + if (header) { + *aHeader = reinterpret_cast(header->UniqueID()); + *aOk = true; + } + } +#endif + + return true; +} + bool DocAccessibleChild::RecvSelectedItems(const uint64_t& aID, nsTArray* aSelectedItemIDs) @@ -1650,6 +1696,19 @@ DocAccessibleChild::RecvKeyboardShortcut(const uint64_t& aID, return true; } +bool +DocAccessibleChild::RecvAtkKeyBinding(const uint64_t& aID, + nsString* aResult) +{ +#ifdef MOZ_ACCESSIBILITY_ATK + Accessible* acc = IdToAccessible(aID); + if (acc) { + AccessibleWrap::GetKeyBinding(acc, *aResult); + } +#endif + return true; +} + bool DocAccessibleChild::RecvCurValue(const uint64_t& aID, double* aValue) diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index 13a0352c81..ebe68976fb 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -48,6 +48,15 @@ public: SendShutdown(); } + virtual void ActorDestroy(ActorDestroyReason) override + { + if (!mDoc) + return; + + mDoc->SetIPCDoc(nullptr); + mDoc = nullptr; + } + void ShowEvent(AccShowEvent* aShowEvent); /* @@ -94,8 +103,8 @@ public: override; virtual bool RecvCaretOffset(const uint64_t& aID, int32_t* aOffset) override; - virtual bool RecvSetCaretOffset(const uint64_t& aID, const int32_t& aOffset, - bool* aValid) override; + virtual bool RecvSetCaretOffset(const uint64_t& aID, const int32_t& aOffset) + override; virtual bool RecvCharacterCount(const uint64_t& aID, int32_t* aCount) override; @@ -123,6 +132,10 @@ public: nsString* aText, int32_t* aStartOffset, int32_t* aEndOffset) override; + virtual bool RecvCharAt(const uint64_t& aID, + const int32_t& aOffset, + uint16_t* aChar) override; + virtual bool RecvTextAttributes(const uint64_t& aID, const bool& aIncludeDefAttrs, const int32_t& aOffset, @@ -211,10 +224,6 @@ public: virtual bool RecvPasteText(const uint64_t& aID, const int32_t& aPosition, bool* aValid) override; - virtual bool RecvCharAt(const uint64_t& aID, - const int32_t& aOffset, - uint16_t* aChar) override; - virtual bool RecvImagePosition(const uint64_t& aID, const uint32_t& aCoordType, nsIntPoint* aRetVal) override; @@ -354,6 +363,14 @@ public: const uint32_t& aRow) override; virtual bool RecvTableIsProbablyForLayout(const uint64_t& aID, bool* aForLayout) override; + virtual bool RecvAtkTableColumnHeader(const uint64_t& aID, + const int32_t& aCol, + uint64_t* aHeader, + bool* aOk) override; + virtual bool RecvAtkTableRowHeader(const uint64_t& aID, + const int32_t& aRow, + uint64_t* aHeader, + bool* aOk) override; virtual bool RecvSelectedItems(const uint64_t& aID, nsTArray* aSelectedItemIDs) override; @@ -407,21 +424,24 @@ public: uint32_t* aKey, uint32_t* aModifierMask) override; + virtual bool RecvAtkKeyBinding(const uint64_t& aID, + nsString* aResult) override; + virtual bool RecvCurValue(const uint64_t& aID, - double* aValue); + double* aValue) override; virtual bool RecvSetCurValue(const uint64_t& aID, const double& aValue, - bool* aRetVal); + bool* aRetVal) override; virtual bool RecvMinValue(const uint64_t& aID, - double* aValue); + double* aValue) override; virtual bool RecvMaxValue(const uint64_t& aID, - double* aValue); + double* aValue) override; virtual bool RecvStep(const uint64_t& aID, - double* aStep); + double* aStep) override; virtual bool RecvTakeFocus(const uint64_t& aID) override; diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index 8938aa2803..66f4b73da1 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -92,7 +92,7 @@ child: // TextSubstring is getText in IDL. prio(high) sync CaretLineNumber(uint64_t aID) returns(int32_t aLineNumber); prio(high) sync CaretOffset(uint64_t aID) returns(int32_t aOffset); - prio(high) sync SetCaretOffset(uint64_t aID, int32_t aOffset) returns (bool aValid); + async SetCaretOffset(uint64_t aID, int32_t aOffset); prio(high) sync CharacterCount(uint64_t aID) returns(int32_t aCount); prio(high) sync SelectionCount(uint64_t aID) returns(int32_t aCount); prio(high) sync TextSubstring(uint64_t aID, int32_t aStartOffset, int32_t @@ -202,6 +202,10 @@ child: prio(high) sync TableUnselectColumn(uint64_t aID, uint32_t aCol); prio(high) sync TableUnselectRow(uint64_t aID, uint32_t aRow); prio(high) sync TableIsProbablyForLayout(uint64_t aID) returns(bool aForLayout); + prio(high) sync AtkTableColumnHeader(uint64_t aID, int32_t aCol) + returns(uint64_t aHeaderID, bool aOk); + prio(high) sync AtkTableRowHeader(uint64_t aID, int32_t aRow) + returns(uint64_t aHeaderID, bool aOk); prio(high) sync SelectedItems(uint64_t aID) returns(uint64_t[] aSelectedItemIDs); prio(high) sync SelectedItemCount(uint64_t aID) returns(uint32_t aCount); @@ -218,6 +222,7 @@ child: prio(high) sync ActionNameAt(uint64_t aID, uint8_t aIndex) returns(nsString aName); prio(high) sync AccessKey(uint64_t aID) returns(uint32_t aKey, uint32_t aModifierMask); prio(high) sync KeyboardShortcut(uint64_t aID) returns(uint32_t aKey, uint32_t aModifierMask); + prio(high) sync AtkKeyBinding(uint64_t aID) returns(nsString aResult); prio(high) sync CurValue(uint64_t aID) returns(double aValue); prio(high) sync SetCurValue(uint64_t aID, double aValue) returns(bool aRetVal); diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 6dd2fcd11a..3c3018492f 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -215,12 +215,10 @@ ProxyAccessible::CaretOffset() return offset; } -bool +void ProxyAccessible::SetCaretOffset(int32_t aOffset) { - bool valid = false; - unused << mDoc->SendSetCaretOffset(mID, aOffset, &valid); - return valid; + unused << mDoc->SendSetCaretOffset(mID, aOffset); } int32_t @@ -278,6 +276,14 @@ ProxyAccessible::GetTextBeforeOffset(int32_t aOffset, &aText, aStartOffset, aEndOffset); } +char16_t +ProxyAccessible::CharAt(int32_t aOffset) +{ + uint16_t retval = 0; + unused << mDoc->SendCharAt(mID, aOffset, &retval); + return static_cast(retval); +} + void ProxyAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset, @@ -431,14 +437,6 @@ ProxyAccessible::PasteText(int32_t aPosition) return valid; } -char16_t -ProxyAccessible::CharAt(int32_t aOffset) -{ - uint16_t retval = 0; - unused << mDoc->SendCharAt(mID, aOffset, &retval); - return static_cast(retval); -} - nsIntPoint ProxyAccessible::ImagePosition(uint32_t aCoordType) { @@ -819,6 +817,24 @@ ProxyAccessible::TableIsProbablyForLayout() return forLayout; } +ProxyAccessible* +ProxyAccessible::AtkTableColumnHeader(int32_t aCol) +{ + uint64_t headerID = 0; + bool ok = false; + unused << mDoc->SendAtkTableColumnHeader(mID, aCol, &headerID, &ok); + return ok ? mDoc->GetAccessible(headerID) : nullptr; +} + +ProxyAccessible* +ProxyAccessible::AtkTableRowHeader(int32_t aRow) +{ + uint64_t headerID = 0; + bool ok = false; + unused << mDoc->SendAtkTableRowHeader(mID, aRow, &headerID, &ok); + return ok ? mDoc->GetAccessible(headerID) : nullptr; +} + void ProxyAccessible::SelectedItems(nsTArray* aSelectedItems) { @@ -933,6 +949,12 @@ ProxyAccessible::KeyboardShortcut() return KeyBinding(key, modifierMask); } +void +ProxyAccessible::AtkKeyBinding(nsString& aBinding) +{ + unused << mDoc->SendAtkKeyBinding(mID, &aBinding); +} + double ProxyAccessible::CurValue() { diff --git a/accessible/ipc/ProxyAccessible.h b/accessible/ipc/ProxyAccessible.h index efd197417a..4b87ddff97 100644 --- a/accessible/ipc/ProxyAccessible.h +++ b/accessible/ipc/ProxyAccessible.h @@ -132,7 +132,7 @@ public: int32_t CaretLineNumber(); int32_t CaretOffset(); - bool SetCaretOffset(int32_t aOffset); + void SetCaretOffset(int32_t aOffset); int32_t CharacterCount(); int32_t SelectionCount(); @@ -282,6 +282,8 @@ public: void TableUnselectColumn(uint32_t aCol); void TableUnselectRow(uint32_t aRow); bool TableIsProbablyForLayout(); + ProxyAccessible* AtkTableColumnHeader(int32_t aCol); + ProxyAccessible* AtkTableRowHeader(int32_t aRow); void SelectedItems(nsTArray* aSelectedItems); uint32_t SelectedItemCount(); @@ -298,6 +300,7 @@ public: void ActionNameAt(uint8_t aIndex, nsString& aName); KeyBinding AccessKey(); KeyBinding KeyboardShortcut(); + void AtkKeyBinding(nsString& aBinding); double CurValue(); bool SetCurValue(double aValue); diff --git a/accessible/windows/ia2/ia2Accessible.cpp b/accessible/windows/ia2/ia2Accessible.cpp index cd15a963c4..f3b539c095 100644 --- a/accessible/windows/ia2/ia2Accessible.cpp +++ b/accessible/windows/ia2/ia2Accessible.cpp @@ -117,12 +117,12 @@ ia2Accessible::get_relation(long aRelationIndex, continue; if (static_cast(aRelationIndex) == i) { - nsTArray> targets; + nsTArray> targets; size_t targetCount = targetSets[i].Length(); for (size_t j = 0; j < targetCount; j++) targets.AppendElement(WrapperFor(targetSets[i][j])); - nsRefPtr rel = + RefPtr rel = new ia2AccessibleRelation(types[i], Move(targets)); rel.forget(aRelation); return S_OK; @@ -139,7 +139,7 @@ ia2Accessible::get_relation(long aRelationIndex, RelationType relationType = sRelationTypePairs[idx].first; Relation rel = acc->RelationByType(relationType); - nsRefPtr ia2Relation = + RefPtr ia2Relation = new ia2AccessibleRelation(relationType, &rel); if (ia2Relation->HasTargets()) { if (relIdx == aRelationIndex) { @@ -185,11 +185,11 @@ ia2Accessible::get_relations(long aMaxRelations, continue; size_t targetCount = targetSets[i].Length(); - nsTArray> targets(targetCount); + nsTArray> targets(targetCount); for (size_t j = 0; j < targetCount; j++) targets.AppendElement(WrapperFor(targetSets[i][j])); - nsRefPtr rel = + RefPtr rel = new ia2AccessibleRelation(types[i], Move(targets)); rel.forget(aRelation + i); i++; @@ -206,7 +206,7 @@ ia2Accessible::get_relations(long aMaxRelations, RelationType relationType = sRelationTypePairs[idx].first; Relation rel = acc->RelationByType(relationType); - nsRefPtr ia2Rel = + RefPtr ia2Rel = new ia2AccessibleRelation(relationType, &rel); if (ia2Rel->HasTargets()) { ia2Rel.forget(aRelation + (*aNRelations)); diff --git a/accessible/windows/ia2/ia2AccessibleRelation.h b/accessible/windows/ia2/ia2AccessibleRelation.h index fd1df09103..faaa31cb03 100644 --- a/accessible/windows/ia2/ia2AccessibleRelation.h +++ b/accessible/windows/ia2/ia2AccessibleRelation.h @@ -25,7 +25,7 @@ public: ia2AccessibleRelation(RelationType aType, Relation* aRel); ia2AccessibleRelation(RelationType aType, - nsTArray>&& aTargets) : + nsTArray>&& aTargets) : mType(aType), mTargets(Move(aTargets)) {} // IUnknown @@ -59,7 +59,7 @@ private: ia2AccessibleRelation& operator = (const ia2AccessibleRelation&); RelationType mType; - nsTArray > mTargets; + nsTArray > mTargets; }; diff --git a/accessible/windows/ia2/ia2AccessibleText.cpp b/accessible/windows/ia2/ia2AccessibleText.cpp index e0fbe3c759..f313cb389b 100644 --- a/accessible/windows/ia2/ia2AccessibleText.cpp +++ b/accessible/windows/ia2/ia2AccessibleText.cpp @@ -427,7 +427,8 @@ ia2AccessibleText::setCaretOffset(long aOffset) A11Y_TRYBLOCK_BEGIN if (ProxyAccessible* proxy = HyperTextProxyFor(this)) { - return proxy->SetCaretOffset(aOffset) ? S_OK : E_INVALIDARG; + proxy->SetCaretOffset(aOffset); + return S_OK; } HyperTextAccessible* textAcc = static_cast(this); diff --git a/accessible/windows/msaa/AccessibleWrap.cpp b/accessible/windows/msaa/AccessibleWrap.cpp index 05e4f958dc..3ec4e52bdc 100644 --- a/accessible/windows/msaa/AccessibleWrap.cpp +++ b/accessible/windows/msaa/AccessibleWrap.cpp @@ -805,7 +805,7 @@ AccessibleWrap::get_accSelection(VARIANT __RPC_FAR *pvarChildren) SelectedItems(&selectedItems); // 1) Create and initialize the enumeration - nsRefPtr pEnum = new AccessibleEnumerator(selectedItems); + RefPtr pEnum = new AccessibleEnumerator(selectedItems); pvarChildren->vt = VT_UNKNOWN; // this must be VT_UNKNOWN for an IEnumVARIANT NS_ADDREF(pvarChildren->punkVal = pEnum); } diff --git a/accessible/windows/msaa/EnumVariant.h b/accessible/windows/msaa/EnumVariant.h index 14c6cc1b5b..39e342dd59 100644 --- a/accessible/windows/msaa/EnumVariant.h +++ b/accessible/windows/msaa/EnumVariant.h @@ -49,7 +49,7 @@ private: virtual ~ChildrenEnumVariant() { } protected: - nsRefPtr mAnchorAcc; + RefPtr mAnchorAcc; Accessible* mCurAcc; uint32_t mCurIndex; }; diff --git a/accessible/windows/msaa/HTMLWin32ObjectAccessible.h b/accessible/windows/msaa/HTMLWin32ObjectAccessible.h index d4ec6880fe..88987b92c5 100644 --- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.h +++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.h @@ -37,7 +37,7 @@ protected: virtual void CacheChildren(); void* mHwnd; - nsRefPtr mNativeAccessible; + RefPtr mNativeAccessible; }; /** diff --git a/accessible/windows/msaa/ServiceProvider.h b/accessible/windows/msaa/ServiceProvider.h index 9a91327d89..b0fc812c5d 100644 --- a/accessible/windows/msaa/ServiceProvider.h +++ b/accessible/windows/msaa/ServiceProvider.h @@ -29,7 +29,7 @@ public: void** aInstancePtr); private: - nsRefPtr mAccessible; + RefPtr mAccessible; }; } diff --git a/accessible/windows/sdn/sdnDocAccessible.h b/accessible/windows/sdn/sdnDocAccessible.h index 031aac8c0c..22c7124b2b 100644 --- a/accessible/windows/sdn/sdnDocAccessible.h +++ b/accessible/windows/sdn/sdnDocAccessible.h @@ -44,7 +44,7 @@ public: /* [in] */ BSTR __RPC_FAR *commaSeparatedMediaTypes); protected: - nsRefPtr mAccessible; + RefPtr mAccessible; }; } // namespace a11y diff --git a/accessible/windows/sdn/sdnTextAccessible.cpp b/accessible/windows/sdn/sdnTextAccessible.cpp index 37b5ee8d65..9bc7500e8b 100644 --- a/accessible/windows/sdn/sdnTextAccessible.cpp +++ b/accessible/windows/sdn/sdnTextAccessible.cpp @@ -148,7 +148,7 @@ sdnTextAccessible::scrollToSubstring(unsigned int aStartIndex, if (mAccessible->IsDefunct()) return CO_E_OBJNOTCONNECTED; - nsRefPtr range = new nsRange(mAccessible->GetContent()); + RefPtr range = new nsRange(mAccessible->GetContent()); if (NS_FAILED(range->SetStart(mAccessible->GetContent(), aStartIndex))) return E_FAIL; @@ -179,7 +179,7 @@ sdnTextAccessible::get_fontFamily(BSTR __RPC_FAR* aFontFamily) if (!frame) return E_FAIL; - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(frame, getter_AddRefs(fm)); const nsString& name = diff --git a/accessible/windows/sdn/sdnTextAccessible.h b/accessible/windows/sdn/sdnTextAccessible.h index 5c44fcf6ce..ed8eecf294 100644 --- a/accessible/windows/sdn/sdnTextAccessible.h +++ b/accessible/windows/sdn/sdnTextAccessible.h @@ -62,7 +62,7 @@ private: int32_t aOffset, bool aPreferNext, nsPoint& aOutPoint); - nsRefPtr mAccessible; + RefPtr mAccessible; }; } // namespace a11y diff --git a/accessible/windows/uia/uiaRawElmProvider.h b/accessible/windows/uia/uiaRawElmProvider.h index ba0921530a..f32daa19bc 100644 --- a/accessible/windows/uia/uiaRawElmProvider.h +++ b/accessible/windows/uia/uiaRawElmProvider.h @@ -66,7 +66,7 @@ private: uiaRawElmProvider(const uiaRawElmProvider&) = delete; protected: - nsRefPtr mAcc; + RefPtr mAcc; }; } // a11y namespace diff --git a/accessible/xpcom/xpcAccessibleDocument.cpp b/accessible/xpcom/xpcAccessibleDocument.cpp index b75e8684e7..412a68a393 100644 --- a/accessible/xpcom/xpcAccessibleDocument.cpp +++ b/accessible/xpcom/xpcAccessibleDocument.cpp @@ -196,7 +196,7 @@ xpcAccessibleDocument::GetAccessible(Accessible* aAccessible) } static PLDHashOperator -ShutdownAndRemove(const Accessible* aKey, nsRefPtr& aValue, +ShutdownAndRemove(const Accessible* aKey, RefPtr& aValue, void* aUnused) { aValue->Shutdown(); diff --git a/accessible/xpcom/xpcAccessibleHyperLink.cpp b/accessible/xpcom/xpcAccessibleHyperLink.cpp index 6160d5df5d..a539e1c155 100644 --- a/accessible/xpcom/xpcAccessibleHyperLink.cpp +++ b/accessible/xpcom/xpcAccessibleHyperLink.cpp @@ -59,7 +59,7 @@ xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI) if (aIndex < 0 || aIndex >= static_cast(Intl()->AnchorCount())) return NS_ERROR_INVALID_ARG; - nsRefPtr(Intl()->AnchorURIAt(aIndex)).forget(aURI); + RefPtr(Intl()->AnchorURIAt(aIndex)).forget(aURI); return NS_OK; } diff --git a/accessible/xpcom/xpcAccessibleHyperText.cpp b/accessible/xpcom/xpcAccessibleHyperText.cpp index 4d0a5e4994..3734ed8518 100644 --- a/accessible/xpcom/xpcAccessibleHyperText.cpp +++ b/accessible/xpcom/xpcAccessibleHyperText.cpp @@ -347,7 +347,7 @@ xpcAccessibleHyperText::GetEnclosingRange(nsIAccessibleTextRange** aRange) if (!Intl()) return NS_ERROR_FAILURE; - nsRefPtr range = new xpcAccessibleTextRange; + RefPtr range = new xpcAccessibleTextRange; Intl()->EnclosingRange(range->mRange); NS_ASSERTION(range->mRange.IsValid(), "Should always have an enclosing range!"); @@ -419,7 +419,7 @@ xpcAccessibleHyperText::GetRangeByChild(nsIAccessible* aChild, Accessible* child = aChild->ToInternalAccessible(); if (child) { - nsRefPtr range = new xpcAccessibleTextRange; + RefPtr range = new xpcAccessibleTextRange; Intl()->RangeByChild(child, range->mRange); if (range->mRange.IsValid()) range.forget(aRange); @@ -438,7 +438,7 @@ xpcAccessibleHyperText::GetRangeAtPoint(int32_t aX, int32_t aY, if (!Intl()) return NS_ERROR_FAILURE; - nsRefPtr range = new xpcAccessibleTextRange; + RefPtr range = new xpcAccessibleTextRange; Intl()->RangeAtPoint(aX, aY, range->mRange); if (range->mRange.IsValid()) range.forget(aRange); diff --git a/accessible/xpcom/xpcAccessibleTextRange.cpp b/accessible/xpcom/xpcAccessibleTextRange.cpp index b551542d31..c83b81f844 100644 --- a/accessible/xpcom/xpcAccessibleTextRange.cpp +++ b/accessible/xpcom/xpcAccessibleTextRange.cpp @@ -99,7 +99,7 @@ xpcAccessibleTextRange::Compare(nsIAccessibleTextRange* aOtherRange, bool* aResult) { - nsRefPtr xpcRange(do_QueryObject(aOtherRange)); + RefPtr xpcRange(do_QueryObject(aOtherRange)); if (!xpcRange || !aResult) return NS_ERROR_INVALID_ARG; @@ -113,7 +113,7 @@ xpcAccessibleTextRange::CompareEndPoints(uint32_t aEndPoint, uint32_t aOtherRangeEndPoint, int32_t* aResult) { - nsRefPtr xpcRange(do_QueryObject(aOtherRange)); + RefPtr xpcRange(do_QueryObject(aOtherRange)); if (!xpcRange || !aResult) return NS_ERROR_INVALID_ARG; diff --git a/accessible/xul/XULElementAccessibles.h b/accessible/xul/XULElementAccessibles.h index 8267f2a436..051ab021a4 100644 --- a/accessible/xul/XULElementAccessibles.h +++ b/accessible/xul/XULElementAccessibles.h @@ -36,7 +36,7 @@ protected: virtual void CacheChildren() override; private: - nsRefPtr mValueTextLeaf; + RefPtr mValueTextLeaf; }; inline XULLabelAccessible* diff --git a/accessible/xul/XULTreeAccessible.cpp b/accessible/xul/XULTreeAccessible.cpp index bef0bfaf58..4c99ccf461 100644 --- a/accessible/xul/XULTreeAccessible.cpp +++ b/accessible/xul/XULTreeAccessible.cpp @@ -167,7 +167,7 @@ XULTreeAccessible::NativeRole() if (!treeFrame) return roles::LIST; - nsRefPtr cols = treeFrame->Columns(); + RefPtr cols = treeFrame->Columns(); nsCOMPtr primaryCol; cols->GetPrimaryColumn(getter_AddRefs(primaryCol)); @@ -210,7 +210,7 @@ XULTreeAccessible::ChildAtPoint(int32_t aX, int32_t aY, Accessible* child = GetTreeItemAccessible(row); if (aWhichChild == eDeepestChild && child) { // Look for accessible cell for the found item accessible. - nsRefPtr treeitem = do_QueryObject(child); + RefPtr treeitem = do_QueryObject(child); Accessible* cell = treeitem->GetCellAccessible(column); if (cell) @@ -533,7 +533,7 @@ XULTreeAccessible::GetTreeItemAccessible(int32_t aRow) const if (cachedTreeItem) return cachedTreeItem; - nsRefPtr treeItem = CreateTreeItemAccessible(aRow); + RefPtr treeItem = CreateTreeItemAccessible(aRow); if (treeItem) { mAccessibleCache.Put(key, treeItem); Document()->BindToDocument(treeItem, nullptr); @@ -568,7 +568,7 @@ XULTreeAccessible::InvalidateCache(int32_t aRow, int32_t aCount) Accessible* treeItem = mAccessibleCache.GetWeak(key); if (treeItem) { - nsRefPtr event = + RefPtr event = new AccEvent(nsIAccessibleEvent::EVENT_HIDE, treeItem); nsEventShell::FireEvent(event); @@ -648,7 +648,7 @@ XULTreeAccessible::TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow, Accessible* accessible = mAccessibleCache.GetWeak(key); if (accessible) { - nsRefPtr treeitemAcc = do_QueryObject(accessible); + RefPtr treeitemAcc = do_QueryObject(accessible); NS_ASSERTION(treeitemAcc, "Wrong accessible at the given key!"); treeitemAcc->RowInvalidated(aStartCol, endCol); @@ -665,7 +665,7 @@ XULTreeAccessible::TreeViewChanged(nsITreeView* aView) // Fire reorder event on tree accessible on accessible tree (do not fire // show/hide events on tree items because it can be expensive to fire them for // each tree item. - nsRefPtr reorderEvent = new AccReorderEvent(this); + RefPtr reorderEvent = new AccReorderEvent(this); Document()->FireDelayedEvent(reorderEvent); // Clear cache. @@ -681,7 +681,7 @@ XULTreeAccessible::TreeViewChanged(nsITreeView* aView) already_AddRefed XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow) const { - nsRefPtr accessible = + RefPtr accessible = new XULTreeItemAccessible(mContent, mDoc, const_cast(this), mTree, mTreeView, aRow); diff --git a/accessible/xul/XULTreeGridAccessible.cpp b/accessible/xul/XULTreeGridAccessible.cpp index d3d3079d64..03ee2642d6 100644 --- a/accessible/xul/XULTreeGridAccessible.cpp +++ b/accessible/xul/XULTreeGridAccessible.cpp @@ -128,7 +128,7 @@ XULTreeGridAccessible::CellAt(uint32_t aRowIndex, uint32_t aColumnIndex) if (!column) return nullptr; - nsRefPtr rowAcc = do_QueryObject(row); + RefPtr rowAcc = do_QueryObject(row); if (!rowAcc) return nullptr; @@ -228,7 +228,7 @@ XULTreeGridAccessible::NativeRole() already_AddRefed XULTreeGridAccessible::CreateTreeItemAccessible(int32_t aRow) const { - nsRefPtr accessible = + RefPtr accessible = new XULTreeGridRowAccessible(mContent, mDoc, const_cast(this), mTree, mTreeView, aRow); @@ -376,7 +376,7 @@ XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const if (cachedCell) return cachedCell; - nsRefPtr cell = + RefPtr cell = new XULTreeGridCellAccessibleWrap(mContent, mDoc, const_cast(this), mTree, mTreeView, mRow, aColumn); @@ -737,7 +737,7 @@ XULTreeGridCellAccessible::CellInvalidated() mTreeView->GetCellValue(mRow, mColumn, textEquiv); if (mCachedTextEquiv != textEquiv) { bool isEnabled = textEquiv.EqualsLiteral("true"); - nsRefPtr accEvent = + RefPtr accEvent = new AccStateChangeEvent(this, states::CHECKED, isEnabled); nsEventShell::FireEvent(accEvent); @@ -784,7 +784,7 @@ XULTreeGridCellAccessible::GetSiblingAtOffset(int32_t aOffset, if (!columnAtOffset) return nullptr; - nsRefPtr rowAcc = do_QueryObject(Parent()); + RefPtr rowAcc = do_QueryObject(Parent()); return rowAcc->GetCellAccessible(columnAtOffset); } diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index deeb640ba9..0ec0c1a4eb 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -413,6 +413,8 @@ @RESPATH@/components/AlarmsManager.manifest @RESPATH@/components/FeedProcessor.manifest @RESPATH@/components/FeedProcessor.js +@RESPATH@/components/PackagedAppUtils.manifest +@RESPATH@/components/PackagedAppUtils.js @RESPATH@/components/BrowserFeeds.manifest @RESPATH@/components/FeedConverter.js @RESPATH@/components/FeedWriter.js diff --git a/browser/components/migration/nsIEHistoryEnumerator.h b/browser/components/migration/nsIEHistoryEnumerator.h index fc14198598..ae6987c4f8 100644 --- a/browser/components/migration/nsIEHistoryEnumerator.h +++ b/browser/components/migration/nsIEHistoryEnumerator.h @@ -28,8 +28,8 @@ private: */ void EnsureInitialized(); - nsRefPtr mIEHistory; - nsRefPtr mURLEnumerator; + RefPtr mIEHistory; + RefPtr mURLEnumerator; nsCOMPtr mCachedNextEntry; }; diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 8f4af68e15..5d6cecfc10 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -386,6 +386,8 @@ @RESPATH@/components/BrowserElementParent.js @RESPATH@/components/FeedProcessor.manifest @RESPATH@/components/FeedProcessor.js +@RESPATH@/components/PackagedAppUtils.js +@RESPATH@/components/PackagedAppUtils.manifest @RESPATH@/browser/components/BrowserFeeds.manifest @RESPATH@/browser/components/FeedConverter.js @RESPATH@/browser/components/FeedWriter.js diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index 7589b18889..cb678b02bc 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -433,12 +433,12 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAt if (!principal) { return nsNullPrincipal::Create(); } - nsRefPtr concrete = Cast(principal); + RefPtr concrete = Cast(principal); return concrete.forget(); } // Mint a codebase principal. - nsRefPtr codebase = new nsPrincipal(); + RefPtr codebase = new nsPrincipal(); rv = codebase->Init(aURI, aAttrs); NS_ENSURE_SUCCESS(rv, nullptr); return codebase.forget(); diff --git a/caps/DomainPolicy.h b/caps/DomainPolicy.h index 12e126de4b..86648fe0bc 100644 --- a/caps/DomainPolicy.h +++ b/caps/DomainPolicy.h @@ -61,10 +61,10 @@ public: private: virtual ~DomainPolicy(); - nsRefPtr mBlacklist; - nsRefPtr mSuperBlacklist; - nsRefPtr mWhitelist; - nsRefPtr mSuperWhitelist; + RefPtr mBlacklist; + RefPtr mSuperBlacklist; + RefPtr mWhitelist; + RefPtr mSuperWhitelist; }; } /* namespace mozilla */ diff --git a/caps/nsNullPrincipal.cpp b/caps/nsNullPrincipal.cpp index b155b82981..e34a8d91cc 100644 --- a/caps/nsNullPrincipal.cpp +++ b/caps/nsNullPrincipal.cpp @@ -38,7 +38,7 @@ NS_IMPL_CI_INTERFACE_GETTER(nsNullPrincipal, /* static */ already_AddRefed nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom) { - nsRefPtr nullPrin = new nsNullPrincipal(); + RefPtr nullPrin = new nsNullPrincipal(); nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef()); return NS_SUCCEEDED(rv) ? nullPrin.forget() : nullptr; } @@ -46,7 +46,7 @@ nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom) /* static */ already_AddRefed nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes) { - nsRefPtr nullPrin = new nsNullPrincipal(); + RefPtr nullPrin = new nsNullPrincipal(); nsresult rv = nullPrin->Init(aOriginAttributes); NS_ENSURE_SUCCESS(rv, nullptr); diff --git a/caps/nsNullPrincipalURI.cpp b/caps/nsNullPrincipalURI.cpp index 74118bc00f..1637f89e15 100644 --- a/caps/nsNullPrincipalURI.cpp +++ b/caps/nsNullPrincipalURI.cpp @@ -54,7 +54,7 @@ nsNullPrincipalURI::Init() already_AddRefed nsNullPrincipalURI::Create() { - nsRefPtr uri = new nsNullPrincipalURI(); + RefPtr uri = new nsNullPrincipalURI(); nsresult rv = uri->Init(); NS_ENSURE_SUCCESS(rv, nullptr); return uri.forget(); diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 8a90ff5fa9..eefbe60e33 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -325,7 +325,7 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel, aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); if (loadInfo) { if (loadInfo->GetLoadingSandboxed()) { - nsRefPtr prin = + RefPtr prin = nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal()); NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE); prin.forget(aPrincipal); @@ -1312,7 +1312,7 @@ nsresult nsScriptSecurityManager::Init() NS_ENSURE_SUCCESS(rv, rv); // Create our system principal singleton - nsRefPtr system = new nsSystemPrincipal(); + RefPtr system = new nsSystemPrincipal(); mSystemPrincipal = system; @@ -1371,7 +1371,7 @@ nsScriptSecurityManager::GetScriptSecurityManager() /* static */ void nsScriptSecurityManager::InitStatics() { - nsRefPtr ssManager = new nsScriptSecurityManager(); + RefPtr ssManager = new nsScriptSecurityManager(); nsresult rv = ssManager->Init(); if (NS_FAILED(rv)) { MOZ_CRASH(); diff --git a/chrome/nsChromeProtocolHandler.cpp b/chrome/nsChromeProtocolHandler.cpp index f4eec56d47..0965538ba0 100644 --- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -76,7 +76,7 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec, // Chrome: URLs (currently) have no additional structure beyond that provided // by standard URLs, so there is no "outer" given to CreateInstance - nsRefPtr surl = new nsStandardURL(); + RefPtr surl = new nsStandardURL(); nsresult rv = surl->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI); diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index ea5605e53d..0fa65ca3f3 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -423,7 +423,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow) if (IsChromeURI(uri)) { // Reload the sheet. - nsRefPtr newSheet; + RefPtr newSheet; rv = document->LoadChromeSheetSync(uri, true, getter_AddRefs(newSheet)); if (NS_FAILED(rv)) return rv; @@ -462,12 +462,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow) // Iterate over our old sheets and kick off a sync load of the new // sheet if and only if it's a chrome URL. for (i = 0; i < count; i++) { - nsRefPtr sheet = do_QueryObject(oldSheets[i]); + RefPtr sheet = do_QueryObject(oldSheets[i]); nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr; if (uri && IsChromeURI(uri)) { // Reload the sheet. - nsRefPtr newSheet; + RefPtr newSheet; // XXX what about chrome sheets that have a title or are disabled? This // only works by sheer dumb luck. document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet)); @@ -686,11 +686,11 @@ already_AddRefed nsChromeRegistry::GetSingleton() { if (gChromeRegistry) { - nsRefPtr registry = gChromeRegistry; + RefPtr registry = gChromeRegistry; return registry.forget(); } - nsRefPtr cr; + RefPtr cr; if (GeckoProcessType_Content == XRE_GetProcessType()) cr = new nsChromeRegistryContent(); else diff --git a/docshell/base/nsAboutRedirector.cpp b/docshell/base/nsAboutRedirector.cpp index 5b3b1679e7..167a2e9f4d 100644 --- a/docshell/base/nsAboutRedirector.cpp +++ b/docshell/base/nsAboutRedirector.cpp @@ -185,6 +185,6 @@ nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult) nsresult nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) { - nsRefPtr about = new nsAboutRedirector(); + RefPtr about = new nsAboutRedirector(); return about->QueryInterface(aIID, aResult); } diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 60d39f6313..0e14321861 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -122,7 +122,7 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType, aContentType.EqualsLiteral("image/jpeg"); if (mExistingJPEGStreamListener && reuseCV) { - nsRefPtr copy(mExistingJPEGStreamListener); + RefPtr copy(mExistingJPEGStreamListener); copy.forget(aContentHandler); rv = NS_OK; } else { @@ -223,7 +223,7 @@ NS_IMETHODIMP nsDSURIContentListener::SetLoadCookie(nsISupports* aLoadCookie) { #ifdef DEBUG - nsRefPtr cookieAsDocLoader = + RefPtr cookieAsDocLoader = nsDocLoader::GetAsDocLoader(aLoadCookie); NS_ASSERTION(cookieAsDocLoader && cookieAsDocLoader == mDocShell, "Invalid load cookie being set!"); diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 0a36113381..c061613f27 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -173,7 +173,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE); - nsRefPtr info = new nsDefaultURIFixupInfo(uriString); + RefPtr info = new nsDefaultURIFixupInfo(uriString); NS_ADDREF(*aInfo = info); nsCOMPtr ioService = @@ -450,7 +450,7 @@ nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword, nsIInputStream** aPostData, nsIURIFixupInfo** aInfo) { - nsRefPtr info = new nsDefaultURIFixupInfo(aKeyword); + RefPtr info = new nsDefaultURIFixupInfo(aKeyword); NS_ADDREF(*aInfo = info); if (aPostData) { diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 89fde88a28..f033f1b41c 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -608,7 +608,7 @@ SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI, loadGroup->SetNotificationCallbacks(callbacks); chan->SetLoadGroup(loadGroup); - nsRefPtr pingListener = new nsPingListener(); + RefPtr pingListener = new nsPingListener(); chan->AsyncOpen2(pingListener); // Even if AsyncOpen failed, we still count this as a successful ping. It's @@ -1834,7 +1834,7 @@ nsDocShell::GetPresContext(nsPresContext** aPresContext) NS_IMETHODIMP_(nsIPresShell*) nsDocShell::GetPresShell() { - nsRefPtr presContext; + RefPtr presContext; (void)GetPresContext(getter_AddRefs(presContext)); return presContext ? presContext->GetPresShell() : nullptr; } @@ -1847,7 +1847,7 @@ nsDocShell::GetEldestPresShell(nsIPresShell** aPresShell) NS_ENSURE_ARG_POINTER(aPresShell); *aPresShell = nullptr; - nsRefPtr presContext; + RefPtr presContext; (void)GetEldestPresContext(getter_AddRefs(presContext)); if (presContext) { @@ -2537,7 +2537,7 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed) // If we have no parent then we're the root docshell; no ancestor of the // original docshell doesn't have a allowfullscreen attribute, so // report fullscreen as allowed. - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); if (!parent) { *aFullscreenAllowed = true; return NS_OK; @@ -2603,7 +2603,7 @@ nsDocShell::GetDocShellEnumerator(int32_t aItemType, int32_t aDirection, NS_ENSURE_ARG_POINTER(aResult); *aResult = nullptr; - nsRefPtr docShellEnum; + RefPtr docShellEnum; if (aDirection == ENUMERATE_FORWARDS) { docShellEnum = new nsDocShellForwardsEnumerator; } else { @@ -2892,7 +2892,7 @@ nsDocShell::Now(DOMHighResTimeStamp* aWhen) NS_IMETHODIMP nsDocShell::SetWindowDraggingAllowed(bool aValue) { - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); if (!aValue && mItemType == typeChrome && !parent) { // Window dragging is always allowed for top level // chrome docshells. @@ -2908,7 +2908,7 @@ nsDocShell::GetWindowDraggingAllowed(bool* aValue) // window dragging regions in CSS (-moz-window-drag:drag) // can be slow. Default behavior is to only allow it for // chrome top level windows. - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); if (mItemType == typeChrome && !parent) { // Top level chrome window *aValue = true; @@ -2970,7 +2970,7 @@ nsDocShell::GetSessionStorageForPrincipal(nsIPrincipal* aPrincipal, nsresult nsDocShell::AddSessionStorage(nsIPrincipal* aPrincipal, nsIDOMStorage* aStorage) { - nsRefPtr storage = static_cast(aStorage); + RefPtr storage = static_cast(aStorage); if (!storage) { return NS_ERROR_UNEXPECTED; } @@ -3149,7 +3149,7 @@ nsDocShell::SetItemType(int32_t aItemType) // disable auth prompting for anything but content mAllowAuth = mItemType == typeContent; - nsRefPtr presContext = nullptr; + RefPtr presContext = nullptr; GetPresContext(getter_AddRefs(presContext)); if (presContext) { presContext->UpdateIsChrome(); @@ -3182,7 +3182,7 @@ void nsDocShell::RecomputeCanExecuteScripts() { bool old = mCanExecuteScripts; - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); // If we have no tree owner, that means that we've been detached from the // docshell tree (this is distinct from having no parent dochshell, which @@ -3347,8 +3347,8 @@ nsDocShell::GetRootTreeItem(nsIDocShellTreeItem** aRootTreeItem) { NS_ENSURE_ARG_POINTER(aRootTreeItem); - nsRefPtr root = this; - nsRefPtr parent = root->GetParentDocshell(); + RefPtr root = this; + RefPtr parent = root->GetParentDocshell(); while (parent) { root = parent; parent = root->GetParentDocshell(); @@ -3740,7 +3740,7 @@ PrintDocTree(nsIDocShellTreeItem* aParentNode, int aLevel) nsCOMPtr parentAsDocShell(do_QueryInterface(aParentNode)); int32_t type = aParentNode->ItemType(); nsCOMPtr presShell = parentAsDocShell->GetPresShell(); - nsRefPtr presContext; + RefPtr presContext; parentAsDocShell->GetPresContext(getter_AddRefs(presContext)); nsIDocument* doc = presShell->GetDocument(); @@ -3883,7 +3883,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem* aChild) { NS_ENSURE_ARG_POINTER(aChild); - nsRefPtr childAsDocLoader = GetAsDocLoader(aChild); + RefPtr childAsDocLoader = GetAsDocLoader(aChild); NS_ENSURE_TRUE(childAsDocLoader, NS_ERROR_UNEXPECTED); // Make sure we're not creating a loop in the docshell tree @@ -3995,7 +3995,7 @@ nsDocShell::RemoveChild(nsIDocShellTreeItem* aChild) { NS_ENSURE_ARG_POINTER(aChild); - nsRefPtr childAsDocLoader = GetAsDocLoader(aChild); + RefPtr childAsDocLoader = GetAsDocLoader(aChild); NS_ENSURE_TRUE(childAsDocLoader, NS_ERROR_UNEXPECTED); nsresult rv = RemoveChildLoader(childAsDocLoader); @@ -4376,7 +4376,7 @@ nsDocShell::SetDeviceSizeIsPageSize(bool aValue) { if (mDeviceSizeIsPageSize != aValue) { mDeviceSizeIsPageSize = aValue; - nsRefPtr presContext; + RefPtr presContext; GetPresContext(getter_AddRefs(presContext)); if (presContext) { presContext->MediaFeatureValuesChanged(nsRestyleHint(0)); @@ -5882,8 +5882,8 @@ nsDocShell::GetVisibility(bool* aVisibility) // for a hidden view, unless we're an off screen browser, which // would make this test meaningless. - nsRefPtr docShell = this; - nsRefPtr parentItem = docShell->GetParentDocshell(); + RefPtr docShell = this; + RefPtr parentItem = docShell->GetParentDocshell(); while (parentItem) { presShell = docShell->GetPresShell(); @@ -8216,7 +8216,7 @@ nsDocShell::RestorePresentation(nsISHEntry* aSHEntry, bool* aRestoring) "should only have one RestorePresentationEvent"); mRestorePresentationEvent.Revoke(); - nsRefPtr evt = new RestorePresentationEvent(this); + RefPtr evt = new RestorePresentationEvent(this); nsresult rv = NS_DispatchToCurrentThread(evt); if (NS_SUCCEEDED(rv)) { mRestorePresentationEvent = evt.get(); @@ -8256,7 +8256,7 @@ public: private: nsRevocableEventPtr& mRestorePresentationEvent; - nsRefPtr mEvent; + RefPtr mEvent; }; } // namespace @@ -8329,7 +8329,7 @@ nsDocShell::RestoreFromHistory() // to be consistent with normal document loading, subframes cannot start // loading until after data arrives, which is after STATE_START completes. - nsRefPtr currentPresentationRestoration = + RefPtr currentPresentationRestoration = mRestorePresentationEvent.get(); Stop(); // Make sure we're still restoring the same presentation. @@ -8541,7 +8541,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr document = do_QueryInterface(domDoc); uint32_t parentSuspendCount = 0; if (document) { - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); if (parent) { nsCOMPtr d = parent->GetDocument(); if (d) { @@ -9381,7 +9381,7 @@ private: nsXPIDLCString mTypeHint; nsString mSrcdoc; - nsRefPtr mDocShell; + RefPtr mDocShell; nsCOMPtr mURI; nsCOMPtr mOriginalURI; bool mLoadReplace; @@ -9527,7 +9527,7 @@ nsDocShell::InternalLoad2(nsIURI* aURI, requestingElement = mScriptGlobal->GetFrameElementInternal(); } - nsRefPtr MMADeathGrip = mScriptGlobal; + RefPtr MMADeathGrip = mScriptGlobal; int16_t shouldLoad = nsIContentPolicy::ACCEPT; uint32_t contentType; @@ -10082,7 +10082,7 @@ nsDocShell::InternalLoad2(nsIURI* aURI, // applies to aURI. CopyFavicon(currentURI, aURI, mInPrivateBrowsing); - nsRefPtr win = mScriptGlobal ? + RefPtr win = mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr; // ScrollToAnchor doesn't necessarily cause us to scroll the window; @@ -13093,7 +13093,7 @@ nsDocShell::GetNestedFrameId(uint64_t* aId) NS_IMETHODIMP nsDocShell::IsAppOfType(uint32_t aAppType, bool* aIsOfType) { - nsRefPtr shell = this; + RefPtr shell = this; while (shell) { uint32_t type; shell->GetAppType(&type); @@ -13321,7 +13321,7 @@ public: } private: - nsRefPtr mHandler; + RefPtr mHandler; nsCOMPtr mURI; nsString mTargetSpec; nsString mFileName; @@ -13849,7 +13849,7 @@ OriginAttributes nsDocShell::GetOriginAttributes() { OriginAttributes attrs; - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); if (parent) { attrs.InheritFromDocShellParent(parent->GetOriginAttributes()); } @@ -13909,7 +13909,7 @@ nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) bool nsDocShell::HasUnloadedParent() { - nsRefPtr parent = GetParentDocshell(); + RefPtr parent = GetParentDocshell(); while (parent) { bool inUnload = false; parent->GetIsInUnload(&inUnload); @@ -14010,8 +14010,7 @@ nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider, } NS_IMETHODIMP -nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, - nsContentPolicyType aLoadContentType, +nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceRequest, bool* aShouldIntercept) { *aShouldIntercept = false; @@ -14030,7 +14029,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, return NS_OK; } - nsRefPtr swm = ServiceWorkerManager::GetInstance(); + RefPtr swm = ServiceWorkerManager::GetInstance(); if (!swm) { return NS_OK; } @@ -14064,7 +14063,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, } } - if (aIsNavigate || nsContentUtils::IsWorkerLoad(aLoadContentType)) { + if (aIsNonSubresourceRequest) { OriginAttributes attrs(GetAppId(), GetIsInBrowserElement()); *aShouldIntercept = swm->IsAvailable(attrs, aURI); return NS_OK; @@ -14113,7 +14112,7 @@ NS_IMPL_ISUPPORTS(FetchEventDispatcher, nsIFetchEventDispatcher) NS_IMETHODIMP FetchEventDispatcher::Dispatch() { - nsRefPtr swm = ServiceWorkerManager::GetInstance(); + RefPtr swm = ServiceWorkerManager::GetInstance(); if (!swm) { mChannel->Cancel(NS_ERROR_INTERCEPTION_FAILED); return NS_OK; @@ -14134,24 +14133,19 @@ NS_IMETHODIMP nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel, nsIFetchEventDispatcher** aFetchDispatcher) { - nsRefPtr swm = ServiceWorkerManager::GetInstance(); + RefPtr swm = ServiceWorkerManager::GetInstance(); if (!swm) { aChannel->Cancel(NS_ERROR_INTERCEPTION_FAILED); return NS_OK; } - bool isNavigation = false; - nsresult rv = aChannel->GetIsNavigation(&isNavigation); - NS_ENSURE_SUCCESS(rv, rv); - - nsContentPolicyType loadType; - rv = aChannel->GetInternalContentPolicyType(&loadType); + nsCOMPtr channel; + nsresult rv = aChannel->GetChannel(getter_AddRefs(channel)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr doc; - bool isSubresourceLoad = !isNavigation && - !nsContentUtils::IsWorkerLoad(loadType); + bool isSubresourceLoad = !nsContentUtils::IsNonSubresourceRequest(channel); if (isSubresourceLoad) { doc = GetDocument(); if (!doc) { @@ -14171,7 +14165,7 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel, } MOZ_ASSERT(runnable); - nsRefPtr dispatcher = + RefPtr dispatcher = new FetchEventDispatcher(aChannel, runnable); dispatcher.forget(aFetchDispatcher); @@ -14212,7 +14206,7 @@ nsDocShell::GetPaymentRequestId(nsAString& aPaymentRequestId) bool nsDocShell::InFrameSwap() { - nsRefPtr shell = this; + RefPtr shell = this; do { if (shell->mInFrameSwap) { return true; diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index c3c54c0dd7..31a026027a 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -111,7 +111,7 @@ public: int32_t GetDelay() { return mDelay ;} - nsRefPtr mDocShell; + RefPtr mDocShell; nsCOMPtr mURI; nsCOMPtr mPrincipal; int32_t mDelay; @@ -743,7 +743,7 @@ public: explicit RestorePresentationEvent(nsDocShell* aDs) : mDocShell(aDs) {} void Revoke() { mDocShell = nullptr; } private: - nsRefPtr mDocShell; + RefPtr mDocShell; }; protected: @@ -792,7 +792,7 @@ protected: nsCOMPtr mRefreshURIList; nsCOMPtr mSavedRefreshURIList; - nsRefPtr mContentListener; + RefPtr mContentListener; nsCOMPtr mContentViewer; nsCOMPtr mParentWidget; @@ -800,7 +800,7 @@ protected: nsCOMPtr mCurrentURI; nsCOMPtr mReferrerURI; uint32_t mReferrerPolicy; - nsRefPtr mScriptGlobal; + RefPtr mScriptGlobal; nsCOMPtr mSessionHistory; nsCOMPtr mGlobalHistory; nsCOMPtr mFind; @@ -977,7 +977,7 @@ protected: static nsIURIFixup* sURIFixup; - nsRefPtr mTiming; + RefPtr mTiming; // This flag means that mTiming has been initialized but nulled out. // We will check the innerWin's timing before creating a new one diff --git a/docshell/base/timeline/AutoGlobalTimelineMarker.h b/docshell/base/timeline/AutoGlobalTimelineMarker.h index 3552a25d38..e0f208d9d1 100644 --- a/docshell/base/timeline/AutoGlobalTimelineMarker.h +++ b/docshell/base/timeline/AutoGlobalTimelineMarker.h @@ -8,7 +8,7 @@ #define mozilla_AutoGlobalTimelineMarker_h_ #include "mozilla/GuardObjects.h" -#include "nsRefPtr.h" +#include "RefPtr.h" class nsDocShell; diff --git a/docshell/base/timeline/AutoTimelineMarker.h b/docshell/base/timeline/AutoTimelineMarker.h index e97ad6c756..bbfa36857e 100644 --- a/docshell/base/timeline/AutoTimelineMarker.h +++ b/docshell/base/timeline/AutoTimelineMarker.h @@ -8,7 +8,7 @@ #define mozilla_AutoTimelineMarker_h_ #include "mozilla/GuardObjects.h" -#include "nsRefPtr.h" +#include "RefPtr.h" class nsIDocShell; class nsDocShell; @@ -36,7 +36,7 @@ class MOZ_RAII AutoTimelineMarker const char* mName; // The docshell that is associated with this marker. - nsRefPtr mDocShell; + RefPtr mDocShell; public: explicit AutoTimelineMarker(nsIDocShell* aDocShell, const char* aName diff --git a/docshell/base/timeline/ObservedDocShell.h b/docshell/base/timeline/ObservedDocShell.h index f3b8dcf7ea..baa3b5dac5 100644 --- a/docshell/base/timeline/ObservedDocShell.h +++ b/docshell/base/timeline/ObservedDocShell.h @@ -8,7 +8,7 @@ #define mozilla_ObservedDocShell_h_ #include "nsTArray.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" class nsDocShell; @@ -26,7 +26,7 @@ struct ProfileTimelineMarker; class ObservedDocShell : public LinkedListElement { private: - nsRefPtr mDocShell; + RefPtr mDocShell; nsTArray> mTimelineMarkers; public: diff --git a/docshell/base/timeline/TimelineConsumers.cpp b/docshell/base/timeline/TimelineConsumers.cpp index c7621f4429..c63824fb89 100644 --- a/docshell/base/timeline/TimelineConsumers.cpp +++ b/docshell/base/timeline/TimelineConsumers.cpp @@ -50,7 +50,7 @@ TimelineConsumers::IsEmpty() } bool -TimelineConsumers::GetKnownDocShells(Vector>& aStore) +TimelineConsumers::GetKnownDocShells(Vector>& aStore) { const LinkedList& docShells = GetOrCreateObservedDocShellsList(); @@ -123,11 +123,11 @@ TimelineConsumers::AddMarkerForDocShell(nsIDocShell* aDocShell, } void -TimelineConsumers::AddMarkerForDocShellsList(Vector>& aDocShells, +TimelineConsumers::AddMarkerForDocShellsList(Vector>& aDocShells, const char* aName, MarkerTracingType aTracingType) { - for (Vector>::Range range = aDocShells.all(); + for (Vector>::Range range = aDocShells.all(); !range.empty(); range.popFront()) { AddMarkerForDocShell(range.front(), aName, aTracingType); @@ -138,7 +138,7 @@ void TimelineConsumers::AddMarkerForAllObservedDocShells(const char* aName, MarkerTracingType aTracingType) { - Vector> docShells; + Vector> docShells; if (!GetKnownDocShells(docShells)) { // If we don't successfully populate our vector with *all* docshells being // observed, don't add the marker to *any* of them. diff --git a/docshell/base/timeline/TimelineConsumers.h b/docshell/base/timeline/TimelineConsumers.h index 56f2a3e285..4ddea399a0 100644 --- a/docshell/base/timeline/TimelineConsumers.h +++ b/docshell/base/timeline/TimelineConsumers.h @@ -33,7 +33,7 @@ public: static void AddConsumer(nsDocShell* aDocShell); static void RemoveConsumer(nsDocShell* aDocShell); static bool IsEmpty(); - static bool GetKnownDocShells(Vector>& aStore); + static bool GetKnownDocShells(Vector>& aStore); // Methods for adding markers relevant for particular docshells, or generic // (meaning that they either can't be tied to a particular docshell, or one @@ -70,7 +70,7 @@ public: UniquePtr&& aMarker); // This method creates custom markers, relevant for a list of docshells. - static void AddMarkerForDocShellsList(Vector>& aDocShells, + static void AddMarkerForDocShellsList(Vector>& aDocShells, const char* aName, MarkerTracingType aTracingType); diff --git a/docshell/shistory/src/nsSHEntry.h b/docshell/shistory/src/nsSHEntry.h index b784b2d052..8224839f5e 100644 --- a/docshell/shistory/src/nsSHEntry.h +++ b/docshell/shistory/src/nsSHEntry.h @@ -46,7 +46,7 @@ private: // We share the state in here with other SHEntries which correspond to the // same document. - nsRefPtr mShared; + RefPtr mShared; // See nsSHEntry.idl for comments on these members. nsCOMPtr mURI; diff --git a/docshell/shistory/src/nsSHEntryShared.cpp b/docshell/shistory/src/nsSHEntryShared.cpp index 2ac88ee5ae..0335ad33fc 100644 --- a/docshell/shistory/src/nsSHEntryShared.cpp +++ b/docshell/shistory/src/nsSHEntryShared.cpp @@ -111,7 +111,7 @@ NS_IMPL_ISUPPORTS(nsSHEntryShared, nsIBFCacheEntry, nsIMutationObserver) already_AddRefed nsSHEntryShared::Duplicate(nsSHEntryShared* aEntry) { - nsRefPtr newEntry = new nsSHEntryShared(); + RefPtr newEntry = new nsSHEntryShared(); newEntry->mDocShellID = aEntry->mDocShellID; newEntry->mChildShells.AppendObjects(aEntry->mChildShells); @@ -151,7 +151,7 @@ nsSHEntryShared::SyncPresentationState() void nsSHEntryShared::DropPresentationState() { - nsRefPtr kungFuDeathGrip = this; + RefPtr kungFuDeathGrip = this; if (mDocument) { mDocument->SetBFCacheEntry(nullptr); diff --git a/docshell/shistory/src/nsSHistory.cpp b/docshell/shistory/src/nsSHistory.cpp index 20ca7789b5..ea2237b1e5 100644 --- a/docshell/shistory/src/nsSHistory.cpp +++ b/docshell/shistory/src/nsSHistory.cpp @@ -1803,7 +1803,7 @@ NS_IMETHODIMP nsSHistory::GetSHistoryEnumerator(nsISimpleEnumerator** aEnumerator) { NS_ENSURE_ARG_POINTER(aEnumerator); - nsRefPtr iterator = new nsSHEnumerator(this); + RefPtr iterator = new nsSHEnumerator(this); iterator.forget(aEnumerator); return NS_OK; } diff --git a/dom/activities/Activity.h b/dom/activities/Activity.h index 7f9e6e7f3b..16bd4e2f17 100644 --- a/dom/activities/Activity.h +++ b/dom/activities/Activity.h @@ -36,7 +36,7 @@ public: return nullptr; } - nsRefPtr activity = new Activity(window); + RefPtr activity = new Activity(window); aRv = activity->Initialize(window, aOwner.Context(), aOptions); return activity.forget(); } diff --git a/dom/alarm/AlarmHalService.cpp b/dom/alarm/AlarmHalService.cpp index 0f618b90ae..d5eee2fe15 100644 --- a/dom/alarm/AlarmHalService.cpp +++ b/dom/alarm/AlarmHalService.cpp @@ -43,7 +43,7 @@ AlarmHalService::GetInstance() ClearOnShutdown(&sSingleton); } - nsRefPtr service = sSingleton.get(); + RefPtr service = sSingleton.get(); return service.forget(); } diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 7f597e961a..204b4f54f7 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -573,7 +573,7 @@ Animation::CanThrottle() const } void -Animation::ComposeStyle(nsRefPtr& aStyleRule, +Animation::ComposeStyle(RefPtr& aStyleRule, nsCSSPropertySet& aSetProperties, bool& aNeedsRefreshes) { @@ -1101,7 +1101,7 @@ Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag) if (aSyncNotifyFlag == SyncNotifyFlag::Sync) { DoFinishNotificationImmediately(); } else if (!mFinishNotificationTask.IsPending()) { - nsRefPtr> runnable = + RefPtr> runnable = NS_NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately); Promise::DispatchToMicroTask(runnable); mFinishNotificationTask = runnable; @@ -1150,11 +1150,11 @@ Animation::DispatchPlaybackEvent(const nsAString& aName) init.mTimelineTime = mTimeline->GetCurrentTimeAsDouble(); } - nsRefPtr event = + RefPtr event = AnimationPlaybackEvent::Constructor(this, aName, init); event->SetTrusted(true); - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(this, event); asyncDispatcher->PostDOMEvent(); } diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index 38f47d9314..66aa395bb8 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -283,7 +283,7 @@ public: * the style rule on the next refresh driver tick as well (because it * is running and has an effect to sample). */ - void ComposeStyle(nsRefPtr& aStyleRule, + void ComposeStyle(RefPtr& aStyleRule, nsCSSPropertySet& aSetProperties, bool& aNeedsRefreshes); @@ -363,8 +363,8 @@ protected: virtual CommonAnimationManager* GetAnimationManager() const = 0; AnimationCollection* GetCollection() const; - nsRefPtr mTimeline; - nsRefPtr mEffect; + RefPtr mTimeline; + RefPtr mEffect; // The beginning of the delay period. Nullable mStartTime; // Timeline timescale Nullable mHoldTime; // Animation timescale @@ -376,14 +376,14 @@ protected: // and fulfilled when Play() is successfully completed. // This object is lazily created by GetReady. // See http://w3c.github.io/web-animations/#current-ready-promise - nsRefPtr mReady; + RefPtr mReady; // A Promise that is resolved when we reach the end of the effect, or // 0 when playing backwards. The Promise is replaced if the animation is // finished but then a state change makes it not finished. // This object is lazily created by GetFinished. // See http://w3c.github.io/web-animations/#current-finished-promise - nsRefPtr mFinished; + RefPtr mFinished; // Indicates if the animation is in the pending state (and what state it is // waiting to enter when it finished pending). We use this rather than diff --git a/dom/animation/AnimationTimeline.cpp b/dom/animation/AnimationTimeline.cpp index 4c2859b263..8c11e9da73 100644 --- a/dom/animation/AnimationTimeline.cpp +++ b/dom/animation/AnimationTimeline.cpp @@ -55,7 +55,7 @@ AnimationTimeline::GetAnimations(AnimationSequence& aAnimations) } // Sort animations by priority - aAnimations.Sort(AnimationPtrComparator>()); + aAnimations.Sort(AnimationPtrComparator>()); } void diff --git a/dom/animation/AnimationTimeline.h b/dom/animation/AnimationTimeline.h index f0e8d28540..2f435edb27 100644 --- a/dom/animation/AnimationTimeline.h +++ b/dom/animation/AnimationTimeline.h @@ -42,7 +42,7 @@ public: nsIGlobalObject* GetParentObject() const { return mWindow; } - typedef nsTArray> AnimationSequence; + typedef nsTArray> AnimationSequence; // AnimationTimeline methods virtual Nullable GetCurrentTime() const = 0; diff --git a/dom/animation/DocumentTimeline.cpp b/dom/animation/DocumentTimeline.cpp index e3ee87e99e..8412833644 100644 --- a/dom/animation/DocumentTimeline.cpp +++ b/dom/animation/DocumentTimeline.cpp @@ -57,7 +57,7 @@ DocumentTimeline::GetCurrentTimeStamp() const // If we don't have a refresh driver and we've never had one use the // timeline's zero time. if (result.IsNull()) { - nsRefPtr timing = mDocument->GetNavigationTiming(); + RefPtr timing = mDocument->GetNavigationTiming(); if (timing) { result = timing->GetNavigationStartTimeStamp(); // Also, let this time represent the current refresh time. This way @@ -82,7 +82,7 @@ DocumentTimeline::ToTimelineTime(const TimeStamp& aTimeStamp) const return result; } - nsRefPtr timing = mDocument->GetNavigationTiming(); + RefPtr timing = mDocument->GetNavigationTiming(); if (MOZ_UNLIKELY(!timing)) { return result; } @@ -95,7 +95,7 @@ TimeStamp DocumentTimeline::ToTimeStamp(const TimeDuration& aTimeDuration) const { TimeStamp result; - nsRefPtr timing = mDocument->GetNavigationTiming(); + RefPtr timing = mDocument->GetNavigationTiming(); if (MOZ_UNLIKELY(!timing)) { return result; } diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 3f40d930e1..15882164e8 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -366,7 +366,7 @@ KeyframeEffectReadOnly::HasAnimationOfProperties( } void -KeyframeEffectReadOnly::ComposeStyle(nsRefPtr& aStyleRule, +KeyframeEffectReadOnly::ComposeStyle(RefPtr& aStyleRule, nsCSSPropertySet& aSetProperties) { ComputedTiming computedTiming = GetComputedTiming(); diff --git a/dom/animation/KeyframeEffect.h b/dom/animation/KeyframeEffect.h index 967cac3e18..f14277c11a 100644 --- a/dom/animation/KeyframeEffect.h +++ b/dom/animation/KeyframeEffect.h @@ -312,7 +312,7 @@ public: // Animation for the current time except any properties already contained // in |aSetProperties|. // Any updated properties are added to |aSetProperties|. - void ComposeStyle(nsRefPtr& aStyleRule, + void ComposeStyle(RefPtr& aStyleRule, nsCSSPropertySet& aSetProperties); bool IsRunningOnCompositor() const; void SetIsRunningOnCompositor(nsCSSProperty aProperty, bool aIsRunning); diff --git a/dom/archivereader/ArchiveEvent.cpp b/dom/archivereader/ArchiveEvent.cpp index dc2dc42c83..afcc665a0d 100644 --- a/dom/archivereader/ArchiveEvent.cpp +++ b/dom/archivereader/ArchiveEvent.cpp @@ -105,12 +105,12 @@ ArchiveReaderEvent::RunShare(nsresult aStatus) void ArchiveReaderEvent::ShareMainThread() { - nsTArray> fileList; + nsTArray> fileList; if (!NS_FAILED(mStatus)) { // This extra step must run in the main thread: for (uint32_t index = 0; index < mFileList.Length(); ++index) { - nsRefPtr item = mFileList[index]; + RefPtr item = mFileList[index]; nsString tmp; nsresult rv = item->GetFilename(tmp); @@ -131,7 +131,7 @@ ArchiveReaderEvent::ShareMainThread() } // This is a File: - nsRefPtr file = item->GetFile(mArchiveReader); + RefPtr file = item->GetFile(mArchiveReader); if (file) { fileList.AppendElement(file); } diff --git a/dom/archivereader/ArchiveEvent.h b/dom/archivereader/ArchiveEvent.h index 34d1aac61c..15b541f93e 100644 --- a/dom/archivereader/ArchiveEvent.h +++ b/dom/archivereader/ArchiveEvent.h @@ -75,7 +75,7 @@ protected: // data nsCOMPtr mMimeService; - nsTArray > mFileList; // this must be populated + nsTArray > mFileList; // this must be populated nsresult mStatus; }; diff --git a/dom/archivereader/ArchiveReader.cpp b/dom/archivereader/ArchiveReader.cpp index 76ce16bc96..88ad2a8f06 100644 --- a/dom/archivereader/ArchiveReader.cpp +++ b/dom/archivereader/ArchiveReader.cpp @@ -37,11 +37,11 @@ ArchiveReader::Constructor(const GlobalObject& aGlobal, nsAutoCString encoding; if (!EncodingUtils::FindEncodingForLabelNoReplacement(aOptions.mEncoding, encoding)) { - aError.ThrowRangeError(MSG_ENCODING_NOT_SUPPORTED, &aOptions.mEncoding); + aError.ThrowRangeError(&aOptions.mEncoding); return nullptr; } - nsRefPtr reader = + RefPtr reader = new ArchiveReader(aBlob, window, encoding); return reader.forget(); } @@ -124,7 +124,7 @@ ArchiveReader::OpenArchive() NS_ASSERTION(target, "Must have stream transport service"); // Here a Event to make everything async: - nsRefPtr event; + RefPtr event; /* FIXME: If we want to support more than 1 format we should check the content type here: */ event = new ArchiveReaderZipEvent(this, mEncoding); @@ -140,7 +140,7 @@ ArchiveReader::OpenArchive() // Data received from the dispatched event: void -ArchiveReader::Ready(nsTArray>& aFileList, +ArchiveReader::Ready(nsTArray>& aFileList, nsresult aStatus) { mStatus = READY; @@ -151,7 +151,7 @@ ArchiveReader::Ready(nsTArray>& aFileList, // Propagate the results: for (uint32_t index = 0; index < mRequests.Length(); ++index) { - nsRefPtr request = mRequests[index]; + RefPtr request = mRequests[index]; RequestReady(request); } @@ -171,7 +171,7 @@ ArchiveReader::RequestReady(ArchiveRequest* aRequest) already_AddRefed ArchiveReader::GetFilenames() { - nsRefPtr request = GenerateArchiveRequest(); + RefPtr request = GenerateArchiveRequest(); request->OpGetFilenames(); return request.forget(); @@ -180,7 +180,7 @@ ArchiveReader::GetFilenames() already_AddRefed ArchiveReader::GetFile(const nsAString& filename) { - nsRefPtr request = GenerateArchiveRequest(); + RefPtr request = GenerateArchiveRequest(); request->OpGetFile(filename); return request.forget(); @@ -189,7 +189,7 @@ ArchiveReader::GetFile(const nsAString& filename) already_AddRefed ArchiveReader::GetFiles() { - nsRefPtr request = GenerateArchiveRequest(); + RefPtr request = GenerateArchiveRequest(); request->OpGetFiles(); return request.forget(); diff --git a/dom/archivereader/ArchiveReader.h b/dom/archivereader/ArchiveReader.h index 8f30910ca9..b9c1f66a64 100644 --- a/dom/archivereader/ArchiveReader.h +++ b/dom/archivereader/ArchiveReader.h @@ -69,7 +69,7 @@ public: // For events: return mBlobImpl; } - void Ready(nsTArray>& aFileList, nsresult aStatus); + void Ready(nsTArray>& aFileList, nsresult aStatus); private: ~ArchiveReader(); @@ -82,7 +82,7 @@ private: protected: // The archive blob/file - nsRefPtr mBlobImpl; + RefPtr mBlobImpl; // The window is needed by the requests nsCOMPtr mWindow; @@ -103,11 +103,11 @@ protected: } mReadStatus; // List of requests to be processed - nsTArray > mRequests; + nsTArray > mRequests; // Everything related to the blobs and the status: struct { - nsTArray> fileList; + nsTArray> fileList; nsresult status; } mData; diff --git a/dom/archivereader/ArchiveRequest.cpp b/dom/archivereader/ArchiveRequest.cpp index 57ddfb9022..fa40abf4d4 100644 --- a/dom/archivereader/ArchiveRequest.cpp +++ b/dom/archivereader/ArchiveRequest.cpp @@ -36,7 +36,7 @@ protected: } private: //data - nsRefPtr mRequest; + RefPtr mRequest; }; NS_IMETHODIMP @@ -59,7 +59,7 @@ ArchiveRequest::ArchiveRequest(nsPIDOMWindow* aWindow, MOZ_COUNT_CTOR(ArchiveRequest); /* An event to make this request asynchronous: */ - nsRefPtr event = new ArchiveRequestEvent(this); + RefPtr event = new ArchiveRequestEvent(this); NS_DispatchToCurrentThread(event); } @@ -122,7 +122,7 @@ ArchiveRequest::OpGetFiles() } nsresult -ArchiveRequest::ReaderReady(nsTArray>& aFileList, +ArchiveRequest::ReaderReady(nsTArray>& aFileList, nsresult aStatus) { if (NS_FAILED(aStatus)) { @@ -174,7 +174,7 @@ ArchiveRequest::ReaderReady(nsTArray>& aFileList, nsresult ArchiveRequest::GetFilenamesResult(JSContext* aCx, JS::Value* aValue, - nsTArray>& aFileList) + nsTArray>& aFileList) { JS::Rooted array(aCx, JS_NewArrayObject(aCx, aFileList.Length())); @@ -184,7 +184,7 @@ ArchiveRequest::GetFilenamesResult(JSContext* aCx, JS::Rooted str(aCx); for (uint32_t i = 0; i < aFileList.Length(); ++i) { - nsRefPtr file = aFileList[i]; + RefPtr file = aFileList[i]; nsString filename; file->GetName(filename); @@ -208,10 +208,10 @@ ArchiveRequest::GetFilenamesResult(JSContext* aCx, nsresult ArchiveRequest::GetFileResult(JSContext* aCx, JS::MutableHandle aValue, - nsTArray>& aFileList) + nsTArray>& aFileList) { for (uint32_t i = 0; i < aFileList.Length(); ++i) { - nsRefPtr file = aFileList[i]; + RefPtr file = aFileList[i]; nsString filename; file->GetName(filename); @@ -231,7 +231,7 @@ ArchiveRequest::GetFileResult(JSContext* aCx, nsresult ArchiveRequest::GetFilesResult(JSContext* aCx, JS::MutableHandle aValue, - nsTArray>& aFileList) + nsTArray>& aFileList) { JS::Rooted array(aCx, JS_NewArrayObject(aCx, aFileList.Length())); if (!array) { @@ -239,7 +239,7 @@ ArchiveRequest::GetFilesResult(JSContext* aCx, } for (uint32_t i = 0; i < aFileList.Length(); ++i) { - nsRefPtr file = aFileList[i]; + RefPtr file = aFileList[i]; JS::Rooted value(aCx); if (!ToJSValue(aCx, file, &value)) { @@ -262,7 +262,7 @@ ArchiveRequest::Create(nsPIDOMWindow* aOwner, { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - nsRefPtr request = new ArchiveRequest(aOwner, aReader); + RefPtr request = new ArchiveRequest(aOwner, aReader); return request.forget(); } diff --git a/dom/archivereader/ArchiveRequest.h b/dom/archivereader/ArchiveRequest.h index 67413b2799..18b7c96eb5 100644 --- a/dom/archivereader/ArchiveRequest.h +++ b/dom/archivereader/ArchiveRequest.h @@ -49,7 +49,7 @@ public: void OpGetFile(const nsAString& aFilename); void OpGetFiles(); - nsresult ReaderReady(nsTArray>& aFileList, nsresult aStatus); + nsresult ReaderReady(nsTArray>& aFileList, nsresult aStatus); public: // static static already_AddRefed Create(nsPIDOMWindow* aOwner, @@ -60,17 +60,17 @@ private: nsresult GetFilenamesResult(JSContext* aCx, JS::Value* aValue, - nsTArray>& aFileList); + nsTArray>& aFileList); nsresult GetFileResult(JSContext* aCx, JS::MutableHandle aValue, - nsTArray>& aFileList); + nsTArray>& aFileList); nsresult GetFilesResult(JSContext* aCx, JS::MutableHandle aValue, - nsTArray>& aFileList); + nsTArray>& aFileList); protected: // The reader: - nsRefPtr mArchiveReader; + RefPtr mArchiveReader; // The operation: enum { diff --git a/dom/archivereader/ArchiveZipEvent.cpp b/dom/archivereader/ArchiveZipEvent.cpp index f2a7d97f13..31bd85cd14 100644 --- a/dom/archivereader/ArchiveZipEvent.cpp +++ b/dom/archivereader/ArchiveZipEvent.cpp @@ -84,7 +84,7 @@ ArchiveZipItem::GetFile(ArchiveReader* aArchiveReader) return nullptr; } - nsRefPtr file = dom::File::Create(aArchiveReader, + RefPtr file = dom::File::Create(aArchiveReader, new ArchiveZipBlobImpl(filename, NS_ConvertUTF8toUTF16(GetType()), StrToInt32(mCentralStruct.orglen), diff --git a/dom/archivereader/ArchiveZipFile.cpp b/dom/archivereader/ArchiveZipFile.cpp index 5c141980dc..d374fe91f0 100644 --- a/dom/archivereader/ArchiveZipFile.cpp +++ b/dom/archivereader/ArchiveZipFile.cpp @@ -377,7 +377,7 @@ ArchiveZipBlobImpl::GetInternalStream(nsIInputStream** aStream, return; } - nsRefPtr stream = new ArchiveInputStream(size, + RefPtr stream = new ArchiveInputStream(size, inputStream, mFilename, mStart, @@ -393,7 +393,7 @@ ArchiveZipBlobImpl::CreateSlice(uint64_t aStart, const nsAString& aContentType, mozilla::ErrorResult& aRv) { - nsRefPtr impl = + RefPtr impl = new ArchiveZipBlobImpl(mFilename, mContentType, aStart, mLength, mCentral, mBlobImpl); return impl.forget(); diff --git a/dom/archivereader/ArchiveZipFile.h b/dom/archivereader/ArchiveZipFile.h index f3264ab237..d1196486c4 100644 --- a/dom/archivereader/ArchiveZipFile.h +++ b/dom/archivereader/ArchiveZipFile.h @@ -71,7 +71,7 @@ protected: private: // Data ZipCentral mCentral; - nsRefPtr mBlobImpl; + RefPtr mBlobImpl; nsString mFilename; }; diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index 471d0a2b33..2a79965e4b 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -322,7 +322,7 @@ protected: mQuotaObject = nullptr; } - nsRefPtr mQuotaObject; + RefPtr mQuotaObject; int64_t mFileSize; PRFileDesc* mFileDesc; PRFileMap* mFileMap; @@ -332,7 +332,7 @@ protected: class UnlockDirectoryRunnable final : public nsRunnable { - nsRefPtr mDirectoryLock; + RefPtr mDirectoryLock; public: explicit @@ -618,7 +618,7 @@ private: quota::PersistenceType mPersistence; nsCString mGroup; nsCString mOrigin; - nsRefPtr mDirectoryLock; + RefPtr mDirectoryLock; // State initialized during eReadyToReadMetadata nsCOMPtr mDirectory; @@ -904,7 +904,7 @@ ParentRunnable::FinishOnOwningThread() FileDescriptorHolder::Finish(); if (mDirectoryLock) { - nsRefPtr runnable = + RefPtr runnable = new UnlockDirectoryRunnable(mDirectoryLock.forget()); NS_DispatchToMainThread(runnable); @@ -1144,7 +1144,7 @@ AllocEntryParent(OpenMode aOpenMode, return nullptr; } - nsRefPtr runnable = + RefPtr runnable = new ParentRunnable(aPrincipalInfo, aOpenMode, aWriteParams); nsresult rv = NS_DispatchToMainThread(runnable); @@ -1158,7 +1158,7 @@ void DeallocEntryParent(PAsmJSCacheEntryParent* aActor) { // Transfer ownership back from IPDL. - nsRefPtr op = + RefPtr op = dont_AddRef(static_cast(aActor)); } @@ -1544,7 +1544,7 @@ OpenFile(nsIPrincipal* aPrincipal, // We need to synchronously call into the parent to open the file and // interact with the QuotaManager. The child can then map the file into its // address space to perform I/O. - nsRefPtr childRunnable = + RefPtr childRunnable = new ChildRunnable(aPrincipal, aOpenMode, aWriteParams, aReadParams); JS::AsmJSCacheResult openResult = diff --git a/dom/audiochannel/AudioChannelAgent.cpp b/dom/audiochannel/AudioChannelAgent.cpp index ca3ffabb5a..3f5c6b3923 100644 --- a/dom/audiochannel/AudioChannelAgent.cpp +++ b/dom/audiochannel/AudioChannelAgent.cpp @@ -121,7 +121,7 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(float *aVolume, MOZ_ASSERT(aVolume); MOZ_ASSERT(aMuted); - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR || service == nullptr || mIsRegToService) { return NS_ERROR_FAILURE; @@ -143,7 +143,7 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying(void) return NS_ERROR_FAILURE; } - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); service->UnregisterAudioChannelAgent(this); mIsRegToService = false; return NS_OK; @@ -170,7 +170,7 @@ AudioChannelAgent::WindowVolumeChanged() float volume = 1.0; bool muted = false; - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); service->GetState(mWindow, mAudioChannelType, &volume, &muted); callback->WindowVolumeChanged(volume, muted); diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 28747f8f3e..7de3b1140e 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -91,7 +91,7 @@ void NotifyChannelActive(uint64_t aWindowID, AudioChannel aAudioChannel, bool aActive) { - nsRefPtr runnable = + RefPtr runnable = new NotifyChannelActiveRunnable(aWindowID, aAudioChannel, aActive); NS_DispatchToCurrentThread(runnable); } @@ -168,7 +168,7 @@ AudioChannelService::GetOrCreate() gAudioChannelService = new AudioChannelService(); } - nsRefPtr service = gAudioChannelService.get(); + RefPtr service = gAudioChannelService.get(); return service.forget(); } @@ -252,7 +252,7 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, // If this is the first agent for this window, we must notify the observers. if (winData->mAgents.Length() == 1) { - nsRefPtr runnable = + RefPtr runnable = new MediaPlaybackRunnable(aAgent->Window(), true /* active */); NS_DispatchToCurrentThread(runnable); } @@ -294,7 +294,7 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent) // If this is the last agent for this window, we must notify the observers. if (winData->mAgents.IsEmpty()) { - nsRefPtr runnable = + RefPtr runnable = new MediaPlaybackRunnable(aAgent->Window(), false /* active */); NS_DispatchToCurrentThread(runnable); } @@ -525,7 +525,7 @@ struct RefreshAgentsVolumeData {} nsPIDOMWindow* mWindow; - nsTArray> mAgents; + nsTArray> mAgents; }; void diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp index 15b07bc715..4c9a8950bd 100644 --- a/dom/base/Attr.cpp +++ b/dom/base/Attr.cpp @@ -144,7 +144,7 @@ Attr::SetOwnerDocument(nsIDocument* aDocument) NS_ASSERTION(doc != aDocument, "bad call to Attr::SetOwnerDocument"); doc->DeleteAllPropertiesFor(this); - nsRefPtr newNodeInfo; + RefPtr newNodeInfo; newNodeInfo = aDocument->NodeInfoManager()-> GetNodeInfo(mNodeInfo->NameAtom(), mNodeInfo->GetPrefixAtom(), mNodeInfo->NamespaceID(), @@ -261,7 +261,7 @@ Attr::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const nsAutoString value; const_cast(this)->GetValue(value); - nsRefPtr ni = aNodeInfo; + RefPtr ni = aNodeInfo; *aResult = new Attr(nullptr, ni.forget(), value, mNsAware); if (!*aResult) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/dom/base/BarProps.h b/dom/base/BarProps.h index ceac18498f..31d6401ae8 100644 --- a/dom/base/BarProps.h +++ b/dom/base/BarProps.h @@ -54,7 +54,7 @@ protected: already_AddRefed GetBrowserChrome(); - nsRefPtr mDOMWindow; + RefPtr mDOMWindow; }; // Script "menubar" object diff --git a/dom/base/BlobSet.h b/dom/base/BlobSet.h index 632133f6c0..3a0596282d 100644 --- a/dom/base/BlobSet.h +++ b/dom/base/BlobSet.h @@ -27,9 +27,9 @@ public: nsresult AppendVoidPtr(const void* aData, uint32_t aLength); nsresult AppendString(const nsAString& aString, bool nativeEOL, JSContext* aCx); nsresult AppendBlobImpl(BlobImpl* aBlobImpl); - nsresult AppendBlobImpls(const nsTArray>& aBlobImpls); + nsresult AppendBlobImpls(const nsTArray>& aBlobImpls); - nsTArray>& GetBlobImpls() { Flush(); return mBlobImpls; } + nsTArray>& GetBlobImpls() { Flush(); return mBlobImpls; } already_AddRefed GetBlobInternal(nsISupports* aParent, const nsACString& aContentType); @@ -68,7 +68,7 @@ protected: // If we have some data, create a blob for it // and put it on the stack - nsRefPtr blobImpl = + RefPtr blobImpl = new BlobImplMemory(mData, mDataLen, EmptyString()); mBlobImpls.AppendElement(blobImpl); mData = nullptr; // The nsDOMMemoryFile takes ownership of the buffer @@ -77,7 +77,7 @@ protected: } } - nsTArray> mBlobImpls; + nsTArray> mBlobImpls; void* mData; uint64_t mDataLen; uint64_t mDataBufferLen; diff --git a/dom/base/Comment.cpp b/dom/base/Comment.cpp index a5e85f42a6..294850cd1e 100644 --- a/dom/base/Comment.cpp +++ b/dom/base/Comment.cpp @@ -35,7 +35,7 @@ Comment::IsNodeOfType(uint32_t aFlags) const nsGenericDOMDataNode* Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const { - nsRefPtr ni = aNodeInfo; + RefPtr ni = aNodeInfo; Comment *it = new Comment(ni.forget()); if (it && aCloneText) { it->mText = mText; diff --git a/dom/base/Console.cpp b/dom/base/Console.cpp index e5db9d6a9d..f799247703 100644 --- a/dom/base/Console.cpp +++ b/dom/base/Console.cpp @@ -67,7 +67,7 @@ struct ConsoleStructuredCloneData { nsCOMPtr mParent; - nsTArray> mBlobs; + nsTArray> mBlobs; }; /** @@ -266,7 +266,7 @@ private: { class ConsoleReleaseRunnable final : public MainThreadWorkerControlRunnable { - nsRefPtr mRunnable; + RefPtr mRunnable; public: ConsoleReleaseRunnable(WorkerPrivate* aWorkerPrivate, @@ -293,7 +293,7 @@ private: {} }; - nsRefPtr runnable = + RefPtr runnable = new ConsoleReleaseRunnable(mWorkerPrivate, this); runnable->Dispatch(nullptr); } @@ -304,7 +304,7 @@ private: AutoJSAPI jsapi; MOZ_ASSERT(aWindow); - nsRefPtr win = static_cast(aWindow); + RefPtr win = static_cast(aWindow); if (NS_WARN_IF(!jsapi.Init(win))) { return; } @@ -362,7 +362,7 @@ protected: JS::Rooted val(aCx); { - nsRefPtr blob = + RefPtr blob = Blob::Create(mClonedData.mParent, mClonedData.mBlobs.ElementAt(aIndex)); if (!ToJSValue(aCx, blob, &val)) { return nullptr; @@ -380,7 +380,7 @@ protected: JSStructuredCloneWriter* aWriter, JS::Handle aObj) override { - nsRefPtr blob; + RefPtr blob; if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, aObj, blob)) && blob->Impl()->MayBeClonedToOtherThreads()) { if (!JS_WriteUint32Pair(aWriter, CONSOLE_TAG_BLOB, @@ -408,7 +408,7 @@ protected: WorkerPrivate* mWorkerPrivate; // This must be released on the worker thread. - nsRefPtr mConsole; + RefPtr mConsole; ConsoleStructuredCloneData mClonedData; }; @@ -430,7 +430,7 @@ private: class ReleaseCallData final : public nsRunnable { public: - explicit ReleaseCallData(nsRefPtr& aCallData) + explicit ReleaseCallData(RefPtr& aCallData) { mCallData.swap(aCallData); } @@ -442,10 +442,10 @@ private: } private: - nsRefPtr mCallData; + RefPtr mCallData; }; - nsRefPtr runnable = new ReleaseCallData(mCallData); + RefPtr runnable = new ReleaseCallData(mCallData); if(NS_FAILED(NS_DispatchToMainThread(runnable))) { NS_WARNING("Failed to dispatch a ReleaseCallData runnable. Leaking."); } @@ -556,7 +556,7 @@ private: mConsole->ProcessCallData(mCallData); } - nsRefPtr mCallData; + RefPtr mCallData; }; // This runnable calls ProfileMethod() on the console on the main-thread. @@ -863,7 +863,7 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction, { if (!NS_IsMainThread()) { // Here we are in a worker thread. - nsRefPtr runnable = + RefPtr runnable = new ConsoleProfileRunnable(this, aAction, aData); runnable->Dispatch(); return; @@ -991,7 +991,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName, const nsAString& aMethodString, const Sequence& aData) { - nsRefPtr callData(new ConsoleCallData()); + RefPtr callData(new ConsoleCallData()); ClearException ce(aCx); @@ -1066,7 +1066,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName, nsGlobalWindow *win = static_cast(mWindow.get()); MOZ_ASSERT(win); - nsRefPtr performance = win->GetPerformance(); + RefPtr performance = win->GetPerformance(); if (!performance) { return; } @@ -1126,7 +1126,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName, return; } - nsRefPtr runnable = + RefPtr runnable = new ConsoleCallDataRunnable(this, callData); runnable->Dispatch(); } diff --git a/dom/base/Console.h b/dom/base/Console.h index 4ef5fdb1a1..506a2c3dac 100644 --- a/dom/base/Console.h +++ b/dom/base/Console.h @@ -204,7 +204,7 @@ private: nsCOMPtr mWindow; nsCOMPtr mStorage; - nsRefPtr mSandbox; + RefPtr mSandbox; #ifdef MOZ_ENABLE_PROFILER_SPS nsCOMPtr mProfiler; #endif diff --git a/dom/base/ConsoleReportCollector.cpp b/dom/base/ConsoleReportCollector.cpp new file mode 100644 index 0000000000..73cbdf6ebc --- /dev/null +++ b/dom/base/ConsoleReportCollector.cpp @@ -0,0 +1,83 @@ +/* -*- 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/. */ + +#include "mozilla/ConsoleReportCollector.h" + +#include "nsNetUtil.h" + +namespace mozilla { + +NS_IMPL_ISUPPORTS(ConsoleReportCollector, nsIConsoleReportCollector) + +ConsoleReportCollector::ConsoleReportCollector() + : mMutex("mozilla::ConsoleReportCollector") +{ +} + +void +ConsoleReportCollector::AddConsoleReport(uint32_t aErrorFlags, + const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, + uint32_t aLineNumber, + uint32_t aColumnNumber, + const nsACString& aMessageName, + const nsTArray& aStringParams) +{ + // any thread + MutexAutoLock lock(mMutex); + + mPendingReports.AppendElement(PendingReport(aErrorFlags, aCategory, + aPropertiesFile, aSourceFileURI, + aLineNumber, aColumnNumber, + aMessageName, aStringParams)); +} + +void +ConsoleReportCollector::FlushConsoleReports(nsIDocument* aDocument) +{ + MOZ_ASSERT(NS_IsMainThread()); + + MutexAutoLock lock(mMutex); + + for (uint32_t i = 0; i < mPendingReports.Length(); ++i) { + PendingReport& report = mPendingReports[i]; + + // It would be nice if we did not have to do this since ReportToConsole() + // just turns around and converts it back to a spec. + nsCOMPtr uri; + nsresult rv = NS_NewURI(getter_AddRefs(uri), report.mSourceFileURI); + if (NS_FAILED(rv)) { + continue; + } + + // Convert back from nsTArray to the char16_t** format required + // by our l10n libraries and ReportToConsole. (bug 1219762) + UniquePtr params; + uint32_t paramsLength = report.mStringParams.Length(); + if (paramsLength > 0) { + params.reset(new char16_t*[paramsLength]); + for (uint32_t j = 0; j < paramsLength; ++j) { + params.get()[j] = const_cast(report.mStringParams[j].get()); + } + } + + nsContentUtils::ReportToConsole(report.mErrorFlags, report.mCategory, + aDocument, report.mPropertiesFile, + report.mMessageName.get(), + const_cast(params.get()), + paramsLength, uri, EmptyString(), + report.mLineNumber, report.mColumnNumber); + } + + mPendingReports.Clear(); +} + +ConsoleReportCollector::~ConsoleReportCollector() +{ +} + +} // namespace mozilla diff --git a/dom/base/ConsoleReportCollector.h b/dom/base/ConsoleReportCollector.h new file mode 100644 index 0000000000..942563bfb2 --- /dev/null +++ b/dom/base/ConsoleReportCollector.h @@ -0,0 +1,73 @@ +/* -*- 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 mozilla_ConsoleReportCollector_h +#define mozilla_ConsoleReportCollector_h + +#include "mozilla/Mutex.h" +#include "nsIConsoleReportCollector.h" +#include "nsTArray.h" + +namespace mozilla { + +class ConsoleReportCollector final : public nsIConsoleReportCollector +{ +public: + ConsoleReportCollector(); + + void + AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, + uint32_t aLineNumber, uint32_t aColumnNumber, + const nsACString& aMessageName, + const nsTArray& aStringParams) override; + + void + FlushConsoleReports(nsIDocument* aDocument) override; + +private: + ~ConsoleReportCollector(); + + struct PendingReport + { + PendingReport(uint32_t aErrorFlags, const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, uint32_t aLineNumber, + uint32_t aColumnNumber, const nsACString& aMessageName, + const nsTArray& aStringParams) + : mErrorFlags(aErrorFlags) + , mCategory(aCategory) + , mPropertiesFile(aPropertiesFile) + , mSourceFileURI(aSourceFileURI) + , mLineNumber(aLineNumber) + , mColumnNumber(aColumnNumber) + , mMessageName(aMessageName) + , mStringParams(aStringParams) + { } + + const uint32_t mErrorFlags; + const nsCString mCategory; + const nsContentUtils::PropertiesFile mPropertiesFile; + const nsCString mSourceFileURI; + const uint32_t mLineNumber; + const uint32_t mColumnNumber; + const nsCString mMessageName; + const nsTArray mStringParams; + }; + + Mutex mMutex; + + // protected by mMutex + nsTArray mPendingReports; + +public: + NS_DECL_THREADSAFE_ISUPPORTS +}; + +} // namespace mozilla + +#endif // mozilla_ConsoleReportCollector_h diff --git a/dom/base/Crypto.h b/dom/base/Crypto.h index 1c4808868f..3d4f0d76ff 100644 --- a/dom/base/Crypto.h +++ b/dom/base/Crypto.h @@ -59,7 +59,7 @@ public: private: nsCOMPtr mParent; - nsRefPtr mSubtle; + RefPtr mSubtle; }; } // namespace dom diff --git a/dom/base/DOMError.cpp b/dom/base/DOMError.cpp index 132d5c42c5..e73698d6e3 100644 --- a/dom/base/DOMError.cpp +++ b/dom/base/DOMError.cpp @@ -71,7 +71,7 @@ DOMError::Constructor(const GlobalObject& aGlobal, // Window is null for chrome code. - nsRefPtr ret = new DOMError(window, aName, aMessage); + RefPtr ret = new DOMError(window, aName, aMessage); return ret.forget(); } diff --git a/dom/base/DOMException.cpp b/dom/base/DOMException.cpp index 3781dda6e9..acf9781440 100644 --- a/dom/base/DOMException.cpp +++ b/dom/base/DOMException.cpp @@ -648,7 +648,7 @@ DOMException::Constructor(GlobalObject& /* unused */, } } - nsRefPtr retval = + RefPtr retval = new DOMException(exceptionResult, NS_ConvertUTF16toUTF8(aMessage), name, @@ -669,7 +669,7 @@ DOMException::Create(nsresult aRv) nsCString message; uint16_t code; NSResultToNameAndMessage(aRv, name, message, &code); - nsRefPtr inst = + RefPtr inst = new DOMException(aRv, message, name, code); return inst.forget(); } @@ -681,7 +681,7 @@ DOMException::Create(nsresult aRv, const nsACString& aMessage) nsCString message; uint16_t code; NSResultToNameAndMessage(aRv, name, message, &code); - nsRefPtr inst = + RefPtr inst = new DOMException(aRv, aMessage, name, code); return inst.forget(); } diff --git a/dom/base/DOMImplementation.cpp b/dom/base/DOMImplementation.cpp index 6a4699b1b7..3f99680ba7 100644 --- a/dom/base/DOMImplementation.cpp +++ b/dom/base/DOMImplementation.cpp @@ -77,7 +77,7 @@ DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName, } // Indicate that there is no internal subset (not just an empty one) - nsRefPtr docType = + RefPtr docType = NS_NewDOMDocumentType(mOwner->NodeInfoManager(), name, aPublicId, aSystemId, NullString(), aRv); return docType.forget(); @@ -226,7 +226,7 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle, rv = head->AppendChildTo(title, false); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr titleText = new nsTextNode(doc->NodeInfoManager()); + RefPtr titleText = new nsTextNode(doc->NodeInfoManager()); rv = titleText->SetText(aTitle, false); NS_ENSURE_SUCCESS(rv, rv); rv = title->AppendChildTo(titleText, false); diff --git a/dom/base/DOMMatrix.cpp b/dom/base/DOMMatrix.cpp index 78c3b157d9..47210d96fe 100644 --- a/dom/base/DOMMatrix.cpp +++ b/dom/base/DOMMatrix.cpp @@ -34,7 +34,7 @@ DOMMatrixReadOnly::Translate(double aTx, double aTy, double aTz) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->TranslateSelf(aTx, aTy, aTz); return retval.forget(); @@ -45,7 +45,7 @@ DOMMatrixReadOnly::Scale(double aScale, double aOriginX, double aOriginY) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->ScaleSelf(aScale, aOriginX, aOriginY); return retval.forget(); @@ -57,7 +57,7 @@ DOMMatrixReadOnly::Scale3d(double aScale, double aOriginY, double aOriginZ) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->Scale3dSelf(aScale, aOriginX, aOriginY, aOriginZ); return retval.forget(); @@ -71,7 +71,7 @@ DOMMatrixReadOnly::ScaleNonUniform(double aScaleX, double aOriginY, double aOriginZ) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->ScaleNonUniformSelf(aScaleX, aScaleY, aScaleZ, aOriginX, aOriginY, aOriginZ); return retval.forget(); @@ -82,7 +82,7 @@ DOMMatrixReadOnly::Rotate(double aAngle, double aOriginX , double aOriginY) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->RotateSelf(aAngle, aOriginX, aOriginY); return retval.forget(); @@ -92,7 +92,7 @@ already_AddRefed DOMMatrixReadOnly::RotateFromVector(double x, double y) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->RotateFromVectorSelf(x, y); return retval.forget(); @@ -104,7 +104,7 @@ DOMMatrixReadOnly::RotateAxisAngle(double aX, double aZ, double aAngle) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->RotateAxisAngleSelf(aX, aY, aZ, aAngle); return retval.forget(); @@ -113,7 +113,7 @@ DOMMatrixReadOnly::RotateAxisAngle(double aX, already_AddRefed DOMMatrixReadOnly::SkewX(double aSx) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->SkewXSelf(aSx); return retval.forget(); @@ -122,7 +122,7 @@ DOMMatrixReadOnly::SkewX(double aSx) const already_AddRefed DOMMatrixReadOnly::SkewY(double aSy) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->SkewYSelf(aSy); return retval.forget(); @@ -131,7 +131,7 @@ DOMMatrixReadOnly::SkewY(double aSy) const already_AddRefed DOMMatrixReadOnly::Multiply(const DOMMatrix& other) const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->MultiplySelf(other); return retval.forget(); @@ -140,7 +140,7 @@ DOMMatrixReadOnly::Multiply(const DOMMatrix& other) const already_AddRefed DOMMatrixReadOnly::FlipX() const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); if (mMatrix3D) { gfx::Matrix4x4 m; m._11 = -1; @@ -157,7 +157,7 @@ DOMMatrixReadOnly::FlipX() const already_AddRefed DOMMatrixReadOnly::FlipY() const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); if (mMatrix3D) { gfx::Matrix4x4 m; m._22 = -1; @@ -174,7 +174,7 @@ DOMMatrixReadOnly::FlipY() const already_AddRefed DOMMatrixReadOnly::Inverse() const { - nsRefPtr retval = new DOMMatrix(mParent, *this); + RefPtr retval = new DOMMatrix(mParent, *this); retval->InvertSelf(); return retval.forget(); @@ -199,7 +199,7 @@ DOMMatrixReadOnly::Identity() const already_AddRefed DOMMatrixReadOnly::TransformPoint(const DOMPointInit& point) const { - nsRefPtr retval = new DOMPoint(mParent); + RefPtr retval = new DOMPoint(mParent); if (mMatrix3D) { gfx::Point4D transformedPoint; @@ -312,14 +312,14 @@ DOMMatrixReadOnly::Stringify(nsAString& aResult) already_AddRefed DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { - nsRefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); + RefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); return obj.forget(); } already_AddRefed DOMMatrix::Constructor(const GlobalObject& aGlobal, const nsAString& aTransformList, ErrorResult& aRv) { - nsRefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); + RefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); obj = obj->SetMatrixValue(aTransformList, aRv); return obj.forget(); @@ -328,7 +328,7 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const nsAString& aTransformL already_AddRefed DOMMatrix::Constructor(const GlobalObject& aGlobal, const DOMMatrixReadOnly& aOther, ErrorResult& aRv) { - nsRefPtr obj = new DOMMatrix(aGlobal.GetAsSupports(), aOther); + RefPtr obj = new DOMMatrix(aGlobal.GetAsSupports(), aOther); return obj.forget(); } @@ -366,7 +366,7 @@ template void SetDataInMatrix(DOMMatrix* aMatrix, const T* aData, i already_AddRefed DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv) { - nsRefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); + RefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); aArray32.ComputeLengthAndData(); SetDataInMatrix(obj, aArray32.Data(), aArray32.Length(), aRv); @@ -376,7 +376,7 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32 already_AddRefed DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv) { - nsRefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); + RefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); aArray64.ComputeLengthAndData(); SetDataInMatrix(obj, aArray64.Data(), aArray64.Length(), aRv); @@ -386,7 +386,7 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64 already_AddRefed DOMMatrix::Constructor(const GlobalObject& aGlobal, const Sequence& aNumberSequence, ErrorResult& aRv) { - nsRefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); + RefPtr obj = new DOMMatrix(aGlobal.GetAsSupports()); SetDataInMatrix(obj, aNumberSequence.Elements(), aNumberSequence.Length(), aRv); return obj.forget(); diff --git a/dom/base/DOMParser.cpp b/dom/base/DOMParser.cpp index 40e9b8ebcc..9511b6bf52 100644 --- a/dom/base/DOMParser.cpp +++ b/dom/base/DOMParser.cpp @@ -381,7 +381,7 @@ DOMParser::Constructor(const GlobalObject& aOwner, rv.Throw(NS_ERROR_DOM_SECURITY_ERR); return nullptr; } - nsRefPtr domParser = new DOMParser(aOwner.GetAsSupports()); + RefPtr domParser = new DOMParser(aOwner.GetAsSupports()); rv = domParser->InitInternal(aOwner.GetAsSupports(), aPrincipal, aDocumentURI, aBaseURI); if (rv.Failed()) { @@ -394,7 +394,7 @@ DOMParser::Constructor(const GlobalObject& aOwner, DOMParser::Constructor(const GlobalObject& aOwner, ErrorResult& rv) { - nsRefPtr domParser = new DOMParser(aOwner.GetAsSupports()); + RefPtr domParser = new DOMParser(aOwner.GetAsSupports()); rv = domParser->InitInternal(aOwner.GetAsSupports(), nsContentUtils::SubjectPrincipal(), nullptr, nullptr); diff --git a/dom/base/DOMPoint.cpp b/dom/base/DOMPoint.cpp index d3eb804e16..7ef04b447e 100644 --- a/dom/base/DOMPoint.cpp +++ b/dom/base/DOMPoint.cpp @@ -22,7 +22,7 @@ already_AddRefed DOMPoint::Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams, ErrorResult& aRV) { - nsRefPtr obj = + RefPtr obj = new DOMPoint(aGlobal.GetAsSupports(), aParams.mX, aParams.mY, aParams.mZ, aParams.mW); return obj.forget(); @@ -32,7 +32,7 @@ already_AddRefed DOMPoint::Constructor(const GlobalObject& aGlobal, double aX, double aY, double aZ, double aW, ErrorResult& aRV) { - nsRefPtr obj = + RefPtr obj = new DOMPoint(aGlobal.GetAsSupports(), aX, aY, aZ, aW); return obj.forget(); } diff --git a/dom/base/DOMQuad.cpp b/dom/base/DOMQuad.cpp index 04fb8866cb..3e10f05e5c 100644 --- a/dom/base/DOMQuad.cpp +++ b/dom/base/DOMQuad.cpp @@ -52,7 +52,7 @@ DOMQuad::Constructor(const GlobalObject& aGlobal, const DOMPointInit& aP4, ErrorResult& aRV) { - nsRefPtr obj = new DOMQuad(aGlobal.GetAsSupports()); + RefPtr obj = new DOMQuad(aGlobal.GetAsSupports()); obj->mPoints[0] = DOMPoint::Constructor(aGlobal, aP1, aRV); obj->mPoints[1] = DOMPoint::Constructor(aGlobal, aP2, aRV); obj->mPoints[2] = DOMPoint::Constructor(aGlobal, aP3, aRV); @@ -70,7 +70,7 @@ DOMQuad::Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect, points[1] = CSSPoint(x + w, y); points[2] = CSSPoint(x + w, y + h); points[3] = CSSPoint(x, y + h); - nsRefPtr obj = new DOMQuad(aGlobal.GetAsSupports(), points); + RefPtr obj = new DOMQuad(aGlobal.GetAsSupports(), points); return obj.forget(); } @@ -139,7 +139,7 @@ public: protected: virtual ~QuadBounds() {} - nsRefPtr mQuad; + RefPtr mQuad; }; NS_IMPL_CYCLE_COLLECTION_INHERITED(DOMQuad::QuadBounds, DOMRectReadOnly, mQuad) diff --git a/dom/base/DOMQuad.h b/dom/base/DOMQuad.h index 9178d46e85..dcd772e532 100644 --- a/dom/base/DOMQuad.h +++ b/dom/base/DOMQuad.h @@ -61,8 +61,8 @@ protected: class QuadBounds; nsCOMPtr mParent; - nsRefPtr mPoints[4]; - mutable nsRefPtr mBounds; // allocated lazily + RefPtr mPoints[4]; + mutable RefPtr mBounds; // allocated lazily }; } // namespace dom diff --git a/dom/base/DOMRect.cpp b/dom/base/DOMRect.cpp index b2cef84fdc..2c44c6a076 100644 --- a/dom/base/DOMRect.cpp +++ b/dom/base/DOMRect.cpp @@ -57,7 +57,7 @@ DOMRect::WrapObject(JSContext* aCx, JS::Handle aGivenProto) already_AddRefed DOMRect::Constructor(const GlobalObject& aGlobal, ErrorResult& aRV) { - nsRefPtr obj = + RefPtr obj = new DOMRect(aGlobal.GetAsSupports(), 0.0, 0.0, 0.0, 0.0); return obj.forget(); } @@ -66,7 +66,7 @@ already_AddRefed DOMRect::Constructor(const GlobalObject& aGlobal, double aX, double aY, double aWidth, double aHeight, ErrorResult& aRV) { - nsRefPtr obj = + RefPtr obj = new DOMRect(aGlobal.GetAsSupports(), aX, aY, aWidth, aHeight); return obj.forget(); } diff --git a/dom/base/DOMRect.h b/dom/base/DOMRect.h index 6a0de2b0cd..eb48b56cfd 100644 --- a/dom/base/DOMRect.h +++ b/dom/base/DOMRect.h @@ -206,7 +206,7 @@ public: } protected: - nsTArray > mArray; + nsTArray > mArray; nsCOMPtr mParent; }; diff --git a/dom/base/DOMRequest.cpp b/dom/base/DOMRequest.cpp index a3949d5298..d83fe54a24 100644 --- a/dom/base/DOMRequest.cpp +++ b/dom/base/DOMRequest.cpp @@ -192,7 +192,7 @@ DOMRequest::FireEvent(const nsAString& aType, bool aBubble, bool aCancelable) return; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); nsresult rv = event->InitEvent(aType, aBubble, aCancelable); if (NS_FAILED(rv)) { return; @@ -314,7 +314,7 @@ public: const JS::Value& aResult) { mozilla::ThreadsafeAutoSafeJSContext cx; - nsRefPtr asyncTask = new FireSuccessAsyncTask(cx, aRequest, aResult); + RefPtr asyncTask = new FireSuccessAsyncTask(cx, aRequest, aResult); MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(asyncTask))); return NS_OK; } @@ -327,7 +327,7 @@ public: } private: - nsRefPtr mReq; + RefPtr mReq; JS::PersistentRooted mResult; }; @@ -348,7 +348,7 @@ public: return NS_OK; } private: - nsRefPtr mReq; + RefPtr mReq; nsString mError; }; diff --git a/dom/base/DOMRequest.h b/dom/base/DOMRequest.h index 21f8a1f231..9c32ff172d 100644 --- a/dom/base/DOMRequest.h +++ b/dom/base/DOMRequest.h @@ -29,8 +29,8 @@ class DOMRequest : public DOMEventTargetHelper, { protected: JS::Heap mResult; - nsRefPtr mError; - nsRefPtr mPromise; + RefPtr mError; + RefPtr mPromise; bool mDone; public: diff --git a/dom/base/DocumentType.cpp b/dom/base/DocumentType.cpp index 6fda996fc6..d6a5cce85c 100644 --- a/dom/base/DocumentType.cpp +++ b/dom/base/DocumentType.cpp @@ -52,7 +52,7 @@ NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager, nsIDOMNode::DOCUMENT_TYPE_NODE, aName); - nsRefPtr docType = + RefPtr docType = new mozilla::dom::DocumentType(ni, aPublicId, aSystemId, aInternalSubset); return docType.forget(); } @@ -142,7 +142,7 @@ DocumentType::MozRemove() nsGenericDOMDataNode* DocumentType::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const { - already_AddRefed ni = nsRefPtr(aNodeInfo).forget(); + already_AddRefed ni = RefPtr(aNodeInfo).forget(); return new DocumentType(ni, mPublicId, mSystemId, mInternalSubset); } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 603d44009e..54aedad9e8 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -401,7 +401,7 @@ Element::GetBindingURL(nsIDocument *aDocument, css::URLValue **aResult) } // Get the computed -moz-binding directly from the style context - nsRefPtr sc = + RefPtr sc = nsComputedDOMStyle::GetStyleContextForElementNoFlush(this, nullptr, shell); NS_ENSURE_TRUE(sc, false); @@ -509,7 +509,7 @@ Element::WrapObject(JSContext *aCx, JS::Handle aGivenProto) { // Make a scope so that ~nsRefPtr can GC before returning obj. - nsRefPtr binding; + RefPtr binding; xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding), &dummy); if (binding) { @@ -911,7 +911,7 @@ Element::GetClientAreaRect() already_AddRefed Element::GetBoundingClientRect() { - nsRefPtr rect = new DOMRect(this); + RefPtr rect = new DOMRect(this); nsIFrame* frame = GetPrimaryFrame(Flush_Layout); if (!frame) { @@ -929,7 +929,7 @@ Element::GetBoundingClientRect() already_AddRefed Element::GetClientRects() { - nsRefPtr rectList = new DOMRectList(this); + RefPtr rectList = new DOMRectList(this); nsIFrame* frame = GetPrimaryFrame(Flush_Layout); if (!frame) { @@ -990,12 +990,12 @@ Element::CreateShadowRoot(ErrorResult& aError) { nsAutoScriptBlocker scriptBlocker; - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = mNodeInfo->NodeInfoManager()->GetNodeInfo( nsGkAtoms::documentFragmentNodeName, nullptr, kNameSpaceID_None, nsIDOMNode::DOCUMENT_FRAGMENT_NODE); - nsRefPtr docInfo = new nsXBLDocumentInfo(OwnerDoc()); + RefPtr docInfo = new nsXBLDocumentInfo(OwnerDoc()); nsXBLPrototypeBinding* protoBinding = new nsXBLPrototypeBinding(); aError = protoBinding->Init(NS_LITERAL_CSTRING("shadowroot"), @@ -1022,7 +1022,7 @@ Element::CreateShadowRoot(ErrorResult& aError) // Calling SetPrototypeBinding takes ownership of protoBinding. docInfo->SetPrototypeBinding(NS_LITERAL_CSTRING("shadowroot"), protoBinding); - nsRefPtr shadowRoot = new ShadowRoot(this, nodeInfo.forget(), + RefPtr shadowRoot = new ShadowRoot(this, nodeInfo.forget(), protoBinding); shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc()); @@ -1047,7 +1047,7 @@ Element::CreateShadowRoot(ErrorResult& aError) } // xblBinding takes ownership of docInfo. - nsRefPtr xblBinding = new nsXBLBinding(shadowRoot, protoBinding); + RefPtr xblBinding = new nsXBLBinding(shadowRoot, protoBinding); shadowRoot->SetAssociatedBinding(xblBinding); xblBinding->SetBoundElement(this); @@ -1138,7 +1138,7 @@ DestinationInsertionPointList::WrapObject(JSContext* aCx, JS::Handle already_AddRefed Element::GetDestinationInsertionPoints() { - nsRefPtr list = + RefPtr list = new DestinationInsertionPointList(this); return list.forget(); } @@ -1304,7 +1304,7 @@ Element::SetAttributeNS(const nsAString& aNamespaceURI, const nsAString& aValue, ErrorResult& aError) { - nsRefPtr ni; + RefPtr ni; aError = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI, aQualifiedName, mNodeInfo->NodeInfoManager(), @@ -1780,7 +1780,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent) } if (GetParent()) { - nsRefPtr p; + RefPtr p; p.swap(mParent); } else { mParent = nullptr; @@ -2004,7 +2004,7 @@ Element::GetExistingAttrNameFromQName(const nsAString& aStr) const return nullptr; } - nsRefPtr nodeInfo; + RefPtr nodeInfo; if (name->IsAtom()) { nodeInfo = mNodeInfo->NodeInfoManager()-> GetNodeInfo(name->Atom(), nullptr, kNameSpaceID_None, @@ -2402,7 +2402,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, } } else { - nsRefPtr ni; + RefPtr ni; ni = mNodeInfo->NodeInfoManager()->GetNodeInfo(aName, aPrefix, aNamespaceID, nsIDOMNode::ATTRIBUTE_NODE); @@ -2417,7 +2417,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, NS_ENSURE_SUCCESS(rv, rv); if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) { - nsRefPtr binding = GetXBLBinding(); + RefPtr binding = GetXBLBinding(); if (binding) { binding->AttributeChanged(aName, aNamespaceID, false, aNotify); } @@ -2629,7 +2629,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, this); // Grab the attr node if needed before we remove it from the attr map - nsRefPtr attrNode; + RefPtr attrNode; if (hasMutationListeners) { nsAutoString ns; nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns); @@ -2665,7 +2665,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, NS_ENSURE_SUCCESS(rv, rv); if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) { - nsRefPtr binding = GetXBLBinding(); + RefPtr binding = GetXBLBinding(); if (binding) { binding->AttributeChanged(aName, aNameSpaceID, true, aNotify); } @@ -3305,7 +3305,7 @@ Element::MozRequestFullScreen(JSContext* aCx, JS::Handle aOptions, NS_LITERAL_CSTRING("DOM"), OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, error); - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(OwnerDoc(), NS_LITERAL_STRING("mozfullscreenerror"), true, @@ -3349,7 +3349,7 @@ Element::MozRequestPointerLock() } void -Element::GetAnimations(nsTArray>& aAnimations) +Element::GetAnimations(nsTArray>& aAnimations) { nsIDocument* doc = GetComposedDoc(); if (doc) { @@ -3376,7 +3376,7 @@ Element::GetAnimations(nsTArray>& aAnimations) } } - aAnimations.Sort(AnimationPtrComparator>()); + aAnimations.Sort(AnimationPtrComparator>()); } NS_IMETHODIMP @@ -3423,7 +3423,7 @@ Element::SetOuterHTML(const nsAString& aOuterHTML, ErrorResult& aError) localName = nsGkAtoms::body; namespaceID = kNameSpaceID_XHTML; } - nsRefPtr fragment = + RefPtr fragment = new DocumentFragment(OwnerDoc()->NodeInfoManager()); nsContentUtils::ParseFragmentHTML(aOuterHTML, fragment, @@ -3442,7 +3442,7 @@ Element::SetOuterHTML(const nsAString& aOuterHTML, ErrorResult& aError) } else { NS_ASSERTION(parent->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE, "How come the parent isn't a document, a fragment or an element?"); - nsRefPtr info = + RefPtr info = OwnerDoc()->NodeInfoManager()->GetNodeInfo(nsGkAtoms::body, nullptr, kNameSpaceID_XHTML, @@ -3618,7 +3618,7 @@ void Element::InsertAdjacentText( const nsAString& aWhere, const nsAString& aData, ErrorResult& aError) { - nsRefPtr textNode = OwnerDoc()->CreateTextNode(aData); + RefPtr textNode = OwnerDoc()->CreateTextNode(aData); InsertAdjacent(aWhere, textNode, aError); } diff --git a/dom/base/Element.h b/dom/base/Element.h index 47c3adce12..5fa5c8dc6c 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -859,7 +859,7 @@ public: { } - void GetAnimations(nsTArray>& aAnimations); + void GetAnimations(nsTArray>& aAnimations); NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML); virtual void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError); @@ -1355,8 +1355,8 @@ public: NS_IMETHOD Run() override; private: virtual ~RemoveFromBindingManagerRunnable(); - nsRefPtr mManager; - nsRefPtr mContent; + RefPtr mManager; + RefPtr mContent; nsCOMPtr mDoc; }; @@ -1380,7 +1380,7 @@ public: protected: virtual ~DestinationInsertionPointList(); - nsRefPtr mParent; + RefPtr mParent; nsCOMArray mDestinationPoints; }; @@ -1448,7 +1448,7 @@ _elementName::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const { \ *aResult = nullptr; \ already_AddRefed ni = \ - nsRefPtr(aNodeInfo).forget(); \ + RefPtr(aNodeInfo).forget(); \ _elementName *it = new _elementName(ni); \ if (!it) { \ return NS_ERROR_OUT_OF_MEMORY; \ @@ -1469,7 +1469,7 @@ _elementName::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const { \ *aResult = nullptr; \ already_AddRefed ni = \ - nsRefPtr(aNodeInfo).forget(); \ + RefPtr(aNodeInfo).forget(); \ _elementName *it = new _elementName(ni); \ if (!it) { \ return NS_ERROR_OUT_OF_MEMORY; \ diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index ac35e0d9eb..8f68c3ce08 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -114,9 +114,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(EventSource, DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrc) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNotificationCallbacks) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLoadGroup) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannelEventSink) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHttpChannel) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTimer) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUnicodeDecoder) @@ -290,7 +288,7 @@ EventSource::Constructor(const GlobalObject& aGlobal, } MOZ_ASSERT(ownerWindow->IsInnerWindow()); - nsRefPtr eventSource = new EventSource(ownerWindow); + RefPtr eventSource = new EventSource(ownerWindow); aRv = eventSource->Init(aGlobal.GetAsSupports(), aURL, aEventSourceInitDict.mWithCredentials); return eventSource.forget(); @@ -490,48 +488,6 @@ EventSource::OnStopRequest(nsIRequest *aRequest, return NS_OK; } -/** - * Simple helper class that just forwards the redirect callback back - * to the EventSource. - */ -class AsyncVerifyRedirectCallbackFwr final : public nsIAsyncVerifyRedirectCallback -{ -public: - explicit AsyncVerifyRedirectCallbackFwr(EventSource* aEventsource) - : mEventSource(aEventsource) - { - } - - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(AsyncVerifyRedirectCallbackFwr) - - // nsIAsyncVerifyRedirectCallback implementation - NS_IMETHOD OnRedirectVerifyCallback(nsresult aResult) override - { - nsresult rv = mEventSource->OnRedirectVerifyCallback(aResult); - if (NS_FAILED(rv)) { - mEventSource->mErrorLoadOnRedirect = true; - mEventSource->DispatchFailConnection(); - } - - return NS_OK; - } - -private: - ~AsyncVerifyRedirectCallbackFwr() {} - nsRefPtr mEventSource; -}; - -NS_IMPL_CYCLE_COLLECTION(AsyncVerifyRedirectCallbackFwr, mEventSource) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AsyncVerifyRedirectCallbackFwr) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback) -NS_INTERFACE_MAP_END - -NS_IMPL_CYCLE_COLLECTING_ADDREF(AsyncVerifyRedirectCallbackFwr) -NS_IMPL_CYCLE_COLLECTING_RELEASE(AsyncVerifyRedirectCallbackFwr) - //----------------------------------------------------------------------------- // EventSource::nsIChannelEventSink //----------------------------------------------------------------------------- @@ -564,56 +520,20 @@ EventSource::AsyncOnChannelRedirect(nsIChannel *aOldChannel, return NS_ERROR_DOM_SECURITY_ERR; } - // Prepare to receive callback - mRedirectFlags = aFlags; - mRedirectCallback = aCallback; - mNewRedirectChannel = aNewChannel; - - if (mChannelEventSink) { - nsRefPtr fwd = - new AsyncVerifyRedirectCallbackFwr(this); - - rv = mChannelEventSink->AsyncOnChannelRedirect(aOldChannel, - aNewChannel, - aFlags, fwd); - if (NS_FAILED(rv)) { - mRedirectCallback = nullptr; - mNewRedirectChannel = nullptr; - mErrorLoadOnRedirect = true; - DispatchFailConnection(); - } - return rv; - } - OnRedirectVerifyCallback(NS_OK); - return NS_OK; -} - -nsresult -EventSource::OnRedirectVerifyCallback(nsresult aResult) -{ - MOZ_ASSERT(mRedirectCallback, "mRedirectCallback not set in callback"); - MOZ_ASSERT(mNewRedirectChannel, - "mNewRedirectChannel not set in callback"); - - NS_ENSURE_SUCCESS(aResult, aResult); - // update our channel - mHttpChannel = do_QueryInterface(mNewRedirectChannel); + mHttpChannel = do_QueryInterface(aNewChannel); NS_ENSURE_STATE(mHttpChannel); - nsresult rv = SetupHttpChannel(); + rv = SetupHttpChannel(); NS_ENSURE_SUCCESS(rv, rv); - if ((mRedirectFlags & nsIChannelEventSink::REDIRECT_PERMANENT) != 0) { + if ((aFlags & nsIChannelEventSink::REDIRECT_PERMANENT) != 0) { rv = NS_GetFinalChannelURI(mHttpChannel, getter_AddRefs(mSrc)); NS_ENSURE_SUCCESS(rv, rv); } - mNewRedirectChannel = nullptr; - - mRedirectCallback->OnRedirectVerifyCallback(aResult); - mRedirectCallback = nullptr; + aCallback->OnRedirectVerifyCallback(NS_OK); return NS_OK; } @@ -626,27 +546,12 @@ NS_IMETHODIMP EventSource::GetInterface(const nsIID & aIID, void **aResult) { - // Make sure to return ourselves for the channel event sink interface, - // no matter what. We can forward these to mNotificationCallbacks - // if it wants to get notifications for them. But we - // need to see these notifications for proper functioning. if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) { - mChannelEventSink = do_GetInterface(mNotificationCallbacks); *aResult = static_cast(this); NS_ADDREF_THIS(); return NS_OK; } - // Now give mNotificationCallbacks (if non-null) a chance to return the - // desired interface. - if (mNotificationCallbacks) { - nsresult rv = mNotificationCallbacks->GetInterface(aIID, aResult); - if (NS_SUCCEEDED(rv)) { - NS_ASSERTION(*aResult, "Lying nsIInterfaceRequestor implementation!"); - return rv; - } - } - if (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) || aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) { nsresult rv = CheckInnerWindowCorrectness(); @@ -807,12 +712,14 @@ EventSource::InitChannelAndRequestEventSource() rv = SetupHttpChannel(); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr notificationCallbacks; - mHttpChannel->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks)); - if (notificationCallbacks != this) { - mNotificationCallbacks = notificationCallbacks; - mHttpChannel->SetNotificationCallbacks(this); +#ifdef DEBUG + { + nsCOMPtr notificationCallbacks; + mHttpChannel->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks)); + MOZ_ASSERT(!notificationCallbacks); } +#endif + mHttpChannel->SetNotificationCallbacks(this); // Start reading from the channel rv = mHttpChannel->AsyncOpen2(this); @@ -847,7 +754,7 @@ EventSource::AnnounceConnection() return; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); // it doesn't bubble, and it isn't cancelable rv = event->InitEvent(NS_LITERAL_STRING("open"), false, false); @@ -878,11 +785,7 @@ EventSource::ResetConnection() mLastConvertionResult = NS_OK; mHttpChannel = nullptr; - mNotificationCallbacks = nullptr; - mChannelEventSink = nullptr; mStatus = PARSE_STATE_OFF; - mRedirectCallback = nullptr; - mNewRedirectChannel = nullptr; mReadyState = CONNECTING; @@ -907,7 +810,7 @@ EventSource::ReestablishConnection() return; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); // it doesn't bubble, and it isn't cancelable rv = event->InitEvent(NS_LITERAL_STRING("error"), false, false); @@ -1058,7 +961,7 @@ EventSource::FailConnection() return; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); // it doesn't bubble, and it isn't cancelable rv = event->InitEvent(NS_LITERAL_STRING("error"), false, false); @@ -1080,7 +983,7 @@ EventSource::FailConnection() void EventSource::TimerCallback(nsITimer* aTimer, void* aClosure) { - nsRefPtr thisObject = static_cast(aClosure); + RefPtr thisObject = static_cast(aClosure); if (thisObject->mReadyState == CLOSED) { return; @@ -1163,7 +1066,7 @@ EventSource::DispatchCurrentMessageEvent() message->mLastEventID.Assign(mLastEventID); } - int32_t sizeBefore = mMessagesToDispatch.GetSize(); + size_t sizeBefore = mMessagesToDispatch.GetSize(); mMessagesToDispatch.Push(message.forget()); NS_ENSURE_TRUE(mMessagesToDispatch.GetSize() == sizeBefore + 1, NS_ERROR_OUT_OF_MEMORY); @@ -1221,7 +1124,7 @@ EventSource::DispatchAllMessageEvents() // create an event that uses the MessageEvent interface, // which does not bubble, is not cancelable, and has no default action - nsRefPtr event = + RefPtr event = NS_NewDOMMessageEvent(this, nullptr, nullptr); rv = event->InitMessageEvent(message->mEventName, false, false, jsData, diff --git a/dom/base/EventSource.h b/dom/base/EventSource.h index 995ed47e1e..ea1fe10aa8 100644 --- a/dom/base/EventSource.h +++ b/dom/base/EventSource.h @@ -34,7 +34,6 @@ class ErrorResult; namespace dom { -class AsyncVerifyRedirectCallbackFwr; struct EventSourceInit; class EventSource final : public DOMEventTargetHelper @@ -44,8 +43,6 @@ class EventSource final : public DOMEventTargetHelper , public nsIInterfaceRequestor , public nsSupportsWeakReference { -friend class AsyncVerifyRedirectCallbackFwr; - public: explicit EventSource(nsPIDOMWindow* aOwnerWindow); NS_DECL_ISUPPORTS_INHERITED @@ -232,13 +229,6 @@ protected: nsCOMPtr mLoadGroup; - /** - * The notification callbacks the channel had initially. - * We want to forward things here as needed. - */ - nsCOMPtr mNotificationCallbacks; - nsCOMPtr mChannelEventSink; - nsCOMPtr mHttpChannel; nsCOMPtr mTimer; @@ -249,10 +239,6 @@ protected: nsCOMPtr mPrincipal; nsString mOrigin; - uint32_t mRedirectFlags; - nsCOMPtr mRedirectCallback; - nsCOMPtr mNewRedirectChannel; - // Event Source owner information: // - the script file name // - source code line number and column number where the Event Source object diff --git a/dom/base/File.cpp b/dom/base/File.cpp index b74485dcce..f2984612bb 100644 --- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -82,7 +82,7 @@ private: NS_ASSERTION(mSeekableStream, "Somebody gave us the wrong stream!"); } - nsRefPtr mDataOwner; + RefPtr mDataOwner; nsCOMPtr mStream; nsCOMPtr mSeekableStream; nsCOMPtr mSerializableInputStream; @@ -168,7 +168,7 @@ Blob::Create(nsISupports* aParent, BlobImpl* aImpl) Blob::Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aLength) { - nsRefPtr blob = Blob::Create(aParent, + RefPtr blob = Blob::Create(aParent, new BlobImplBase(aContentType, aLength)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); @@ -178,7 +178,7 @@ Blob::Create(nsISupports* aParent, const nsAString& aContentType, Blob::Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aStart, uint64_t aLength) { - nsRefPtr blob = Blob::Create(aParent, + RefPtr blob = Blob::Create(aParent, new BlobImplBase(aContentType, aStart, aLength)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); @@ -188,7 +188,7 @@ Blob::Create(nsISupports* aParent, const nsAString& aContentType, Blob::CreateMemoryBlob(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength, const nsAString& aContentType) { - nsRefPtr blob = Blob::Create(aParent, + RefPtr blob = Blob::Create(aParent, new BlobImplMemory(aMemoryBuffer, aLength, aContentType)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); @@ -199,7 +199,7 @@ Blob::CreateTemporaryBlob(nsISupports* aParent, PRFileDesc* aFD, uint64_t aStartPos, uint64_t aLength, const nsAString& aContentType) { - nsRefPtr blob = Blob::Create(aParent, + RefPtr blob = Blob::Create(aParent, new BlobImplTemporaryBlob(aFD, aStartPos, aLength, aContentType)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); @@ -233,7 +233,7 @@ Blob::IsDirectory() const return mImpl->IsDirectory(); } -const nsTArray>* +const nsTArray>* Blob::GetSubBlobImpls() const { return mImpl->GetSubBlobImpls(); @@ -246,7 +246,7 @@ Blob::ToFile() return nullptr; } - nsRefPtr file; + RefPtr file; if (HasFileInterface()) { file = static_cast(this); } else { @@ -259,16 +259,16 @@ Blob::ToFile() already_AddRefed Blob::ToFile(const nsAString& aName) const { - nsAutoTArray, 1> blobImpls; + nsAutoTArray, 1> blobImpls; blobImpls.AppendElement(mImpl); nsAutoString contentType; mImpl->GetType(contentType); - nsRefPtr impl = + RefPtr impl = new MultipartBlobImpl(blobImpls, aName, contentType); - nsRefPtr file = new File(mParent, impl); + RefPtr file = new File(mParent, impl); return file.forget(); } @@ -277,13 +277,13 @@ Blob::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr impl = mImpl->CreateSlice(aStart, aLength, + RefPtr impl = mImpl->CreateSlice(aStart, aLength, aContentType, aRv); if (aRv.Failed()) { return nullptr; } - nsRefPtr blob = Blob::Create(mParent, impl); + RefPtr blob = Blob::Create(mParent, impl); return blob.forget(); } @@ -305,13 +305,13 @@ Blob::Slice(const Optional& aStart, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr impl = + RefPtr impl = mImpl->Slice(aStart, aEnd, aContentType, aRv); if (aRv.Failed()) { return nullptr; } - nsRefPtr blob = Blob::Create(mParent, impl); + RefPtr blob = Blob::Create(mParent, impl); return blob.forget(); } @@ -345,12 +345,12 @@ Blob::WrapObject(JSContext* aCx, JS::Handle aGivenProto) /* static */ already_AddRefed Blob::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { - nsRefPtr impl = new MultipartBlobImpl(); + RefPtr impl = new MultipartBlobImpl(); impl->InitializeBlob(); MOZ_ASSERT(!impl->IsFile()); - nsRefPtr blob = Blob::Create(aGlobal.GetAsSupports(), impl); + RefPtr blob = Blob::Create(aGlobal.GetAsSupports(), impl); return blob.forget(); } @@ -361,7 +361,7 @@ Blob::Constructor( const BlobPropertyBag& aBag, ErrorResult& aRv) { - nsRefPtr impl = new MultipartBlobImpl(); + RefPtr impl = new MultipartBlobImpl(); impl->InitializeBlob(aGlobal.Context(), aData, aBag.mType, aBag.mEndings == EndingTypes::Native, aRv); @@ -370,7 +370,7 @@ Blob::Constructor( } MOZ_ASSERT(!impl->IsFile()); - nsRefPtr blob = Blob::Create(aGlobal.GetAsSupports(), impl); + RefPtr blob = Blob::Create(aGlobal.GetAsSupports(), impl); return blob.forget(); } @@ -415,7 +415,7 @@ File::Create(nsISupports* aParent, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aLastModifiedDate, BlobDirState aDirState) { - nsRefPtr file = new File(aParent, + RefPtr file = new File(aParent, new BlobImplBase(aName, aContentType, aLength, aLastModifiedDate, aDirState)); return file.forget(); @@ -425,7 +425,7 @@ File::Create(nsISupports* aParent, const nsAString& aName, File::Create(nsISupports* aParent, const nsAString& aName, const nsAString& aContentType, uint64_t aLength) { - nsRefPtr file = new File(aParent, + RefPtr file = new File(aParent, new BlobImplBase(aName, aContentType, aLength)); return file.forget(); } @@ -436,7 +436,7 @@ File::CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, const nsAString& aContentType, int64_t aLastModifiedDate) { - nsRefPtr file = new File(aParent, + RefPtr file = new File(aParent, new BlobImplMemory(aMemoryBuffer, aLength, aName, aContentType, aLastModifiedDate)); return file.forget(); @@ -445,7 +445,7 @@ File::CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, /* static */ already_AddRefed File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, bool aTemporary) { - nsRefPtr file = new File(aParent, new BlobImplFile(aFile, aTemporary)); + RefPtr file = new File(aParent, new BlobImplFile(aFile, aTemporary)); return file.forget(); } @@ -453,7 +453,7 @@ File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, bool aTemporary) File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, const nsAString& aName, const nsAString& aContentType) { - nsRefPtr file = new File(aParent, + RefPtr file = new File(aParent, new BlobImplFile(aFile, aName, aContentType)); return file.forget(); } @@ -550,7 +550,7 @@ File::Constructor( const FilePropertyBag& aBag, ErrorResult& aRv) { - nsRefPtr impl = new MultipartBlobImpl(aName); + RefPtr impl = new MultipartBlobImpl(aName); impl->InitializeBlob(aGlobal.Context(), aData, aBag.mType, false, aRv); if (aRv.Failed()) { @@ -562,7 +562,7 @@ File::Constructor( impl->SetLastModified(aBag.mLastModified.Value()); } - nsRefPtr file = new File(aGlobal.GetAsSupports(), impl); + RefPtr file = new File(aGlobal.GetAsSupports(), impl); return file.forget(); } @@ -577,7 +577,7 @@ File::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr impl = new MultipartBlobImpl(EmptyString()); + RefPtr impl = new MultipartBlobImpl(EmptyString()); impl->InitializeChromeFile(aData, aBag, aRv); if (aRv.Failed()) { return nullptr; @@ -588,7 +588,7 @@ File::Constructor(const GlobalObject& aGlobal, impl->SetLastModified(aBag.mLastModified.Value()); } - nsRefPtr domFile = new File(aGlobal.GetAsSupports(), impl); + RefPtr domFile = new File(aGlobal.GetAsSupports(), impl); return domFile.forget(); } @@ -606,7 +606,7 @@ File::Constructor(const GlobalObject& aGlobal, nsCOMPtr window = do_QueryInterface(aGlobal.GetAsSupports()); - nsRefPtr impl = new MultipartBlobImpl(EmptyString()); + RefPtr impl = new MultipartBlobImpl(EmptyString()); impl->InitializeChromeFile(window, aData, aBag, true, aRv); if (aRv.Failed()) { return nullptr; @@ -617,7 +617,7 @@ File::Constructor(const GlobalObject& aGlobal, impl->SetLastModified(aBag.mLastModified.Value()); } - nsRefPtr domFile = new File(aGlobal.GetAsSupports(), impl); + RefPtr domFile = new File(aGlobal.GetAsSupports(), impl); return domFile.forget(); } @@ -634,7 +634,7 @@ File::Constructor(const GlobalObject& aGlobal, nsCOMPtr window = do_QueryInterface(aGlobal.GetAsSupports()); - nsRefPtr impl = new MultipartBlobImpl(EmptyString()); + RefPtr impl = new MultipartBlobImpl(EmptyString()); impl->InitializeChromeFile(window, aData, aBag, aRv); if (aRv.Failed()) { return nullptr; @@ -645,7 +645,7 @@ File::Constructor(const GlobalObject& aGlobal, impl->SetLastModified(aBag.mLastModified.Value()); } - nsRefPtr domFile = new File(aGlobal.GetAsSupports(), impl); + RefPtr domFile = new File(aGlobal.GetAsSupports(), impl); return domFile.forget(); } @@ -836,7 +836,7 @@ BlobImplFile::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr impl = + RefPtr impl = new BlobImplFile(this, aStart, aLength, aContentType); return impl.forget(); } @@ -969,7 +969,7 @@ BlobImplMemory::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr impl = + RefPtr impl = new BlobImplMemory(this, aStart, aLength, aContentType); return impl.forget(); } @@ -1102,7 +1102,7 @@ BlobImplTemporaryBlob::CreateSlice(uint64_t aStart, uint64_t aLength, return nullptr; } - nsRefPtr impl = + RefPtr impl = new BlobImplTemporaryBlob(this, aStart + mStartPos, aLength, aContentType); return impl.forget(); @@ -1123,7 +1123,7 @@ BlobImplTemporaryBlob::GetInternalStream(nsIInputStream** aStream, already_AddRefed BlobSet::GetBlobInternal(nsISupports* aParent, const nsACString& aContentType) { - nsRefPtr blob = Blob::Create(aParent, + RefPtr blob = Blob::Create(aParent, new MultipartBlobImpl(GetBlobImpls(), NS_ConvertASCIItoUTF16(aContentType))); return blob.forget(); @@ -1174,7 +1174,7 @@ BlobSet::AppendBlobImpl(BlobImpl* aBlobImpl) } nsresult -BlobSet::AppendBlobImpls(const nsTArray>& aBlobImpls) +BlobSet::AppendBlobImpls(const nsTArray>& aBlobImpls) { Flush(); mBlobImpls.AppendElements(aBlobImpls); diff --git a/dom/base/File.h b/dom/base/File.h index fb9eb9badc..bb1a2cb5c9 100644 --- a/dom/base/File.h +++ b/dom/base/File.h @@ -106,7 +106,7 @@ public: */ bool IsDirectory() const; - const nsTArray>* GetSubBlobImpls() const; + const nsTArray>* GetSubBlobImpls() const; // This method returns null if this Blob is not a File; it returns // the same object in case this Blob already implements the File interface; @@ -173,7 +173,7 @@ protected: // It's thread-safe and not CC-able and it's the only element that is moved // between threads. // Note: we should not store any other state in this class! - nsRefPtr mImpl; + RefPtr mImpl; private: nsCOMPtr mParent; @@ -311,7 +311,7 @@ public: CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) = 0; - virtual const nsTArray>* + virtual const nsTArray>* GetSubBlobImpls() const = 0; virtual void GetInternalStream(nsIInputStream** aStream, @@ -472,7 +472,7 @@ public: return nullptr; } - virtual const nsTArray>* + virtual const nsTArray>* GetSubBlobImpls() const override { return nullptr; @@ -680,7 +680,7 @@ private: ~BlobImplMemory() {} // Used when backed by a memory store - nsRefPtr mDataOwner; + RefPtr mDataOwner; }; class BlobImplTemporaryBlob final : public BlobImplBase @@ -715,7 +715,7 @@ private: ~BlobImplTemporaryBlob() {} uint64_t mStartPos; - nsRefPtr mFileDescOwner; + RefPtr mFileDescOwner; }; class BlobImplFile : public BlobImplBase diff --git a/dom/base/FileIOObject.cpp b/dom/base/FileIOObject.cpp index 2d1ebcd88e..8c0c097b55 100644 --- a/dom/base/FileIOObject.cpp +++ b/dom/base/FileIOObject.cpp @@ -118,7 +118,7 @@ FileIOObject::DispatchProgressEvent(const nsAString& aType) init.mLengthComputable = false; init.mTotal = 0; } - nsRefPtr event = + RefPtr event = ProgressEvent::Constructor(this, aType, init); event->SetTrusted(true); diff --git a/dom/base/FileIOObject.h b/dom/base/FileIOObject.h index 67069d8971..769f09b041 100644 --- a/dom/base/FileIOObject.h +++ b/dom/base/FileIOObject.h @@ -89,7 +89,7 @@ protected: nsCOMPtr mAsyncStream; - nsRefPtr mError; + RefPtr mError; uint16_t mReadyState; diff --git a/dom/base/FileList.h b/dom/base/FileList.h index 2b4aedc523..3e262153c2 100644 --- a/dom/base/FileList.h +++ b/dom/base/FileList.h @@ -98,7 +98,7 @@ public: private: ~FileList() {} - nsTArray> mFiles; + nsTArray> mFiles; nsCOMPtr mParent; }; diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index c1abb9e5d4..3c73e9657d 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -645,7 +645,7 @@ FragmentOrElement::~FragmentOrElement() already_AddRefed FragmentOrElement::GetChildren(uint32_t aFilter) { - nsRefPtr list = new nsSimpleContentList(this); + RefPtr list = new nsSimpleContentList(this); AllChildrenIterator iter(this, aFilter); while (nsIContent* kid = iter.GetNextChild()) { list->AppendElement(kid); @@ -1022,7 +1022,7 @@ FragmentOrElement::SetXBLBinding(nsXBLBinding* aBinding, // constructor twice (if aBinding inherits from it) or firing its constructor // after aContent has been deleted (if aBinding is null and the content node // dies before we process mAttachedStack). - nsRefPtr oldBinding = GetXBLBinding(); + RefPtr oldBinding = GetXBLBinding(); if (oldBinding) { bindingManager->RemoveFromAttachedQueue(oldBinding); } @@ -1285,7 +1285,7 @@ public: if (this == sContentUnbinder) { sContentUnbinder = nullptr; if (mNext) { - nsRefPtr next; + RefPtr next; next.swap(mNext); sContentUnbinder = next; next->mLast = mLast; @@ -1298,7 +1298,7 @@ public: static void UnbindAll() { - nsRefPtr ub = sContentUnbinder; + RefPtr ub = sContentUnbinder; sContentUnbinder = nullptr; while (ub) { ub->Run(); @@ -1325,7 +1325,7 @@ public: private: nsAutoTArray, SUBTREE_UNBINDINGS_PER_RUNNABLE> mSubtreeRoots; - nsRefPtr mNext; + RefPtr mNext; ContentUnbinder* mLast; static ContentUnbinder* sContentUnbinder; }; @@ -2859,7 +2859,7 @@ FragmentOrElement::SetInnerHTMLInternal(const nsAString& aInnerHTML, ErrorResult nsContentUtils::FireMutationEventsForDirectParsing(doc, target, oldChildCount); } else { - nsRefPtr df = + RefPtr df = nsContentUtils::CreateContextualFragment(target, aInnerHTML, true, aError); if (!aError.Failed()) { // Suppress assertion about node removal mutation events that can't have diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h index b92d045672..d7c27fb634 100644 --- a/dom/base/FragmentOrElement.h +++ b/dom/base/FragmentOrElement.h @@ -277,7 +277,7 @@ public: * The .undoManager property. * @see nsGenericHTMLElement::GetUndoManager */ - nsRefPtr mUndoManager; + RefPtr mUndoManager; /** * SMIL Overridde style rules (for SMIL animation of CSS properties) @@ -288,13 +288,13 @@ public: /** * Holds any SMIL override style rules for this element. */ - nsRefPtr mSMILOverrideStyleRule; + RefPtr mSMILOverrideStyleRule; /** * An object implementing nsIDOMMozNamedAttrMap for this content (attributes) * @see FragmentOrElement::GetAttributes */ - nsRefPtr mAttributeMap; + RefPtr mAttributeMap; union { /** @@ -312,22 +312,22 @@ public: /** * An object implementing the .children property for this element. */ - nsRefPtr mChildrenList; + RefPtr mChildrenList; /** * An object implementing the .classList property for this element. */ - nsRefPtr mClassList; + RefPtr mClassList; /** * ShadowRoot bound to the element. */ - nsRefPtr mShadowRoot; + RefPtr mShadowRoot; /** * The root ShadowRoot of this element if it is in a shadow tree. */ - nsRefPtr mContainingShadow; + RefPtr mContainingShadow; /** * An array of web component insertion points to which this element @@ -338,7 +338,7 @@ public: /** * XBL binding installed on the element. */ - nsRefPtr mXBLBinding; + RefPtr mXBLBinding; /** * XBL binding installed on the lement. @@ -348,7 +348,7 @@ public: /** * Web components custom element data. */ - nsRefPtr mCustomElementData; + RefPtr mCustomElementData; }; protected: diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp index 11e2ae9d14..c96ef24501 100644 --- a/dom/base/ImageEncoder.cpp +++ b/dom/base/ImageEncoder.cpp @@ -64,7 +64,7 @@ private: already_AddRefed GetBRGADataSourceSurfaceSync(already_AddRefed aImage) { - nsRefPtr helper = new SurfaceHelper(Move(aImage)); + RefPtr helper = new SurfaceHelper(Move(aImage)); return helper->GetDataSurfaceSafe(); } @@ -92,7 +92,7 @@ public: if (!mFailed) { // The correct parentObject has to be set by the mEncodeCompleteCallback. - nsRefPtr blob = + RefPtr blob = Blob::CreateMemoryBlob(nullptr, mImgData, mImgSize, mType); MOZ_ASSERT(blob); @@ -122,7 +122,7 @@ private: nsAutoString mType; void* mImgData; nsCOMPtr mEncoderThread; - nsRefPtr mEncodeCompleteCallback; + RefPtr mEncodeCompleteCallback; bool mFailed; }; @@ -218,9 +218,9 @@ private: nsAutoString mType; nsAutoString mOptions; nsAutoArrayPtr mImageBuffer; - nsRefPtr mImage; + RefPtr mImage; nsCOMPtr mEncoder; - nsRefPtr mEncodingCompleteEvent; + RefPtr mEncodingCompleteEvent; int32_t mFormat; const nsIntSize mSize; bool mUsingCustomOptions; @@ -263,7 +263,7 @@ ImageEncoder::ExtractDataFromLayersImageAsync(nsAString& aType, nsresult rv = NS_NewThread(getter_AddRefs(encoderThread), nullptr); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr completeEvent = + RefPtr completeEvent = new EncodingCompleteEvent(encoderThread, aEncodeCallback); nsIntSize size(aImage->GetSize().width, aImage->GetSize().height); @@ -298,7 +298,7 @@ ImageEncoder::ExtractDataAsync(nsAString& aType, nsresult rv = NS_NewThread(getter_AddRefs(encoderThread), nullptr); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr completeEvent = + RefPtr completeEvent = new EncodingCompleteEvent(encoderThread, aEncodeCallback); nsCOMPtr event = new EncodingRunnable(aType, diff --git a/dom/base/ImportManager.cpp b/dom/base/ImportManager.cpp index c56fbd039b..db6f51aaa1 100644 --- a/dom/base/ImportManager.cpp +++ b/dom/base/ImportManager.cpp @@ -64,7 +64,7 @@ ImportLoader::Updater::GetReferrerChain(nsINode* aNode, aResult.AppendElement(aNode); nsINode* node = aNode; - nsRefPtr manager = mLoader->Manager(); + RefPtr manager = mLoader->Manager(); for (ImportLoader* referrersLoader = manager->Find(node->OwnerDoc()); referrersLoader; referrersLoader = manager->Find(node->OwnerDoc())) @@ -154,7 +154,7 @@ ImportLoader::Updater::UpdateMainReferrer(uint32_t aNewIdx) if (mLoader->mDocument) { // Our nearest predecessor has changed. So let's add the ScriptLoader to the // new one if there is any. And remove it from the old one. - nsRefPtr manager = mLoader->Manager(); + RefPtr manager = mLoader->Manager(); nsScriptLoader* loader = mLoader->mDocument->ScriptLoader(); ImportLoader*& pred = mLoader->mBlockingPredecessor; ImportLoader* newPred = manager->GetNearestPredecessor(newMainReferrer); @@ -658,7 +658,7 @@ ImportManager::Get(nsIURI* aURI, nsINode* aNode, nsIDocument* aOrigDocument) { // Check if we have a loader for that URI, if not create one, // and start it up. - nsRefPtr loader; + RefPtr loader; mImports.Get(aURI, getter_AddRefs(loader)); bool needToStart = false; if (!loader) { @@ -716,7 +716,7 @@ ImportLoader* ImportManager::GetNearestPredecessor(nsINode* aNode) HTMLLinkElement* link = static_cast(doc->GetSubImportLink(idx - 1)); nsCOMPtr uri = link->GetHrefURI(); - nsRefPtr ret; + RefPtr ret; mImports.Get(uri, getter_AddRefs(ret)); // Only main referrer links are interesting. if (ret->GetMainReferrer() == link) { diff --git a/dom/base/ImportManager.h b/dom/base/ImportManager.h index cf25261dce..9003726403 100644 --- a/dom/base/ImportManager.h +++ b/dom/base/ImportManager.h @@ -224,7 +224,7 @@ private: // List of pending ScriptLoaders that are waiting for this import // to finish. - nsTArray> mBlockedScriptLoaders; + nsTArray> mBlockedScriptLoaders; // There is always exactly one referrer link that is flagged as // the main referrer the primary link. This is the one that is diff --git a/dom/base/Link.h b/dom/base/Link.h index 95f9367831..2ce0a3908f 100644 --- a/dom/base/Link.h +++ b/dom/base/Link.h @@ -169,7 +169,7 @@ private: bool mRegistered; protected: - nsRefPtr mSearchParams; + RefPtr mSearchParams; }; NS_DEFINE_STATIC_IID_ACCESSOR(Link, MOZILLA_DOM_LINK_IMPLEMENTATION_IID) diff --git a/dom/base/MultipartBlobImpl.cpp b/dom/base/MultipartBlobImpl.cpp index 7bb7b73e93..4d2c309c2f 100644 --- a/dom/base/MultipartBlobImpl.cpp +++ b/dom/base/MultipartBlobImpl.cpp @@ -63,7 +63,7 @@ MultipartBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, ErrorResult& aRv) { // If we clamped to nothing we create an empty blob - nsTArray> blobImpls; + nsTArray> blobImpls; uint64_t length = aLength; uint64_t skipStart = aStart; @@ -81,7 +81,7 @@ MultipartBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, if (skipStart < l) { uint64_t upperBound = std::min(l - skipStart, length); - nsRefPtr firstBlobImpl = + RefPtr firstBlobImpl = blobImpl->CreateSlice(skipStart, upperBound, aContentType, aRv); if (NS_WARN_IF(aRv.Failed())) { @@ -111,7 +111,7 @@ MultipartBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, } if (length < l) { - nsRefPtr lastBlobImpl = + RefPtr lastBlobImpl = blobImpl->CreateSlice(0, length, aContentType, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; @@ -125,7 +125,7 @@ MultipartBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, } // we can create our blob now - nsRefPtr impl = + RefPtr impl = new MultipartBlobImpl(blobImpls, aContentType); return impl.forget(); } @@ -151,7 +151,7 @@ MultipartBlobImpl::InitializeBlob( const OwningArrayBufferOrArrayBufferViewOrBlobOrString& data = aData[i]; if (data.IsBlob()) { - nsRefPtr blob = data.GetAsBlob().get(); + RefPtr blob = data.GetAsBlob().get(); blobSet.AppendBlobImpl(blob->Impl()); } @@ -201,7 +201,7 @@ MultipartBlobImpl::SetLengthAndModifiedDate() bool lastModifiedSet = false; for (uint32_t index = 0, count = mBlobImpls.Length(); index < count; index++) { - nsRefPtr& blob = mBlobImpls[index]; + RefPtr& blob = mBlobImpls[index]; #ifdef DEBUG MOZ_ASSERT(!blob->IsSizeUnknown()); @@ -362,7 +362,7 @@ MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindow* aWindow, aFile->GetLeafName(mName); } - nsRefPtr blob = File::CreateFromFile(aWindow, aFile, aBag.mTemporary); + RefPtr blob = File::CreateFromFile(aWindow, aFile, aBag.mTemporary); // Pre-cache size. blob->GetSize(aRv); diff --git a/dom/base/MultipartBlobImpl.h b/dom/base/MultipartBlobImpl.h index 0b43efbe49..2a0778be28 100644 --- a/dom/base/MultipartBlobImpl.h +++ b/dom/base/MultipartBlobImpl.h @@ -25,7 +25,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // Create as a file - MultipartBlobImpl(const nsTArray>& aBlobImpls, + MultipartBlobImpl(const nsTArray>& aBlobImpls, const nsAString& aName, const nsAString& aContentType) : BlobImplBase(aName, aContentType, UINT64_MAX), @@ -36,7 +36,7 @@ public: } // Create as a blob - MultipartBlobImpl(const nsTArray>& aBlobImpls, + MultipartBlobImpl(const nsTArray>& aBlobImpls, const nsAString& aContentType) : BlobImplBase(aContentType, UINT64_MAX), mBlobImpls(aBlobImpls), @@ -96,7 +96,7 @@ public: virtual void GetInternalStream(nsIInputStream** aInputStream, ErrorResult& aRv) override; - virtual const nsTArray>* GetSubBlobImpls() const override + virtual const nsTArray>* GetSubBlobImpls() const override { return mBlobImpls.Length() ? &mBlobImpls : nullptr; } @@ -124,7 +124,7 @@ protected: void SetLengthAndModifiedDate(); - nsTArray> mBlobImpls; + nsTArray> mBlobImpls; bool mIsFromNsIFile; }; diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index b70f351170..f0fffdfff0 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -324,7 +324,7 @@ Navigator::Invalidate() uint32_t len = mDeviceStorageStores.Length(); for (uint32_t i = 0; i < len; ++i) { - nsRefPtr ds = do_QueryReferent(mDeviceStorageStores[i]); + RefPtr ds = do_QueryReferent(mDeviceStorageStores[i]); if (ds) { ds->Shutdown(); } @@ -959,7 +959,7 @@ Navigator::FindDeviceStorage(const nsAString& aName, const nsAString& aType) auto i = mDeviceStorageStores.Length(); while (i > 0) { --i; - nsRefPtr storage = + RefPtr storage = do_QueryReferent(mDeviceStorageStores[i]); if (storage) { if (storage->Equals(mWindow, aName, aType)) { @@ -982,7 +982,7 @@ Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv) nsString name; nsDOMDeviceStorage::GetDefaultStorageName(aType, name); - nsRefPtr storage = FindDeviceStorage(name, aType); + RefPtr storage = FindDeviceStorage(name, aType); if (storage) { return storage.forget(); } @@ -1001,7 +1001,7 @@ Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv) void Navigator::GetDeviceStorages(const nsAString& aType, - nsTArray >& aStores, + nsTArray >& aStores, ErrorResult& aRv) { if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { @@ -1012,7 +1012,7 @@ Navigator::GetDeviceStorages(const nsAString& aType, nsDOMDeviceStorage::VolumeNameArray volumes; nsDOMDeviceStorage::GetOrderedVolumeNames(aType, volumes); if (volumes.IsEmpty()) { - nsRefPtr storage = GetDeviceStorage(aType, aRv); + RefPtr storage = GetDeviceStorage(aType, aRv); if (storage) { aStores.AppendElement(storage.forget()); } @@ -1020,7 +1020,7 @@ Navigator::GetDeviceStorages(const nsAString& aType, uint32_t len = volumes.Length(); aStores.SetCapacity(len); for (uint32_t i = 0; i < len; ++i) { - nsRefPtr storage = + RefPtr storage = GetDeviceStorageByNameAndType(volumes[i], aType, aRv); if (aRv.Failed()) { break; @@ -1043,7 +1043,7 @@ Navigator::GetDeviceStorageByNameAndType(const nsAString& aName, return nullptr; } - nsRefPtr storage = FindDeviceStorage(aName, aType); + RefPtr storage = FindDeviceStorage(aName, aType); if (storage) { return storage.forget(); } @@ -1290,7 +1290,7 @@ Navigator::SendBeacon(const nsAString& aUrl, loadGroup->SetNotificationCallbacks(callbacks); channel->SetLoadGroup(loadGroup); - nsRefPtr beaconListener = new BeaconStreamListener(); + RefPtr beaconListener = new BeaconStreamListener(); // Start a preflight if cross-origin and content type is not whitelisted nsCOMPtr secMan = nsContentUtils::GetSecurityManager(); @@ -1464,7 +1464,7 @@ Navigator::GetBattery(ErrorResult& aRv) } nsCOMPtr go = do_QueryInterface(mWindow); - nsRefPtr batteryPromise = Promise::Create(go, aRv); + RefPtr batteryPromise = Promise::Create(go, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } @@ -1508,7 +1508,7 @@ Navigator::GetDataStores(nsPIDOMWindow* aWindow, return nullptr; } - nsRefPtr service = DataStoreService::GetOrCreate(); + RefPtr service = DataStoreService::GetOrCreate(); if (!service) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; @@ -1517,7 +1517,7 @@ Navigator::GetDataStores(nsPIDOMWindow* aWindow, nsCOMPtr promise; aRv = service->GetDataStores(aWindow, aName, aOwner, getter_AddRefs(promise)); - nsRefPtr p = static_cast(promise.get()); + RefPtr p = static_cast(promise.get()); return p.forget(); } @@ -1533,7 +1533,7 @@ already_AddRefed Navigator::GetFeature(const nsAString& aName, ErrorResult& aRv) { nsCOMPtr go = do_QueryInterface(mWindow); - nsRefPtr p = Promise::Create(go, aRv); + RefPtr p = Promise::Create(go, aRv); if (aRv.Failed()) { return nullptr; } @@ -1551,7 +1551,7 @@ Navigator::GetFeature(const nsAString& aName, ErrorResult& aRv) } else { mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); - nsRefPtr ipcRef(p); + RefPtr ipcRef(p); cc->SendGetSystemMemory(reinterpret_cast(ipcRef.forget().take())); } return p.forget(); @@ -1586,7 +1586,7 @@ already_AddRefed Navigator::HasFeature(const nsAString& aName, ErrorResult& aRv) { nsCOMPtr go = do_QueryInterface(mWindow); - nsRefPtr p = Promise::Create(go, aRv); + RefPtr p = Promise::Create(go, aRv); if (aRv.Failed()) { return nullptr; } @@ -1720,7 +1720,7 @@ Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv) return nullptr; } - nsRefPtr pmService = + RefPtr pmService = power::PowerManagerService::GetInstance(); // Maybe it went away for some reason... Or maybe we're just called // from our XPCOM method. @@ -1794,7 +1794,7 @@ Navigator::GetInputPortManager(ErrorResult& aRv) already_AddRefed Navigator::MozTCPSocket() { - nsRefPtr socket = new LegacyMozTCPSocket(GetWindow()); + RefPtr socket = new LegacyMozTCPSocket(GetWindow()); return socket.forget(); } @@ -1832,7 +1832,7 @@ Navigator::GetMobileIdAssertion(const MobileIdOptions& aOptions, optionsValue, getter_AddRefs(promise)); - nsRefPtr p = static_cast(promise.get()); + RefPtr p = static_cast(promise.get()); return p.forget(); } #endif // MOZ_B2G @@ -1902,7 +1902,7 @@ Navigator::GetMozIccManager(ErrorResult& aRv) #ifdef MOZ_GAMEPAD void -Navigator::GetGamepads(nsTArray >& aGamepads, +Navigator::GetGamepads(nsTArray >& aGamepads, ErrorResult& aRv) { if (!mWindow) { @@ -1925,14 +1925,14 @@ Navigator::GetVRDevices(ErrorResult& aRv) } nsCOMPtr go = do_QueryInterface(mWindow); - nsRefPtr p = Promise::Create(go, aRv); + RefPtr p = Promise::Create(go, aRv); if (aRv.Failed()) { return nullptr; } nsGlobalWindow* win = static_cast(mWindow.get()); - nsTArray> vrDevs; + nsTArray> vrDevs; if (!win->GetVRDevices(vrDevs)) { p->MaybeReject(NS_ERROR_FAILURE); } else { @@ -2123,7 +2123,7 @@ Navigator::ServiceWorker() mServiceWorkerContainer = new ServiceWorkerContainer(mWindow); } - nsRefPtr ref = mServiceWorkerContainer; + RefPtr ref = mServiceWorkerContainer; return ref.forget(); } @@ -2523,7 +2523,7 @@ Navigator::HasDataStoreSupport(JSContext* aCx, JSObject* aGlobal) workers::GetWorkerPrivateFromContext(aCx); workerPrivate->AssertIsOnWorkerThread(); - nsRefPtr runnable = + RefPtr runnable = new HasDataStoreSupportRunnable(workerPrivate); runnable->Dispatch(aCx); diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 13b8b2b0a5..4ec458f63f 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -225,7 +225,7 @@ public: ErrorResult& aRv); void GetDeviceStorages(const nsAString& aType, - nsTArray >& aStores, + nsTArray >& aStores, ErrorResult& aRv); already_AddRefed @@ -258,7 +258,7 @@ public: MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv); #endif // MOZ_B2G_RIL #ifdef MOZ_GAMEPAD - void GetGamepads(nsTArray >& aGamepads, ErrorResult& aRv); + void GetGamepads(nsTArray >& aGamepads, ErrorResult& aRv); #endif // MOZ_GAMEPAD already_AddRefed GetVRDevices(ErrorResult& aRv); #ifdef MOZ_B2G_FM @@ -354,43 +354,43 @@ private: already_AddRefed FindDeviceStorage(const nsAString& aName, const nsAString& aType); - nsRefPtr mMimeTypes; - nsRefPtr mPlugins; - nsRefPtr mPermissions; - nsRefPtr mGeolocation; - nsRefPtr mNotification; - nsRefPtr mBatteryManager; - nsRefPtr mBatteryPromise; + RefPtr mMimeTypes; + RefPtr mPlugins; + RefPtr mPermissions; + RefPtr mGeolocation; + RefPtr mNotification; + RefPtr mBatteryManager; + RefPtr mBatteryPromise; #ifdef MOZ_B2G_FM - nsRefPtr mFMRadio; + RefPtr mFMRadio; #endif - nsRefPtr mPowerManager; - nsRefPtr mCellBroadcast; - nsRefPtr mIccManager; - nsRefPtr mMobileMessageManager; - nsRefPtr mTelephony; - nsRefPtr mVoicemail; - nsRefPtr mTVManager; - nsRefPtr mInputPortManager; - nsRefPtr mConnection; + RefPtr mPowerManager; + RefPtr mCellBroadcast; + RefPtr mIccManager; + RefPtr mMobileMessageManager; + RefPtr mTelephony; + RefPtr mVoicemail; + RefPtr mTVManager; + RefPtr mInputPortManager; + RefPtr mConnection; #ifdef MOZ_B2G_RIL - nsRefPtr mMobileConnections; + RefPtr mMobileConnections; #endif #ifdef MOZ_B2G_BT - nsRefPtr mBluetooth; + RefPtr mBluetooth; #endif #ifdef MOZ_AUDIO_CHANNEL_MANAGER - nsRefPtr mAudioChannelManager; + RefPtr mAudioChannelManager; #endif - nsRefPtr mCameraManager; - nsRefPtr mMediaDevices; + RefPtr mCameraManager; + RefPtr mMediaDevices; nsCOMPtr mMessagesManager; nsTArray mDeviceStorageStores; - nsRefPtr mTimeManager; - nsRefPtr mServiceWorkerContainer; + RefPtr mTimeManager; + RefPtr mServiceWorkerContainer; nsCOMPtr mWindow; - nsRefPtr mDeviceStorageAreaListener; - nsRefPtr mPresentation; + RefPtr mDeviceStorageAreaListener; + RefPtr mPresentation; // Hashtable for saving cached objects DoResolve created, so we don't create // the object twice if asked for it twice, whether due to use of "delete" or diff --git a/dom/base/NodeInfo.cpp b/dom/base/NodeInfo.cpp index 0016678375..9643456609 100644 --- a/dom/base/NodeInfo.cpp +++ b/dom/base/NodeInfo.cpp @@ -206,7 +206,7 @@ NodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const void NodeInfo::DeleteCycleCollectable() { - nsRefPtr kungFuDeathGrip = mOwnerManager; + RefPtr kungFuDeathGrip = mOwnerManager; delete this; } diff --git a/dom/base/NodeInfo.h b/dom/base/NodeInfo.h index 87751d8145..72fb087e6f 100644 --- a/dom/base/NodeInfo.h +++ b/dom/base/NodeInfo.h @@ -280,7 +280,7 @@ protected: NodeInfoInner mInner; - nsRefPtr mOwnerManager; + RefPtr mOwnerManager; /* * Members for various functions of mName+mPrefix that we can be diff --git a/dom/base/PerformanceObserver.cpp b/dom/base/PerformanceObserver.cpp index 28c09a8836..8223f1270f 100644 --- a/dom/base/PerformanceObserver.cpp +++ b/dom/base/PerformanceObserver.cpp @@ -86,7 +86,7 @@ PerformanceObserver::Constructor(const GlobalObject& aGlobal, } MOZ_ASSERT(ownerWindow->IsInnerWindow()); - nsRefPtr observer = + RefPtr observer = new PerformanceObserver(ownerWindow, aCb); return observer.forget(); } @@ -95,7 +95,7 @@ PerformanceObserver::Constructor(const GlobalObject& aGlobal, WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx); MOZ_ASSERT(workerPrivate); - nsRefPtr observer = + RefPtr observer = new PerformanceObserver(workerPrivate, aCb); return observer.forget(); } @@ -112,7 +112,7 @@ PerformanceObserver::Notify() if (mQueuedEntries.IsEmpty()) { return; } - nsRefPtr list = + RefPtr list = new PerformanceObserverEntryList(this, mQueuedEntries); ErrorResult rv; diff --git a/dom/base/PerformanceObserver.h b/dom/base/PerformanceObserver.h index ef1a74cf3e..20e9fe9116 100644 --- a/dom/base/PerformanceObserver.h +++ b/dom/base/PerformanceObserver.h @@ -9,7 +9,7 @@ #include "nsCOMPtr.h" #include "nsISupports.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsString.h" #include "nsTArray.h" #include "nsWrapperCache.h" @@ -66,11 +66,11 @@ private: ~PerformanceObserver(); nsCOMPtr mOwner; - nsRefPtr mCallback; - nsRefPtr mPerformance; + RefPtr mCallback; + RefPtr mPerformance; nsTArray mEntryTypes; bool mConnected; - nsTArray> mQueuedEntries; + nsTArray> mQueuedEntries; }; } // namespace dom diff --git a/dom/base/PerformanceObserverEntryList.cpp b/dom/base/PerformanceObserverEntryList.cpp index 19166714cb..8cf03bcbf2 100644 --- a/dom/base/PerformanceObserverEntryList.cpp +++ b/dom/base/PerformanceObserverEntryList.cpp @@ -39,10 +39,10 @@ PerformanceObserverEntryList::WrapObject(JSContext* aCx, JS::Handle a void PerformanceObserverEntryList::GetEntries( const PerformanceEntryFilterOptions& aFilter, - nsTArray>& aRetval) + nsTArray>& aRetval) { aRetval.Clear(); - for (const nsRefPtr& entry : mEntries) { + for (const RefPtr& entry : mEntries) { if (aFilter.mInitiatorType.WasPassed()) { const PerformanceResourceTiming* resourceEntry = entry->ToResourceTiming(); @@ -71,10 +71,10 @@ PerformanceObserverEntryList::GetEntries( void PerformanceObserverEntryList::GetEntriesByType( const nsAString& aEntryType, - nsTArray>& aRetval) + nsTArray>& aRetval) { aRetval.Clear(); - for (const nsRefPtr& entry : mEntries) { + for (const RefPtr& entry : mEntries) { if (entry->GetEntryType().Equals(aEntryType)) { aRetval.AppendElement(entry); } @@ -85,10 +85,10 @@ void PerformanceObserverEntryList::GetEntriesByName( const nsAString& aName, const Optional& aEntryType, - nsTArray>& aRetval) + nsTArray>& aRetval) { aRetval.Clear(); - for (const nsRefPtr& entry : mEntries) { + for (const RefPtr& entry : mEntries) { if (entry->GetName().Equals(aName)) { aRetval.AppendElement(entry); } diff --git a/dom/base/PerformanceObserverEntryList.h b/dom/base/PerformanceObserverEntryList.h index 9606fcc762..e78ce7dfb3 100644 --- a/dom/base/PerformanceObserverEntryList.h +++ b/dom/base/PerformanceObserverEntryList.h @@ -27,7 +27,7 @@ class PerformanceObserverEntryList final : public nsISupports, public: PerformanceObserverEntryList(nsISupports* aOwner, - nsTArray>& + nsTArray>& aEntries) : mOwner(aOwner) , mEntries(aEntries) @@ -46,16 +46,16 @@ public: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceObserverEntryList) void GetEntries(const PerformanceEntryFilterOptions& aFilter, - nsTArray>& aRetval); + nsTArray>& aRetval); void GetEntriesByType(const nsAString& aEntryType, - nsTArray>& aRetval); + nsTArray>& aRetval); void GetEntriesByName(const nsAString& aName, const Optional& aEntryType, - nsTArray>& aRetval); + nsTArray>& aRetval); private: nsCOMPtr mOwner; - nsTArray> mEntries; + nsTArray> mEntries; }; } // namespace dom diff --git a/dom/base/PerformanceResourceTiming.cpp b/dom/base/PerformanceResourceTiming.cpp index 5123ac3d3c..0e54013317 100644 --- a/dom/base/PerformanceResourceTiming.cpp +++ b/dom/base/PerformanceResourceTiming.cpp @@ -27,7 +27,10 @@ PerformanceResourceTiming::PerformanceResourceTiming(nsPerformanceTiming* aPerfo nsPerformance* aPerformance, const nsAString& aName) : PerformanceEntry(aPerformance, aName, NS_LITERAL_STRING("resource")), - mTiming(aPerformanceTiming) + mTiming(aPerformanceTiming), + mEncodedBodySize(0), + mTransferSize(0), + mDecodedBodySize(0) { MOZ_ASSERT(aPerformance, "Parent performance object should be provided"); } diff --git a/dom/base/PerformanceResourceTiming.h b/dom/base/PerformanceResourceTiming.h index 659429f496..cdbd8733c7 100644 --- a/dom/base/PerformanceResourceTiming.h +++ b/dom/base/PerformanceResourceTiming.h @@ -52,6 +52,16 @@ public: mInitiatorType = aInitiatorType; } + void GetNextHopProtocol(nsAString& aNextHopProtocol) const + { + aNextHopProtocol = mNextHopProtocol; + } + + void SetNextHopProtocol(const nsAString& aNextHopProtocol) + { + mNextHopProtocol = aNextHopProtocol; + } + DOMHighResTimeStamp FetchStart() const { return mTiming ? mTiming->FetchStartHighRes() @@ -128,11 +138,45 @@ public: return this; } + uint64_t TransferSize() const + { + return mTiming && mTiming->TimingAllowed() ? mTransferSize : 0; + } + + uint64_t EncodedBodySize() const + { + return mTiming && mTiming->TimingAllowed() ? mEncodedBodySize : 0; + } + + uint64_t DecodedBodySize() const + { + return mTiming && mTiming->TimingAllowed() ? mDecodedBodySize : 0; + } + + void SetEncodedBodySize(uint64_t aEncodedBodySize) + { + mEncodedBodySize = aEncodedBodySize; + } + + void SetTransferSize(uint64_t aTransferSize) + { + mTransferSize = aTransferSize; + } + + void SetDecodedBodySize(uint64_t aDecodedBodySize) + { + mDecodedBodySize = aDecodedBodySize; + } + protected: virtual ~PerformanceResourceTiming(); nsString mInitiatorType; - nsRefPtr mTiming; + nsString mNextHopProtocol; + RefPtr mTiming; + uint64_t mEncodedBodySize; + uint64_t mTransferSize; + uint64_t mDecodedBodySize; }; } // namespace dom diff --git a/dom/base/PostMessageEvent.cpp b/dom/base/PostMessageEvent.cpp index 72f338abb4..b33445189c 100644 --- a/dom/base/PostMessageEvent.cpp +++ b/dom/base/PostMessageEvent.cpp @@ -60,7 +60,7 @@ PostMessageEvent::Run() // If we bailed before this point we're going to leak mMessage, but // that's probably better than crashing. - nsRefPtr targetWindow; + RefPtr targetWindow; if (mTargetWindow->IsClosedOrClosing() || !(targetWindow = mTargetWindow->GetCurrentInnerWindowInternal()) || targetWindow->IsClosedOrClosing()) @@ -108,14 +108,14 @@ PostMessageEvent::Run() // Create the event nsCOMPtr eventTarget = do_QueryInterface(static_cast(targetWindow.get())); - nsRefPtr event = + RefPtr event = new MessageEvent(eventTarget, nullptr, nullptr); event->InitMessageEvent(NS_LITERAL_STRING("message"), false /*non-bubbling */, false /*cancelable */, messageData, mCallerOrigin, EmptyString(), mSource); - nsTArray> ports = TakeTransferredPorts(); + nsTArray> ports = TakeTransferredPorts(); event->SetPorts(new MessagePortList(static_cast(event.get()), ports)); @@ -126,7 +126,7 @@ PostMessageEvent::Run() // window if it can get a reference to it. nsIPresShell *shell = targetWindow->GetExtantDoc()->GetShell(); - nsRefPtr presContext; + RefPtr presContext; if (shell) presContext = shell->GetPresContext(); diff --git a/dom/base/PostMessageEvent.h b/dom/base/PostMessageEvent.h index c3fa369b96..2916a4818a 100644 --- a/dom/base/PostMessageEvent.h +++ b/dom/base/PostMessageEvent.h @@ -9,7 +9,7 @@ #include "mozilla/dom/StructuredCloneHolder.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsTArray.h" #include "nsThreadUtils.h" @@ -39,9 +39,9 @@ public: private: ~PostMessageEvent(); - nsRefPtr mSource; + RefPtr mSource; nsString mCallerOrigin; - nsRefPtr mTargetWindow; + RefPtr mTargetWindow; nsCOMPtr mProvidedPrincipal; bool mTrustedCaller; }; diff --git a/dom/base/ProcessGlobal.h b/dom/base/ProcessGlobal.h index 3568cbeed3..1c8de86415 100644 --- a/dom/base/ProcessGlobal.h +++ b/dom/base/ProcessGlobal.h @@ -73,7 +73,7 @@ protected: private: bool mInitialized; - nsRefPtr mMessageManager; + RefPtr mMessageManager; }; } // namespace dom diff --git a/dom/base/ScreenOrientation.cpp b/dom/base/ScreenOrientation.cpp index a1e327e969..868a1d524b 100644 --- a/dom/base/ScreenOrientation.cpp +++ b/dom/base/ScreenOrientation.cpp @@ -16,6 +16,7 @@ #include "mozilla/dom/Promise.h" +using namespace mozilla; using namespace mozilla::dom; NS_IMPL_CYCLE_COLLECTION_INHERITED(ScreenOrientation, @@ -122,8 +123,8 @@ public: protected: bool OrientationLockContains(OrientationType aOrientationType); - nsRefPtr mScreenOrientation; - nsRefPtr mPromise; + RefPtr mScreenOrientation; + RefPtr mPromise; ScreenOrientationInternal mOrientationLock; nsCOMPtr mDocument; bool mIsFullScreen; @@ -302,7 +303,7 @@ ScreenOrientation::LockInternal(ScreenOrientationInternal aOrientation, ErrorRes nsCOMPtr go = do_QueryInterface(owner); MOZ_ASSERT(go); - nsRefPtr p = Promise::Create(go, aRv); + RefPtr p = Promise::Create(go, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } @@ -376,7 +377,7 @@ ScreenOrientation::LockDeviceOrientation(ScreenOrientationInternal aOrientation, void ScreenOrientation::Unlock(ErrorResult& aRv) { - nsRefPtr p = LockInternal(eScreenOrientation_None, aRv); + RefPtr p = LockInternal(eScreenOrientation_None, aRv); } void diff --git a/dom/base/ScreenOrientation.h b/dom/base/ScreenOrientation.h index 796cb9a9bd..afb5e778d6 100644 --- a/dom/base/ScreenOrientation.h +++ b/dom/base/ScreenOrientation.h @@ -107,9 +107,9 @@ private: // Gets the responsible document as defined in the spec. nsIDocument* GetResponsibleDocument() const; - nsRefPtr mScreen; - nsRefPtr mFullScreenListener; - nsRefPtr mVisibleListener; + RefPtr mScreen; + RefPtr mFullScreenListener; + RefPtr mVisibleListener; OrientationType mType; uint16_t mAngle; }; diff --git a/dom/base/ScriptSettings.cpp b/dom/base/ScriptSettings.cpp index 182b2903ec..a4e008afe3 100644 --- a/dom/base/ScriptSettings.cpp +++ b/dom/base/ScriptSettings.cpp @@ -466,7 +466,7 @@ WarningOnlyErrorReporter(JSContext* aCx, const char* aMessage, JSErrorReport* aR MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(JSREPORT_IS_WARNING(aRep->flags)); - nsRefPtr xpcReport = new xpc::ErrorReport(); + RefPtr xpcReport = new xpc::ErrorReport(); nsPIDOMWindow* win = xpc::CurrentWindowOrNull(aCx); xpcReport->Init(aRep, aMessage, nsContentUtils::IsCallerChrome(), win ? win->WindowID() : 0); @@ -512,7 +512,7 @@ AutoJSAPI::ReportException() js::ErrorReport jsReport(cx()); if (StealException(&exn) && jsReport.init(cx(), exn)) { if (mIsMainThread) { - nsRefPtr xpcReport = new xpc::ErrorReport(); + RefPtr xpcReport = new xpc::ErrorReport(); nsCOMPtr win = xpc::WindowGlobalOrNull(errorGlobal); xpcReport->Init(jsReport.report(), jsReport.message(), nsContentUtils::IsCallerChrome(), diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index 232e7ae1d3..a2b71244c5 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -157,20 +157,20 @@ protected: // It is necessary to hold a reference to the associated nsXBLBinding // because the binding holds a reference on the nsXBLDocumentInfo that // owns |mProtoBinding|. - nsRefPtr mAssociatedBinding; + RefPtr mAssociatedBinding; - nsRefPtr mStyleSheetList; + RefPtr mStyleSheetList; // The current shadow insertion point of this ShadowRoot. HTMLShadowElement* mShadowElement; // The ShadowRoot that was created by the host element before // this ShadowRoot was created. - nsRefPtr mOlderShadow; + RefPtr mOlderShadow; // The ShadowRoot that was created by the host element after // this ShadowRoot was created. - nsRefPtr mYoungerShadow; + RefPtr mYoungerShadow; // A boolean that indicates that an insertion point was added or removed // from this ShadowRoot and that the nodes need to be redistributed into @@ -206,7 +206,7 @@ public: protected: virtual ~ShadowRootStyleSheetList(); - nsRefPtr mShadowRoot; + RefPtr mShadowRoot; }; } // namespace dom diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp index bc375c9853..a9b41c9e5a 100644 --- a/dom/base/StructuredCloneHolder.cpp +++ b/dom/base/StructuredCloneHolder.cpp @@ -403,7 +403,7 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx, // Prevent the return value from being trashed by a GC during ~nsRefPtr. JS::Rooted result(aCx); { - nsRefPtr key = new CryptoKey(global); + RefPtr key = new CryptoKey(global); if (!key->ReadStructuredClone(aReader)) { result = nullptr; } else { @@ -451,7 +451,7 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx, // Prevent the return value from being trashed by a GC during ~nsRefPtr. JS::Rooted result(aCx); { - nsRefPtr ndefRecord = new MozNDEFRecord(global); + RefPtr ndefRecord = new MozNDEFRecord(global); result = ndefRecord->ReadStructuredClone(aCx, aReader) ? ndefRecord->WrapObject(aCx, nullptr) : nullptr; } @@ -473,7 +473,7 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx, // Prevent the return value from being trashed by a GC during ~nsRefPtr. JS::Rooted result(aCx); { - nsRefPtr cert = new RTCCertificate(global); + RefPtr cert = new RTCCertificate(global); if (!cert->ReadStructuredClone(aReader)) { result = nullptr; } else { @@ -563,9 +563,9 @@ EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl, MOZ_ASSERT(aManager); } - nsRefPtr blobImpl = aBlobImpl; + RefPtr blobImpl = aBlobImpl; - const nsTArray>* subBlobImpls = + const nsTArray>* subBlobImpls = aBlobImpl->GetSubBlobImpls(); if (!subBlobImpls || !subBlobImpls->Length()) { @@ -591,16 +591,16 @@ EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl, const uint32_t subBlobCount = subBlobImpls->Length(); MOZ_ASSERT(subBlobCount); - nsTArray> newSubBlobImpls; + nsTArray> newSubBlobImpls; newSubBlobImpls.SetLength(subBlobCount); bool newBlobImplNeeded = false; for (uint32_t index = 0; index < subBlobCount; index++) { - const nsRefPtr& subBlobImpl = subBlobImpls->ElementAt(index); + const RefPtr& subBlobImpl = subBlobImpls->ElementAt(index); MOZ_ASSERT(subBlobImpl); - nsRefPtr& newSubBlobImpl = newSubBlobImpls[index]; + RefPtr& newSubBlobImpl = newSubBlobImpls[index]; newSubBlobImpl = EnsureBlobForBackgroundManager(subBlobImpl, aManager); MOZ_ASSERT(newSubBlobImpl); @@ -636,19 +636,19 @@ ReadBlob(JSContext* aCx, { MOZ_ASSERT(aHolder); MOZ_ASSERT(aIndex < aHolder->BlobImpls().Length()); - nsRefPtr blobImpl = aHolder->BlobImpls()[aIndex]; + RefPtr blobImpl = aHolder->BlobImpls()[aIndex]; blobImpl = EnsureBlobForBackgroundManager(blobImpl); MOZ_ASSERT(blobImpl); - // nsRefPtr needs to go out of scope before toObjectOrNull() is + // RefPtr needs to go out of scope before toObjectOrNull() is // called because the static analysis thinks dereferencing XPCOM objects // can GC (because in some cases it can!), and a return statement with a // JSObject* type means that JSObject* is on the stack as a raw pointer // while destructors are running. JS::Rooted val(aCx); { - nsRefPtr blob = Blob::Create(aHolder->ParentDuringRead(), blobImpl); + RefPtr blob = Blob::Create(aHolder->ParentDuringRead(), blobImpl); if (!ToJSValue(aCx, blob, &val)) { return nullptr; } @@ -666,7 +666,7 @@ WriteBlob(JSStructuredCloneWriter* aWriter, MOZ_ASSERT(aBlob); MOZ_ASSERT(aHolder); - nsRefPtr blobImpl = EnsureBlobForBackgroundManager(aBlob->Impl()); + RefPtr blobImpl = EnsureBlobForBackgroundManager(aBlob->Impl()); MOZ_ASSERT(blobImpl); // We store the position of the blobImpl in the array as index. @@ -691,7 +691,7 @@ ReadFileList(JSContext* aCx, JS::Rooted val(aCx); { - nsRefPtr fileList = new FileList(aHolder->ParentDuringRead()); + RefPtr fileList = new FileList(aHolder->ParentDuringRead()); uint32_t tag, offset; // Offset is the index of the blobImpl from which we can find the blobImpl @@ -707,13 +707,13 @@ ReadFileList(JSContext* aCx, uint32_t index = offset + i; MOZ_ASSERT(index < aHolder->BlobImpls().Length()); - nsRefPtr blobImpl = aHolder->BlobImpls()[index]; + RefPtr blobImpl = aHolder->BlobImpls()[index]; MOZ_ASSERT(blobImpl->IsFile()); blobImpl = EnsureBlobForBackgroundManager(blobImpl); MOZ_ASSERT(blobImpl); - nsRefPtr file = File::Create(aHolder->ParentDuringRead(), blobImpl); + RefPtr file = File::Create(aHolder->ParentDuringRead(), blobImpl); if (!fileList->Append(file)) { return nullptr; } @@ -750,7 +750,7 @@ WriteFileList(JSStructuredCloneWriter* aWriter, } for (uint32_t i = 0; i < aFileList->Length(); ++i) { - nsRefPtr blobImpl = + RefPtr blobImpl = EnsureBlobForBackgroundManager(aFileList->Item(i)->Impl()); MOZ_ASSERT(blobImpl); @@ -774,7 +774,7 @@ ReadFormData(JSContext* aCx, // See the serialization of the FormData for the format. JS::Rooted val(aCx); { - nsRefPtr formData = + RefPtr formData = new nsFormData(aHolder->ParentDuringRead()); Optional thirdArg; @@ -792,11 +792,11 @@ ReadFormData(JSContext* aCx, if (tag == SCTAG_DOM_BLOB) { MOZ_ASSERT(indexOrLengthOfString < aHolder->BlobImpls().Length()); - nsRefPtr blobImpl = + RefPtr blobImpl = aHolder->BlobImpls()[indexOrLengthOfString]; MOZ_ASSERT(blobImpl->IsFile()); - nsRefPtr file = + RefPtr file = File::Create(aHolder->ParentDuringRead(), blobImpl); MOZ_ASSERT(file); @@ -997,7 +997,7 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx, // aExtraData is the index of this port identifier. ErrorResult rv; - nsRefPtr port = + RefPtr port = MessagePort::Create(window, portIdentifier, rv); if (NS_WARN_IF(rv.Failed())) { return false; diff --git a/dom/base/StructuredCloneHolder.h b/dom/base/StructuredCloneHolder.h index 9d77b73662..7439587be8 100644 --- a/dom/base/StructuredCloneHolder.h +++ b/dom/base/StructuredCloneHolder.h @@ -184,7 +184,7 @@ public: !mClonedImages.IsEmpty(); } - nsTArray>& BlobImpls() + nsTArray>& BlobImpls() { MOZ_ASSERT(mSupportsCloning, "Blobs cannot be taken/set if cloning is not supported."); return mBlobImplArray; @@ -200,7 +200,7 @@ public: // This must be called if the transferring has ports generated by Read(). // MessagePorts are not thread-safe and they must be retrieved in the thread // where they are created. - nsTArray>&& TakeTransferredPorts() + nsTArray>&& TakeTransferredPorts() { MOZ_ASSERT(mSupportsTransferring); return Move(mTransferredPorts); @@ -212,7 +212,7 @@ public: return mPortIdentifiers; } - nsTArray>& GetImages() + nsTArray>& GetImages() { return mClonedImages; } @@ -289,20 +289,20 @@ protected: ContextSupport mSupportedContext; // Used for cloning blobs in the structured cloning algorithm. - nsTArray> mBlobImplArray; + nsTArray> mBlobImplArray; // This is used for sharing the backend of ImageBitmaps. // The layers::Image object must be thread-safely reference-counted. // The layers::Image object will not be written ever via any ImageBitmap // instance, so no race condition will occur. - nsTArray> mClonedImages; + nsTArray> mClonedImages; // This raw pointer is only set within ::Read() and is unset by the end. nsISupports* MOZ_NON_OWNING_REF mParent; // This array contains the ports once we've finished the reading. It's // generated from the mPortIdentifiers array. - nsTArray> mTransferredPorts; + nsTArray> mTransferredPorts; // This array contains the identifiers of the MessagePorts. Based on these we // are able to reconnect the new transferred ports with the other diff --git a/dom/base/SubtleCrypto.cpp b/dom/base/SubtleCrypto.cpp index b293ec0a7c..debce4ce65 100644 --- a/dom/base/SubtleCrypto.cpp +++ b/dom/base/SubtleCrypto.cpp @@ -36,11 +36,11 @@ SubtleCrypto::WrapObject(JSContext* aCx, JS::Handle aGivenProto) #define SUBTLECRYPTO_METHOD_BODY(Operation, aRv, ...) \ MOZ_ASSERT(mParent); \ - nsRefPtr p = Promise::Create(mParent, aRv); \ + RefPtr p = Promise::Create(mParent, aRv); \ if (aRv.Failed()) { \ return nullptr; \ } \ - nsRefPtr task = WebCryptoTask::Create ## Operation ## Task(__VA_ARGS__); \ + RefPtr task = WebCryptoTask::Create ## Operation ## Task(__VA_ARGS__); \ task->DispatchWithPromise(p); \ return p.forget(); diff --git a/dom/base/TextInputProcessor.cpp b/dom/base/TextInputProcessor.cpp index 4d4dd07458..06fbda65d8 100644 --- a/dom/base/TextInputProcessor.cpp +++ b/dom/base/TextInputProcessor.cpp @@ -73,7 +73,7 @@ TextInputProcessor::~TextInputProcessor() // the rights of TextEventDispatcher from this instance. Therefore, this // needs to cancel the composition here. if (NS_SUCCEEDED(IsValidStateForComposition())) { - nsRefPtr kungFuDeathGrip(mDispatcher); + RefPtr kungFuDeathGrip(mDispatcher); nsEventStatus status = nsEventStatus_eIgnore; mDispatcher->CommitComposition(status, &EmptyString()); } @@ -143,7 +143,7 @@ TextInputProcessor::BeginInputTransactionInternal( if (NS_WARN_IF(!docShell)) { return NS_ERROR_FAILURE; } - nsRefPtr presContext; + RefPtr presContext; nsresult rv = docShell->GetPresContext(getter_AddRefs(presContext)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -156,7 +156,7 @@ TextInputProcessor::BeginInputTransactionInternal( return NS_ERROR_FAILURE; } - nsRefPtr dispatcher = widget->GetTextEventDispatcher(); + RefPtr dispatcher = widget->GetTextEventDispatcher(); MOZ_RELEASE_ASSERT(dispatcher, "TextEventDispatcher must not be null"); // If the instance was initialized and is being initialized for same @@ -222,7 +222,7 @@ TextInputProcessor::UnlinkFromTextEventDispatcher() nsCOMPtr callback(mCallback); mCallback = nullptr; - nsRefPtr notification = + RefPtr notification = new TextInputProcessorNotification("notify-end-input-transaction"); bool result = false; callback->OnNotify(this, notification, &result); @@ -370,7 +370,7 @@ TextInputProcessor::StartComposition(nsIDOMKeyEvent* aDOMKeyEvent, MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); *aSucceeded = false; - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); WidgetKeyboardEvent* keyboardEvent; nsresult rv = @@ -406,7 +406,7 @@ NS_IMETHODIMP TextInputProcessor::SetPendingCompositionString(const nsAString& aString) { MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); nsresult rv = IsValidStateForComposition(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -419,7 +419,7 @@ TextInputProcessor::AppendClauseToPendingComposition(uint32_t aLength, uint32_t aAttribute) { MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); switch (aAttribute) { case ATTR_RAW_CLAUSE: case ATTR_SELECTED_RAW_CLAUSE: @@ -440,7 +440,7 @@ NS_IMETHODIMP TextInputProcessor::SetCaretInPendingComposition(uint32_t aOffset) { MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); nsresult rv = IsValidStateForComposition(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -462,7 +462,7 @@ TextInputProcessor::FlushPendingComposition(nsIDOMKeyEvent* aDOMKeyEvent, AutoPendingCompositionResetter resetter(this); *aSucceeded = false; - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); bool wasComposing = IsComposing(); WidgetKeyboardEvent* keyboardEvent; @@ -550,7 +550,7 @@ TextInputProcessor::CommitCompositionInternal( if (aSucceeded) { *aSucceeded = false; } - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); bool wasComposing = IsComposing(); EventDispatcherResult dispatcherResult = @@ -606,7 +606,7 @@ TextInputProcessor::CancelCompositionInternal( const WidgetKeyboardEvent* aKeyboardEvent, uint32_t aKeyFlags) { - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); EventDispatcherResult dispatcherResult = MaybeDispatchKeydownForComposition(aKeyboardEvent, aKeyFlags); @@ -639,7 +639,7 @@ TextInputProcessor::NotifyIME(TextEventDispatcher* aTextEventDispatcher, NS_ASSERTION(mForTests || mCallback, "mCallback can be null only when IME is initialized for tests"); if (mCallback) { - nsRefPtr notification; + RefPtr notification; switch (aNotification.mMessage) { case REQUEST_TO_COMMIT_COMPOSITION: { NS_ASSERTION(aTextEventDispatcher->IsComposing(), @@ -830,7 +830,7 @@ TextInputProcessor::KeydownInternal(const WidgetKeyboardEvent& aKeyboardEvent, } keyEvent.modifiers = GetActiveModifiers(); - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); rv = IsValidStateForComposition(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -912,7 +912,7 @@ TextInputProcessor::KeyupInternal(const WidgetKeyboardEvent& aKeyboardEvent, } keyEvent.modifiers = GetActiveModifiers(); - nsRefPtr kungfuDeathGrip(mDispatcher); + RefPtr kungfuDeathGrip(mDispatcher); rv = IsValidStateForComposition(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; diff --git a/dom/base/TextInputProcessor.h b/dom/base/TextInputProcessor.h index 811598c234..c6bc157906 100644 --- a/dom/base/TextInputProcessor.h +++ b/dom/base/TextInputProcessor.h @@ -105,7 +105,7 @@ private: ~AutoPendingCompositionResetter(); private: - nsRefPtr mTIP; + RefPtr mTIP; }; /** @@ -177,7 +177,7 @@ private: TextEventDispatcher* mDispatcher; // [Weak] nsCOMPtr mCallback; - nsRefPtr mModifierKeyDataArray; + RefPtr mModifierKeyDataArray; bool mForTests; }; diff --git a/dom/base/URL.cpp b/dom/base/URL.cpp index 3f8d8eb4f6..ce9f785cb8 100644 --- a/dom/base/URL.cpp +++ b/dom/base/URL.cpp @@ -78,7 +78,7 @@ URL::Constructor(nsISupports* aParent, const nsAString& aUrl, nsresult rv = NS_NewURI(getter_AddRefs(baseUri), aBase, nullptr, nullptr, nsContentUtils::GetIOService()); if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.ThrowTypeError(MSG_INVALID_URL, &aBase); + aRv.ThrowTypeError(&aBase); return nullptr; } @@ -94,11 +94,11 @@ URL::Constructor(nsISupports* aParent, const nsAString& aUrl, nsIURI* aBase, nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, nullptr, aBase, nsContentUtils::GetIOService()); if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.ThrowTypeError(MSG_INVALID_URL, &aUrl); + aRv.ThrowTypeError(&aUrl); return nullptr; } - nsRefPtr url = new URL(aParent, uri.forget()); + RefPtr url = new URL(aParent, uri.forget()); return url.forget(); } @@ -230,7 +230,7 @@ URL::SetHref(const nsAString& aHref, ErrorResult& aRv) rv = ioService->NewURI(href, nullptr, nullptr, getter_AddRefs(uri)); if (NS_FAILED(rv)) { nsAutoString label(aHref); - aRv.ThrowTypeError(MSG_INVALID_URL, &label); + aRv.ThrowTypeError(&label); return; } diff --git a/dom/base/URL.h b/dom/base/URL.h index 81e5625a6b..04be06b71c 100644 --- a/dom/base/URL.h +++ b/dom/base/URL.h @@ -167,7 +167,7 @@ private: nsCOMPtr mParent; nsCOMPtr mURI; - nsRefPtr mSearchParams; + RefPtr mSearchParams; friend class mozilla::dom::workers::URLProxy; }; diff --git a/dom/base/URLSearchParams.cpp b/dom/base/URLSearchParams.cpp index 4191fc59aa..9780a54a92 100644 --- a/dom/base/URLSearchParams.cpp +++ b/dom/base/URLSearchParams.cpp @@ -334,7 +334,7 @@ URLSearchParams::Constructor(const GlobalObject& aGlobal, const nsAString& aInit, ErrorResult& aRv) { - nsRefPtr sp = + RefPtr sp = new URLSearchParams(aGlobal.GetAsSupports(), nullptr); sp->ParseInput(NS_ConvertUTF16toUTF8(aInit)); @@ -346,7 +346,7 @@ URLSearchParams::Constructor(const GlobalObject& aGlobal, URLSearchParams& aInit, ErrorResult& aRv) { - nsRefPtr sp = + RefPtr sp = new URLSearchParams(aGlobal.GetAsSupports(), aInit); return sp.forget(); diff --git a/dom/base/URLSearchParams.h b/dom/base/URLSearchParams.h index 286f10b6f6..3c36524d85 100644 --- a/dom/base/URLSearchParams.h +++ b/dom/base/URLSearchParams.h @@ -177,7 +177,7 @@ private: UniquePtr mParams; nsCOMPtr mParent; - nsRefPtr mObserver; + RefPtr mObserver; }; } // namespace dom diff --git a/dom/base/WebSocket.cpp b/dom/base/WebSocket.cpp index 206aa61d7b..16950e3ea9 100644 --- a/dom/base/WebSocket.cpp +++ b/dom/base/WebSocket.cpp @@ -173,7 +173,7 @@ public: nsresult CancelInternal(); - nsRefPtr mWebSocket; + RefPtr mWebSocket; nsCOMPtr mChannel; @@ -276,7 +276,7 @@ public: } private: - nsRefPtr mWebSocketImpl; + RefPtr mWebSocketImpl; }; //----------------------------------------------------------------------------- @@ -338,7 +338,7 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI, if (!NS_IsMainThread()) { MOZ_ASSERT(mWorkerPrivate); - nsRefPtr runnable = + RefPtr runnable = new PrintErrorOnConsoleRunnable(this, aBundleURI, aError, aFormatStrings, aFormatStringsLen); runnable->Dispatch(mWorkerPrivate->GetJSContext()); @@ -463,7 +463,7 @@ public: } private: - nsRefPtr mImpl; + RefPtr mImpl; uint16_t mReasonCode; const nsCString mReasonString; }; @@ -475,7 +475,7 @@ WebSocketImpl::CloseConnection(uint16_t aReasonCode, const nsACString& aReasonString) { if (!IsTargetThread()) { - nsRefPtr runnable = + RefPtr runnable = new CloseConnectionRunnable(this, aReasonCode, aReasonString); return Dispatch(runnable, NS_DISPATCH_NORMAL); } @@ -507,7 +507,7 @@ WebSocketImpl::CloseConnection(uint16_t aReasonCode, return mChannel->Close(aReasonCode, aReasonString); } - nsRefPtr runnable = + RefPtr runnable = new CancelWebSocketRunnable(mChannel, aReasonCode, aReasonString); return NS_DispatchToMainThread(runnable); } @@ -622,14 +622,14 @@ WebSocketImpl::Disconnect() if (NS_IsMainThread()) { DisconnectInternal(); } else { - nsRefPtr runnable = + RefPtr runnable = new DisconnectInternalRunnable(this); runnable->Dispatch(mWorkerPrivate->GetJSContext()); } // DontKeepAliveAnyMore() can release the object. So hold a reference to this // until the end of the method. - nsRefPtr kungfuDeathGrip = this; + RefPtr kungfuDeathGrip = this; nsCOMPtr mainThread; if (NS_FAILED(NS_GetMainThread(getter_AddRefs(mainThread))) || @@ -772,7 +772,7 @@ WebSocketImpl::OnStart(nsISupports* aContext) // Let's keep the object alive because the webSocket can be CCed in the // onopen callback. - nsRefPtr webSocket = mWebSocket; + RefPtr webSocket = mWebSocket; // Call 'onopen' rv = webSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open")); @@ -1220,8 +1220,8 @@ WebSocket::Constructor(const GlobalObject& aGlobal, protocolArray.AppendElement(protocolElement); } - nsRefPtr webSocket = new WebSocket(ownerWindow); - nsRefPtr kungfuDeathGrip = webSocket->mImpl; + RefPtr webSocket = new WebSocket(ownerWindow); + RefPtr kungfuDeathGrip = webSocket->mImpl; bool connectionFailed = true; @@ -1243,7 +1243,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal, NS_WARNING("Failed to get line number and filename in workers."); } - nsRefPtr runnable = + RefPtr runnable = new InitRunnable(webSocket->mImpl, aUrl, protocolArray, nsAutoCString(file.get()), lineno, column, aRv, &connectionFailed); @@ -1312,7 +1312,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal, MOZ_ASSERT(principal); webSocket->mImpl->AsyncOpen(principal, aRv); } else { - nsRefPtr runnable = + RefPtr runnable = new AsyncOpenRunnable(webSocket->mImpl, aRv); runnable->Dispatch(aGlobal.Context()); } @@ -1415,7 +1415,7 @@ WebSocketImpl::Init(JSContext* aCx, // We need to keep the implementation alive in case the init disconnects it // because of some error. - nsRefPtr kungfuDeathGrip = this; + RefPtr kungfuDeathGrip = this; // Attempt to kill "ghost" websocket: but usually too early for check to fail aRv = mWebSocket->CheckInnerWindowCorrectness(); @@ -1646,7 +1646,7 @@ public: } } private: - nsRefPtr mWebSocketImpl; + RefPtr mWebSocketImpl; }; nsresult @@ -1724,7 +1724,7 @@ WebSocketImpl::DispatchConnectionCloseEvents() // Let's keep the object alive because the webSocket can be CCed in the // onerror or in the onclose callback. - nsRefPtr webSocket = mWebSocket; + RefPtr webSocket = mWebSocket; // Call 'onerror' if needed if (mFailed) { @@ -1757,7 +1757,7 @@ WebSocket::CreateAndDispatchSimpleEvent(const nsAString& aName) return NS_OK; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); // it doesn't bubble, and it isn't cancelable rv = event->InitEvent(aName, false, false); @@ -1835,7 +1835,7 @@ WebSocket::CreateAndDispatchMessageEvent(JSContext* aCx, // create an event that uses the MessageEvent interface, // which does not bubble, is not cancelable, and has no default action - nsRefPtr event = NS_NewDOMMessageEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMMessageEvent(this, nullptr, nullptr); rv = event->InitMessageEvent(NS_LITERAL_STRING("message"), false, false, jsData, mImpl->mUTF16Origin, EmptyString(), @@ -1868,7 +1868,7 @@ WebSocket::CreateAndDispatchCloseEvent(bool aWasClean, init.mCode = aCode; init.mReason = aReason; - nsRefPtr event = + RefPtr event = CloseEvent::Constructor(this, NS_LITERAL_STRING("close"), init); event->SetTrusted(true); @@ -2138,7 +2138,7 @@ WebSocketImpl::UpdateURI() AssertIsOnTargetThread(); // Check for Redirections - nsRefPtr channel; + RefPtr channel; channel = static_cast(mChannel.get()); MOZ_ASSERT(channel); @@ -2502,7 +2502,7 @@ public: } private: - nsRefPtr mImpl; + RefPtr mImpl; }; } // namespace @@ -2515,7 +2515,7 @@ WebSocketImpl::Cancel(nsresult aStatus) if (!mIsMainThread) { MOZ_ASSERT(mWorkerPrivate); - nsRefPtr runnable = + RefPtr runnable = new CancelRunnable(mWorkerPrivate, this); if (!runnable->Dispatch(nullptr)) { return NS_ERROR_FAILURE; @@ -2630,7 +2630,7 @@ namespace { class WorkerRunnableDispatcher final : public WorkerRunnable { - nsRefPtr mWebSocketImpl; + RefPtr mWebSocketImpl; public: WorkerRunnableDispatcher(WebSocketImpl* aImpl, WorkerPrivate* aWorkerPrivate, @@ -2707,7 +2707,7 @@ WebSocketImpl::Dispatch(already_AddRefed&& aEvent, uint32_t aFlags) // If the target is a worker, we have to use a custom WorkerRunnableDispatcher // runnable. - nsRefPtr event = + RefPtr event = new WorkerRunnableDispatcher(this, mWorkerPrivate, event_ref.forget()); if (!event->Dispatch(nullptr)) { diff --git a/dom/base/WindowNamedPropertiesHandler.cpp b/dom/base/WindowNamedPropertiesHandler.cpp index 169308d5a9..8c8c013c7b 100644 --- a/dom/base/WindowNamedPropertiesHandler.cpp +++ b/dom/base/WindowNamedPropertiesHandler.cpp @@ -161,7 +161,7 @@ WindowNamedPropertiesHandler::defineProperty(JSContext* aCx, JS::ObjectOpResult &result) const { ErrorResult rv; - rv.ThrowTypeError(MSG_DEFINEPROPERTY_ON_GSP); + rv.ThrowTypeError(); rv.ReportErrorWithMessage(aCx); return false; } diff --git a/dom/base/moz.build b/dom/base/moz.build index aaac5f087b..750de6b66e 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -84,6 +84,7 @@ EXPORTS += [ 'nsHostObjectURI.h', 'nsIAnimationObserver.h', 'nsIAttribute.h', + 'nsIConsoleReportCollector.h', 'nsIContent.h', 'nsIContentInlines.h', 'nsIContentIterator.h', @@ -142,6 +143,7 @@ if CONFIG['MOZ_WEBRTC']: ] EXPORTS.mozilla += [ + 'ConsoleReportCollector.h', 'CORSMode.h', 'FeedWriterEnabled.h', 'TextInputProcessor.h', @@ -219,6 +221,7 @@ UNIFIED_SOURCES += [ 'ChromeUtils.cpp', 'Comment.cpp', 'Console.cpp', + 'ConsoleReportCollector.cpp', 'Crypto.cpp', 'DirectionalityUtils.cpp', 'DocumentFragment.cpp', diff --git a/dom/base/nsAttrAndChildArray.cpp b/dom/base/nsAttrAndChildArray.cpp index ec66820b0e..6a3d02970f 100644 --- a/dom/base/nsAttrAndChildArray.cpp +++ b/dom/base/nsAttrAndChildArray.cpp @@ -465,7 +465,7 @@ nsAttrAndChildArray::RemoveAttrAt(uint32_t aPos, nsAttrValue& aValue) return NS_OK; } - nsRefPtr mapped = + RefPtr mapped = GetModifiableMapped(nullptr, nullptr, false); mapped->RemoveAttrAt(aPos, aValue); @@ -582,7 +582,7 @@ nsAttrAndChildArray::SetAndTakeMappedAttr(nsIAtom* aLocalName, willAdd = !mImpl->mMappedAttrs->GetAttr(aLocalName); } - nsRefPtr mapped = + RefPtr mapped = GetModifiableMapped(aContent, aSheet, willAdd); mapped->SetAndTakeAttr(aLocalName, aValue); @@ -599,7 +599,7 @@ nsAttrAndChildArray::DoSetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet) return NS_OK; } - nsRefPtr mapped = + RefPtr mapped = GetModifiableMapped(nullptr, nullptr, false); mapped->SetStyleSheet(aSheet); @@ -738,13 +738,13 @@ nsAttrAndChildArray::MakeMappedUnique(nsMappedAttributes* aAttributes) if (!aAttributes->GetStyleSheet()) { // This doesn't currently happen, but it could if we do loading right - nsRefPtr mapped(aAttributes); + RefPtr mapped(aAttributes); mapped.swap(mImpl->mMappedAttrs); return NS_OK; } - nsRefPtr mapped = + RefPtr mapped = aAttributes->GetStyleSheet()->UniqueMappedAttributes(aAttributes); NS_ENSURE_TRUE(mapped, NS_ERROR_OUT_OF_MEMORY); diff --git a/dom/base/nsAttrValue.cpp b/dom/base/nsAttrValue.cpp index c938976f2e..cae81b83f1 100644 --- a/dom/base/nsAttrValue.cpp +++ b/dom/base/nsAttrValue.cpp @@ -1690,7 +1690,7 @@ nsAttrValue::ParseStyleAttribute(const nsAString& aString, css::Loader* cssLoader = ownerDoc->CSSLoader(); nsCSSParser cssParser(cssLoader); - nsRefPtr rule; + RefPtr rule; cssParser.ParseStyleAttribute(aString, docURI, baseURI, aElement->NodePrincipal(), getter_AddRefs(rule)); @@ -1876,7 +1876,7 @@ nsAttrValue::GetStringBuffer(const nsAString& aValue) const return nullptr; } - nsRefPtr buf = nsStringBuffer::FromString(aValue); + RefPtr buf = nsStringBuffer::FromString(aValue); if (buf && (buf->StorageSize()/sizeof(char16_t) - 1) == len) { return buf.forget(); } diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index 0256e9f471..b32c254fa0 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -350,7 +350,7 @@ DragDataProducer::GetNodeString(nsIContent* inNode, // use a range to get the text-equivalent of the node nsCOMPtr doc = node->OwnerDoc(); mozilla::ErrorResult rv; - nsRefPtr range = doc->CreateRange(rv); + RefPtr range = doc->CreateRange(rv); if (range) { range->SelectNode(*node, rv); range->ToString(outNodeString); @@ -420,7 +420,7 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer, if (isChromeShell && !editingElement) { nsCOMPtr flo = do_QueryInterface(mTarget); if (flo) { - nsRefPtr fl = flo->GetFrameLoader(); + RefPtr fl = flo->GetFrameLoader(); if (fl) { TabParent* tp = static_cast(fl->GetRemoteBrowser()); if (tp) { diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp index db17726287..1100c43e06 100644 --- a/dom/base/nsContentIterator.cpp +++ b/dom/base/nsContentIterator.cpp @@ -1146,7 +1146,7 @@ protected: virtual void LastRelease() override; - nsRefPtr mRange; + RefPtr mRange; // these arrays all typically are used and have elements nsAutoTArray mEndNodes; diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index d412ae6f29..d83a17d3b3 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -198,7 +198,7 @@ NS_GetContentList(nsINode* aRootNode, { NS_ASSERTION(aRootNode, "content list has to have a root"); - nsRefPtr list; + RefPtr list; nsContentListKey hashKey(aRootNode, aMatchNameSpaceId, aTagname); uint32_t recentlyUsedCacheIndex = RecentlyUsedCacheIndex(hashKey); nsContentList* cachedList = sRecentlyUsedContentLists[recentlyUsedCacheIndex]; @@ -308,7 +308,7 @@ GetFuncStringContentList(nsINode* aRootNode, { NS_ASSERTION(aRootNode, "content list has to have a root"); - nsRefPtr list; + RefPtr list; static const PLDHashTableOps hash_table_ops = { diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index ddc0cf1773..760b541246 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -120,7 +120,7 @@ class ContentPermissionRequestParent : public PContentPermissionRequestParent nsCOMPtr mPrincipal; nsCOMPtr mElement; - nsRefPtr mProxy; + RefPtr mProxy; nsTArray mRequests; private: @@ -249,7 +249,7 @@ nsContentPermissionUtils::ConvertPermissionRequestToArray(nsTArray cpt = + RefPtr cpt = new ContentPermissionType(aSrcArray[i].type(), aSrcArray[i].access(), aSrcArray[i].options()); @@ -307,7 +307,7 @@ nsContentPermissionUtils::CreatePermissionArray(const nsACString& aType, nsIArray** aTypesArray) { nsCOMPtr types = do_CreateInstance(NS_ARRAY_CONTRACTID); - nsRefPtr permType = new ContentPermissionType(aType, + RefPtr permType = new ContentPermissionType(aType, aAccess, aOptions); types->AppendElement(permType, false); @@ -338,7 +338,7 @@ nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, n // for content process if (XRE_IsContentProcess()) { - nsRefPtr req = + RefPtr req = new RemotePermissionRequest(aRequest, aWindow); MOZ_ASSERT(NS_IsMainThread()); // IPC can only be execute on main thread. @@ -690,7 +690,7 @@ nsContentPermissionRequestProxy::GetRequester(nsIContentPermissionRequester** aR { NS_ENSURE_ARG_POINTER(aRequester); - nsRefPtr requester = mRequester; + RefPtr requester = mRequester; requester.forget(aRequester); return NS_OK; } diff --git a/dom/base/nsContentPermissionHelper.h b/dom/base/nsContentPermissionHelper.h index b8785ab05d..3b030d9ad3 100644 --- a/dom/base/nsContentPermissionHelper.h +++ b/dom/base/nsContentPermissionHelper.h @@ -122,7 +122,7 @@ private: virtual ~nsContentPermissionRequester(); nsCOMPtr mWindow; - nsRefPtr mListener; + RefPtr mListener; }; } // namespace dom @@ -171,7 +171,7 @@ private: // Non-owning pointer to the ContentPermissionRequestParent object which owns this proxy. ContentPermissionRequestParent* mParent; nsTArray mPermissionRequests; - nsRefPtr mRequester; + RefPtr mRequester; }; /** @@ -217,7 +217,7 @@ private: nsCOMPtr mRequest; nsCOMPtr mWindow; bool mIPCOpen; - nsRefPtr mListener; + RefPtr mListener; }; #endif // nsContentPermissionHelper_h diff --git a/dom/base/nsContentPolicy.cpp b/dom/base/nsContentPolicy.cpp index 73a9f547af..19078a4833 100644 --- a/dom/base/nsContentPolicy.cpp +++ b/dom/base/nsContentPolicy.cpp @@ -193,7 +193,7 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod, MOZ_ASSERT(window->IsOuterWindow()); if (topFrameElement) { - nsCOMPtr topWindow = window->GetScriptableTop(); + nsCOMPtr topWindow = window->GetScriptableTop(); isTopLevel = topWindow == window; } else { // If we don't have a top frame element, then requestingContext is diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index bd57f94abb..e954cdaa5a 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -1538,7 +1538,7 @@ nsContentSink::DropParserAndPerfHint(void) // actually broken. // Drop our reference to the parser to get rid of a circular // reference. - nsRefPtr kungFuDeathGrip(mParser.forget()); + RefPtr kungFuDeathGrip(mParser.forget()); if (mDynamicLowerValue) { // Reset the performance hint which was set to FALSE diff --git a/dom/base/nsContentSink.h b/dom/base/nsContentSink.h index f66359065b..1339cef3ad 100644 --- a/dom/base/nsContentSink.h +++ b/dom/base/nsContentSink.h @@ -273,12 +273,12 @@ private: protected: nsCOMPtr mDocument; - nsRefPtr mParser; + RefPtr mParser; nsCOMPtr mDocumentURI; nsCOMPtr mDocShell; - nsRefPtr mCSSLoader; - nsRefPtr mNodeInfoManager; - nsRefPtr mScriptLoader; + RefPtr mCSSLoader; + RefPtr mNodeInfoManager; + RefPtr mScriptLoader; // back off timer notification after count int32_t mBackoffCount; diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index aa93963cb5..e179176c00 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -404,7 +404,7 @@ protected: // declared protected to silence clang warnings const void *mKey; // must be first, to look like PLDHashEntryStub public: - nsRefPtr mListenerManager; + RefPtr mListenerManager; }; static void @@ -488,7 +488,7 @@ nsContentUtils::Init() // We use the constructor here because we want infallible initialization; we // apparently don't care whether sNullSubjectPrincipal has a sane URI or not. - nsRefPtr nullPrincipal = new nsNullPrincipal(); + RefPtr nullPrincipal = new nsNullPrincipal(); nullPrincipal->Init(); nullPrincipal.forget(&sNullSubjectPrincipal); @@ -1767,7 +1767,7 @@ nsContentUtils::IsControlledByServiceWorker(nsIDocument* aDocument) return false; } - nsRefPtr swm = + RefPtr swm = workers::ServiceWorkerManager::GetInstance(); MOZ_ASSERT(swm); @@ -3229,7 +3229,7 @@ already_AddRefed nsContentUtils::GetStaticRequest(imgRequestProxy* aRequest) { NS_ENSURE_TRUE(aRequest, nullptr); - nsRefPtr retval; + RefPtr retval; aRequest->GetStaticRequest(getter_AddRefs(retval)); return retval.forget(); } @@ -4218,7 +4218,7 @@ nsContentUtils::RemoveListenerManager(nsINode *aNode) auto entry = static_cast (sEventListenerManagersHash->Search(aNode)); if (entry) { - nsRefPtr listenerManager; + RefPtr listenerManager; listenerManager.swap(entry->mListenerManager); // Remove the entry and *then* do operations that could cause further // modification of sEventListenerManagersHash. See bug 334177. @@ -4299,7 +4299,7 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode, #endif if (isHTML) { - nsRefPtr frag = + RefPtr frag = new DocumentFragment(document->NodeInfoManager()); nsCOMPtr contextAsContent = do_QueryInterface(aContextNode); @@ -4629,7 +4629,7 @@ nsContentUtils::SetNodeTextContent(nsIContent* aContent, return NS_OK; } - nsRefPtr textContent = + RefPtr textContent = new nsTextNode(aContent->NodeInfo()->NodeInfoManager()); textContent->SetText(aValue, true); @@ -6227,7 +6227,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx, { uint32_t blobLen = aData.Length(); void* blobData = moz_malloc(blobLen); - nsRefPtr blob; + RefPtr blob; if (blobData) { memcpy(blobData, aData.BeginReading(), blobLen); blob = mozilla::dom::Blob::CreateMemoryBlob(aParent, blobData, blobLen, @@ -6559,7 +6559,7 @@ LayerManagerForDocumentInternal(const nsIDocument *aDoc, bool aRequirePersistent { nsIWidget *widget = nsContentUtils::WidgetForDocument(aDoc); if (widget) { - nsRefPtr manager = + RefPtr manager = widget->GetLayerManager(aRequirePersistent ? nsIWidget::LAYER_MANAGER_PERSISTENT : nsIWidget::LAYER_MANAGER_CURRENT, aAllowRetaining); @@ -6817,7 +6817,7 @@ CheckForWindowedPlugins(nsISupports* aSupports, void* aResult) if (!olc) { return; } - nsRefPtr plugin; + RefPtr plugin; olc->GetPluginInstance(getter_AddRefs(plugin)); if (!plugin) { return; @@ -7512,7 +7512,7 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable, image->GetFrame(imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE); if (surface) { - mozilla::RefPtr dataSurface = + RefPtr dataSurface = surface->GetDataSurface(); size_t length; int32_t stride; @@ -8150,10 +8150,21 @@ nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj) // static bool -nsContentUtils::IsWorkerLoad(nsContentPolicyType aType) +nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel) { - return aType == nsIContentPolicy::TYPE_INTERNAL_WORKER || - aType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER; + nsLoadFlags loadFlags = 0; + aChannel->GetLoadFlags(&loadFlags); + if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) { + return true; + } + + nsCOMPtr loadInfo = aChannel->GetLoadInfo(); + if (!loadInfo) { + return false; + } + nsContentPolicyType type = loadInfo->InternalContentPolicyType(); + return type == nsIContentPolicy::TYPE_INTERNAL_WORKER || + type == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER; } // static, public diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 9f4ccc8f73..859dd1dfcf 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2515,7 +2515,7 @@ public: static bool PushEnabled(JSContext* aCx, JSObject* aObj); - static bool IsWorkerLoad(nsContentPolicyType aLoadType); + static bool IsNonSubresourceRequest(nsIChannel* aChannel); // The order of these entries matters, as we use std::min for total ordering // of permissions. Private Browsing is considered to be more limiting diff --git a/dom/base/nsCopySupport.cpp b/dom/base/nsCopySupport.cpp index d468f6ebb3..d39781b1b9 100644 --- a/dom/base/nsCopySupport.cpp +++ b/dom/base/nsCopySupport.cpp @@ -309,7 +309,7 @@ nsCopySupport::GetTransferableForNode(nsINode* aNode, NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr node = do_QueryInterface(aNode); NS_ENSURE_TRUE(node, NS_ERROR_FAILURE); - nsRefPtr range = new nsRange(aNode); + RefPtr range = new nsRange(aNode); rv = range->SelectNode(node); NS_ENSURE_SUCCESS(rv, rv); ErrorResult result; @@ -689,7 +689,7 @@ nsCopySupport::FireClipboardEvent(EventMessage aEventMessage, // next, fire the cut, copy or paste event bool doDefault = true; - nsRefPtr clipboardData; + RefPtr clipboardData; if (chromeShell || Preferences::GetBool("dom.event.clipboardevents.enabled", true)) { clipboardData = new DataTransfer(piWindow, aEventMessage, aEventMessage == ePaste, diff --git a/dom/base/nsDOMAttributeMap.cpp b/dom/base/nsDOMAttributeMap.cpp index 501e74e61b..87e58627be 100644 --- a/dom/base/nsDOMAttributeMap.cpp +++ b/dom/base/nsDOMAttributeMap.cpp @@ -41,7 +41,7 @@ nsDOMAttributeMap::nsDOMAttributeMap(Element* aContent) * Clear map pointer for attributes. */ PLDHashOperator -RemoveMapRef(nsAttrHashKey::KeyType aKey, nsRefPtr& aData, +RemoveMapRef(nsAttrHashKey::KeyType aKey, RefPtr& aData, void* aUserArg) { aData->SetMap(nullptr); @@ -71,7 +71,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END PLDHashOperator -TraverseMapEntry(nsAttrHashKey::KeyType aKey, nsRefPtr& aData, +TraverseMapEntry(nsAttrHashKey::KeyType aKey, RefPtr& aData, void* aUserArg) { nsCycleCollectionTraversalCallback *cb = @@ -126,7 +126,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMAttributeMap) PLDHashOperator SetOwnerDocumentFunc(nsAttrHashKey::KeyType aKey, - nsRefPtr& aData, + RefPtr& aData, void* aUserArg) { nsresult rv = aData->SetOwnerDocument(static_cast(aUserArg)); @@ -164,13 +164,13 @@ nsDOMAttributeMap::RemoveAttribute(mozilla::dom::NodeInfo* aNodeInfo) nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom()); - nsRefPtr node; + RefPtr node; if (!mAttributeCache.Get(attr, getter_AddRefs(node))) { nsAutoString value; // As we are removing the attribute we need to set the current value in // the attribute node. mContent->GetAttr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom(), value); - nsRefPtr ni = aNodeInfo; + RefPtr ni = aNodeInfo; node = new Attr(nullptr, ni.forget(), value, true); } else { @@ -193,8 +193,8 @@ nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo, bool aNsAware Attr* node = mAttributeCache.GetWeak(attr); if (!node) { - nsRefPtr ni = aNodeInfo; - nsRefPtr newAttr = + RefPtr ni = aNodeInfo; + RefPtr newAttr = new Attr(this, ni.forget(), EmptyString(), aNsAware); mAttributeCache.Put(attr, newAttr); node = newAttr; @@ -209,7 +209,7 @@ nsDOMAttributeMap::NamedGetter(const nsAString& aAttrName, bool& aFound) aFound = false; NS_ENSURE_TRUE(mContent, nullptr); - nsRefPtr ni = mContent->GetExistingAttrNameFromQName(aAttrName); + RefPtr ni = mContent->GetExistingAttrNameFromQName(aAttrName); if (!ni) { return nullptr; } @@ -284,7 +284,7 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr, // setting a preexisting attribute is a no-op, just return the same // node. - nsRefPtr attribute = &aAttr; + RefPtr attribute = &aAttr; return attribute.forget(); } @@ -300,7 +300,7 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr, } // Get nodeinfo and preexisting attribute (if it exists) - nsRefPtr oldNi; + RefPtr oldNi; if (!aWithNS) { nsAutoString name; @@ -323,10 +323,10 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr, } } - nsRefPtr attr; + RefPtr attr; if (oldNi) { - nsRefPtr oldAttr = GetAttribute(oldNi, true); + RefPtr oldAttr = GetAttribute(oldNi, true); if (oldAttr == &aAttr) { return oldAttr.forget(); @@ -361,7 +361,7 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr, nsAutoString value; aAttr.GetValue(value); - nsRefPtr ni = aAttr.NodeInfo(); + RefPtr ni = aAttr.NodeInfo(); // Add the new attribute to the attribute map before updating // its value in the element. @see bug 364413. @@ -382,7 +382,7 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr, already_AddRefed nsDOMAttributeMap::RemoveNamedItem(NodeInfo* aNodeInfo, ErrorResult& aError) { - nsRefPtr attribute = GetAttribute(aNodeInfo, true); + RefPtr attribute = GetAttribute(aNodeInfo, true); // This removes the attribute node from the attribute map. aError = mContent->UnsetAttr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom(), true); return attribute.forget(); @@ -407,7 +407,7 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError) return nullptr; } - nsRefPtr ni = mContent->GetExistingAttrNameFromQName(aName); + RefPtr ni = mContent->GetExistingAttrNameFromQName(aName); if (!ni) { aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR); return nullptr; @@ -429,7 +429,7 @@ nsDOMAttributeMap::IndexedGetter(uint32_t aIndex, bool& aFound) aFound = true; // Don't use the nodeinfo even if one exists since it can have the wrong // owner document. - nsRefPtr ni = mContent->NodeInfo()->NodeInfoManager()-> + RefPtr ni = mContent->NodeInfo()->NodeInfoManager()-> GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID(), nsIDOMNode::ATTRIBUTE_NODE); return GetAttribute(ni, true); @@ -478,7 +478,7 @@ Attr* nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI, const nsAString& aLocalName) { - nsRefPtr ni = GetAttrNodeInfo(aNamespaceURI, aLocalName); + RefPtr ni = GetAttrNodeInfo(aNamespaceURI, aLocalName); if (!ni) { return nullptr; } @@ -514,7 +514,7 @@ nsDOMAttributeMap::GetAttrNodeInfo(const nsAString& aNamespaceURI, // we're purposefully ignoring the prefix. if (nameSpaceID == attrNS && nameAtom->Equals(aLocalName)) { - nsRefPtr ni; + RefPtr ni; ni = mContent->NodeInfo()->NodeInfoManager()-> GetNodeInfo(nameAtom, name->GetPrefix(), nameSpaceID, nsIDOMNode::ATTRIBUTE_NODE); @@ -542,7 +542,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI, const nsAString& aLocalName, ErrorResult& aError) { - nsRefPtr ni = GetAttrNodeInfo(aNamespaceURI, aLocalName); + RefPtr ni = GetAttrNodeInfo(aNamespaceURI, aLocalName); if (!ni) { aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR); return nullptr; diff --git a/dom/base/nsDOMCaretPosition.cpp b/dom/base/nsDOMCaretPosition.cpp index f5762f47f4..0ee7c305f5 100644 --- a/dom/base/nsDOMCaretPosition.cpp +++ b/dom/base/nsDOMCaretPosition.cpp @@ -33,8 +33,8 @@ nsDOMCaretPosition::GetClientRect() const return nullptr; } - nsRefPtr rect; - nsRefPtr domRange; + RefPtr rect; + RefPtr domRange; nsCOMPtr node; if (mAnonymousContentNode) { diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 3721497466..a2861a8975 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1755,7 +1755,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx, name_struct->mType == nsGlobalNameStruct::eTypeClassProto), "Wrong type or missing ci_data!"); - nsRefPtr constructor; + RefPtr constructor; nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct, aWin, getter_AddRefs(constructor)); NS_ENSURE_SUCCESS(rv, rv); @@ -2125,7 +2125,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx, if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) { // We're resolving a name of a DOM interface for which there is no // direct DOM class, create a constructor object... - nsRefPtr constructor; + RefPtr constructor; rv = nsDOMConstructor::Create(class_name, nullptr, name_struct, @@ -2234,7 +2234,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx, } if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) { - nsRefPtr constructor; + RefPtr constructor; rv = nsDOMConstructor::Create(class_name, nullptr, name_struct, static_cast(aWin), getter_AddRefs(constructor)); diff --git a/dom/base/nsDOMDataChannel.cpp b/dom/base/nsDOMDataChannel.cpp index d86784bc92..69503c300f 100644 --- a/dom/base/nsDOMDataChannel.cpp +++ b/dom/base/nsDOMDataChannel.cpp @@ -413,7 +413,7 @@ nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData, jsData.setString(jsString); } - nsRefPtr event = NS_NewDOMMessageEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMMessageEvent(this, nullptr, nullptr); rv = event->InitMessageEvent(NS_LITERAL_STRING("message"), false, false, jsData, mOrigin, EmptyString(), nullptr); @@ -454,7 +454,7 @@ nsDOMDataChannel::OnSimpleEvent(nsISupports* aContext, const nsAString& aName) return NS_OK; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); rv = event->InitEvent(aName, false, false); NS_ENSURE_SUCCESS(rv,rv); @@ -500,7 +500,7 @@ NS_NewDOMDataChannel(already_AddRefed&& aDataChannel, nsPIDOMWindow* aWindow, nsIDOMDataChannel** aDomDataChannel) { - nsRefPtr domdc = + RefPtr domdc = new nsDOMDataChannel(aDataChannel, aWindow); nsresult rv = domdc->Init(aWindow); diff --git a/dom/base/nsDOMDataChannel.h b/dom/base/nsDOMDataChannel.h index 7369a15e96..9fae54dbba 100644 --- a/dom/base/nsDOMDataChannel.h +++ b/dom/base/nsDOMDataChannel.h @@ -114,7 +114,7 @@ private: uint32_t aMsgLength, bool aIsBinary, mozilla::ErrorResult& aRv); // Owning reference - nsRefPtr mDataChannel; + RefPtr mDataChannel; nsString mOrigin; enum DataChannelBinaryType { DC_BINARY_TYPE_ARRAYBUFFER, diff --git a/dom/base/nsDOMFileReader.cpp b/dom/base/nsDOMFileReader.cpp index cb0ef2fc7e..a5b1b82776 100644 --- a/dom/base/nsDOMFileReader.cpp +++ b/dom/base/nsDOMFileReader.cpp @@ -114,7 +114,7 @@ nsDOMFileReader::Init() /* static */ already_AddRefed nsDOMFileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { - nsRefPtr fileReader = new nsDOMFileReader(); + RefPtr fileReader = new nsDOMFileReader(); nsCOMPtr owner = do_QueryInterface(aGlobal.GetAsSupports()); if (!owner) { @@ -187,7 +187,7 @@ nsDOMFileReader::ReadAsArrayBuffer(nsIDOMBlob* aBlob, JSContext* aCx) { NS_ENSURE_TRUE(aBlob, NS_ERROR_NULL_POINTER); ErrorResult rv; - nsRefPtr blob = static_cast(aBlob); + RefPtr blob = static_cast(aBlob); ReadAsArrayBuffer(aCx, *blob, rv); return rv.StealNSResult(); } @@ -197,7 +197,7 @@ nsDOMFileReader::ReadAsBinaryString(nsIDOMBlob* aBlob) { NS_ENSURE_TRUE(aBlob, NS_ERROR_NULL_POINTER); ErrorResult rv; - nsRefPtr blob = static_cast(aBlob); + RefPtr blob = static_cast(aBlob); ReadAsBinaryString(*blob, rv); return rv.StealNSResult(); } @@ -208,7 +208,7 @@ nsDOMFileReader::ReadAsText(nsIDOMBlob* aBlob, { NS_ENSURE_TRUE(aBlob, NS_ERROR_NULL_POINTER); ErrorResult rv; - nsRefPtr blob = static_cast(aBlob); + RefPtr blob = static_cast(aBlob); ReadAsText(*blob, aCharset, rv); return rv.StealNSResult(); } @@ -218,7 +218,7 @@ nsDOMFileReader::ReadAsDataURL(nsIDOMBlob* aBlob) { NS_ENSURE_TRUE(aBlob, NS_ERROR_NULL_POINTER); ErrorResult rv; - nsRefPtr blob = static_cast(aBlob); + RefPtr blob = static_cast(aBlob); ReadAsDataURL(*blob, rv); return rv.StealNSResult(); } @@ -280,7 +280,7 @@ nsDOMFileReader::DoOnLoadEnd(nsresult aStatus, nsCOMPtr stream; mAsyncStream.swap(stream); - nsRefPtr blob; + RefPtr blob; mBlob.swap(blob); aSuccessEvent = NS_LITERAL_STRING(LOAD_STR); diff --git a/dom/base/nsDOMFileReader.h b/dom/base/nsDOMFileReader.h index de20505875..0fa7080a67 100644 --- a/dom/base/nsDOMFileReader.h +++ b/dom/base/nsDOMFileReader.h @@ -141,7 +141,7 @@ protected: } char *mFileData; - nsRefPtr mBlob; + RefPtr mBlob; nsCString mCharset; uint32_t mDataLen; diff --git a/dom/base/nsDOMMutationObserver.cpp b/dom/base/nsDOMMutationObserver.cpp index 0959f0b3c9..dd4226b173 100644 --- a/dom/base/nsDOMMutationObserver.cpp +++ b/dom/base/nsDOMMutationObserver.cpp @@ -22,7 +22,7 @@ using mozilla::dom::TreeOrderComparator; using mozilla::dom::Animation; -nsAutoTArray, 4>* +nsAutoTArray, 4>* nsDOMMutationObserver::sScheduledMutationObservers = nullptr; nsDOMMutationObserver* nsDOMMutationObserver::sCurrentObserver = nullptr; @@ -30,7 +30,7 @@ nsDOMMutationObserver* nsDOMMutationObserver::sCurrentObserver = nullptr; uint32_t nsDOMMutationObserver::sMutationLevel = 0; uint64_t nsDOMMutationObserver::sCount = 0; -nsAutoTArray, 4>, 4>* +nsAutoTArray, 4>, 4>* nsDOMMutationObserver::sCurrentlyHandlingObservers = nullptr; nsINodeList* @@ -553,7 +553,7 @@ void nsDOMMutationObserver::RescheduleForRun() { if (!sScheduledMutationObservers) { - sScheduledMutationObservers = new nsAutoTArray, 4>; + sScheduledMutationObservers = new nsAutoTArray, 4>; } bool didInsert = false; @@ -682,14 +682,14 @@ nsDOMMutationObserver::Disconnect() void nsDOMMutationObserver::TakeRecords( - nsTArray >& aRetVal) + nsTArray >& aRetVal) { aRetVal.Clear(); aRetVal.SetCapacity(mPendingMutationCount); - nsRefPtr current; + RefPtr current; current.swap(mFirstPendingMutation); for (uint32_t i = 0; i < mPendingMutationCount; ++i) { - nsRefPtr next; + RefPtr next; current->mNext.swap(next); if (!mMergeAttributeRecords || !MergeableAttributeRecord(aRetVal.SafeLastElement(nullptr), @@ -747,7 +747,7 @@ nsDOMMutationObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal, } MOZ_ASSERT(window->IsInnerWindow()); bool isChrome = nsContentUtils::IsChromeDoc(window->GetExtantDoc()); - nsRefPtr observer = + RefPtr observer = new nsDOMMutationObserver(window.forget(), aCb, isChrome); return observer.forget(); } @@ -793,10 +793,10 @@ nsDOMMutationObserver::HandleMutation() if (mutations.SetCapacity(mPendingMutationCount, mozilla::fallible)) { // We can't use TakeRecords easily here, because it deals with a // different type of array, and we want to optimize out any extra copying. - nsRefPtr current; + RefPtr current; current.swap(mFirstPendingMutation); for (uint32_t i = 0; i < mPendingMutationCount; ++i) { - nsRefPtr next; + RefPtr next; current->mNext.swap(next); if (!mMergeAttributeRecords || !MergeableAttributeRecord(mutations.Length() ? @@ -830,7 +830,7 @@ nsDOMMutationObserver::HandleMutationsInternal() nsContentUtils::AddScriptRunner(new AsyncMutationHandler()); return; } - static nsRefPtr sCurrentObserver; + static RefPtr sCurrentObserver; if (sCurrentObserver && !sCurrentObserver->Suppressed()) { // In normal cases sScheduledMutationObservers will be handled // after previous mutations are handled. But in case some @@ -841,10 +841,10 @@ nsDOMMutationObserver::HandleMutationsInternal() return; } - nsTArray >* suppressedObservers = nullptr; + nsTArray >* suppressedObservers = nullptr; while (sScheduledMutationObservers) { - nsAutoTArray, 4>* observers = + nsAutoTArray, 4>* observers = sScheduledMutationObservers; sScheduledMutationObservers = nullptr; for (uint32_t i = 0; i < observers->Length(); ++i) { @@ -853,7 +853,7 @@ nsDOMMutationObserver::HandleMutationsInternal() sCurrentObserver->HandleMutation(); } else { if (!suppressedObservers) { - suppressedObservers = new nsTArray >; + suppressedObservers = new nsTArray >; } if (!suppressedObservers->Contains(sCurrentObserver)) { suppressedObservers->AppendElement(sCurrentObserver); @@ -885,7 +885,7 @@ nsDOMMutationObserver::CurrentRecord(nsIAtom* aType) uint32_t last = sMutationLevel - 1; if (!mCurrentMutations[last]) { - nsRefPtr r = new nsDOMMutationRecord(aType, GetParentObject()); + RefPtr r = new nsDOMMutationRecord(aType, GetParentObject()); mCurrentMutations[last] = r; AppendMutationRecord(r.forget()); ScheduleForRun(); @@ -919,7 +919,7 @@ nsDOMMutationObserver::LeaveMutationHandling() { if (sCurrentlyHandlingObservers && sCurrentlyHandlingObservers->Length() == sMutationLevel) { - nsTArray >& obs = + nsTArray >& obs = sCurrentlyHandlingObservers->ElementAt(sMutationLevel - 1); for (uint32_t i = 0; i < obs.Length(); ++i) { nsDOMMutationObserver* o = @@ -941,7 +941,7 @@ nsDOMMutationObserver::AddCurrentlyHandlingObserver(nsDOMMutationObserver* aObse if (!sCurrentlyHandlingObservers) { sCurrentlyHandlingObservers = - new nsAutoTArray, 4>, 4>; + new nsAutoTArray, 4>, 4>; } while (sCurrentlyHandlingObservers->Length() < sMutationLevel) { @@ -986,7 +986,7 @@ nsAutoMutationBatch::Done() nsDOMMutationObserver* ob = mObservers[i].mObserver; bool wantsChildList = mObservers[i].mWantsChildList; - nsRefPtr removedList; + RefPtr removedList; if (wantsChildList) { removedList = new nsSimpleContentList(mBatchTarget); } @@ -1027,12 +1027,12 @@ nsAutoMutationBatch::Done() } } if (wantsChildList && (mRemovedNodes.Length() || mAddedNodes.Length())) { - nsRefPtr addedList = + RefPtr addedList = new nsSimpleContentList(mBatchTarget); for (uint32_t i = 0; i < mAddedNodes.Length(); ++i) { addedList->AppendElement(mAddedNodes[i]); } - nsRefPtr m = + RefPtr m = new nsDOMMutationRecord(nsGkAtoms::childList, ob->GetParentObject()); m->mTarget = mBatchTarget; @@ -1076,7 +1076,7 @@ nsAutoAnimationMutationBatch::Done() MOZ_ASSERT(entries, "Targets in entry table and targets list should match"); - nsRefPtr m = + RefPtr m = new nsDOMMutationRecord(nsGkAtoms::animations, ob->GetParentObject()); m->mTarget = target; diff --git a/dom/base/nsDOMMutationObserver.h b/dom/base/nsDOMMutationObserver.h index 542e188c8e..678f7fb1af 100644 --- a/dom/base/nsDOMMutationObserver.h +++ b/dom/base/nsDOMMutationObserver.h @@ -36,7 +36,7 @@ class nsDOMMutationRecord final : public nsISupports, virtual ~nsDOMMutationRecord() {} public: - typedef nsTArray> AnimationArray; + typedef nsTArray> AnimationArray; nsDOMMutationRecord(nsIAtom* aType, nsISupports* aOwner) : mType(aType), mAttrNamespace(NullString()), mPrevValue(NullString()), mOwner(aOwner) @@ -115,15 +115,15 @@ public: nsCOMPtr mAttrName; nsString mAttrNamespace; nsString mPrevValue; - nsRefPtr mAddedNodes; - nsRefPtr mRemovedNodes; + RefPtr mAddedNodes; + RefPtr mRemovedNodes; nsCOMPtr mPreviousSibling; nsCOMPtr mNextSibling; AnimationArray mAddedAnimations; AnimationArray mRemovedAnimations; AnimationArray mChangedAnimations; - nsRefPtr mNext; + RefPtr mNext; nsCOMPtr mOwner; }; @@ -284,7 +284,7 @@ protected: // The target for the MutationObserver.observe() method. nsINode* mTarget; nsDOMMutationObserver* mObserver; - nsRefPtr mParent; // Cleared after microtask. + RefPtr mParent; // Cleared after microtask. // The node to which Gecko-internal nsIMutationObserver was registered to. // This is different than mTarget when dealing with transient observers. nsINode* mRegisterTarget; @@ -490,7 +490,7 @@ public: void Disconnect(); - void TakeRecords(nsTArray >& aRetVal); + void TakeRecords(nsTArray >& aRetVal); void HandleMutation(); @@ -517,7 +517,7 @@ public: void AppendMutationRecord(already_AddRefed aRecord) { - nsRefPtr record = aRecord; + RefPtr record = aRecord; MOZ_ASSERT(record); if (!mLastPendingMutation) { MOZ_ASSERT(!mFirstPendingMutation); @@ -594,11 +594,11 @@ protected: nsAutoTArray mCurrentMutations; // MutationRecords which will be handed to the callback at the end of // the microtask. - nsRefPtr mFirstPendingMutation; + RefPtr mFirstPendingMutation; nsDOMMutationRecord* mLastPendingMutation; uint32_t mPendingMutationCount; - nsRefPtr mCallback; + RefPtr mCallback; bool mWaitingForRun; bool mIsChrome; @@ -607,11 +607,11 @@ protected: uint64_t mId; static uint64_t sCount; - static nsAutoTArray, 4>* sScheduledMutationObservers; + static nsAutoTArray, 4>* sScheduledMutationObservers; static nsDOMMutationObserver* sCurrentObserver; static uint32_t sMutationLevel; - static nsAutoTArray, 4>, 4>* + static nsAutoTArray, 4>, 4>* sCurrentlyHandlingObservers; }; @@ -887,7 +887,7 @@ private: struct Entry { - nsRefPtr mAnimation; + RefPtr mAnimation; State mState; bool mChanged; }; diff --git a/dom/base/nsDOMSerializer.h b/dom/base/nsDOMSerializer.h index 77c08ef450..715dad850e 100644 --- a/dom/base/nsDOMSerializer.h +++ b/dom/base/nsDOMSerializer.h @@ -32,7 +32,7 @@ public: Constructor(const mozilla::dom::GlobalObject& aOwner, mozilla::ErrorResult& rv) { - nsRefPtr domSerializer = new nsDOMSerializer(aOwner.GetAsSupports()); + RefPtr domSerializer = new nsDOMSerializer(aOwner.GetAsSupports()); return domSerializer.forget(); } diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 5e15fa3c68..672429737b 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -163,7 +163,7 @@ nsDOMWindowUtils::GetPresContext() nsIDocShell *docShell = window->GetDocShell(); if (!docShell) return nullptr; - nsRefPtr presContext; + RefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); return presContext; } @@ -287,7 +287,7 @@ nsDOMWindowUtils::UpdateLayerTree() { if (nsIPresShell* presShell = GetPresShell()) { presShell->FlushPendingNotifications(Flush_Display); - nsRefPtr vm = presShell->GetViewManager(); + RefPtr vm = presShell->GetViewManager(); nsView* view = vm->GetRootView(); if (view) { presShell->Paint(view, view->GetBounds(), @@ -983,7 +983,7 @@ nsDOMWindowUtils::SendTouchEventCommon(const nsAString& aType, for (uint32_t i = 0; i < aCount; ++i) { LayoutDeviceIntPoint pt = nsContentUtils::ToWidgetPoint(CSSPoint(aXs[i], aYs[i]), offset, presContext); - nsRefPtr t = new Touch(aIdentifiers[i], + RefPtr t = new Touch(aIdentifiers[i], pt, nsIntPoint(aRxs[i], aRys[i]), aRotationAngles[i], @@ -1397,7 +1397,7 @@ nsDOMWindowUtils::GetTranslationNodes(nsIDOMNode* aRoot, } nsTHashtable> translationNodesHash(500); - nsRefPtr list = new nsTranslationNodeList; + RefPtr list = new nsTranslationNodeList; uint32_t limit = 15000; @@ -1697,7 +1697,7 @@ nsDOMWindowUtils::GetBoundsWithoutFlushing(nsIDOMElement *aElement, nsCOMPtr content = do_QueryInterface(aElement, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr rect = new DOMRect(window); + RefPtr rect = new DOMRect(window); nsIFrame* frame = content->GetPrimaryFrame(); if (frame) { @@ -1733,7 +1733,7 @@ nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult) } nsCOMPtr window = do_QueryReferent(mWindow); - nsRefPtr rect = new DOMRect(window); + RefPtr rect = new DOMRect(window); rect->SetRect(nsPresContext::AppUnitsToFloatCSSPixels(bounds.x), nsPresContext::AppUnitsToFloatCSSPixels(bounds.y), nsPresContext::AppUnitsToFloatCSSPixels(bounds.width), @@ -1805,7 +1805,7 @@ nsDOMWindowUtils::FindElementWithViewId(nsViewID aID, { MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - nsRefPtr content = nsLayoutUtils::FindContentFor(aID); + RefPtr content = nsLayoutUtils::FindContentFor(aID); return content ? CallQueryInterface(content, aResult) : NS_OK; } @@ -1864,7 +1864,7 @@ nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsIDOMNode* aTarget, } nsCOMPtr targetDoc = content->GetCurrentDoc(); NS_ENSURE_STATE(targetDoc); - nsRefPtr targetShell = targetDoc->GetShell(); + RefPtr targetShell = targetDoc->GetShell(); NS_ENSURE_STATE(targetShell); targetDoc->FlushPendingNotifications(Flush_Layout); @@ -2978,7 +2978,7 @@ nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName, int64_t aId, quota::PersistenceType persistenceType = quota::PersistenceTypeFromStorage(options.mStorage); - nsRefPtr mgr = + RefPtr mgr = indexedDB::IndexedDatabaseManager::Get(); if (mgr) { @@ -3002,7 +3002,7 @@ nsDOMWindowUtils::FlushPendingFileDeletions() using mozilla::dom::indexedDB::IndexedDatabaseManager; - nsRefPtr mgr = IndexedDatabaseManager::Get(); + RefPtr mgr = IndexedDatabaseManager::Get(); if (mgr) { nsresult rv = mgr->FlushPendingFileDeletions(); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -3499,7 +3499,7 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMElement* aElement, return NS_ERROR_INVALID_ARG; } - nsRefPtr cssValue = nullptr; + RefPtr cssValue = nullptr; nsIFrame* frame = element->GetPrimaryFrame(); if (frame && !aPseudoElement.IsEmpty()) { if (aPseudoElement.EqualsLiteral("::before")) { @@ -3619,7 +3619,7 @@ nsDOMWindowUtils::SetHandlingUserInput(bool aHandlingUserInput, return NS_ERROR_DOM_SECURITY_ERR; } - nsRefPtr helper( + RefPtr helper( new HandlingUserInputHelper(aHandlingUserInput)); helper.forget(aHelper); return NS_OK; @@ -3632,7 +3632,7 @@ nsDOMWindowUtils::GetContentAPZTestData(JSContext* aContext, MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); if (nsIWidget* widget = GetWidget()) { - nsRefPtr lm = widget->GetLayerManager(); + RefPtr lm = widget->GetLayerManager(); if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { ClientLayerManager* clm = static_cast(lm.get()); if (!clm->GetAPZTestData().ToJS(aOutContentTestData, aContext)) { @@ -3651,7 +3651,7 @@ nsDOMWindowUtils::GetCompositorAPZTestData(JSContext* aContext, MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); if (nsIWidget* widget = GetWidget()) { - nsRefPtr lm = widget->GetLayerManager(); + RefPtr lm = widget->GetLayerManager(); if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { ClientLayerManager* clm = static_cast(lm.get()); APZTestData compositorSideData; @@ -3752,7 +3752,7 @@ nsDOMWindowUtils::GetFrameUniformityTestData(JSContext* aContext, return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr manager = widget->GetLayerManager(); + RefPtr manager = widget->GetLayerManager(); if (!manager) { return NS_ERROR_NOT_AVAILABLE; } @@ -3887,7 +3887,7 @@ nsDOMWindowUtils::SetNextPaintSyncId(int32_t aSyncId) { MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); if (nsIWidget* widget = GetWidget()) { - nsRefPtr lm = widget->GetLayerManager(); + RefPtr lm = widget->GetLayerManager(); if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { ClientLayerManager* clm = static_cast(lm.get()); clm->SetNextPaintSyncId(aSyncId); diff --git a/dom/base/nsDataDocumentContentPolicy.cpp b/dom/base/nsDataDocumentContentPolicy.cpp index bd33ee34d7..a0a97f6159 100644 --- a/dom/base/nsDataDocumentContentPolicy.cpp +++ b/dom/base/nsDataDocumentContentPolicy.cpp @@ -94,7 +94,7 @@ nsDataDocumentContentPolicy::ShouldLoad(uint32_t aContentType, // Report error, if we can. if (node) { nsIPrincipal* requestingPrincipal = node->NodePrincipal(); - nsRefPtr principalURI; + RefPtr principalURI; nsresult rv = requestingPrincipal->GetURI(getter_AddRefs(principalURI)); if (NS_SUCCEEDED(rv) && principalURI) { diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 61c5fa19b6..20d2f7c24a 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -706,7 +706,7 @@ struct nsRadioGroupStruct /** * A strong pointer to the currently selected radio button. */ - nsRefPtr mSelectedRadioButton; + RefPtr mSelectedRadioButton; nsCOMArray mRadioButtons; uint32_t mRequiredRadioCount; bool mGroupSuffersFromValueMissing; @@ -907,7 +907,7 @@ nsExternalResourceMap::RequestResource(nsIURI* aURI, return resource->mDocument; } - nsRefPtr load; + RefPtr load; mPendingLoads.Get(clone, getter_AddRefs(load)); if (load) { load.forget(aPendingLoad); @@ -1073,7 +1073,7 @@ nsExternalResourceMap::AddExternalResource(nsIURI* aURI, NS_PRECONDITION((aViewer && aLoadGroup) || (!aViewer && !aLoadGroup), "Must have both or neither"); - nsRefPtr load; + RefPtr load; mPendingLoads.Get(aURI, getter_AddRefs(load)); mPendingLoads.Remove(aURI); @@ -1470,7 +1470,7 @@ struct nsIDocument::FrameRequest // Conversion operator so that we can append these to a // FrameRequestCallbackList - operator const nsRefPtr& () const { + operator const RefPtr& () const { return mCallback; } @@ -1483,7 +1483,7 @@ struct nsIDocument::FrameRequest return mHandle < aHandle; } - nsRefPtr mCallback; + RefPtr mCallback; int32_t mHandle; }; @@ -3217,7 +3217,7 @@ nsDocument::GetUndoManager() mUndoManager = new UndoManager(rootElement); } - nsRefPtr undoManager = mUndoManager; + RefPtr undoManager = mUndoManager; return undoManager.forget(); } @@ -3341,7 +3341,7 @@ nsIDocument::GetActiveElement() } // No focused element anywhere in this document. Try to get the BODY. - nsRefPtr htmlDoc = AsHTMLDocument(); + RefPtr htmlDoc = AsHTMLDocument(); if (htmlDoc) { // Because of IE compatibility, return null when html document doesn't have // a body. @@ -3384,7 +3384,7 @@ nsIDocument::ElementFromPoint(float aX, float aY) void nsIDocument::ElementsFromPoint(float aX, float aY, - nsTArray>& aElements) + nsTArray>& aElements) { ElementsFromPointHelper(aX, aY, nsIDocument::FLUSH_LAYOUT, aElements); } @@ -3394,7 +3394,7 @@ nsDocument::ElementFromPointHelper(float aX, float aY, bool aIgnoreRootScrollFrame, bool aFlushLayout) { - nsAutoTArray, 1> elementArray; + nsAutoTArray, 1> elementArray; ElementsFromPointHelper(aX, aY, ((aIgnoreRootScrollFrame ? nsIDocument::IGNORE_ROOT_SCROLL_FRAME : 0) | (aFlushLayout ? nsIDocument::FLUSH_LAYOUT : 0) | @@ -3409,7 +3409,7 @@ nsDocument::ElementFromPointHelper(float aX, float aY, void nsDocument::ElementsFromPointHelper(float aX, float aY, uint32_t aFlags, - nsTArray>& aElements) + nsTArray>& aElements) { // As per the the spec, we return null if either coord is negative if (!(aFlags & nsIDocument::IGNORE_ROOT_SCROLL_FRAME) && (aX < 0 || aY < 0)) { @@ -3836,7 +3836,7 @@ nsDocument::doCreateShell(nsPresContext* aContext, FillStyleSet(aStyleSet); - nsRefPtr shell = new PresShell; + RefPtr shell = new PresShell; shell->Init(this, aContext, aViewManager, aStyleSet, aCompatMode); // Note: we don't hold a ref to the shell (it holds a ref to us) @@ -4217,7 +4217,7 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet) #define DO_STYLESHEET_NOTIFICATION(className, type, memberName, argName) \ do { \ - nsRefPtr cssSheet = do_QueryObject(aSheet); \ + RefPtr cssSheet = do_QueryObject(aSheet); \ if (!cssSheet) { \ return; \ } \ @@ -4228,11 +4228,11 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet) init.mStylesheet = cssSheet; \ init.memberName = argName; \ \ - nsRefPtr event = \ + RefPtr event = \ className::Constructor(this, NS_LITERAL_STRING(type), init); \ event->SetTrusted(true); \ event->SetTarget(this); \ - nsRefPtr asyncDispatcher = \ + RefPtr asyncDispatcher = \ new AsyncEventDispatcher(this, event); \ asyncDispatcher->mOnlyChromeDispatch = true; \ asyncDispatcher->PostDOMEvent(); \ @@ -4453,9 +4453,9 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetUR return NS_ERROR_INVALID_ARG; // Loading the sheet sync. - nsRefPtr loader = new mozilla::css::Loader(); + RefPtr loader = new mozilla::css::Loader(); - nsRefPtr sheet; + RefPtr sheet; nsresult rv = loader->LoadSheetSync(aSheetURI, aType == eAgentSheet, true, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -4553,7 +4553,7 @@ CheckIfContainsMSEContent(nsISupports* aSupports, void* aContainsMSE) MOZ_ASSERT(content, "aSupports is not a content"); HTMLMediaElement* mediaElem = static_cast(content.get()); bool* contains = static_cast(aContainsMSE); - nsRefPtr ms = mediaElem->GetMozMediaSourceObject(); + RefPtr ms = mediaElem->GetMozMediaSourceObject(); if (ms) { *contains = true; } @@ -5160,7 +5160,7 @@ nsDocument::DispatchContentLoadedEvents() nsIPresShell *shell = parent->GetShell(); if (shell) { - nsRefPtr context = shell->GetPresContext(); + RefPtr context = shell->GetPresContext(); if (context) { EventDispatcher::Dispatch(parent, context, innerEvent, event, @@ -5322,7 +5322,7 @@ nsIDocument::InsertAnonymousContent(Element& aElement, ErrorResult& aRv) return nullptr; } - nsRefPtr anonymousContent = + RefPtr anonymousContent = new AnonymousContent(clonedElement->AsElement()); mAnonymousContents.AppendElement(anonymousContent); @@ -5536,7 +5536,7 @@ nsDocument::CreateElement(const nsAString& aTagName, const nsAString& aTypeExtension, ErrorResult& rv) { - nsRefPtr elem = nsIDocument::CreateElement(aTagName, rv); + RefPtr elem = nsIDocument::CreateElement(aTagName, rv); if (rv.Failed()) { return nullptr; } @@ -5567,7 +5567,7 @@ nsIDocument::CreateElementNS(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, ErrorResult& rv) { - nsRefPtr nodeInfo; + RefPtr nodeInfo; rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI, aQualifiedName, mNodeInfoManager, @@ -5592,7 +5592,7 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI, const nsAString& aTypeExtension, ErrorResult& rv) { - nsRefPtr elem = nsIDocument::CreateElementNS(aNamespaceURI, + RefPtr elem = nsIDocument::CreateElementNS(aNamespaceURI, aQualifiedName, rv); if (rv.Failed()) { @@ -5626,7 +5626,7 @@ nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn) already_AddRefed nsIDocument::CreateTextNode(const nsAString& aData) const { - nsRefPtr text = new nsTextNode(mNodeInfoManager); + RefPtr text = new nsTextNode(mNodeInfoManager); // Don't notify; this node is still being created. text->SetText(aData, false); return text.forget(); @@ -5642,7 +5642,7 @@ nsDocument::CreateDocumentFragment(nsIDOMDocumentFragment** aReturn) already_AddRefed nsIDocument::CreateDocumentFragment() const { - nsRefPtr frag = new DocumentFragment(mNodeInfoManager); + RefPtr frag = new DocumentFragment(mNodeInfoManager); return frag.forget(); } @@ -5657,7 +5657,7 @@ nsDocument::CreateComment(const nsAString& aData, nsIDOMComment** aReturn) already_AddRefed nsIDocument::CreateComment(const nsAString& aData) const { - nsRefPtr comment = new dom::Comment(mNodeInfoManager); + RefPtr comment = new dom::Comment(mNodeInfoManager); // Don't notify; this node is still being created. comment->SetText(aData, false); @@ -5688,7 +5688,7 @@ nsIDocument::CreateCDATASection(const nsAString& aData, return nullptr; } - nsRefPtr cdata = new CDATASection(mNodeInfoManager); + RefPtr cdata = new CDATASection(mNodeInfoManager); // Don't notify; this node is still being created. cdata->SetText(aData, false); @@ -5723,7 +5723,7 @@ nsIDocument::CreateProcessingInstruction(const nsAString& aTarget, return nullptr; } - nsRefPtr pi = + RefPtr pi = NS_NewXMLProcessingInstruction(mNodeInfoManager, aTarget, aData); return pi.forget(); @@ -5761,7 +5761,7 @@ nsIDocument::CreateAttribute(const nsAString& aName, ErrorResult& rv) name = aName; } - nsRefPtr nodeInfo; + RefPtr nodeInfo; res = mNodeInfoManager->GetNodeInfo(name, nullptr, kNameSpaceID_None, nsIDOMNode::ATTRIBUTE_NODE, getter_AddRefs(nodeInfo)); @@ -5770,7 +5770,7 @@ nsIDocument::CreateAttribute(const nsAString& aName, ErrorResult& rv) return nullptr; } - nsRefPtr attribute = new Attr(nullptr, nodeInfo.forget(), + RefPtr attribute = new Attr(nullptr, nodeInfo.forget(), EmptyString(), false); return attribute.forget(); } @@ -5793,7 +5793,7 @@ nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI, { WarnOnceAbout(eCreateAttributeNS); - nsRefPtr nodeInfo; + RefPtr nodeInfo; rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI, aQualifiedName, mNodeInfoManager, @@ -5803,7 +5803,7 @@ nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI, return nullptr; } - nsRefPtr attribute = new Attr(nullptr, nodeInfo.forget(), + RefPtr attribute = new Attr(nullptr, nodeInfo.forget(), EmptyString(), true); return attribute.forget(); } @@ -6061,7 +6061,7 @@ nsDocument::ProcessTopElementQueue() { MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); - nsTArray>& stack = *sProcessingStack; + nsTArray>& stack = *sProcessingStack; uint32_t firstQueue = stack.LastIndexOf((CustomElementData*) nullptr); for (uint32_t i = firstQueue + 1; i < stack.Length(); ++i) { @@ -6093,7 +6093,7 @@ nsDocument::RegisterEnabled() } // static -Maybe>> +Maybe>> nsDocument::sProcessingStack; void @@ -6387,7 +6387,7 @@ NS_IMETHODIMP nsDocument::GetElementsByTagName(const nsAString& aTagname, nsIDOMNodeList** aReturn) { - nsRefPtr list = GetElementsByTagName(aTagname); + RefPtr list = GetElementsByTagName(aTagname); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); // transfer ref to aReturn @@ -6404,7 +6404,7 @@ nsDocument::BlockedTrackingNodeCount() const already_AddRefed nsDocument::BlockedTrackingNodes() const { - nsRefPtr list = new nsSimpleContentList(nullptr); + RefPtr list = new nsSimpleContentList(nullptr); nsTArray blockedTrackingNodes; blockedTrackingNodes = mBlockedTrackingNodes; @@ -6450,7 +6450,7 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI, nsIDOMNodeList** aReturn) { ErrorResult rv; - nsRefPtr list = + RefPtr list = nsIDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv); if (rv.Failed()) { return rv.StealNSResult(); @@ -6881,7 +6881,7 @@ nsDocument::CreateRange(nsIDOMRange** aReturn) already_AddRefed nsIDocument::CreateRange(ErrorResult& rv) { - nsRefPtr range = new nsRange(this); + RefPtr range = new nsRange(this); nsresult res = range->Set(this, 0, this, 0); if (NS_FAILED(res)) { rv.Throw(res); @@ -6933,7 +6933,7 @@ nsIDocument::CreateNodeIterator(nsINode& aRoot, uint32_t aWhatToShow, ErrorResult& rv) const { nsINode* root = &aRoot; - nsRefPtr iterator = new NodeIterator(root, aWhatToShow, + RefPtr iterator = new NodeIterator(root, aWhatToShow, aFilter); return iterator.forget(); } @@ -6976,7 +6976,7 @@ nsIDocument::CreateTreeWalker(nsINode& aRoot, uint32_t aWhatToShow, ErrorResult& rv) const { nsINode* root = &aRoot; - nsRefPtr walker = new TreeWalker(root, aWhatToShow, aFilter); + RefPtr walker = new TreeWalker(root, aWhatToShow, aFilter); return walker.forget(); } @@ -7049,7 +7049,7 @@ nsDocument::GetTitleContent(uint32_t aNamespace) if (!mMayHaveTitleElement) return nullptr; - nsRefPtr list = + RefPtr list = NS_GetContentList(this, aNamespace, NS_LITERAL_STRING("title")); return list->Item(0, false); @@ -7132,7 +7132,7 @@ nsDocument::SetTitle(const nsAString& aTitle) return NS_OK; { - nsRefPtr titleInfo; + RefPtr titleInfo; titleInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::title, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE); @@ -7168,7 +7168,7 @@ nsDocument::NotifyPossibleTitleChange(bool aBoundTitleElement) if (mPendingTitleChangeEvent.IsPending()) return; - nsRefPtr > event = + RefPtr > event = NS_NewNonOwningRunnableMethod(this, &nsDocument::DoNotifyPossibleTitleChange); nsresult rv = NS_DispatchToCurrentThread(event); @@ -7290,7 +7290,7 @@ nsDocument::ClearBoxObjectFor(nsIContent* aContent) already_AddRefed nsIDocument::MatchMedia(const nsAString& aMediaQueryList) { - nsRefPtr result = new MediaQueryList(this, aMediaQueryList); + RefPtr result = new MediaQueryList(this, aMediaQueryList); // Insert the new item at the end of the linked list. PR_INSERT_BEFORE(result, &mDOMMediaQueryLists); @@ -7371,7 +7371,7 @@ nsDocument::MaybeInitializeFinalizeFrameLoaders() // loading a frame may cause some other frameloader to be removed from the // array. But be careful to keep the loader alive when starting the load! while (mInitializableFrameLoaders.Length()) { - nsRefPtr loader = mInitializableFrameLoaders[0]; + RefPtr loader = mInitializableFrameLoaders[0]; mInitializableFrameLoaders.RemoveElementAt(0); NS_ASSERTION(loader, "null frameloader in the array?"); loader->ReallyStartLoading(); @@ -7695,7 +7695,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv) case nsIDOMNode::ATTRIBUTE_NODE: { // Remove from ownerElement. - nsRefPtr adoptedAttr = static_cast(adoptedNode); + RefPtr adoptedAttr = static_cast(adoptedNode); nsCOMPtr ownerElement = adoptedAttr->GetOwnerElement(rv); if (rv.Failed()) { @@ -7703,7 +7703,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv) } if (ownerElement) { - nsRefPtr newAttr = + RefPtr newAttr = ownerElement->RemoveAttributeNode(*adoptedAttr, rv); if (rv.Failed()) { return nullptr; @@ -8144,7 +8144,7 @@ nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const } // Create event even without presContext. - nsRefPtr ev = + RefPtr ev = EventDispatcher::CreateEvent(const_cast(this), presContext, nullptr, aEventType); if (!ev) { @@ -8415,7 +8415,7 @@ nsDocument::GetNextRadioButton(const nsAString& aName, // Return the radio button relative to the focused radio button. // If no radio is focused, get the radio relative to the selected one. - nsRefPtr currentRadio; + RefPtr currentRadio; if (aFocusedRadio) { currentRadio = aFocusedRadio; } @@ -8431,7 +8431,7 @@ nsDocument::GetNextRadioButton(const nsAString& aName, } int32_t numRadios = radioGroup->mRadioButtons.Count(); - nsRefPtr radio; + RefPtr radio; do { if (aPrevious) { if (--index < 0) { @@ -8630,7 +8630,7 @@ nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix, "check caller."); #endif - nsRefPtr nodeInfo; + RefPtr nodeInfo; mNodeInfoManager->GetNodeInfo(aName, aPrefix, aNamespaceID, nsIDOMNode::ELEMENT_NODE, getter_AddRefs(nodeInfo)); @@ -8664,7 +8664,7 @@ nsDocument::Sanitize() // First locate all input elements, regardless of whether they are // in a form, and reset the password and autocomplete=off elements. - nsRefPtr nodes = GetElementsByTagName(NS_LITERAL_STRING("input")); + RefPtr nodes = GetElementsByTagName(NS_LITERAL_STRING("input")); nsCOMPtr item; nsAutoString value; @@ -8673,7 +8673,7 @@ nsDocument::Sanitize() for (uint32_t i = 0; i < length; ++i) { NS_ASSERTION(nodes->Item(i), "null item in node list!"); - nsRefPtr input = HTMLInputElement::FromContentOrNull(nodes->Item(i)); + RefPtr input = HTMLInputElement::FromContentOrNull(nodes->Item(i)); if (!input) continue; @@ -9017,7 +9017,7 @@ nsDocument::UnblockOnload(bool aFireSync) // event to indicate that the SVG should be considered fully loaded. // Because scripting is disabled on SVG-as-image documents, this event // is not accessible to content authors. (See bug 837315.) - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(this, NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), false, @@ -9035,7 +9035,7 @@ public: return NS_OK; } private: - nsRefPtr mDoc; + RefPtr mDoc; }; void @@ -9118,7 +9118,7 @@ nsDocument::DispatchPageTransition(EventTarget* aDispatchTarget, init.mCancelable = true; init.mPersisted = aPersisted; - nsRefPtr event = + RefPtr event = PageTransitionEvent::Constructor(this, aType, init); event->SetTrusted(true); @@ -9147,7 +9147,7 @@ nsDocument::OnPageShow(bool aPersisted, Element* root = GetRootElement(); if (aPersisted && root) { // Send out notifications that our elements are attached. - nsRefPtr links = NS_GetContentList(root, + RefPtr links = NS_GetContentList(root, kNameSpaceID_XHTML, NS_LITERAL_STRING("link")); @@ -9206,7 +9206,7 @@ NotifyPageHide(nsIDocument* aDocument, void* aData) static void DispatchFullScreenChange(nsIDocument* aTarget) { - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(aTarget, NS_LITERAL_STRING("mozfullscreenchange"), true, @@ -9222,7 +9222,7 @@ nsDocument::OnPageHide(bool aPersisted, // but only if this is not a full unload. Element* root = GetRootElement(); if (aPersisted && root) { - nsRefPtr links = NS_GetContentList(root, + RefPtr links = NS_GetContentList(root, kNameSpaceID_XHTML, NS_LITERAL_STRING("link")); @@ -9537,7 +9537,7 @@ nsDocument::SetReadyStateInternal(ReadyState rs) mLoadingTimeStamp = mozilla::TimeStamp::Now(); } - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(this, NS_LITERAL_STRING("readystatechange"), false, false); asyncDispatcher->RunDOMEventWhenSafe(); @@ -9742,7 +9742,7 @@ nsDocument::MaybePreLoadImage(nsIURI* uri, const nsAString &aCrossOriginAttr, } // Image not in cache - trigger preload - nsRefPtr request; + RefPtr request; nsresult rv = nsContentUtils::LoadImage(uri, this, @@ -10185,13 +10185,13 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer) mCreatingStaticClone = true; // Make document use different container during cloning. - nsRefPtr originalShell = mDocumentContainer.get(); + RefPtr originalShell = mDocumentContainer.get(); SetContainer(static_cast(aCloneContainer)); nsCOMPtr clonedNode; nsresult rv = thisAsDoc->CloneNode(true, 1, getter_AddRefs(clonedNode)); SetContainer(originalShell); - nsRefPtr clonedDoc; + RefPtr clonedDoc; if (NS_SUCCEEDED(rv)) { nsCOMPtr tmp = do_QueryInterface(clonedNode); if (tmp) { @@ -10206,10 +10206,10 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer) int32_t sheetsCount = GetNumberOfStyleSheets(); for (int32_t i = 0; i < sheetsCount; ++i) { - nsRefPtr sheet = do_QueryObject(GetStyleSheetAt(i)); + RefPtr sheet = do_QueryObject(GetStyleSheetAt(i)); if (sheet) { if (sheet->IsApplicable()) { - nsRefPtr clonedSheet = + RefPtr clonedSheet = sheet->Clone(nullptr, nullptr, clonedDoc, nullptr); NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!"); if (clonedSheet) { @@ -10222,11 +10222,11 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer) sheetsCount = thisAsDoc->mOnDemandBuiltInUASheets.Count(); // Iterate backwards to maintain order for (int32_t i = sheetsCount - 1; i >= 0; --i) { - nsRefPtr sheet = + RefPtr sheet = do_QueryObject(thisAsDoc->mOnDemandBuiltInUASheets[i]); if (sheet) { if (sheet->IsApplicable()) { - nsRefPtr clonedSheet = + RefPtr clonedSheet = sheet->Clone(nullptr, nullptr, clonedDoc, nullptr); NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!"); if (clonedSheet) { @@ -10669,7 +10669,7 @@ nsIDocument::CreateTouch(nsIDOMWindow* aView, float aRotationAngle, float aForce) { - nsRefPtr touch = new Touch(aTarget, + RefPtr touch = new Touch(aTarget, aIdentifier, aPageX, aPageY, aScreenX, aScreenY, @@ -10683,7 +10683,7 @@ nsIDocument::CreateTouch(nsIDOMWindow* aView, already_AddRefed nsIDocument::CreateTouchList() { - nsRefPtr retval = new TouchList(ToSupports(this)); + RefPtr retval = new TouchList(ToSupports(this)); return retval.forget(); } @@ -10691,7 +10691,7 @@ already_AddRefed nsIDocument::CreateTouchList(Touch& aTouch, const Sequence >& aTouches) { - nsRefPtr retval = new TouchList(ToSupports(this)); + RefPtr retval = new TouchList(ToSupports(this)); retval->Append(&aTouch); for (uint32_t i = 0; i < aTouches.Length(); ++i) { retval->Append(aTouches[i].get()); @@ -10702,7 +10702,7 @@ nsIDocument::CreateTouchList(Touch& aTouch, already_AddRefed nsIDocument::CreateTouchList(const Sequence >& aTouches) { - nsRefPtr retval = new TouchList(ToSupports(this)); + RefPtr retval = new TouchList(ToSupports(this)); for (uint32_t i = 0; i < aTouches.Length(); ++i) { retval->Append(aTouches[i].get()); } @@ -10776,7 +10776,7 @@ nsIDocument::CaretPositionFromPoint(float aX, float aY) } } - nsRefPtr aCaretPos = new nsDOMCaretPosition(node, offset); + RefPtr aCaretPos = new nsDOMCaretPosition(node, offset); if (nodeIsAnonymous) { aCaretPos->SetAnonymousContentNode(anonNode); } @@ -11066,7 +11066,7 @@ public: private: nsCOMPtr mDoc; bool mValue; - nsRefPtr mHMD; + RefPtr mHMD; }; static nsIDocument* @@ -11259,7 +11259,7 @@ ExitFullscreenInDocTree(nsIDocument* aMaybeNotARootDoc) // Dispatch MozExitedDomFullscreen to the last document in // the list since we want this event to follow the same path // MozEnteredDomFullscreen dispatched. - nsRefPtr asyncDispatcher = new AsyncEventDispatcher( + RefPtr asyncDispatcher = new AsyncEventDispatcher( changed.LastElement(), NS_LITERAL_STRING("MozExitedDomFullscreen"), true, true); asyncDispatcher->PostDOMEvent(); // Move the top-level window out of fullscreen mode. @@ -11389,7 +11389,7 @@ nsDocument::RestorePreviousFullScreenState() if (!nsContentUtils::HaveEqualPrincipals(fullScreenDoc, doc) || (!nsContentUtils::IsSitePermAllow(doc->NodePrincipal(), "fullscreen") && !static_cast(doc)->mIsApprovedForFullscreen)) { - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(doc, NS_LITERAL_STRING("MozEnteredDomFullscreen"), true, @@ -11418,7 +11418,7 @@ nsDocument::RestorePreviousFullScreenState() // move the top-level window out of fullscreen mode. NS_ASSERTION(!GetFullscreenRootDocument(this)->IsFullScreenDoc(), "Should have cleared all docs' stacks"); - nsRefPtr asyncDispatcher = new AsyncEventDispatcher( + RefPtr asyncDispatcher = new AsyncEventDispatcher( this, NS_LITERAL_STRING("MozExitedDomFullscreen"), true, true); asyncDispatcher->PostDOMEvent(); SetWindowFullScreen(this, false); @@ -11462,7 +11462,7 @@ public: return NS_OK; } - nsRefPtr mElement; + RefPtr mElement; nsCOMPtr mDoc; bool mWasCallerChrome; bool mHadRequestPending; @@ -11489,7 +11489,7 @@ LogFullScreenDenied(bool aLogFailure, const char* aMessage, nsIDocument* aDoc) if (!aLogFailure) { return; } - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(aDoc, NS_LITERAL_STRING("mozfullscreenerror"), true, @@ -11815,7 +11815,7 @@ nsDocument::RequestFullScreen(Element* aElement, // Process options -- in this case, just HMD if (aOptions.mVRHMDDevice) { - nsRefPtr hmdRef = aOptions.mVRHMDDevice; + RefPtr hmdRef = aOptions.mVRHMDDevice; aElement->SetProperty(nsGkAtoms::vr_state, hmdRef.forget().take(), ReleaseHMDInfoRef, true); @@ -11882,7 +11882,7 @@ nsDocument::RequestFullScreen(Element* aElement, // session. if (!mIsApprovedForFullscreen || !nsContentUtils::HaveEqualPrincipals(previousFullscreenDoc, this)) { - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(this, NS_LITERAL_STRING("MozEnteredDomFullscreen"), true, @@ -12071,7 +12071,7 @@ DispatchPointerLockChange(nsIDocument* aTarget) return; } - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(aTarget, NS_LITERAL_STRING("mozpointerlockchange"), true, @@ -12086,7 +12086,7 @@ DispatchPointerLockError(nsIDocument* aTarget) return; } - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(aTarget, NS_LITERAL_STRING("mozpointerlockerror"), true, @@ -12345,7 +12345,7 @@ nsDocument::OnAppThemeChanged() } for (int32_t i = 0; i < GetNumberOfStyleSheets(); i++) { - nsRefPtr sheet = do_QueryObject(GetStyleSheetAt(i)); + RefPtr sheet = do_QueryObject(GetStyleSheetAt(i)); if (!sheet) { continue; } @@ -12478,7 +12478,7 @@ nsDocument::SetPointerLock(Element* aElement, int aCursorStyle) return false; } - nsRefPtr presContext; + RefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) { NS_WARNING("SetPointerLock(): Unable to get presContext in \ @@ -12511,7 +12511,7 @@ nsDocument::SetPointerLock(Element* aElement, int aCursorStyle) } // Hide the cursor and set pointer lock for future mouse events - nsRefPtr esm = presContext->EventStateManager(); + RefPtr esm = presContext->EventStateManager(); esm->SetCursor(aCursorStyle, nullptr, false, 0.0f, 0.0f, widget, true); esm->SetPointerLock(widget, aElement); @@ -13161,7 +13161,7 @@ nsIDocument::SetStateObject(nsIStructuredCloneContainer *scContainer) already_AddRefed nsIDocument::CreateHTMLElement(nsIAtom* aTag) { - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = mNodeInfoManager->GetNodeInfo(aTag, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE); MOZ_ASSERT(nodeInfo, "GetNodeInfo should never fail"); diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index c2484922b2..82852ad3c1 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -228,9 +228,9 @@ private: // empty if there are no elements with this ID. // The elements are stored as weak pointers. nsTArray mIdContentList; - nsRefPtr mNameContentList; + RefPtr mNameContentList; nsAutoPtr > mChangeCallbacks; - nsRefPtr mImageElement; + RefPtr mImageElement; }; namespace mozilla { @@ -304,8 +304,8 @@ public: private: // The this value to use for invocation of the callback. - nsRefPtr mThisObject; - nsRefPtr mCallback; + RefPtr mThisObject; + RefPtr mCallback; // The type of callback (eCreated, eAttached, etc.) nsIDocument::ElementCallbackType mType; // Arguments to be passed to the callback, @@ -563,7 +563,7 @@ protected: nsILoadGroup** aLoadGroup); private: - nsRefPtr mDisplayDocument; + RefPtr mDisplayDocument; nsCOMPtr mTargetListener; nsCOMPtr mURI; }; @@ -1023,7 +1023,7 @@ public: virtual void ElementsFromPointHelper(float aX, float aY, uint32_t aFlags, - nsTArray>& aElements) override; + nsTArray>& aElements) override; virtual nsresult NodesFromRectHelper(float aX, float aY, float aTopSize, float aRightSize, @@ -1559,7 +1559,7 @@ protected: // Tracker for animations that are waiting to start. // nullptr until GetOrCreatePendingAnimationTracker is called. - nsRefPtr mPendingAnimationTracker; + RefPtr mPendingAnimationTracker; // Weak reference to the scope object (aka the script global object) // that, unlike mScriptGlobalObject, is never unset once set. This @@ -1582,7 +1582,7 @@ private: // CustomElementData in this array, separated by nullptr that // represent the boundaries of the items in the stack. The first // queue in the stack is the base element queue. - static mozilla::Maybe>> sProcessingStack; + static mozilla::Maybe>> sProcessingStack; static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp); @@ -1597,12 +1597,12 @@ public: static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject); // The "registry" from the web components spec. - nsRefPtr mRegistry; + RefPtr mRegistry; - nsRefPtr mListenerManager; - nsRefPtr mDOMStyleSheets; - nsRefPtr mStyleSheetSetList; - nsRefPtr mScriptLoader; + RefPtr mListenerManager; + RefPtr mDOMStyleSheets; + RefPtr mStyleSheetSetList; + RefPtr mScriptLoader; nsDocHeaderData* mHeaderData; /* mIdentifierMap works as follows for IDs: * 1) Attribute changes affect the table immediately (removing and adding @@ -1679,7 +1679,7 @@ public: // ScreenOrientation "pending promise" as described by // http://www.w3.org/TR/screen-orientation/ - nsRefPtr mOrientationPendingPromise; + RefPtr mOrientationPendingPromise; uint16_t mCurrentOrientationAngle; mozilla::dom::OrientationType mCurrentOrientationType; @@ -1726,7 +1726,7 @@ public: mozilla::EventStates mDocumentState; mozilla::EventStates mGotDocumentState; - nsRefPtr mTiming; + RefPtr mTiming; private: friend class nsUnblockOnloadEvent; // Recomputes the visibility state but doesn't set the new value. @@ -1802,9 +1802,9 @@ private: // Member to store out last-selected stylesheet set. nsString mLastStyleSheetSet; - nsTArray > mInitializableFrameLoaders; + nsTArray > mInitializableFrameLoaders; nsTArray > mFrameLoaderFinalizers; - nsRefPtr > mFrameLoaderRunner; + RefPtr > mFrameLoaderRunner; nsRevocableEventPtr > mPendingTitleChangeEvent; @@ -1828,9 +1828,9 @@ private: // Set if we've found a URL for the current picture nsString mPreloadPictureFoundSource; - nsRefPtr mDOMImplementation; + RefPtr mDOMImplementation; - nsRefPtr mImageMaps; + RefPtr mImageMaps; nsCString mScrollToRef; uint8_t mScrolledToRefAlready : 1; @@ -1842,9 +1842,9 @@ private: // Tracking for plugins in the document. nsTHashtable< nsPtrHashKey > mPlugins; - nsRefPtr mUndoManager; + RefPtr mUndoManager; - nsRefPtr mDocumentTimeline; + RefPtr mDocumentTimeline; enum ViewportType { DisplayWidthHeight, @@ -1870,7 +1870,7 @@ private: CSPErrorQueue mCSPWebConsoleErrorQueue; nsCOMPtr mMasterDocument; - nsRefPtr mImportManager; + RefPtr mImportManager; nsTArray > mSubImportLinks; // Set to true when the document is possibly controlled by the ServiceWorker. diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index e3bc37c9f9..418ae311ef 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -144,7 +144,7 @@ protected: nsCOMPtr mDocument; nsCOMPtr mSelection; - nsRefPtr mRange; + RefPtr mRange; nsCOMPtr mNode; nsCOMPtr mStream; nsCOMPtr mSerializer; diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index ea569f1261..a7d21a55c7 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -727,7 +727,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow) if (presShell) { // disable selection mousedown state on activation // XXXndeakin P3 not sure if this is necessary, but it doesn't hurt - nsRefPtr frameSelection = presShell->FrameSelection(); + RefPtr frameSelection = presShell->FrameSelection(); frameSelection->SetDragState(false); } @@ -1688,12 +1688,12 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, SetCaretVisible(presShell, false, nullptr); } - nsRefPtr selectionCarets = presShell->GetSelectionCarets(); + RefPtr selectionCarets = presShell->GetSelectionCarets(); if (selectionCarets) { selectionCarets->NotifyBlur(aIsLeavingDocument || !mActiveWindow); } - nsRefPtr eventHub = presShell->GetAccessibleCaretEventHub(); + RefPtr eventHub = presShell->GetAccessibleCaretEventHub(); if (eventHub) { eventHub->NotifyBlur(aIsLeavingDocument || !mActiveWindow); } @@ -1982,7 +1982,7 @@ public: } nsCOMPtr mTarget; - nsRefPtr mContext; + RefPtr mContext; EventMessage mEventMessage; bool mWindowRaised; bool mIsRefocus; @@ -2206,7 +2206,7 @@ nsFocusManager::MoveCaretToFocus(nsIPresShell* aPresShell, nsIContent* aContent) // domDoc is a document interface we can create a range with nsCOMPtr domDoc = do_QueryInterface(aPresShell->GetDocument()); if (domDoc) { - nsRefPtr frameSelection = aPresShell->FrameSelection(); + RefPtr frameSelection = aPresShell->FrameSelection(); nsCOMPtr domSelection = frameSelection-> GetSelection(nsISelectionController::SELECTION_NORMAL); if (domSelection) { @@ -2247,7 +2247,7 @@ nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell, // When browsing with caret, make sure caret is visible after new focus // Return early if there is no caret. This can happen for the testcase // for bug 308025 where a window is closed in a blur handler. - nsRefPtr caret = aPresShell->GetCaret(); + RefPtr caret = aPresShell->GetCaret(); if (!caret) return NS_OK; @@ -2255,7 +2255,7 @@ nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell, if (!aVisible && !caretVisible) return NS_OK; - nsRefPtr frameSelection; + RefPtr frameSelection; if (aContent) { NS_ASSERTION(aContent->GetComposedDoc() == aPresShell->GetDocument(), "Wrong document?"); @@ -2264,7 +2264,7 @@ nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell, frameSelection = focusFrame->GetFrameSelection(); } - nsRefPtr docFrameSelection = aPresShell->FrameSelection(); + RefPtr docFrameSelection = aPresShell->FrameSelection(); if (docFrameSelection && caret && (frameSelection == docFrameSelection || !aContent)) { @@ -2307,7 +2307,7 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument, nsPresContext* presContext = aPresShell->GetPresContext(); NS_ASSERTION(presContext, "mPresContent is null!!"); - nsRefPtr frameSelection = aPresShell->FrameSelection(); + RefPtr frameSelection = aPresShell->FrameSelection(); nsCOMPtr domSelection; if (frameSelection) { diff --git a/dom/base/nsFormData.cpp b/dom/base/nsFormData.cpp index 903a6cff90..afe48ed0f9 100644 --- a/dom/base/nsFormData.cpp +++ b/dom/base/nsFormData.cpp @@ -39,7 +39,7 @@ CreateNewFileInstance(Blob& aBlob, const Optional& aFilename) } else { // If value is already a File and filename is not passed, the spec says not // to create a new instance. - nsRefPtr file = aBlob.ToFile(); + RefPtr file = aBlob.ToFile(); if (file) { return file.forget(); } @@ -110,7 +110,7 @@ void nsFormData::Append(const nsAString& aName, Blob& aBlob, const Optional& aFilename) { - nsRefPtr file = CreateNewFileInstance(aBlob, aFilename); + RefPtr file = CreateNewFileInstance(aBlob, aFilename); AddNameFilePair(aName, file); } @@ -211,7 +211,7 @@ nsFormData::Set(const nsAString& aName, Blob& aBlob, { FormDataTuple* tuple = RemoveAllOthersAndGetFirstFormDataTuple(aName); if (tuple) { - nsRefPtr file = CreateNewFileInstance(aBlob, aFilename); + RefPtr file = CreateNewFileInstance(aBlob, aFilename); SetNameFilePair(tuple, aName, file); } else { Append(aName, aBlob, aFilename); @@ -249,7 +249,7 @@ nsFormData::Append(const nsAString& aName, nsIVariant* aValue) free(iid); nsCOMPtr domBlob = do_QueryInterface(supports); - nsRefPtr blob = static_cast(domBlob.get()); + RefPtr blob = static_cast(domBlob.get()); if (domBlob) { Optional temp; Append(aName, *blob, temp); @@ -280,7 +280,7 @@ nsFormData::Constructor(const GlobalObject& aGlobal, const Optional >& aFormElement, ErrorResult& aRv) { - nsRefPtr formData = new nsFormData(aGlobal.GetAsSupports()); + RefPtr formData = new nsFormData(aGlobal.GetAsSupports()); if (aFormElement.WasPassed()) { aRv = aFormElement.Value().WalkFormElements(formData); } diff --git a/dom/base/nsFormData.h b/dom/base/nsFormData.h index 0d810da000..0ec96f5945 100644 --- a/dom/base/nsFormData.h +++ b/dom/base/nsFormData.h @@ -42,7 +42,7 @@ private: { nsString name; nsString stringValue; - nsRefPtr fileValue; + RefPtr fileValue; bool valueIsFile; }; diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 1fe83cf535..70c1c6ccb3 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -247,7 +247,7 @@ nsFrameLoader::FireErrorEvent() if (!mOwnerContent) { return; } - nsRefPtr loadBlockingAsyncDispatcher = + RefPtr loadBlockingAsyncDispatcher = new LoadBlockingAsyncEventDispatcher(mOwnerContent, NS_LITERAL_STRING("error"), false, false); @@ -278,7 +278,7 @@ NS_IMETHODIMP nsFrameLoader::SwitchProcessAndLoadURI(nsIURI* aURI) { nsCOMPtr URIToLoad = aURI; - nsRefPtr tp = nullptr; + RefPtr tp = nullptr; MutableTabContext context; nsCOMPtr ownApp = GetOwnApp(); @@ -778,7 +778,7 @@ nsFrameLoader::MarginsChanged(uint32_t aMarginWidth, // Trigger a restyle if there's a prescontext // FIXME: This could do something much less expensive. - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (presContext) presContext->RebuildAllStyleData(nsChangeHint(0), eRestyle_Subtree); @@ -804,7 +804,7 @@ nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size, return false; } - nsRefPtr layerManager = + RefPtr layerManager = nsContentUtils::LayerManagerForDocument(mOwnerContent->GetComposedDoc()); if (!layerManager) { // This is just not going to work. @@ -870,8 +870,8 @@ nsFrameLoader::Hide() nsresult nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, - nsRefPtr& aFirstToSwap, - nsRefPtr& aSecondToSwap) + RefPtr& aFirstToSwap, + RefPtr& aSecondToSwap) { MOZ_ASSERT(NS_IsMainThread()); @@ -948,7 +948,7 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, aOther->mRemoteBrowser->ManagedPPluginWidgetParent(); nsPIDOMWindow* newWin = ourDoc->GetWindow(); if (newWin) { - nsRefPtr newParent = ((nsGlobalWindow*)newWin)->GetMainWidget(); + RefPtr newParent = ((nsGlobalWindow*)newWin)->GetMainWidget(); for (uint32_t idx = 0; idx < plugins.Length(); ++idx) { static_cast(plugins[idx])->SetParent(newParent); } @@ -966,8 +966,8 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, MaybeUpdatePrimaryTabParent(eTabParentChanged); aOther->MaybeUpdatePrimaryTabParent(eTabParentChanged); - nsRefPtr ourMessageManager = mMessageManager; - nsRefPtr otherMessageManager = aOther->mMessageManager; + RefPtr ourMessageManager = mMessageManager; + RefPtr otherMessageManager = aOther->mMessageManager; // Swap and setup things in parent message managers. if (mMessageManager) { mMessageManager->SetCallback(aOther); @@ -1039,10 +1039,10 @@ public: } private: - nsRefPtr mThisFrameLoader; - nsRefPtr mOtherFrameLoader; - nsRefPtr mThisDocShell; - nsRefPtr mOtherDocShell; + RefPtr mThisFrameLoader; + RefPtr mOtherFrameLoader; + RefPtr mThisDocShell; + RefPtr mOtherDocShell; nsCOMPtr mThisEventTarget; nsCOMPtr mOtherEventTarget; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER @@ -1050,8 +1050,8 @@ private: nsresult nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, - nsRefPtr& aFirstToSwap, - nsRefPtr& aSecondToSwap) + RefPtr& aFirstToSwap, + RefPtr& aSecondToSwap) { NS_PRECONDITION((aFirstToSwap == this && aSecondToSwap == aOther) || (aFirstToSwap == aOther && aSecondToSwap == this), @@ -1084,8 +1084,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, return NS_ERROR_DOM_SECURITY_ERR; } - nsRefPtr ourDocshell = static_cast(GetExistingDocShell()); - nsRefPtr otherDocshell = static_cast(aOther->GetExistingDocShell()); + RefPtr ourDocshell = static_cast(GetExistingDocShell()); + RefPtr otherDocshell = static_cast(aOther->GetExistingDocShell()); if (!ourDocshell || !otherDocshell) { // How odd return NS_ERROR_NOT_IMPLEMENTED; @@ -1280,8 +1280,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, ourWindow->SetFrameElementInternal(otherFrameElement); otherWindow->SetFrameElementInternal(ourFrameElement); - nsRefPtr ourMessageManager = mMessageManager; - nsRefPtr otherMessageManager = aOther->mMessageManager; + RefPtr ourMessageManager = mMessageManager; + RefPtr otherMessageManager = aOther->mMessageManager; // Swap pointers in child message managers. if (mChildMessageManager) { nsInProcessTabChildGlobal* tabChild = @@ -1355,7 +1355,7 @@ class nsFrameLoaderDestroyRunnable : public nsRunnable eDestroyComplete }; - nsRefPtr mFrameLoader; + RefPtr mFrameLoader; DestroyPhase mPhase; public: @@ -2443,7 +2443,7 @@ nsFrameLoader::DoLoadMessageManagerScript(const nsAString& aURL, bool aRunInGlob if (tabParent) { return tabParent->SendLoadRemoteScript(nsString(aURL), aRunInGlobalScope); } - nsRefPtr tabChild = + RefPtr tabChild = static_cast(GetTabChildGlobalAsEventTarget()); if (tabChild) { tabChild->LoadFrameScript(aURL, aRunInGlobalScope); @@ -2479,7 +2479,7 @@ public: } return NS_OK; } - nsRefPtr mFrameLoader; + RefPtr mFrameLoader; }; bool @@ -2543,7 +2543,7 @@ nsFrameLoader::GetMessageManager(nsIMessageSender** aManager) { EnsureMessageManager(); if (mMessageManager) { - nsRefPtr mm(mMessageManager); + RefPtr mm(mMessageManager); mm.forget(aManager); return NS_OK; } @@ -2656,7 +2656,7 @@ nsFrameLoader::SetRemoteBrowser(nsITabParent* aTabParent) nsresult nsFrameLoader::SwapRemoteBrowser(nsITabParent* aTabParent) { - nsRefPtr newParent = TabParent::GetFrom(aTabParent); + RefPtr newParent = TabParent::GetFrom(aTabParent); if (!newParent || !mRemoteBrowser) { return NS_ERROR_DOM_INVALID_STATE_ERR; } @@ -2885,7 +2885,7 @@ nsFrameLoader::RequestNotifyLayerTreeReady() return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr event = + RefPtr event = new AsyncEventDispatcher(mOwnerContent, NS_LITERAL_STRING("MozLayerTreeReady"), true, false); @@ -2905,7 +2905,7 @@ nsFrameLoader::RequestNotifyLayerTreeCleared() return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr event = + RefPtr event = new AsyncEventDispatcher(mOwnerContent, NS_LITERAL_STRING("MozLayerTreeCleared"), true, false); diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index 28a9e4be81..afd866fdfa 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -124,12 +124,12 @@ public: // frame loader owner needs to call this, and pass in the two references to // nsRefPtrs for frame loaders that need to be swapped. nsresult SwapWithOtherLoader(nsFrameLoader* aOther, - nsRefPtr& aFirstToSwap, - nsRefPtr& aSecondToSwap); + RefPtr& aFirstToSwap, + RefPtr& aSecondToSwap); nsresult SwapWithOtherRemoteLoader(nsFrameLoader* aOther, - nsRefPtr& aFirstToSwap, - nsRefPtr& aSecondToSwap); + RefPtr& aFirstToSwap, + RefPtr& aSecondToSwap); /** * Return the primary frame for our owning content, or null if it @@ -219,7 +219,7 @@ public: nsresult GetWindowDimensions(nsIntRect& aRect); // public because a callback needs these. - nsRefPtr mMessageManager; + RefPtr mMessageManager; nsCOMPtr mChildMessageManager; private: @@ -328,7 +328,7 @@ private: // After the frameloader has been removed from the DOM but before all of the // messages from the frame have been received, we keep a strong reference to // our element. - nsRefPtr mOwnerContentStrong; + RefPtr mOwnerContentStrong; // Note: this variable must be modified only by ResetPermissionManagerStatus() uint32_t mAppIdSentToPermissionManager; diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 3af6e00372..e7a31e78cd 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -282,7 +282,7 @@ BuildClonedMessageData(typename BlobTraits::ConcreteContentManagerType* SerializedStructuredCloneBuffer& buffer = aClonedData.data(); buffer.data = aData.Data(); buffer.dataLength = aData.DataLength(); - const nsTArray>& blobImpls = aData.BlobImpls(); + const nsTArray>& blobImpls = aData.BlobImpls(); if (!blobImpls.IsEmpty()) { typedef typename BlobTraits::ProtocolType ProtocolType; @@ -336,7 +336,7 @@ UnpackClonedMessageData(const ClonedMessageData& aClonedData, static_cast::BlobType*>(blobs[i]); MOZ_ASSERT(blob); - nsRefPtr blobImpl = blob->GetBlobImpl(); + RefPtr blobImpl = blob->GetBlobImpl(); MOZ_ASSERT(blobImpl); aData.BlobImpls().AppendElement(blobImpl); @@ -532,7 +532,7 @@ nsFrameMessageManager::LoadScript(const nsAString& aURL, } for (int32_t i = 0; i < mChildManagers.Count(); ++i) { - nsRefPtr mm = + RefPtr mm = static_cast(mChildManagers[i]); if (mm) { // Use false here, so that child managers don't cache the script, which @@ -1051,7 +1051,7 @@ public: } bool mWasHandlingMessage; - nsRefPtr mMM; + RefPtr mMM; }; @@ -1281,7 +1281,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, } } } - nsRefPtr kungfuDeathGrip = mParentManager; + RefPtr kungfuDeathGrip = mParentManager; return mParentManager ? mParentManager->ReceiveMessage(aTarget, aTargetFrameLoader, aTargetClosed, aMessage, aIsSync, aCloneData, @@ -1294,8 +1294,8 @@ nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager) { mChildManagers.AppendObject(aManager); - nsRefPtr kungfuDeathGrip = this; - nsRefPtr kungfuDeathGrip2 = aManager; + RefPtr kungfuDeathGrip = this; + RefPtr kungfuDeathGrip2 = aManager; LoadPendingScripts(this, aManager); } @@ -1322,7 +1322,7 @@ nsFrameMessageManager::LoadPendingScripts(nsFrameMessageManager* aManager, void nsFrameMessageManager::LoadPendingScripts() { - nsRefPtr kungfuDeathGrip = this; + RefPtr kungfuDeathGrip = this; LoadPendingScripts(this, this); } @@ -1539,7 +1539,7 @@ MessageManagerReporter::CountReferents(nsFrameMessageManager* aMessageManager, // Add referent count in child managers because the listeners // participate in messages dispatched from parent message manager. for (uint32_t i = 0; i < aMessageManager->mChildManagers.Length(); ++i) { - nsRefPtr mm = + RefPtr mm = static_cast(aMessageManager->mChildManagers[i]); CountReferents(mm, aReferentCount); } @@ -1603,7 +1603,7 @@ MessageManagerReporter::CollectReports(nsIMemoryReporterCallback* aCb, nsCOMPtr globalmm = do_GetService("@mozilla.org/globalmessagemanager;1"); if (globalmm) { - nsRefPtr mm = + RefPtr mm = static_cast(globalmm.get()); MessageManagerReferentCount count; CountReferents(mm, &count); @@ -1637,7 +1637,7 @@ NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult) { NS_ENSURE_TRUE(XRE_IsParentProcess(), NS_ERROR_NOT_AVAILABLE); - nsRefPtr mm = new nsFrameMessageManager(nullptr, + RefPtr mm = new nsFrameMessageManager(nullptr, nullptr, MM_CHROME | MM_GLOBAL | MM_BROADCASTER); RegisterStrongMemoryReporter(new MessageManagerReporter()); @@ -1657,7 +1657,7 @@ nsMessageManagerScriptExecutor::DidCreateGlobal() sCachedScripts = new nsDataHashtable; - nsRefPtr scriptCacheCleaner = + RefPtr scriptCacheCleaner = new nsScriptCacheCleaner(); scriptCacheCleaner.forget(&sScriptCacheCleaner); } @@ -1684,7 +1684,7 @@ nsMessageManagerScriptExecutor::Shutdown() delete sCachedScripts; sCachedScripts = nullptr; - nsRefPtr scriptCacheCleaner; + RefPtr scriptCacheCleaner; scriptCacheCleaner.swap(sScriptCacheCleaner); } } @@ -2093,7 +2093,7 @@ public: if (nsFrameMessageManager::sSameProcessParentManager) { SameProcessCpowHolder cpows(js::GetRuntime(aCx), aCpows); - nsRefPtr ppm = nsFrameMessageManager::sSameProcessParentManager; + RefPtr ppm = nsFrameMessageManager::sSameProcessParentManager; ppm->ReceiveMessage(static_cast(ppm.get()), nullptr, aMessage, true, &aData, &cpows, aPrincipal, aRetVal); } @@ -2107,7 +2107,7 @@ public: nsIPrincipal* aPrincipal) override { SameProcessMessageQueue* queue = SameProcessMessageQueue::Get(); - nsRefPtr ev = + RefPtr ev = new nsAsyncMessageToSameProcessParent(aCx, aMessage, aData, aCpows, aPrincipal); queue->Push(ev); return true; @@ -2122,7 +2122,7 @@ NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult) { NS_ASSERTION(!nsFrameMessageManager::sParentProcessManager, "Re-creating sParentProcessManager"); - nsRefPtr mm = new nsFrameMessageManager(nullptr, + RefPtr mm = new nsFrameMessageManager(nullptr, nullptr, MM_CHROME | MM_PROCESSMANAGER | MM_BROADCASTER); nsFrameMessageManager::sParentProcessManager = mm; @@ -2175,7 +2175,7 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult) nullptr, MM_PROCESSMANAGER | MM_OWNSCALLBACK); nsFrameMessageManager::SetChildProcessManager(mm); - nsRefPtr global = new ProcessGlobal(mm); + RefPtr global = new ProcessGlobal(mm); NS_ENSURE_TRUE(global->Init(), NS_ERROR_UNEXPECTED); global.forget(aResult); return NS_OK; @@ -2233,7 +2233,7 @@ nsSameProcessAsyncMessageBase::ReceiveMessage(nsISupports* aTarget, if (aManager) { SameProcessCpowHolder cpows(mRuntime, mCpows); - nsRefPtr mm = aManager; + RefPtr mm = aManager; mm->ReceiveMessage(aTarget, aTargetFrameLoader, mMessage, false, &mData, &cpows, mPrincipal, nullptr); } diff --git a/dom/base/nsFrameMessageManager.h b/dom/base/nsFrameMessageManager.h index d247fdfc47..00d06cbe28 100644 --- a/dom/base/nsFrameMessageManager.h +++ b/dom/base/nsFrameMessageManager.h @@ -289,7 +289,7 @@ protected: bool mDisconnected; mozilla::dom::ipc::MessageManagerCallback* mCallback; nsAutoPtr mOwnedCallback; - nsRefPtr mParentManager; + RefPtr mParentManager; nsTArray mPendingScripts; nsTArray mPendingScriptsGlobalStates; JS::Heap mInitialProcessData; diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h index 840f11fb4d..52b44c1bd3 100644 --- a/dom/base/nsGenericDOMDataNode.h +++ b/dom/base/nsGenericDOMDataNode.h @@ -270,7 +270,7 @@ protected: /** * @see nsIContent::GetContainingShadow */ - nsRefPtr mContainingShadow; + RefPtr mContainingShadow; /** * @see nsIContent::GetDestInsertionPoints diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 3bd9571713..69af709612 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1364,7 +1364,7 @@ nsGlobalWindow::DisconnectEventTargetObjects() { for (auto iter = mEventTargetObjects.ConstIter(); !iter.Done(); iter.Next()) { - nsRefPtr target = iter.Get()->GetKey(); + RefPtr target = iter.Get()->GetKey(); target->DisconnectFromOwner(); } mEventTargetObjects.Clear(); @@ -2450,7 +2450,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, currentInner->mNavigator->OnNavigation(); } - nsRefPtr newInnerWindow; + RefPtr newInnerWindow; bool createdInnerWindow = false; bool thisChrome = IsChromeWindow(); @@ -2909,7 +2909,7 @@ nsGlobalWindow::DetachFromDocShell() // Call FreeInnerObjects on all inner windows, not just the current // one, since some could be held by WindowStateHolder objects that // are GC-owned. - for (nsRefPtr inner = (nsGlobalWindow *)PR_LIST_HEAD(this); + for (RefPtr inner = (nsGlobalWindow *)PR_LIST_HEAD(this); inner != this; inner = (nsGlobalWindow*)PR_NEXT_LINK(inner)) { NS_ASSERTION(!inner->mOuterWindow || inner->mOuterWindow == this, @@ -2991,7 +2991,7 @@ TryGetTabChildGlobalAsEventTarget(nsISupports *aFrom) return nullptr; } - nsRefPtr frameLoader = frameLoaderOwner->GetFrameLoader(); + RefPtr frameLoader = frameLoaderOwner->GetFrameLoader(); if (!frameLoader) { return nullptr; } @@ -3612,7 +3612,7 @@ nsGlobalWindow::GetScreen(nsIDOMScreen** aScreen) FORWARD_TO_INNER(GetScreen, (aScreen), NS_ERROR_UNEXPECTED); ErrorResult rv; - nsRefPtr screen = GetScreen(rv); + RefPtr screen = GetScreen(rv); screen.forget(aScreen); return rv.StealNSResult(); @@ -3658,7 +3658,7 @@ nsPIDOMWindow::CreatePerformanceObjectIfNeeded() if (mPerformance || !mDoc) { return; } - nsRefPtr timing = mDoc->GetNavigationTiming(); + RefPtr timing = mDoc->GetNavigationTiming(); nsCOMPtr timedChannel(do_QueryInterface(mDoc->GetChannel())); bool timingEnabled = false; if (!timedChannel || @@ -3743,7 +3743,7 @@ nsPIDOMWindow::SetAudioVolume(float aVolume) void nsPIDOMWindow::RefreshMediaElements() { - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); service->RefreshAgentsVolume(GetOuterWindow()); } @@ -3761,7 +3761,7 @@ nsPIDOMWindow::SetAudioCapture(bool aCapture) mAudioCaptured = aCapture; - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); service->RefreshAgentsCapture(GetOuterWindow(), mWindowID); return NS_OK; @@ -4413,7 +4413,7 @@ nsGlobalWindow::GetApplicationCache(ErrorResult& aError) nsCOMPtr manifestURI; nsContentUtils::GetOfflineAppManifest(mDoc, getter_AddRefs(manifestURI)); - nsRefPtr applicationCache = + RefPtr applicationCache = new nsDOMOfflineResourceList(manifestURI, uri, this); applicationCache->Init(); @@ -4792,7 +4792,7 @@ nsGlobalWindow::DevToCSSIntPixels(int32_t px) if (!mDocShell) return px; // assume 1:1 - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; @@ -4806,7 +4806,7 @@ nsGlobalWindow::CSSToDevIntPixels(int32_t px) if (!mDocShell) return px; // assume 1:1 - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; @@ -4820,7 +4820,7 @@ nsGlobalWindow::DevToCSSIntPixels(nsIntSize px) if (!mDocShell) return px; // assume 1:1 - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; @@ -4836,7 +4836,7 @@ nsGlobalWindow::CSSToDevIntPixels(nsIntSize px) if (!mDocShell) return px; // assume 1:1 - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; @@ -4855,9 +4855,9 @@ nsGlobalWindow::GetInnerSize(CSSIntSize& aSize) NS_ENSURE_STATE(mDocShell); - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); - nsRefPtr presShell = mDocShell->GetPresShell(); + RefPtr presShell = mDocShell->GetPresShell(); if (!presContext || !presShell) { aSize = CSSIntSize(0, 0); @@ -4874,7 +4874,7 @@ nsGlobalWindow::GetInnerSize(CSSIntSize& aSize) aSize = CSSIntRect::FromAppUnitsRounded( presShell->GetScrollPositionClampingScrollPortSize()); } else { - nsRefPtr viewManager = presShell->GetViewManager(); + RefPtr viewManager = presShell->GetViewManager(); if (viewManager) { viewManager->FlushDelayedResize(false); } @@ -4933,13 +4933,13 @@ nsGlobalWindow::SetInnerWidthOuter(int32_t aInnerWidth, ErrorResult& aError) CheckSecurityWidthAndHeight(&aInnerWidth, nullptr); - nsRefPtr presShell = mDocShell->GetPresShell(); + RefPtr presShell = mDocShell->GetPresShell(); if (presShell && presShell->GetIsViewportOverridden()) { nscoord height = 0; - nsRefPtr presContext; + RefPtr presContext; presContext = presShell->GetPresContext(); nsRect shellArea = presContext->GetVisibleArea(); @@ -5032,11 +5032,11 @@ nsGlobalWindow::SetInnerHeightOuter(int32_t aInnerHeight, ErrorResult& aError) return; } - nsRefPtr presShell = mDocShell->GetPresShell(); + RefPtr presShell = mDocShell->GetPresShell(); if (presShell && presShell->GetIsViewportOverridden()) { - nsRefPtr presContext; + RefPtr presContext; presContext = presShell->GetPresContext(); nsRect shellArea = presContext->GetVisibleArea(); @@ -5445,7 +5445,7 @@ nsGlobalWindow::GetDevicePixelRatioOuter() return 1.0; } - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) { return 1.0; @@ -5536,7 +5536,7 @@ nsGlobalWindow::RequestAnimationFrame(JS::Handle aCallback, } JS::Rooted callbackObj(cx, &aCallback.toObject()); - nsRefPtr callback = + RefPtr callback = new FrameRequestCallback(cx, callbackObj, GetIncumbentGlobal()); ErrorResult rv; @@ -5598,7 +5598,7 @@ nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList, FORWARD_TO_INNER(MatchMedia, (aMediaQueryList, aResult), NS_ERROR_UNEXPECTED); ErrorResult rv; - nsRefPtr mediaQueryList = MatchMedia(aMediaQueryList, rv); + RefPtr mediaQueryList = MatchMedia(aMediaQueryList, rv); mediaQueryList.forget(aResult); return rv.StealNSResult(); @@ -5796,7 +5796,7 @@ nsGlobalWindow::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInner { MOZ_ASSERT(IsOuterWindow()); - nsRefPtr presContext; + RefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); nsRect shellArea = presContext->GetVisibleArea(); @@ -6129,7 +6129,7 @@ nsGlobalWindow::DispatchResizeEvent(const CSSIntSize& aSize) MOZ_ASSERT(IsOuterWindow()); ErrorResult res; - nsRefPtr domEvent = + RefPtr domEvent = mDoc->CreateEvent(NS_LITERAL_STRING("CustomEvent"), res); if (res.Failed()) { return false; @@ -6352,7 +6352,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aFullscreenMode, } if (!mWakeLock && mFullScreen) { - nsRefPtr pmService = + RefPtr pmService = power::PowerManagerService::GetInstance(); NS_ENSURE_TRUE(pmService, NS_OK); @@ -7927,7 +7927,7 @@ nsGlobalWindow::FirePopupBlockedEvent(nsIDocument* aDoc, init.mPopupWindowName = aPopupWindowName; init.mPopupWindowFeatures = aPopupWindowFeatures; - nsRefPtr event = + RefPtr event = PopupBlockedEvent::Constructor(aDoc, NS_LITERAL_STRING("DOMPopupBlocked"), init); @@ -8201,7 +8201,7 @@ nsGlobalWindow::OpenDialog(JSContext* aCx, const nsAString& aUrl, already_AddRefed nsGlobalWindow::GetFramesOuter() { - nsRefPtr frames(this); + RefPtr frames(this); FlushPendingNotifications(Flush_ContentAndNotify); return frames.forget(); } @@ -8264,7 +8264,7 @@ nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle aMessa // // First, get the caller's window - nsRefPtr callerInnerWin = CallerInnerWindow(); + RefPtr callerInnerWin = CallerInnerWindow(); nsIPrincipal* callerPrin; if (callerInnerWin) { MOZ_ASSERT(callerInnerWin->IsInnerWindow(), @@ -8352,7 +8352,7 @@ nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle aMessa // Create and asynchronously dispatch a runnable which will handle actual DOM // event creation and dispatch. - nsRefPtr event = + RefPtr event = new PostMessageEvent(nsContentUtils::IsCallerChrome() || !callerInnerWin ? nullptr : callerInnerWin->GetOuterWindowInternal(), @@ -8426,7 +8426,7 @@ nsGlobalWindow::PostMessageMoz(JS::Handle aMessage, class nsCloseEvent : public nsRunnable { - nsRefPtr mWindow; + RefPtr mWindow; bool mIndirect; nsCloseEvent(nsGlobalWindow *aWindow, bool aIndirect) @@ -8715,7 +8715,7 @@ nsGlobalWindow::EnterModalState() activeShell->SetCapturingContent(nullptr, 0); if (activeShell) { - nsRefPtr frameSelection = activeShell->FrameSelection(); + RefPtr frameSelection = activeShell->FrameSelection(); frameSelection->SetDragState(false); } } @@ -8816,7 +8816,7 @@ public: } private: - nsRefPtr mWindow; + RefPtr mWindow; }; void @@ -8852,7 +8852,7 @@ nsGlobalWindow::LeaveModalState() inner->mLastDialogQuitTime = TimeStamp::Now(); if (topWin->mModalStateDepth == 0) { - nsRefPtr event = NS_NewDOMEvent(topWin, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(topWin, nullptr, nullptr); event->InitEvent(NS_LITERAL_STRING("endmodalstate"), true, false); event->SetTrusted(true); event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true; @@ -9260,7 +9260,7 @@ nsGlobalWindow::ShowModalDialogOuter(const nsAString& aUrl, nsIVariant* aArgumen Telemetry::Accumulate(Telemetry::DOM_WINDOW_SHOWMODALDIALOG_USED, true); - nsRefPtr argHolder = + RefPtr argHolder = new DialogValueHolder(nsContentUtils::SubjectPrincipal(), aArgument); // Before bringing up the window/dialog, unsuppress painting and flush @@ -9406,7 +9406,7 @@ public: } private: - nsRefPtr mWindow; + RefPtr mWindow; nsCOMPtr mTabChild; nsString mAction; }; @@ -9646,7 +9646,7 @@ nsGlobalWindow::RemoveEventListener(const nsAString& aType, nsIDOMEventListener* aListener, bool aUseCapture) { - if (nsRefPtr elm = GetExistingListenerManager()) { + if (RefPtr elm = GetExistingListenerManager()) { elm->RemoveEventListener(aType, aListener, aUseCapture); } return NS_OK; @@ -9671,7 +9671,7 @@ nsGlobalWindow::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal) // Obtain a presentation shell nsIPresShell *shell = mDoc->GetShell(); - nsRefPtr presContext; + RefPtr presContext; if (shell) { // Retrieve the context presContext = shell->GetPresContext(); @@ -9995,7 +9995,7 @@ nsGlobalWindow::EnableGamepadUpdates() if (mHasGamepad) { #ifdef MOZ_GAMEPAD - nsRefPtr gamepadsvc(GamepadService::GetService()); + RefPtr gamepadsvc(GamepadService::GetService()); if (gamepadsvc) { gamepadsvc->AddListener(this); } @@ -10010,7 +10010,7 @@ nsGlobalWindow::DisableGamepadUpdates() if (mHasGamepad) { #ifdef MOZ_GAMEPAD - nsRefPtr gamepadsvc(GamepadService::GetService()); + RefPtr gamepadsvc(GamepadService::GetService()); if (gamepadsvc) { gamepadsvc->RemoveListener(this); } @@ -10252,7 +10252,7 @@ public: private: nsString mOldURL; nsString mNewURL; - nsRefPtr mWindow; + RefPtr mWindow; }; nsresult @@ -10296,7 +10296,7 @@ nsGlobalWindow::FireHashchange(const nsAString &aOldURL, NS_ENSURE_STATE(IsCurrentInnerWindow()); nsIPresShell *shell = mDoc->GetShell(); - nsRefPtr presContext; + RefPtr presContext; if (shell) { presContext = shell->GetPresContext(); } @@ -10307,7 +10307,7 @@ nsGlobalWindow::FireHashchange(const nsAString &aOldURL, init.mNewURL = aNewURL; init.mOldURL = aOldURL; - nsRefPtr event = + RefPtr event = HashChangeEvent::Constructor(this, NS_LITERAL_STRING("hashchange"), init); @@ -10345,7 +10345,7 @@ nsGlobalWindow::DispatchSyncPopState() // Obtain a presentation shell for use in creating a popstate event. nsIPresShell *shell = mDoc->GetShell(); - nsRefPtr presContext; + RefPtr presContext; if (shell) { presContext = shell->GetPresContext(); } @@ -10369,7 +10369,7 @@ nsGlobalWindow::DispatchSyncPopState() init.mCancelable = false; init.mState = stateJSValue; - nsRefPtr event = + RefPtr event = PopStateEvent::Constructor(outerWindowET, NS_LITERAL_STRING("popstate"), init); event->SetTrusted(true); @@ -10540,7 +10540,7 @@ nsGlobalWindow::GetComputedStyleHelperOuter(Element& aElt, } } - nsRefPtr compStyle = + RefPtr compStyle = NS_NewComputedDOMStyle(&aElt, aPseudoElt, presShell, aDefaultStylesOnly ? nsComputedDOMStyle::eDefaultOnly : nsComputedDOMStyle::eAll); @@ -10843,7 +10843,7 @@ nsGlobalWindow::GetCaches(ErrorResult& aRv) forceTrustedOrigin, aRv); } - nsRefPtr ref = mCacheStorage; + RefPtr ref = mCacheStorage; return ref.forget(); } @@ -10908,7 +10908,7 @@ public: private: nsCOMPtr mIdleObserver; uint32_t mTimeInS; - nsRefPtr mIdleWindow; + RefPtr mIdleWindow; // If false then call on active bool mCallOnidle; @@ -10950,7 +10950,7 @@ nsGlobalWindow::ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t aT void IdleActiveTimerCallback(nsITimer* aTimer, void* aClosure) { - nsRefPtr idleWindow = static_cast(aClosure); + RefPtr idleWindow = static_cast(aClosure); MOZ_ASSERT(idleWindow, "Idle window has not been instantiated."); idleWindow->HandleIdleActiveEvent(); } @@ -10958,7 +10958,7 @@ IdleActiveTimerCallback(nsITimer* aTimer, void* aClosure) void IdleObserverTimerCallback(nsITimer* aTimer, void* aClosure) { - nsRefPtr idleWindow = static_cast(aClosure); + RefPtr idleWindow = static_cast(aClosure); MOZ_ASSERT(idleWindow, "Idle window has not been instantiated."); idleWindow->HandleIdleObserverCallback(); } @@ -11114,7 +11114,7 @@ nsGlobalWindow::ShowSlowScriptDialog() if (XRE_IsContentProcess() && ProcessHangMonitor::Get()) { ProcessHangMonitor::SlowScriptAction action; - nsRefPtr monitor = ProcessHangMonitor::Get(); + RefPtr monitor = ProcessHangMonitor::Get(); nsCOMPtr child = do_GetInterface(GetDocShell()); action = monitor->NotifySlowScript(child, filename.get(), @@ -11127,7 +11127,7 @@ nsGlobalWindow::ShowSlowScriptDialog() // Spin a nested event loop so that the debugger in the parent can fetch // any information it needs. Once the debugger has started, return to the // script. - nsRefPtr outer = GetOuterWindowInternal(); + RefPtr outer = GetOuterWindowInternal(); outer->EnterModalState(); while (!monitor->IsDebuggerStartupComplete()) { NS_ProcessNextEvent(nullptr, true); @@ -11521,12 +11521,12 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, nsIPrincipal *principal; nsresult rv; - nsRefPtr event = static_cast(aSubject); + RefPtr event = static_cast(aSubject); if (!event) { return NS_ERROR_FAILURE; } - nsRefPtr changingStorage = event->GetStorageArea(); + RefPtr changingStorage = event->GetStorageArea(); if (!changingStorage) { return NS_ERROR_FAILURE; } @@ -11595,7 +11595,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, // Clone the storage event included in the observer notification. We want // to dispatch clones rather than the original event. ErrorResult error; - nsRefPtr newEvent = + RefPtr newEvent = CloneStorageEvent(fireMozStorageChanged ? NS_LITERAL_STRING("MozStorageChanged") : NS_LITERAL_STRING("storage"), @@ -11650,7 +11650,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); nsresult rv = event->InitEvent( !nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC) ? NETWORK_UPLOAD_EVENT_NAME @@ -11686,7 +11686,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); nsresult rv = event->InitEvent(NS_LITERAL_STRING("languagechange"), false, false); NS_ENSURE_SUCCESS(rv, rv); @@ -11702,7 +11702,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, already_AddRefed nsGlobalWindow::CloneStorageEvent(const nsAString& aType, - const nsRefPtr& aEvent, + const RefPtr& aEvent, ErrorResult& aRv) { MOZ_ASSERT(IsInnerWindow()); @@ -11716,10 +11716,10 @@ nsGlobalWindow::CloneStorageEvent(const nsAString& aType, aEvent->GetNewValue(dict.mNewValue); aEvent->GetUrl(dict.mUrl); - nsRefPtr storageArea = aEvent->GetStorageArea(); + RefPtr storageArea = aEvent->GetStorageArea(); MOZ_ASSERT(storageArea); - nsRefPtr storage; + RefPtr storage; if (storageArea->GetType() == DOMStorage::LocalStorage) { storage = GetLocalStorage(aRv); } else { @@ -11736,7 +11736,7 @@ nsGlobalWindow::CloneStorageEvent(const nsAString& aType, dict.mStorageArea = storage; - nsRefPtr event = StorageEvent::Constructor(this, aType, dict); + RefPtr event = StorageEvent::Constructor(this, aType, dict); return event.forget(); } @@ -11824,7 +11824,7 @@ nsGlobalWindow::UnblockScriptedClosing() class AutoUnblockScriptClosing { private: - nsRefPtr mWin; + RefPtr mWin; public: explicit AutoUnblockScriptClosing(nsGlobalWindow* aWin) : mWin(aWin) @@ -12186,7 +12186,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, interval = maxTimeoutMs; } - nsRefPtr timeout = new nsTimeout(); + RefPtr timeout = new nsTimeout(); timeout->mIsInterval = aIsInterval; timeout->mInterval = interval; timeout->mScriptHandler = aHandler; @@ -12233,7 +12233,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, return rv; } - nsRefPtr copy = timeout; + RefPtr copy = timeout; rv = timeout->InitTimer(realInterval); if (NS_FAILED(rv)) { @@ -12346,7 +12346,7 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout, { // Hold on to the timeout in case mExpr or mFunObj releases its // doc. - nsRefPtr timeout = aTimeout; + RefPtr timeout = aTimeout; nsTimeout* last_running_timeout = mRunningTimeout; mRunningTimeout = timeout; timeout->mRunning = true; @@ -12379,7 +12379,7 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout, } nsCOMPtr handler(timeout->mScriptHandler); - nsRefPtr callback = handler->GetCallback(); + RefPtr callback = handler->GetCallback(); if (!callback) { // Evaluate the timeout expression. const char16_t* script = handler->GetHandlerText(); @@ -12582,11 +12582,11 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout) // timeouts that will be processed in a future call to // win_run_timeout(). This dummy timeout serves as the head of the // list for any timeouts inserted as a result of running a timeout. - nsRefPtr dummy_timeout = new nsTimeout(); + RefPtr dummy_timeout = new nsTimeout(); dummy_timeout->mFiringDepth = firingDepth; dummy_timeout->mWhen = now; last_expired_timeout->setNext(dummy_timeout); - nsRefPtr timeoutExtraRef(dummy_timeout); + RefPtr timeoutExtraRef(dummy_timeout); last_insertion_point = mTimeoutInsertionPoint; // If we ever start setting mTimeoutInsertionPoint to a non-dummy timeout, @@ -12873,7 +12873,7 @@ nsGlobalWindow::InsertTimeoutIntoList(nsTimeout *aTimeout) void nsGlobalWindow::TimerCallback(nsITimer *aTimer, void *aClosure) { - nsRefPtr timeout = (nsTimeout *)aClosure; + RefPtr timeout = (nsTimeout *)aClosure; timeout->mWindow->RunTimeout(timeout); } @@ -12883,7 +12883,7 @@ void nsGlobalWindow::TimerNameCallback(nsITimer* aTimer, void* aClosure, char* aBuf, size_t aLen) { - nsRefPtr timeout = (nsTimeout*)aClosure; + RefPtr timeout = (nsTimeout*)aClosure; const char* filename; uint32_t lineNum, column; @@ -13437,7 +13437,7 @@ void nsGlobalWindow::RemoveGamepad(uint32_t aIndex) { MOZ_ASSERT(IsInnerWindow()); - nsRefPtr gamepad; + RefPtr gamepad; if (!mGamepads.Get(aIndex, getter_AddRefs(gamepad))) { return; } @@ -13451,15 +13451,15 @@ PLDHashOperator nsGlobalWindow::EnumGamepadsForGet(const uint32_t& aKey, Gamepad* aData, void* aUserArg) { - nsTArray >* array = - static_cast >*>(aUserArg); + nsTArray >* array = + static_cast >*>(aUserArg); array->EnsureLengthAtLeast(aData->Index() + 1); (*array)[aData->Index()] = aData; return PL_DHASH_NEXT; } void -nsGlobalWindow::GetGamepads(nsTArray >& aGamepads) +nsGlobalWindow::GetGamepads(nsTArray >& aGamepads) { MOZ_ASSERT(IsInnerWindow()); aGamepads.Clear(); @@ -13472,7 +13472,7 @@ already_AddRefed nsGlobalWindow::GetGamepad(uint32_t aIndex) { MOZ_ASSERT(IsInnerWindow()); - nsRefPtr gamepad; + RefPtr gamepad; if (mGamepads.Get(aIndex, getter_AddRefs(gamepad))) { return gamepad.forget(); @@ -13500,7 +13500,7 @@ PLDHashOperator nsGlobalWindow::EnumGamepadsForSync(const uint32_t& aKey, Gamepad* aData, void* aUserArg) { - nsRefPtr gamepadsvc(GamepadService::GetService()); + RefPtr gamepadsvc(GamepadService::GetService()); gamepadsvc->SyncGamepadState(aKey, aData); return PL_DHASH_NEXT; } @@ -13516,7 +13516,7 @@ nsGlobalWindow::SyncGamepadState() #endif // MOZ_GAMEPAD bool -nsGlobalWindow::GetVRDevices(nsTArray>& aDevices) +nsGlobalWindow::GetVRDevices(nsTArray>& aDevices) { FORWARD_TO_INNER(GetVRDevices, (aDevices), false); @@ -13570,7 +13570,7 @@ NS_IMPL_RELEASE_INHERITED(nsGlobalChromeWindow, nsGlobalWindow) /* static */ already_AddRefed nsGlobalChromeWindow::Create(nsGlobalWindow *aOuterWindow) { - nsRefPtr window = new nsGlobalChromeWindow(aOuterWindow); + RefPtr window = new nsGlobalChromeWindow(aOuterWindow); window->InitWasOffline(); return window.forget(); } @@ -13814,7 +13814,7 @@ nsGlobalWindow::SetCursorOuter(const nsAString& aCursor, ErrorResult& aError) } } - nsRefPtr presContext; + RefPtr presContext; if (mDocShell) { mDocShell->GetPresContext(getter_AddRefs(presContext)); } @@ -14079,7 +14079,7 @@ nsGlobalWindow::GetDialogArguments(JSContext* aCx, /* static */ already_AddRefed nsGlobalModalWindow::Create(nsGlobalWindow *aOuterWindow) { - nsRefPtr window = new nsGlobalModalWindow(aOuterWindow); + RefPtr window = new nsGlobalModalWindow(aOuterWindow); window->InitWasOffline(); return window.forget(); } @@ -14098,7 +14098,7 @@ nsGlobalModalWindow::GetDialogArguments(nsIVariant **aArguments) /* static */ already_AddRefed nsGlobalWindow::Create(nsGlobalWindow *aOuterWindow) { - nsRefPtr window = new nsGlobalWindow(aOuterWindow); + RefPtr window = new nsGlobalWindow(aOuterWindow); window->InitWasOffline(); return window.forget(); } @@ -14203,7 +14203,7 @@ nsGlobalWindow::GetConsole(JSContext* aCx, FORWARD_TO_INNER(GetConsole, (aCx, aConsole), NS_ERROR_FAILURE); ErrorResult rv; - nsRefPtr console = GetConsole(rv); + RefPtr console = GetConsole(rv); if (rv.Failed()) { return rv.StealNSResult(); } @@ -14252,7 +14252,7 @@ nsGlobalWindow::GetExternal(ErrorResult& aRv) mExternal = new External(jsImplObj, this); } - nsRefPtr external = static_cast(mExternal.get()); + RefPtr external = static_cast(mExternal.get()); return external.forget(); #else aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); @@ -14274,7 +14274,7 @@ nsGlobalWindow::GetSidebar(OwningExternalOrWindowProxy& aResult, return; } - nsRefPtr external = GetExternal(aRv); + RefPtr external = GetExternal(aRv); if (external) { aResult.SetAsExternal() = external; } diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 2156d6dd8b..4c023f7bd3 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -164,7 +164,7 @@ public: bool HasRefCntOne(); // Window for which this timeout fires - nsRefPtr mWindow; + RefPtr mWindow; // The actual timer object nsCOMPtr mTimer; @@ -759,7 +759,7 @@ public: // Inner windows only. void AddGamepad(uint32_t aIndex, mozilla::dom::Gamepad* aGamepad); void RemoveGamepad(uint32_t aIndex); - void GetGamepads(nsTArray >& aGamepads); + void GetGamepads(nsTArray >& aGamepads); already_AddRefed GetGamepad(uint32_t aIndex); void SetHasSeenGamepadInput(bool aHasSeen); bool HasSeenGamepadInput(); @@ -778,7 +778,7 @@ public: void DisableGamepadUpdates(); // Get the VR devices for this window, initializing if necessary - bool GetVRDevices(nsTArray>& aDevices); + bool GetVRDevices(nsTArray>& aDevices); #define EVENT(name_, id_, type_, struct_) \ mozilla::dom::EventHandlerNonNull* GetOn##name_() \ @@ -1249,7 +1249,7 @@ protected: nsCOMPtr mIdleService; - nsRefPtr mWakeLock; + RefPtr mWakeLock; static bool sIdleObserversAPIFuzzTimeDisabled; @@ -1565,7 +1565,7 @@ protected: // Inner windows only. already_AddRefed CloneStorageEvent(const nsAString& aType, - const nsRefPtr& aEvent, + const RefPtr& aEvent, mozilla::ErrorResult& aRv); // Outer windows only. @@ -1715,41 +1715,41 @@ protected: nsCOMPtr mArguments; // For |window.dialogArguments|, via |showModalDialog|. - nsRefPtr mDialogArguments; + RefPtr mDialogArguments; // Only used in the outer. - nsRefPtr mReturnValue; + RefPtr mReturnValue; - nsRefPtr mNavigator; - nsRefPtr mScreen; - nsRefPtr mFrames; + RefPtr mNavigator; + RefPtr mScreen; + RefPtr mFrames; // All BarProps are inner window only. - nsRefPtr mMenubar; - nsRefPtr mToolbar; - nsRefPtr mLocationbar; - nsRefPtr mPersonalbar; - nsRefPtr mStatusbar; - nsRefPtr mScrollbars; - nsRefPtr mWindowUtils; + RefPtr mMenubar; + RefPtr mToolbar; + RefPtr mLocationbar; + RefPtr mPersonalbar; + RefPtr mStatusbar; + RefPtr mScrollbars; + RefPtr mWindowUtils; nsString mStatus; nsString mDefaultStatus; - nsRefPtr mObserver; // Inner windows only. - nsRefPtr mCrypto; - nsRefPtr mCacheStorage; - nsRefPtr mConsole; + RefPtr mObserver; // Inner windows only. + RefPtr mCrypto; + RefPtr mCacheStorage; + RefPtr mConsole; // We need to store an nsISupports pointer to this object because the // mozilla::dom::External class doesn't exist on b2g and using the type // forward declared here means that ~nsGlobalWindow wouldn't compile because // it wouldn't see the ~External function's declaration. nsCOMPtr mExternal; - nsRefPtr mMozSelfSupport; + RefPtr mMozSelfSupport; - nsRefPtr mLocalStorage; - nsRefPtr mSessionStorage; + RefPtr mLocalStorage; + RefPtr mSessionStorage; // These member variable are used only on inner windows. - nsRefPtr mListenerManager; + RefPtr mListenerManager; // mTimeouts is generally sorted by mWhen, unless mTimeoutInsertionPoint is // non-null. In that case, the dummy timeout pointed to by // mTimeoutInsertionPoint may have a later mWhen than some of the timeouts @@ -1761,13 +1761,13 @@ protected: nsTimeout* mTimeoutInsertionPoint; uint32_t mTimeoutPublicIdCounter; uint32_t mTimeoutFiringDepth; - nsRefPtr mLocation; - nsRefPtr mHistory; + RefPtr mLocation; + RefPtr mHistory; // These member variables are used on both inner and the outer windows. nsCOMPtr mDocumentPrincipal; - typedef nsTArray> nsDOMStorageEventArray; + typedef nsTArray> nsDOMStorageEventArray; nsDOMStorageEventArray mPendingStorageEvents; uint32_t mTimeoutsSuspendDepth; @@ -1801,7 +1801,7 @@ protected: // unsuspending it. nsCOMPtr mSuspendedDoc; - nsRefPtr mIndexedDB; + RefPtr mIndexedDB; // This counts the number of windows that have been opened in rapid succession // (i.e. within dom.successive_dialog_time_limit of each other). It is reset @@ -1825,7 +1825,7 @@ protected: #ifdef MOZ_WEBSPEECH // mSpeechSynthesis is only used on inner windows. - nsRefPtr mSpeechSynthesis; + RefPtr mSpeechSynthesis; #endif // This is the CC generation the last time we called CanSkip. @@ -1834,9 +1834,9 @@ protected: // Did VR get initialized for this window? bool mVRDevicesInitialized; // The VRDevies for this window - nsTArray> mVRDevices; + nsTArray> mVRDevices; // Any attached HMD when fullscreen - nsRefPtr mVRHMDInfo; + RefPtr mVRHMDInfo; friend class nsDOMScriptableHelper; friend class nsDOMWindowUtils; @@ -1961,7 +1961,7 @@ protected: inline already_AddRefed NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow) { - nsRefPtr global; + RefPtr global; if (aIsChrome) { global = nsGlobalChromeWindow::Create(nullptr); diff --git a/dom/base/nsHTMLContentSerializer.cpp b/dom/base/nsHTMLContentSerializer.cpp index 03bb8fd8d8..ef31e6d4a9 100644 --- a/dom/base/nsHTMLContentSerializer.cpp +++ b/dom/base/nsHTMLContentSerializer.cpp @@ -43,7 +43,7 @@ using namespace mozilla::dom; nsresult NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer) { - nsRefPtr it = new nsHTMLContentSerializer(); + RefPtr it = new nsHTMLContentSerializer(); it.forget(aSerializer); return NS_OK; } diff --git a/dom/base/nsHostObjectProtocolHandler.cpp b/dom/base/nsHostObjectProtocolHandler.cpp index c2680c33d8..ea52e6ed28 100644 --- a/dom/base/nsHostObjectProtocolHandler.cpp +++ b/dom/base/nsHostObjectProtocolHandler.cpp @@ -171,7 +171,7 @@ class BlobURLsReporter final : public nsIMemoryReporter { EnumArg* envp = static_cast(aUserArg); nsCOMPtr tmp = do_QueryInterface(aInfo->mObject); - nsRefPtr blob = static_cast(tmp.get()); + RefPtr blob = static_cast(tmp.get()); if (blob) { NS_NAMED_LITERAL_CSTRING @@ -481,7 +481,7 @@ nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec, DataInfo* info = GetDataInfo(aSpec); - nsRefPtr uri = + RefPtr uri = new nsHostObjectURI(info ? info->mPrincipal.get() : nullptr); rv = uri->SetSpec(aSpec); @@ -530,11 +530,14 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri, return rv.StealNSResult(); } + nsAutoString contentType; + blob->GetType(contentType); + nsCOMPtr channel; rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel), uri, stream, - EmptyCString(), // aContentType + NS_ConvertUTF16toUTF8(contentType), EmptyCString(), // aContentCharset aLoadInfo); if (NS_WARN_IF(rv.Failed())) { @@ -640,7 +643,7 @@ NS_GetBlobForBlobURISpec(const nsACString& aSpec, BlobImpl** aBlob) nsresult NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream) { - nsRefPtr blobImpl; + RefPtr blobImpl; ErrorResult rv; rv = NS_GetBlobForBlobURI(aURI, getter_AddRefs(blobImpl)); if (NS_WARN_IF(rv.Failed())) { @@ -675,7 +678,7 @@ nsFontTableProtocolHandler::NewURI(const nsACString& aSpec, nsIURI *aBaseURI, nsIURI **aResult) { - nsRefPtr uri; + RefPtr uri; // Either you got here via a ref or a fonttable: uri if (aSpec.Length() && aSpec.CharAt(0) == '#') { diff --git a/dom/base/nsHostObjectURI.cpp b/dom/base/nsHostObjectURI.cpp index 40ebb65d3e..0bbbef8a07 100644 --- a/dom/base/nsHostObjectURI.cpp +++ b/dom/base/nsHostObjectURI.cpp @@ -155,7 +155,7 @@ nsHostObjectURI::CloneInternal(nsSimpleURI::RefHandlingEnum aRefHandlingMode, NS_ENSURE_SUCCESS(rv, rv); #ifdef DEBUG - nsRefPtr uriCheck; + RefPtr uriCheck; rv = simpleClone->QueryInterface(kHOSTOBJECTURICID, getter_AddRefs(uriCheck)); MOZ_ASSERT(NS_SUCCEEDED(rv) && uriCheck); #endif @@ -178,7 +178,7 @@ nsHostObjectURI::EqualsInternal(nsIURI* aOther, return NS_OK; } - nsRefPtr otherUri; + RefPtr otherUri; aOther->QueryInterface(kHOSTOBJECTURICID, getter_AddRefs(otherUri)); if (!otherUri) { *aResult = false; diff --git a/dom/base/nsIAttribute.h b/dom/base/nsIAttribute.h index 5f25544ee5..ddbd897da3 100644 --- a/dom/base/nsIAttribute.h +++ b/dom/base/nsIAttribute.h @@ -46,7 +46,7 @@ protected: #endif //MOZILLA_INTERNAL_API virtual ~nsIAttribute(); - nsRefPtr mAttrMap; + RefPtr mAttrMap; bool mNsAware; }; diff --git a/dom/base/nsIConsoleReportCollector.h b/dom/base/nsIConsoleReportCollector.h new file mode 100644 index 0000000000..0b140a5f18 --- /dev/null +++ b/dom/base/nsIConsoleReportCollector.h @@ -0,0 +1,81 @@ +/* -*- 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 nsIConsoleReportCollector_h +#define nsIConsoleReportCollector_h + +#include "nsContentUtils.h" +#include "nsISupports.h" +#include "nsTArrayForwardDeclare.h" + +class nsACString; +class nsIDocument; +class nsString; + +#define NS_NSICONSOLEREPORTCOLLECTOR_IID \ + {0xdd98a481, 0xd2c4, 0x4203, {0x8d, 0xfa, 0x85, 0xbf, 0xd7, 0xdc, 0xd7, 0x05}} + +// An interface for saving reports until we can flush them to the correct +// window at a later time. +class NS_NO_VTABLE nsIConsoleReportCollector : public nsISupports +{ +public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_NSICONSOLEREPORTCOLLECTOR_IID) + + // Add a pending report to be later displayed on the console. This may be + // called from any thread. + // + // aErrorFlags A nsIScriptError flags value. + // aCategory Name of module reporting error. + // aPropertiesFile Properties file containing localized message. + // aSourceFileURI The URI of the script generating the error. Must be a URI + // spec. + // aLineNumber The line number where the error was generated. May be 0 if + // the line number is not known. + // aColumnNumber The column number where the error was generated. May be 0 + // if the line number is not known. + // aMessageName The name of the localized message contained in the + // properties file. + // aStringParams An array of nsString parameters to use when localizing the + // message. + virtual void + AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, uint32_t aLineNumber, + uint32_t aColumnNumber, const nsACString& aMessageName, + const nsTArray& aStringParams) = 0; + + // A version of AddConsoleReport() that accepts the message parameters + // as variable nsString arguments. Note, the parameters must be exactly + // nsString and not another string class. All other args the same as + // AddConsoleReport(). + template + void + AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, uint32_t aLineNumber, + uint32_t aColumnNumber, const nsACString& aMessageName, + Params... aParams) + { + nsTArray params; + mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params), aParams...); + AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, aSourceFileURI, + aLineNumber, aColumnNumber, aMessageName, params); + } + + // Flush all pending reports to the console. + // + // aDocument An optional document representing where to flush the + // reports. If provided, then the corresponding window's + // web console will get the reports. Otherwise the reports + // go to the browser console. + virtual void + FlushConsoleReports(nsIDocument* aDocument) = 0; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsIConsoleReportCollector, NS_NSICONSOLEREPORTCOLLECTOR_IID) + +#endif // nsIConsoleReportCollector_h diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index 6bb3be73ae..598aee0067 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -153,7 +153,7 @@ typedef CallbackObjectHolder NodeFilterHolder; struct FullScreenOptions { FullScreenOptions(); - nsRefPtr mVRHMDDevice; + RefPtr mVRHMDDevice; }; } // namespace dom @@ -784,7 +784,7 @@ public: mozilla::ErrorResult& aError); void RemoveAnonymousContent(mozilla::dom::AnonymousContent& aContent, mozilla::ErrorResult& aError); - nsTArray>& GetAnonymousContents() { + nsTArray>& GetAnonymousContents() { return mAnonymousContents; } @@ -1641,7 +1641,7 @@ public: virtual void ElementsFromPointHelper(float aX, float aY, uint32_t aFlags, - nsTArray>& aElements) = 0; + nsTArray>& aElements) = 0; virtual nsresult NodesFromRectHelper(float aX, float aY, float aTopSize, float aRightSize, @@ -2173,7 +2173,7 @@ public: int32_t *aHandle); void CancelFrameRequestCallback(int32_t aHandle); - typedef nsTArray> FrameRequestCallbackList; + typedef nsTArray> FrameRequestCallbackList; /** * Put this document's frame request callbacks into the provided * list, and forget about them. @@ -2532,7 +2532,7 @@ public: Element* ElementFromPoint(float aX, float aY); void ElementsFromPoint(float aX, float aY, - nsTArray>& aElements); + nsTArray>& aElements); /** * Retrieve the location of the caret position (DOM node and character @@ -2764,11 +2764,11 @@ protected: // This is a weak reference, but we hold a strong reference to mNodeInfo, // which in turn holds a strong reference to this mNodeInfoManager. nsNodeInfoManager* mNodeInfoManager; - nsRefPtr mCSSLoader; - nsRefPtr mStyleImageLoader; - nsRefPtr mAttrStyleSheet; - nsRefPtr mStyleAttrStyleSheet; - nsRefPtr mSVGAttrAnimationRuleProcessor; + RefPtr mCSSLoader; + RefPtr mStyleImageLoader; + RefPtr mAttrStyleSheet; + RefPtr mStyleAttrStyleSheet; + RefPtr mSVGAttrAnimationRuleProcessor; // The set of all object, embed, applet, video/audio elements or // nsIObjectLoadingContent or nsIDocumentActivity for which this is the @@ -2783,7 +2783,7 @@ protected: nsTHashtable > mLinksToUpdate; // SMIL Animation Controller, lazily-initialized in GetAnimationController - nsRefPtr mAnimationController; + RefPtr mAnimationController; // Table of element properties for this document. nsPropertyTable mPropertyTable; @@ -2793,7 +2793,7 @@ protected: nsCOMPtr mChildrenCollection; // container for per-context fonts (downloadable, SVG, etc.) - nsRefPtr mFontFaceSet; + RefPtr mFontFaceSet; // Compatibility mode nsCompatibility mCompatMode; @@ -3058,9 +3058,9 @@ protected: uint32_t mInSyncOperationCount; - nsRefPtr mXPathEvaluator; + RefPtr mXPathEvaluator; - nsTArray> mAnonymousContents; + nsTArray> mAnonymousContents; uint32_t mBlockDOMContentLoaded; bool mDidFireDOMContentLoaded:1; diff --git a/dom/base/nsIGlobalObject.cpp b/dom/base/nsIGlobalObject.cpp index e7ee71cf3b..62c51ceb36 100644 --- a/dom/base/nsIGlobalObject.cpp +++ b/dom/base/nsIGlobalObject.cpp @@ -84,7 +84,7 @@ nsIGlobalObject::UnlinkHostObjectURIs() // nsHostObjectProtocolHandler is main-thread only. - nsRefPtr runnable = + RefPtr runnable = new UnlinkHostObjectURIsRunnable(mHostObjectURIs); MOZ_ASSERT(mHostObjectURIs.IsEmpty()); diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index bf88c1db66..27ff9d5ffa 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -340,7 +340,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell) } } - nsRefPtr fs = aPresShell->FrameSelection(); + RefPtr fs = aPresShell->FrameSelection(); nsIContent* content = fs->GetLimiter(); if (!content) { content = fs->GetAncestorLimiter(); @@ -1243,7 +1243,7 @@ nsINode::PreHandleEvent(EventChainPreVisitor& aVisitor) void nsINode::GetBoxQuads(const BoxQuadOptions& aOptions, - nsTArray >& aResult, + nsTArray >& aResult, mozilla::ErrorResult& aRv) { mozilla::GetBoxQuads(this, aOptions, aResult, aRv); @@ -1291,7 +1291,7 @@ nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal) // Obtain a presentation shell nsIPresShell *shell = document->GetShell(); - nsRefPtr context; + RefPtr context; if (shell) { context = shell->GetPresContext(); } @@ -1665,7 +1665,7 @@ GetNodeFromNodeOrString(const OwningNodeOrString& aNode, } if (aNode.IsString()){ - nsRefPtr textNode = + RefPtr textNode = aDocument->CreateTextNode(aNode.GetAsString()); return textNode.forget(); } @@ -2538,7 +2538,7 @@ nsINode::UnbindObject(nsISupports* aObject) } void -nsINode::GetBoundMutationObservers(nsTArray >& aResult) +nsINode::GetBoundMutationObservers(nsTArray >& aResult) { nsCOMArray* objects = static_cast*>(GetProperty(nsGkAtoms::keepobjectsalive)); @@ -2866,7 +2866,7 @@ nsINode::QuerySelector(const nsAString& aSelector, ErrorResult& aResult) already_AddRefed nsINode::QuerySelectorAll(const nsAString& aSelector, ErrorResult& aResult) { - nsRefPtr contentList = new nsSimpleContentList(this); + RefPtr contentList = new nsSimpleContentList(this); nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aResult); if (selectorList) { diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index 243d3fba7b..b740a53900 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -1056,7 +1056,7 @@ public: * @see nsIDOMNodeList * @see nsGenericHTMLElement::GetChildNodes */ - nsRefPtr mChildNodes; + RefPtr mChildNodes; /** * Weak reference to this node. This is cleared by the destructor of @@ -1700,7 +1700,7 @@ public: // aObject alive anymore. void UnbindObject(nsISupports* aObject); - void GetBoundMutationObservers(nsTArray >& aResult); + void GetBoundMutationObservers(nsTArray >& aResult); /** * Returns the length of this node, as specified at @@ -1821,7 +1821,7 @@ public: void Append(const Sequence& aNodes, ErrorResult& aRv); void GetBoxQuads(const BoxQuadOptions& aOptions, - nsTArray >& aResult, + nsTArray >& aResult, mozilla::ErrorResult& aRv); already_AddRefed ConvertQuadFromNode(DOMQuad& aQuad, @@ -1975,7 +1975,7 @@ protected: static bool Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb); static void Unlink(nsINode *tmp); - nsRefPtr mNodeInfo; + RefPtr mNodeInfo; // mParent is an owning ref most of the time, except for the case of document // nodes, so it cannot be represented by nsCOMPtr, so mark is as diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index 1f49e7f557..ee95b1bcb7 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -680,7 +680,7 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel, // Do the load. nsCOMPtr listener; - nsRefPtr& req = PrepareNextRequest(eImageLoadType_Normal); + RefPtr& req = PrepareNextRequest(eImageLoadType_Normal); nsresult rv = loader-> LoadImageWithChannel(aChannel, this, doc, getter_AddRefs(listener), @@ -960,7 +960,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI, } // Not blocked. Do the load. - nsRefPtr& req = PrepareNextRequest(aImageLoadType); + RefPtr& req = PrepareNextRequest(aImageLoadType); nsIContent* content = AsContent(); nsresult rv = nsContentUtils::LoadImage(aNewURI, aDocument, aDocument->NodePrincipal(), @@ -1148,7 +1148,7 @@ nsImageLoadingContent::UseAsPrimaryRequest(imgRequestProxy* aRequest, ClearCurrentRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_REQUEST_DISCARD); // Clone the request we were given. - nsRefPtr& req = PrepareNextRequest(aImageLoadType); + RefPtr& req = PrepareNextRequest(aImageLoadType); nsresult rv = aRequest->Clone(this, getter_AddRefs(req)); if (NS_SUCCEEDED(rv)) { TrackImage(req); @@ -1225,14 +1225,14 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType) nsCOMPtr thisNode = do_QueryInterface(static_cast(this)); - nsRefPtr loadBlockingAsyncDispatcher = + RefPtr loadBlockingAsyncDispatcher = new LoadBlockingAsyncEventDispatcher(thisNode, aEventType, false, false); loadBlockingAsyncDispatcher->PostDOMEvent(); return NS_OK; } -nsRefPtr& +RefPtr& nsImageLoadingContent::PrepareNextRequest(ImageLoadType aImageLoadType) { nsImageFrame* frame = do_QueryFrame(GetOurPrimaryFrame()); @@ -1290,7 +1290,7 @@ nsImageLoadingContent::SetBlockedRequest(nsIURI* aURI, int16_t aContentDecision) } } -nsRefPtr& +RefPtr& nsImageLoadingContent::PrepareCurrentRequest(ImageLoadType aImageLoadType) { // Blocked images go through SetBlockedRequest, which is a separate path. For @@ -1313,7 +1313,7 @@ nsImageLoadingContent::PrepareCurrentRequest(ImageLoadType aImageLoadType) return mCurrentRequest; } -nsRefPtr& +RefPtr& nsImageLoadingContent::PreparePendingRequest(ImageLoadType aImageLoadType) { // Get rid of anything that was there previously. diff --git a/dom/base/nsImageLoadingContent.h b/dom/base/nsImageLoadingContent.h index 24411b9bba..d684d2ecc0 100644 --- a/dom/base/nsImageLoadingContent.h +++ b/dom/base/nsImageLoadingContent.h @@ -294,7 +294,7 @@ protected: * * @param aImageLoadType The ImageLoadType for this request */ - nsRefPtr& PrepareNextRequest(ImageLoadType aImageLoadType); + RefPtr& PrepareNextRequest(ImageLoadType aImageLoadType); /** * Called when we would normally call PrepareNextRequest(), but the request was @@ -311,8 +311,8 @@ protected: * * @param aImageLoadType The ImageLoadType for this request */ - nsRefPtr& PrepareCurrentRequest(ImageLoadType aImageLoadType); - nsRefPtr& PreparePendingRequest(ImageLoadType aImageLoadType); + RefPtr& PrepareCurrentRequest(ImageLoadType aImageLoadType); + RefPtr& PreparePendingRequest(ImageLoadType aImageLoadType); /** * Switch our pending request to be our current request. @@ -366,8 +366,8 @@ protected: uint32_t aNonvisibleAction = ON_NONVISIBLE_NO_ACTION); /* MEMBERS */ - nsRefPtr mCurrentRequest; - nsRefPtr mPendingRequest; + RefPtr mCurrentRequest; + RefPtr mPendingRequest; uint32_t mCurrentRequestFlags; uint32_t mPendingRequestFlags; diff --git a/dom/base/nsInProcessTabChildGlobal.cpp b/dom/base/nsInProcessTabChildGlobal.cpp index cd004dae27..dc9a277704 100644 --- a/dom/base/nsInProcessTabChildGlobal.cpp +++ b/dom/base/nsInProcessTabChildGlobal.cpp @@ -37,7 +37,7 @@ nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx, if (mChromeMessageManager) { SameProcessCpowHolder cpows(js::GetRuntime(aCx), aCpows); - nsRefPtr mm = mChromeMessageManager; + RefPtr mm = mChromeMessageManager; nsCOMPtr fl = GetFrameLoader(); mm->ReceiveMessage(mOwner, fl, aMessage, true, &aData, &cpows, aPrincipal, aRetVal); @@ -66,7 +66,7 @@ public: ReceiveMessage(mTabChild->mOwner, fl, mTabChild->mChromeMessageManager); return NS_OK; } - nsRefPtr mTabChild; + RefPtr mTabChild; }; bool @@ -77,7 +77,7 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx, nsIPrincipal* aPrincipal) { SameProcessMessageQueue* queue = SameProcessMessageQueue::Get(); - nsRefPtr ev = + RefPtr ev = new nsAsyncMessageToParent(aCx, this, aMessage, aData, aCpows, aPrincipal); queue->Push(ev); return true; @@ -258,7 +258,7 @@ nsInProcessTabChildGlobal::PreHandleEvent(EventChainPreVisitor& aVisitor) #ifdef DEBUG if (mOwner) { nsCOMPtr owner = do_QueryInterface(mOwner); - nsRefPtr fl = owner->GetFrameLoader(); + RefPtr fl = owner->GetFrameLoader(); if (fl) { NS_ASSERTION(this == fl->GetTabChildGlobalAsEventTarget(), "Wrong event target!"); @@ -319,7 +319,7 @@ public: mTabChild->LoadFrameScript(mURL, mRunInGlobalScope); return NS_OK; } - nsRefPtr mTabChild; + RefPtr mTabChild; nsString mURL; bool mRunInGlobalScope; }; diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index ea42f74197..39ea784404 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -332,7 +332,7 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal, nsCOMPtr win(do_QueryInterface(aScriptGlobal)); nsIDocShell *docShell = win ? win->GetDocShell() : nullptr; if (docShell) { - nsRefPtr presContext; + RefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); static int32_t errorDepth; // Recursion prevention @@ -341,7 +341,7 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal, if (errorDepth < 2) { // Dispatch() must be synchronous for the recursion block // (errorDepth) to work. - nsRefPtr event = + RefPtr event = ErrorEvent::Constructor(static_cast(win.get()), NS_LITERAL_STRING("error"), aErrorEventInit); @@ -379,7 +379,7 @@ public: AutoRestore recursionGuard(sHandlingScriptError); sHandlingScriptError = true; - nsRefPtr presContext; + RefPtr presContext; win->GetDocShell()->GetPresContext(getter_AddRefs(presContext)); ThreadsafeAutoJSContext cx; @@ -400,7 +400,7 @@ public: init.mLineno = 0; } - nsRefPtr event = + RefPtr event = ErrorEvent::Constructor(static_cast(win), NS_LITERAL_STRING("error"), init); event->SetTrusted(true); @@ -431,7 +431,7 @@ public: private: nsCOMPtr mWindow; - nsRefPtr mReport; + RefPtr mReport; JS::PersistentRootedValue mError; static bool sHandlingScriptError; @@ -490,7 +490,7 @@ SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) } if (globalObject) { - nsRefPtr xpcReport = new xpc::ErrorReport(); + RefPtr xpcReport = new xpc::ErrorReport(); bool isChrome = nsContentUtils::IsSystemPrincipal(globalObject->PrincipalOrNull()); nsCOMPtr win = do_QueryInterface(globalObject); xpcReport->Init(report, message, isChrome, win ? win->WindowID() : 0); @@ -2247,7 +2247,7 @@ DOMGCSliceCallback(JSRuntime *aRt, JS::GCProgress aProgress, const JS::GCDescrip if (sPostGCEventsToObserver) { nsString json; json.Adopt(aDesc.formatJSON(aRt, PR_Now())); - nsRefPtr notify = new NotifyGCEndRunnable(json); + RefPtr notify = new NotifyGCEndRunnable(json); NS_DispatchToMainThread(notify); } diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index b9ca555fb0..c4a123a669 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -204,7 +204,7 @@ public: } protected: - nsRefPtr mReport; + RefPtr mReport; }; } // namespace dom diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp index 1af923cfd6..bc4b36c5e1 100644 --- a/dom/base/nsJSTimeoutHandler.cpp +++ b/dom/base/nsJSTimeoutHandler.cpp @@ -76,7 +76,7 @@ private: // The expression to evaluate or function to call. If mFunction is non-null // it should be used, else use mExpr. nsString mExpr; - nsRefPtr mFunction; + RefPtr mFunction; }; @@ -277,7 +277,7 @@ NS_CreateJSTimeoutHandler(JSContext *aCx, nsGlobalWindow *aWindow, return nullptr; } - nsRefPtr handler = + RefPtr handler = new nsJSScriptTimeoutHandler(aCx, aWindow, aFunction, args, aError); return aError.Failed() ? nullptr : handler.forget(); } @@ -287,7 +287,7 @@ NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow, const nsAString& aExpression, ErrorResult& aError) { bool allowEval = false; - nsRefPtr handler = + RefPtr handler = new nsJSScriptTimeoutHandler(aCx, aWindow, aExpression, &allowEval, aError); if (aError.Failed() || !allowEval) { return nullptr; diff --git a/dom/base/nsLineBreaker.cpp b/dom/base/nsLineBreaker.cpp index 0f05bfc377..b0e71275fa 100644 --- a/dom/base/nsLineBreaker.cpp +++ b/dom/base/nsLineBreaker.cpp @@ -89,7 +89,7 @@ nsLineBreaker::FlushCurrentWord() } } if (autoHyphenate) { - nsRefPtr hyphenator = + RefPtr hyphenator = nsHyphenationManager::Instance()->GetHyphenator(mCurrentWordLanguage); if (hyphenator) { FindHyphenationPoints(hyphenator, @@ -221,7 +221,7 @@ nsLineBreaker::AppendText(nsIAtom* aHyphenationLanguage, const char16_t* aText, uint32_t wordStart = offset; bool wordHasComplexChar = false; - nsRefPtr hyphenator; + RefPtr hyphenator; if ((aFlags & BREAK_USE_AUTO_HYPHENATION) && !(aFlags & BREAK_SUPPRESS_INSIDE) && aHyphenationLanguage) { diff --git a/dom/base/nsMimeTypeArray.cpp b/dom/base/nsMimeTypeArray.cpp index 74f8851c3d..3f5067b21f 100644 --- a/dom/base/nsMimeTypeArray.cpp +++ b/dom/base/nsMimeTypeArray.cpp @@ -90,7 +90,7 @@ nsMimeTypeArray::IndexedGetter(uint32_t aIndex, bool &aFound) } static nsMimeType* -FindMimeType(const nsTArray >& aMimeTypes, +FindMimeType(const nsTArray >& aMimeTypes, const nsAString& aType) { for (uint32_t i = 0; i < aMimeTypes.Length(); ++i) { diff --git a/dom/base/nsMimeTypeArray.h b/dom/base/nsMimeTypeArray.h index 1e22fcd7e8..1707b97f33 100644 --- a/dom/base/nsMimeTypeArray.h +++ b/dom/base/nsMimeTypeArray.h @@ -49,7 +49,7 @@ protected: // mMimeTypes contains MIME types handled by plugins or by an OS // PreferredApplicationHandler. - nsTArray > mMimeTypes; + nsTArray > mMimeTypes; }; class nsMimeType final : public nsWrapperCache @@ -87,7 +87,7 @@ protected: // creates an explicit reference cycle through the plugin element's // mimetype array. We rely on the cycle collector to break this // cycle. - nsRefPtr mPluginElement; + RefPtr mPluginElement; nsString mType; nsString mDescription; nsString mExtension; diff --git a/dom/base/nsNameSpaceManager.cpp b/dom/base/nsNameSpaceManager.cpp index 9ff1bc0543..4ff5124290 100644 --- a/dom/base/nsNameSpaceManager.cpp +++ b/dom/base/nsNameSpaceManager.cpp @@ -141,7 +141,7 @@ NS_NewElement(Element** aResult, already_AddRefed&& aNodeInfo, FromParser aFromParser) { - nsRefPtr ni = aNodeInfo; + RefPtr ni = aNodeInfo; int32_t ns = ni->NamespaceID(); if (ns == kNameSpaceID_XHTML) { return NS_NewHTMLElement(aResult, ni.forget(), aFromParser); diff --git a/dom/base/nsNodeInfoManager.cpp b/dom/base/nsNodeInfoManager.cpp index 5d850daa09..e0d4c03089 100644 --- a/dom/base/nsNodeInfoManager.cpp +++ b/dom/base/nsNodeInfoManager.cpp @@ -238,12 +238,12 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey); if (node) { - nsRefPtr nodeInfo = static_cast(node); + RefPtr nodeInfo = static_cast(node); return nodeInfo.forget(); } - nsRefPtr newNodeInfo = + RefPtr newNodeInfo = new NodeInfo(aName, aPrefix, aNamespaceID, aNodeType, aExtraName, this); DebugOnly he = @@ -288,7 +288,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, nsCOMPtr nameAtom = do_GetAtom(aName); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); - nsRefPtr newNodeInfo = + RefPtr newNodeInfo = new NodeInfo(nameAtom, aPrefix, aNamespaceID, aNodeType, nullptr, this); NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY); @@ -327,7 +327,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, already_AddRefed nsNodeInfoManager::GetTextNodeInfo() { - nsRefPtr nodeInfo; + RefPtr nodeInfo; if (!mTextNodeInfo) { nodeInfo = GetNodeInfo(nsGkAtoms::textTagName, nullptr, kNameSpaceID_None, @@ -344,7 +344,7 @@ nsNodeInfoManager::GetTextNodeInfo() already_AddRefed nsNodeInfoManager::GetCommentNodeInfo() { - nsRefPtr nodeInfo; + RefPtr nodeInfo; if (!mCommentNodeInfo) { nodeInfo = GetNodeInfo(nsGkAtoms::commentTagName, nullptr, @@ -363,7 +363,7 @@ nsNodeInfoManager::GetCommentNodeInfo() already_AddRefed nsNodeInfoManager::GetDocumentNodeInfo() { - nsRefPtr nodeInfo; + RefPtr nodeInfo; if (!mDocumentNodeInfo) { NS_ASSERTION(mDocument, "Should have mDocument!"); diff --git a/dom/base/nsNodeInfoManager.h b/dom/base/nsNodeInfoManager.h index 96f77ed1d0..b317bbb7e9 100644 --- a/dom/base/nsNodeInfoManager.h +++ b/dom/base/nsNodeInfoManager.h @@ -137,7 +137,7 @@ private: mozilla::dom::NodeInfo *mTextNodeInfo; // WEAK to avoid circular ownership mozilla::dom::NodeInfo *mCommentNodeInfo; // WEAK to avoid circular ownership mozilla::dom::NodeInfo *mDocumentNodeInfo; // WEAK to avoid circular ownership - nsRefPtr mBindingManager; + RefPtr mBindingManager; }; #endif /* nsNodeInfoManager_h___ */ diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 93df6fdcaa..8cb569c974 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -429,7 +429,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, // aNode. NodeInfo *nodeInfo = aNode->mNodeInfo; - nsRefPtr newNodeInfo; + RefPtr newNodeInfo; if (nodeInfoManager) { // Don't allow importing/adopting nodes from non-privileged "scriptable" diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index bac83938d2..1522473a54 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -352,7 +352,7 @@ nsPluginCrashedEvent::Run() init.mBubbles = true; init.mCancelable = true; - nsRefPtr event = + RefPtr event = PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init); event->SetTrusted(true); @@ -387,7 +387,7 @@ protected: private: nsCOMPtr mTimer; - nsRefPtr mInstanceOwner; + RefPtr mInstanceOwner; nsCOMPtr mContent; }; @@ -554,7 +554,7 @@ IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType) return false; } - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if (!pluginHost) { NS_NOTREACHED("No pluginhost"); @@ -587,14 +587,14 @@ nsObjectLoadingContent::MakePluginListener() NS_NOTREACHED("expecting a spawned plugin"); return false; } - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if (!pluginHost) { NS_NOTREACHED("No pluginHost"); return false; } NS_ASSERTION(!mFinalListener, "overwriting a final listener"); nsresult rv; - nsRefPtr inst; + RefPtr inst; nsCOMPtr finalListener; rv = mInstanceOwner->GetInstance(getter_AddRefs(inst)); NS_ENSURE_SUCCESS(rv, false); @@ -771,7 +771,7 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) } nsresult rv = NS_ERROR_FAILURE; - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if (!pluginHost) { NS_NOTREACHED("No pluginhost"); @@ -786,7 +786,7 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) appShell->SuspendNative(); } - nsRefPtr newOwner; + RefPtr newOwner; rv = pluginHost->InstantiatePluginInstance(mContentType, mURI.get(), this, getter_AddRefs(newOwner)); @@ -803,7 +803,7 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) // don't want to touch the protochain or delayed stop. // (Bug 767635) if (newOwner) { - nsRefPtr inst; + RefPtr inst; newOwner->GetInstance(getter_AddRefs(inst)); newOwner->SetFrame(nullptr); if (inst) { @@ -817,7 +817,7 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) mInstanceOwner = newOwner; if (mInstanceOwner) { - nsRefPtr inst; + RefPtr inst; rv = mInstanceOwner->GetInstance(getter_AddRefs(inst)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -842,7 +842,7 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) // Set up scripting interfaces. NotifyContentObjectWrapper(); - nsRefPtr pluginInstance; + RefPtr pluginInstance; GetPluginInstance(getter_AddRefs(pluginInstance)); if (pluginInstance) { nsCOMPtr pluginTag; @@ -1206,7 +1206,7 @@ nsObjectLoadingContent::GetFrameLoader(nsIFrameLoader** aFrameLoader) NS_IMETHODIMP_(already_AddRefed) nsObjectLoadingContent::GetFrameLoader() { - nsRefPtr loader = mFrameLoader; + RefPtr loader = mFrameLoader; return loader.forget(); } @@ -1313,7 +1313,7 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ObjectInterfaceRequestorShim, nsIInterfaceRequestor) NS_DECL_NSIINTERFACEREQUESTOR - // nsRefPtr fails due to ambiguous AddRef/Release, + // RefPtr fails due to ambiguous AddRef/Release, // hence the ugly static cast :( NS_FORWARD_NSICHANNELEVENTSINK(static_cast (mContent.get())->) @@ -1622,7 +1622,7 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI) nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME); NS_ASSERTION(IsJavaMIME(javaMIME), "plugin.mime.java should be recognized as java"); - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if (StringBeginsWith(classIDAttr, NS_LITERAL_STRING("java:")) && pluginHost && pluginHost->HavePluginForType(javaMIME)) { @@ -2468,7 +2468,7 @@ nsObjectLoadingContent::OpenChannel() nsCOMPtr group = doc->GetDocumentLoadGroup(); nsCOMPtr chan; - nsRefPtr shim = + RefPtr shim = new ObjectInterfaceRequestorShim(this); bool isSandBoxed = doc->GetSandboxFlags() & SANDBOXED_ORIGIN; @@ -2680,7 +2680,7 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType) return eType_Document; } - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if ((caps & eSupportPlugins) && pluginHost && pluginHost->HavePluginForType(aMIMEType, nsPluginHost::eExcludeNone)) { @@ -2977,8 +2977,8 @@ nsObjectLoadingContent::DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner, } mIsStopping = true; - nsRefPtr kungFuDeathGrip(aInstanceOwner); - nsRefPtr inst; + RefPtr kungFuDeathGrip(aInstanceOwner); + RefPtr inst; aInstanceOwner->GetInstance(getter_AddRefs(inst)); if (inst) { if (DoDelayedStop(aInstanceOwner, this, aDelayedStop)) { @@ -2989,7 +2989,7 @@ nsObjectLoadingContent::DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner, aInstanceOwner->HidePluginWindow(); #endif - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); NS_ASSERTION(pluginHost, "No plugin host?"); pluginHost->StopPluginInstance(inst); } @@ -3039,7 +3039,7 @@ nsObjectLoadingContent::StopPluginInstance() bool delayedStop = false; #ifdef XP_WIN // Force delayed stop for Real plugin only; see bug 420886, 426852. - nsRefPtr inst; + RefPtr inst; mInstanceOwner->GetInstance(getter_AddRefs(inst)); if (inst) { const char* mime = nullptr; @@ -3052,7 +3052,7 @@ nsObjectLoadingContent::StopPluginInstance() } #endif - nsRefPtr ownerGrip(mInstanceOwner); + RefPtr ownerGrip(mInstanceOwner); mInstanceOwner = nullptr; // This can/will re-enter @@ -3206,7 +3206,7 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp return false; } - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); nsCOMPtr playPreviewInfo; bool isPlayPreviewSpecified = NS_SUCCEEDED(pluginHost->GetPlayPreviewInfo( @@ -3428,7 +3428,7 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx, return; } - nsRefPtr pi; + RefPtr pi; nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi)); if (NS_FAILED(rv)) { aRv.Throw(rv); @@ -3473,7 +3473,7 @@ nsObjectLoadingContent::SetupProtoChain(JSContext* aCx, } if (!nsContentUtils::IsSafeToRunScript()) { - nsRefPtr runner = new SetupProtoChainRunner(this); + RefPtr runner = new SetupProtoChainRunner(this); nsContentUtils::AddScriptRunner(runner); return; } @@ -3485,7 +3485,7 @@ nsObjectLoadingContent::SetupProtoChain(JSContext* aCx, JSAutoCompartment ac(aCx, aObject); - nsRefPtr pi; + RefPtr pi; nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi)); if (NS_FAILED(rv)) { return; @@ -3658,7 +3658,7 @@ nsObjectLoadingContent::DoResolve(JSContext* aCx, JS::Handle aObject, // We don't resolve anything; we just try to make sure we're instantiated. // This purposefully does not fire for chrome/xray resolves, see bug 967694 - nsRefPtr pi; + RefPtr pi; nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi)); if (NS_FAILED(rv)) { return mozilla::dom::Throw(aCx, rv); @@ -3682,7 +3682,7 @@ nsObjectLoadingContent::GetOwnPropertyNames(JSContext* aCx, // Just like DoResolve, just make sure we're instantiated. That will do // the work our Enumerate hook needs to do. This purposefully does not fire // for xray resolves, see bug 967694 - nsRefPtr pi; + RefPtr pi; aRv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi)); } diff --git a/dom/base/nsObjectLoadingContent.h b/dom/base/nsObjectLoadingContent.h index d246eac042..acd23874b6 100644 --- a/dom/base/nsObjectLoadingContent.h +++ b/dom/base/nsObjectLoadingContent.h @@ -540,7 +540,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent private: // We store an nsIObjectLoadingContent because we can // unambiguously refcount that. - nsRefPtr mContent; + RefPtr mContent; }; // Utility getter for getting our nsNPAPIPluginInstance in a safe way. @@ -558,7 +558,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent nsCOMPtr mFinalListener; // Frame loader, for content documents we load. - nsRefPtr mFrameLoader; + RefPtr mFrameLoader; // Track if we have a pending AsyncInstantiateEvent nsCOMPtr mPendingInstantiateEvent; @@ -637,7 +637,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent nsWeakFrame mPrintFrame; - nsRefPtr mInstanceOwner; + RefPtr mInstanceOwner; nsTArray mCachedAttributes; nsTArray mCachedParameters; }; diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index d70429c426..a7b41de507 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -801,7 +801,7 @@ protected: nsIDocShell *mDocShell; // Weak Reference // mPerformance is only used on inner windows. - nsRefPtr mPerformance; + RefPtr mPerformance; uint32_t mModalStateDepth; diff --git a/dom/base/nsPerformance.cpp b/dom/base/nsPerformance.cpp index 2259517fd2..37d9eac91b 100644 --- a/dom/base/nsPerformance.cpp +++ b/dom/base/nsPerformance.cpp @@ -480,7 +480,7 @@ nsPerformance::Timing() void nsPerformance::DispatchBufferFullEvent() { - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); // it bubbles, and it isn't cancelable nsresult rv = event->InitEvent(NS_LITERAL_STRING("resourcetimingbufferfull"), true, false); @@ -556,15 +556,34 @@ nsPerformance::AddEntry(nsIHttpChannel* channel, // The last argument is the "zero time" (offset). Since we don't want // any offset for the resource timing, this will be set to "0" - the // resource timing returns a relative timing (no offset). - nsRefPtr performanceTiming = + RefPtr performanceTiming = new nsPerformanceTiming(this, timedChannel, channel, 0); // The PerformanceResourceTiming object will use the nsPerformanceTiming // object to get all the required timings. - nsRefPtr performanceEntry = + RefPtr performanceEntry = new PerformanceResourceTiming(performanceTiming, this, entryName); + nsAutoCString protocol; + channel->GetProtocolVersion(protocol); + performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol)); + + uint64_t encodedBodySize = 0; + channel->GetEncodedBodySize(&encodedBodySize); + performanceEntry->SetEncodedBodySize(encodedBodySize); + + uint64_t transferSize = 0; + channel->GetTransferSize(&transferSize); + performanceEntry->SetTransferSize(transferSize); + + uint64_t decodedBodySize = 0; + channel->GetDecodedBodySize(&decodedBodySize); + if (decodedBodySize == 0) { + decodedBodySize = encodedBodySize; + } + performanceEntry->SetDecodedBodySize(decodedBodySize); + // If the initiator type had no valid value, then set it to the default // ("other") value. if (initiatorType.IsEmpty()) { @@ -731,7 +750,7 @@ nsPerformance::IsEnabled(JSContext* aCx, JSObject* aGlobal) MOZ_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); - nsRefPtr runnable = + RefPtr runnable = new PrefEnabledRunnable(workerPrivate, NS_LITERAL_CSTRING("dom.enable_user_timing")); runnable->Dispatch(workerPrivate->GetJSContext()); @@ -750,7 +769,7 @@ nsPerformance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal) MOZ_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); - nsRefPtr runnable = + RefPtr runnable = new PrefEnabledRunnable(workerPrivate, NS_LITERAL_CSTRING("dom.enable_performance_observer")); runnable->Dispatch(workerPrivate->GetJSContext()); @@ -829,7 +848,7 @@ PerformanceBase::~PerformanceBase() {} void -PerformanceBase::GetEntries(nsTArray>& aRetval) +PerformanceBase::GetEntries(nsTArray>& aRetval) { aRetval = mResourceEntries; aRetval.AppendElements(mUserEntries); @@ -838,7 +857,7 @@ PerformanceBase::GetEntries(nsTArray>& aRetval) void PerformanceBase::GetEntriesByType(const nsAString& aEntryType, - nsTArray>& aRetval) + nsTArray>& aRetval) { if (aEntryType.EqualsLiteral("resource")) { aRetval = mResourceEntries; @@ -860,7 +879,7 @@ PerformanceBase::GetEntriesByType(const nsAString& aEntryType, void PerformanceBase::GetEntriesByName(const nsAString& aName, const Optional& aEntryType, - nsTArray>& aRetval) + nsTArray>& aRetval) { aRetval.Clear(); @@ -919,7 +938,7 @@ PerformanceBase::Mark(const nsAString& aName, ErrorResult& aRv) return; } - nsRefPtr performanceMark = + RefPtr performanceMark = new PerformanceMark(GetAsISupports(), aName, Now()); InsertUserEntry(performanceMark); } @@ -934,7 +953,7 @@ DOMHighResTimeStamp PerformanceBase::ResolveTimestampFromName(const nsAString& aName, ErrorResult& aRv) { - nsAutoTArray, 1> arr; + nsAutoTArray, 1> arr; DOMHighResTimeStamp ts; Optional typeParam; nsAutoString str; @@ -1000,7 +1019,7 @@ PerformanceBase::Measure(const nsAString& aName, endTime = Now(); } - nsRefPtr performanceMeasure = + RefPtr performanceMeasure = new PerformanceMeasure(GetAsISupports(), aName, startTime, endTime); InsertUserEntry(performanceMeasure); } @@ -1036,7 +1055,7 @@ PerformanceBase::TimingNotification(PerformanceEntry* aEntry, const nsACString& init.mEpoch = aEpoch; init.mOrigin = NS_ConvertUTF8toUTF16(aOwner.BeginReading()); - nsRefPtr perfEntryEvent = + RefPtr perfEntryEvent = PerformanceEntryEvent::Constructor(this, NS_LITERAL_STRING("performanceentry"), init); nsCOMPtr et = do_QueryInterface(GetOwner()); @@ -1134,7 +1153,7 @@ private: { } - nsRefPtr mPerformance; + RefPtr mPerformance; }; void diff --git a/dom/base/nsPerformance.h b/dom/base/nsPerformance.h index a6b4c0d2ed..bca309cf21 100644 --- a/dom/base/nsPerformance.h +++ b/dom/base/nsPerformance.h @@ -227,7 +227,7 @@ private: ~nsPerformanceTiming(); bool IsInitialized() const; void InitializeTimingInfo(nsITimedChannel* aChannel); - nsRefPtr mPerformance; + RefPtr mPerformance; DOMHighResTimeStamp mFetchStart; // This is an offset that will be added to each timing ([ms] resolution). // There are only 2 possible values: (1) logicaly equal to navigationStart @@ -286,7 +286,7 @@ public: private: ~nsPerformanceNavigation(); - nsRefPtr mPerformance; + RefPtr mPerformance; }; // Base class for main-thread and worker Performance API @@ -303,12 +303,12 @@ public: typedef mozilla::dom::PerformanceEntry PerformanceEntry; typedef mozilla::dom::PerformanceObserver PerformanceObserver; - void GetEntries(nsTArray>& aRetval); + void GetEntries(nsTArray>& aRetval); void GetEntriesByType(const nsAString& aEntryType, - nsTArray>& aRetval); + nsTArray>& aRetval); void GetEntriesByName(const nsAString& aName, const mozilla::dom::Optional& aEntryType, - nsTArray>& aRetval); + nsTArray>& aRetval); void ClearResourceTimings(); virtual DOMHighResTimeStamp Now() const = 0; @@ -366,8 +366,8 @@ protected: nsTObserverArray mObservers; private: - nsTArray> mUserEntries; - nsTArray> mResourceEntries; + nsTArray> mUserEntries; + nsTArray> mResourceEntries; uint64_t mResourceTimingBufferSize; static const uint64_t kDefaultResourceTimingBufferSize = 150; @@ -453,11 +453,11 @@ private: void DispatchBufferFullEvent() override; - nsRefPtr mDOMTiming; + RefPtr mDOMTiming; nsCOMPtr mChannel; - nsRefPtr mTiming; - nsRefPtr mNavigation; - nsRefPtr mParentPerformance; + RefPtr mTiming; + RefPtr mNavigation; + RefPtr mParentPerformance; JS::Heap mMozMemory; }; diff --git a/dom/base/nsPlainTextSerializer.cpp b/dom/base/nsPlainTextSerializer.cpp index 1bc4486b58..e5bcd6b3b4 100644 --- a/dom/base/nsPlainTextSerializer.cpp +++ b/dom/base/nsPlainTextSerializer.cpp @@ -58,7 +58,7 @@ static const uint32_t OLStackSize = 100; nsresult NS_NewPlainTextSerializer(nsIContentSerializer** aSerializer) { - nsRefPtr it = new nsPlainTextSerializer(); + RefPtr it = new nsPlainTextSerializer(); it.forget(aSerializer); return NS_OK; } @@ -1821,7 +1821,7 @@ nsPlainTextSerializer::IsInPre() bool nsPlainTextSerializer::IsElementPreformatted(Element* aElement) { - nsRefPtr styleContext = + RefPtr styleContext = nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr, nullptr); if (styleContext) { @@ -1835,7 +1835,7 @@ nsPlainTextSerializer::IsElementPreformatted(Element* aElement) bool nsPlainTextSerializer::IsElementBlock(Element* aElement) { - nsRefPtr styleContext = + RefPtr styleContext = nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr, nullptr); if (styleContext) { diff --git a/dom/base/nsPlainTextSerializer.h b/dom/base/nsPlainTextSerializer.h index e47735cc39..9c941eefda 100644 --- a/dom/base/nsPlainTextSerializer.h +++ b/dom/base/nsPlainTextSerializer.h @@ -192,7 +192,7 @@ private: section. mHeaderCounter[1] for

etc. */ - nsRefPtr mElement; + RefPtr mElement; // For handling table rows nsAutoTArray mHasWrittenCellsForRow; diff --git a/dom/base/nsPluginArray.cpp b/dom/base/nsPluginArray.cpp index c4429e257d..857184c1ea 100644 --- a/dom/base/nsPluginArray.cpp +++ b/dom/base/nsPluginArray.cpp @@ -69,8 +69,8 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginArray, mPlugins) static void -GetPluginMimeTypes(const nsTArray >& aPlugins, - nsTArray >& aMimeTypes) +GetPluginMimeTypes(const nsTArray >& aPlugins, + nsTArray >& aMimeTypes) { for (uint32_t i = 0; i < aPlugins.Length(); ++i) { nsPluginElement *plugin = aPlugins[i]; @@ -79,14 +79,14 @@ GetPluginMimeTypes(const nsTArray >& aPlugins, } static bool -operator<(const nsRefPtr& lhs, const nsRefPtr& rhs) +operator<(const RefPtr& lhs, const RefPtr& rhs) { // Sort MIME types alphabetically by type name. return lhs->Type() < rhs->Type(); } void -nsPluginArray::GetMimeTypes(nsTArray>& aMimeTypes) +nsPluginArray::GetMimeTypes(nsTArray>& aMimeTypes) { aMimeTypes.Clear(); @@ -120,7 +120,7 @@ nsPluginArray::NamedItem(const nsAString& aName) void nsPluginArray::Refresh(bool aReloadDocuments) { - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if(!AllowPlugins() || !pluginHost) { return; @@ -193,7 +193,7 @@ nsPluginArray::Invalidate() } static nsPluginElement* -FindPlugin(const nsTArray >& aPlugins, +FindPlugin(const nsTArray >& aPlugins, const nsAString& aName) { for (uint32_t i = 0; i < aPlugins.Length(); ++i) { @@ -279,8 +279,8 @@ nsPluginArray::AllowPlugins() const } static bool -operator<(const nsRefPtr& lhs, - const nsRefPtr& rhs) +operator<(const RefPtr& lhs, + const RefPtr& rhs) { // Sort plugins alphabetically by name. return lhs->PluginTag()->Name() < rhs->PluginTag()->Name(); @@ -294,7 +294,7 @@ nsPluginArray::EnsurePlugins() return; } - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); if (!pluginHost) { // We have no plugin host. return; @@ -444,7 +444,7 @@ nsPluginElement::GetSupportedNames(unsigned, nsTArray& retval) } } -nsTArray >& +nsTArray >& nsPluginElement::MimeTypes() { EnsurePluginMimeTypes(); diff --git a/dom/base/nsPluginArray.h b/dom/base/nsPluginArray.h index f73f50511b..aa6142ea8f 100644 --- a/dom/base/nsPluginArray.h +++ b/dom/base/nsPluginArray.h @@ -40,7 +40,7 @@ public: void Init(); void Invalidate(); - void GetMimeTypes(nsTArray>& aMimeTypes); + void GetMimeTypes(nsTArray>& aMimeTypes); // PluginArray WebIDL methods @@ -60,7 +60,7 @@ private: void EnsurePlugins(); nsCOMPtr mWindow; - nsTArray > mPlugins; + nsTArray > mPlugins; }; class nsPluginElement final : public nsISupports, @@ -94,7 +94,7 @@ public: uint32_t Length(); void GetSupportedNames(unsigned, nsTArray& retval); - nsTArray >& MimeTypes(); + nsTArray >& MimeTypes(); protected: ~nsPluginElement(); @@ -103,7 +103,7 @@ protected: nsCOMPtr mWindow; nsCOMPtr mPluginTag; - nsTArray > mMimeTypes; + nsTArray > mMimeTypes; }; #endif /* nsPluginArray_h___ */ diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index b882c9e863..6b99b8f0a2 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -246,7 +246,7 @@ nsRange::CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset, nsCOMPtr startParent = do_QueryInterface(aStartParent); NS_ENSURE_ARG_POINTER(startParent); - nsRefPtr range = new nsRange(startParent); + RefPtr range = new nsRange(startParent); nsresult rv = range->SetStart(startParent, aStartOffset); NS_ENSURE_SUCCESS(rv, rv); @@ -264,7 +264,7 @@ nsRange::CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset, nsIDOMNode* aEndParent, int32_t aEndOffset, nsIDOMRange** aRange) { - nsRefPtr range; + RefPtr range; nsresult rv = nsRange::CreateRange(aStartParent, aStartOffset, aEndParent, aEndOffset, getter_AddRefs(range)); range.forget(aRange); @@ -1799,7 +1799,7 @@ nsRange::CutContents(DocumentFragment** aFragment) NS_ENSURE_TRUE(!res.Failed(), res.StealNSResult()); // If aFragment isn't null, create a temporary fragment to hold our return. - nsRefPtr retval; + RefPtr retval; if (aFragment) { retval = new DocumentFragment(doc->NodeInfoManager()); } @@ -1822,7 +1822,7 @@ nsRange::CutContents(DocumentFragment** aFragment) // we just need to find its doctype child and check if that's in the range. nsCOMPtr commonAncestorDocument = do_QueryInterface(commonAncestor); if (commonAncestorDocument) { - nsRefPtr doctype = commonAncestorDocument->GetDoctype(); + RefPtr doctype = commonAncestorDocument->GetDoctype(); if (doctype && nsContentUtils::ComparePoints(startContainer, startOffset, @@ -2075,7 +2075,7 @@ NS_IMETHODIMP nsRange::ExtractContents(nsIDOMDocumentFragment** aReturn) { NS_ENSURE_ARG_POINTER(aReturn); - nsRefPtr fragment; + RefPtr fragment; nsresult rv = CutContents(getter_AddRefs(fragment)); fragment.forget(aReturn); return rv; @@ -2084,7 +2084,7 @@ nsRange::ExtractContents(nsIDOMDocumentFragment** aReturn) already_AddRefed nsRange::ExtractContents(ErrorResult& rv) { - nsRefPtr fragment; + RefPtr fragment; rv = CutContents(getter_AddRefs(fragment)); return fragment.forget(); } @@ -2228,7 +2228,7 @@ nsRange::CloneContents(ErrorResult& aRv) // which might be null - nsRefPtr clonedFrag = + RefPtr clonedFrag = new DocumentFragment(doc->NodeInfoManager()); nsCOMPtr commonCloneAncestor = clonedFrag.get(); @@ -2418,7 +2418,7 @@ nsRange::CloneContents(ErrorResult& aRv) already_AddRefed nsRange::CloneRange() const { - nsRefPtr range = new nsRange(mOwner); + RefPtr range = new nsRange(mOwner); range->SetMaySpanAnonymousSubtrees(mMaySpanAnonymousSubtrees); @@ -2589,7 +2589,7 @@ nsRange::SurroundContents(nsINode& aNewParent, ErrorResult& aRv) // Extract the contents within the range. - nsRefPtr docFrag = ExtractContents(aRv); + RefPtr docFrag = ExtractContents(aRv); if (aRv.Failed()) { return; @@ -2933,7 +2933,7 @@ nsRange::GetBoundingClientRect(nsIDOMClientRect** aResult) already_AddRefed nsRange::GetBoundingClientRect(bool aClampToEdge, bool aFlushLayout) { - nsRefPtr rect = new DOMRect(ToSupports(this)); + RefPtr rect = new DOMRect(ToSupports(this)); if (!mStartParent) { return rect.forget(); } @@ -2962,7 +2962,7 @@ nsRange::GetClientRects(bool aClampToEdge, bool aFlushLayout) return nullptr; } - nsRefPtr rectList = + RefPtr rectList = new DOMRectList(static_cast(this)); nsLayoutUtils::RectListBuilder builder(rectList); @@ -2990,7 +2990,7 @@ nsRange::GetUsedFontFaces(nsIDOMFontFaceList** aResult) // Recheck whether we're still in the document NS_ENSURE_TRUE(mStartParent->IsInDoc(), NS_ERROR_UNEXPECTED); - nsRefPtr fontFaceList = new nsFontFaceList(); + RefPtr fontFaceList = new nsFontFaceList(); RangeSubtreeIterator iter; nsresult rv = iter.Init(this); @@ -3081,14 +3081,14 @@ nsRange::Constructor(const GlobalObject& aGlobal, } void -nsRange::ExcludeNonSelectableNodes(nsTArray>* aOutRanges) +nsRange::ExcludeNonSelectableNodes(nsTArray>* aOutRanges) { MOZ_ASSERT(mIsPositioned); MOZ_ASSERT(mEndParent); MOZ_ASSERT(mStartParent); nsRange* range = this; - nsRefPtr newRange; + RefPtr newRange; while (range) { nsCOMPtr iter = NS_NewPreContentIterator(); nsresult rv = iter->Init(range); @@ -3240,7 +3240,7 @@ ElementIsVisibleNoFlush(Element* aElement) if (!aElement) { return false; } - nsRefPtr sc = + RefPtr sc = nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr, nullptr); return sc && sc->StyleVisibility()->IsVisible(); diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h index 333866168f..688138a330 100644 --- a/dom/base/nsRange.h +++ b/dom/base/nsRange.h @@ -271,7 +271,7 @@ public: * will be empty. * @param aOutRanges the resulting set of ranges */ - void ExcludeNonSelectableNodes(nsTArray>* aOutRanges); + void ExcludeNonSelectableNodes(nsTArray>* aOutRanges); typedef nsTHashtable > RangeHashTable; protected: @@ -312,7 +312,7 @@ protected: } ~AutoInvalidateSelection(); nsRange* mRange; - nsRefPtr mCommonAncestor; + RefPtr mCommonAncestor; #ifdef DEBUG bool mWasInSelection; #endif @@ -323,7 +323,7 @@ protected: nsCOMPtr mRoot; nsCOMPtr mStartParent; nsCOMPtr mEndParent; - nsRefPtr mSelection; + RefPtr mSelection; int32_t mStartOffset; int32_t mEndOffset; diff --git a/dom/base/nsReferencedElement.cpp b/dom/base/nsReferencedElement.cpp index 3cb9fc0150..961e591041 100644 --- a/dom/base/nsReferencedElement.cpp +++ b/dom/base/nsReferencedElement.cpp @@ -89,7 +89,7 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI, bool isEqualExceptRef; rv = aURI->EqualsExceptRef(doc->GetDocumentURI(), &isEqualExceptRef); if (NS_FAILED(rv) || !isEqualExceptRef) { - nsRefPtr load; + RefPtr load; doc = doc->RequestExternalResource(aURI, aFromContent, getter_AddRefs(load)); if (!doc) { diff --git a/dom/base/nsReferencedElement.h b/dom/base/nsReferencedElement.h index 9b5f3d8675..e792245724 100644 --- a/dom/base/nsReferencedElement.h +++ b/dom/base/nsReferencedElement.h @@ -148,8 +148,8 @@ private: protected: virtual ~ChangeNotification() {} - nsRefPtr mFrom; - nsRefPtr mTo; + RefPtr mFrom; + RefPtr mTo; }; friend class ChangeNotification; @@ -179,8 +179,8 @@ private: nsCOMPtr mWatchID; nsCOMPtr mWatchDocument; - nsRefPtr mElement; - nsRefPtr mPendingNotification; + RefPtr mElement; + RefPtr mPendingNotification; bool mReferencingImage; }; diff --git a/dom/base/nsScreen.cpp b/dom/base/nsScreen.cpp index 5dd1fbdb33..83685cff0d 100644 --- a/dom/base/nsScreen.cpp +++ b/dom/base/nsScreen.cpp @@ -34,7 +34,7 @@ nsScreen::Create(nsPIDOMWindow* aWindow) do_QueryInterface(static_cast(aWindow)); NS_ENSURE_TRUE(sgo, nullptr); - nsRefPtr screen = new nsScreen(aWindow); + RefPtr screen = new nsScreen(aWindow); return screen.forget(); } diff --git a/dom/base/nsScreen.h b/dom/base/nsScreen.h index 2041c1c759..1bcc017780 100644 --- a/dom/base/nsScreen.h +++ b/dom/base/nsScreen.h @@ -141,7 +141,7 @@ private: bool ShouldResistFingerprinting() const; - nsRefPtr mScreenOrientation; + RefPtr mScreenOrientation; }; #endif /* nsScreen_h___ */ diff --git a/dom/base/nsScriptElement.cpp b/dom/base/nsScriptElement.cpp index a63557151e..c7f6449940 100644 --- a/dom/base/nsScriptElement.cpp +++ b/dom/base/nsScriptElement.cpp @@ -55,7 +55,7 @@ nsScriptElement::ScriptEvaluated(nsresult aResult, nsCOMPtr cont = do_QueryInterface((nsIScriptElement*) this); - nsRefPtr presContext = + RefPtr presContext = nsContentUtils::GetContextForContent(cont); nsEventStatus status = nsEventStatus_eIgnore; @@ -138,6 +138,6 @@ nsScriptElement::MaybeProcessScript() } } - nsRefPtr loader = ownerDoc->ScriptLoader(); + RefPtr loader = ownerDoc->ScriptLoader(); return loader->ProcessScriptElement(this); } diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index 48e7ed5ec8..5870c75461 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -85,7 +85,7 @@ void nsScriptLoadRequestList::Clear() { while (!isEmpty()) { - nsRefPtr first = StealFirst(); + RefPtr first = StealFirst(); first->Cancel(); // And just let it go out of scope and die. } @@ -362,7 +362,7 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType, if (aRequest->mCORSMode != CORS_NONE) { bool withCredentials = (aRequest->mCORSMode == CORS_USE_CREDENTIALS); - nsRefPtr corsListener = + RefPtr corsListener = new nsCORSListenerProxy(listener, mDocument->NodePrincipal(), withCredentials); rv = corsListener->Init(channel, DataURIHandling::Allow); @@ -388,8 +388,8 @@ nsScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi, class nsScriptRequestProcessor : public nsRunnable { private: - nsRefPtr mLoader; - nsRefPtr mRequest; + RefPtr mLoader; + RefPtr mRequest; public: nsScriptRequestProcessor(nsScriptLoader* aLoader, nsScriptLoadRequest* aRequest) @@ -528,7 +528,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) // Step 14. in the HTML5 spec nsresult rv = NS_OK; - nsRefPtr request; + RefPtr request; if (aElement->GetScriptExternal()) { // external script nsCOMPtr scriptURI = aElement->GetScriptURI(); @@ -755,8 +755,8 @@ namespace { class NotifyOffThreadScriptLoadCompletedRunnable : public nsRunnable { - nsRefPtr mRequest; - nsRefPtr mLoader; + RefPtr mRequest; + RefPtr mLoader; void *mToken; public: @@ -811,8 +811,8 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run() // We want these to be dropped on the main thread, once we return from this // function. - nsRefPtr request = mRequest.forget(); - nsRefPtr loader = mLoader.forget(); + RefPtr request = mRequest.forget(); + RefPtr loader = mLoader.forget(); request->mOffThreadToken = mToken; nsresult rv = loader->ProcessOffThreadRequest(request); @@ -823,7 +823,7 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run() static void OffThreadScriptLoaderCallback(void *aToken, void *aCallbackData) { - nsRefPtr aRunnable = + RefPtr aRunnable = dont_AddRef(static_cast(aCallbackData)); aRunnable->SetToken(aToken); NS_DispatchToMainThread(aRunnable); @@ -855,7 +855,7 @@ nsScriptLoader::AttemptAsyncScriptParse(nsScriptLoadRequest* aRequest) return NS_ERROR_FAILURE; } - nsRefPtr runnable = + RefPtr runnable = new NotifyOffThreadScriptLoadCompletedRunnable(aRequest, this); if (!JS::CompileOffThread(cx, options, @@ -1168,7 +1168,7 @@ nsScriptLoader::ProcessPendingRequestsAsync() void nsScriptLoader::ProcessPendingRequests() { - nsRefPtr request; + RefPtr request; if (mParserBlockingRequest && mParserBlockingRequest->IsReadyToRun() && @@ -1209,7 +1209,7 @@ nsScriptLoader::ProcessPendingRequests() } while (!mPendingChildLoaders.IsEmpty() && ReadyToExecuteScripts()) { - nsRefPtr child = mPendingChildLoaders[0]; + RefPtr child = mPendingChildLoaders[0]; mPendingChildLoaders.RemoveElementAt(0); child->RemoveExecuteBlocker(); } @@ -1253,8 +1253,8 @@ nsScriptLoader::ReadyToExecuteScripts() } if (mDocument && !mDocument->IsMasterDocument()) { - nsRefPtr im = mDocument->ImportManager(); - nsRefPtr loader = im->Find(mDocument); + RefPtr im = mDocument->ImportManager(); + RefPtr loader = im->Find(mDocument); MOZ_ASSERT(loader, "How can we have an import document without a loader?"); // The referring link that counts in the execution order calculation @@ -1266,7 +1266,7 @@ nsScriptLoader::ReadyToExecuteScripts() // wait with script execution until all the predecessors are done. // Technically it means we have to wait for the last one to finish, // which is the neares one to us in the order. - nsRefPtr lastPred = im->GetNearestPredecessor(referrer); + RefPtr lastPred = im->GetNearestPredecessor(referrer); if (!lastPred) { // If there is no predecessor we can run. return true; @@ -1436,23 +1436,23 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader, if (request->mIsDefer) { if (request->isInList()) { - nsRefPtr req = mDeferRequests.Steal(request); + RefPtr req = mDeferRequests.Steal(request); FireScriptAvailable(rv, req); } } else if (request->mIsAsync) { if (request->isInList()) { - nsRefPtr req = mLoadingAsyncRequests.Steal(request); + RefPtr req = mLoadingAsyncRequests.Steal(request); FireScriptAvailable(rv, req); } } else if (request->mIsNonAsyncScriptInserted) { if (request->isInList()) { - nsRefPtr req = + RefPtr req = mNonAsyncExternalScriptInsertedRequests.Steal(request); FireScriptAvailable(rv, req); } } else if (request->mIsXSLT) { if (request->isInList()) { - nsRefPtr req = mXSLTRequests.Steal(request); + RefPtr req = mXSLTRequests.Steal(request); FireScriptAvailable(rv, req); } } else if (mParserBlockingRequest == request) { @@ -1581,7 +1581,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest, if (aRequest->mIsAsync) { MOZ_ASSERT(aRequest->isInList()); if (aRequest->isInList()) { - nsRefPtr req = mLoadingAsyncRequests.Steal(aRequest); + RefPtr req = mLoadingAsyncRequests.Steal(aRequest); mLoadedAsyncRequests.AppendElement(req); } } @@ -1636,7 +1636,7 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset, SRICheck::IntegrityMetadata(aIntegrity, mDocument, &sriMetadata); } - nsRefPtr request = + RefPtr request = new nsScriptLoadRequest(nullptr, 0, Element::StringToCORSMode(aCrossOrigin), sriMetadata); diff --git a/dom/base/nsScriptLoader.h b/dom/base/nsScriptLoader.h index 468f50f5d5..d530cfd61e 100644 --- a/dom/base/nsScriptLoader.h +++ b/dom/base/nsScriptLoader.h @@ -504,11 +504,11 @@ private: nsScriptLoadRequestList mLoadedAsyncRequests; nsScriptLoadRequestList mDeferRequests; nsScriptLoadRequestList mXSLTRequests; - nsRefPtr mParserBlockingRequest; + RefPtr mParserBlockingRequest; // In mRequests, the additional information here is stored by the element. struct PreloadInfo { - nsRefPtr mRequest; + RefPtr mRequest; nsString mCharset; }; @@ -527,7 +527,7 @@ private: nsCOMPtr mCurrentScript; nsCOMPtr mCurrentParserInsertedScript; // XXXbz do we want to cycle-collect these or something? Not sure. - nsTArray< nsRefPtr > mPendingChildLoaders; + nsTArray< RefPtr > mPendingChildLoaders; uint32_t mBlockerCount; bool mEnabled; bool mDeferEnabled; @@ -555,7 +555,7 @@ public: } bool mWasEnabled; - nsRefPtr mLoader; + RefPtr mLoader; }; #endif //__nsScriptLoader_h__ diff --git a/dom/base/nsStyleLinkElement.cpp b/dom/base/nsStyleLinkElement.cpp index 9fc8465436..e0660e8f3c 100644 --- a/dom/base/nsStyleLinkElement.cpp +++ b/dom/base/nsStyleLinkElement.cpp @@ -291,7 +291,7 @@ UpdateIsElementInStyleScopeFlagOnSubtree(Element* aElement) static Element* GetScopeElement(nsIStyleSheet* aSheet) { - nsRefPtr cssStyleSheet = do_QueryObject(aSheet); + RefPtr cssStyleSheet = do_QueryObject(aSheet); if (!cssStyleSheet) { return nullptr; } diff --git a/dom/base/nsStyleLinkElement.h b/dom/base/nsStyleLinkElement.h index 1d7dd5d374..a712cff8d9 100644 --- a/dom/base/nsStyleLinkElement.h +++ b/dom/base/nsStyleLinkElement.h @@ -128,7 +128,7 @@ private: bool* aIsAlternate, bool aForceUpdate); - nsRefPtr mStyleSheet; + RefPtr mStyleSheet; protected: bool mDontLoadStyle; bool mUpdatesEnabled; diff --git a/dom/base/nsSyncLoadService.cpp b/dom/base/nsSyncLoadService.cpp index 9cd3a563df..2a67cac150 100644 --- a/dom/base/nsSyncLoadService.cpp +++ b/dom/base/nsSyncLoadService.cpp @@ -187,7 +187,7 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel, } if (aLoaderPrincipal) { - nsRefPtr corsListener = + RefPtr corsListener = new nsCORSListenerProxy(listener, aLoaderPrincipal, false); rv = corsListener->Init(mChannel, DataURIHandling::Disallow); NS_ENSURE_SUCCESS(rv, rv); @@ -333,7 +333,7 @@ nsSyncLoadService::LoadDocument(nsIURI *aURI, nsIPrincipal *aLoaderPrincipal, (NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)) && isResource); - nsRefPtr loader = new nsSyncLoader(); + RefPtr loader = new nsSyncLoader(); return loader->LoadDocument(channel, aLoaderPrincipal, isSync, aForceToXML, aReferrerPolicy, aResult); diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index 8ae17c31f5..8b7fa9b696 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -59,7 +59,7 @@ public: bool aCloneText) const override { already_AddRefed ni = - nsRefPtr(aNodeInfo).forget(); + RefPtr(aNodeInfo).forget(); nsAttributeTextNode *it = new nsAttributeTextNode(ni, mNameSpaceID, mAttrName); @@ -115,7 +115,7 @@ nsTextNode::IsNodeOfType(uint32_t aFlags) const nsGenericDOMDataNode* nsTextNode::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const { - already_AddRefed ni = nsRefPtr(aNodeInfo).forget(); + already_AddRefed ni = RefPtr(aNodeInfo).forget(); nsTextNode *it = new nsTextNode(ni); if (aCloneText) { it->mText = mText; diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp index 8775f91215..8cd2b1ff5d 100644 --- a/dom/base/nsTreeSanitizer.cpp +++ b/dom/base/nsTreeSanitizer.cpp @@ -1097,7 +1097,7 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal, // -moz-binding is blacklisted. bool didSanitize = false; // Create a sheet to hold the parsed CSS - nsRefPtr sheet = new CSSStyleSheet(CORS_NONE, aDocument->GetReferrerPolicy()); + RefPtr sheet = new CSSStyleSheet(CORS_NONE, aDocument->GetReferrerPolicy()); sheet->SetURIs(aDocument->GetDocumentURI(), nullptr, aBaseURI); sheet->SetPrincipal(aDocument->NodePrincipal()); // Create the CSS parser, and parse the CSS text. @@ -1136,7 +1136,7 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal, case mozilla::css::Rule::STYLE_RULE: { // For style rules, we will just look for and remove the // -moz-binding properties. - nsRefPtr styleRule = do_QueryObject(rule); + RefPtr styleRule = do_QueryObject(rule); NS_ASSERTION(styleRule, "Must be a style rule"); nsAutoString decl; bool sanitized = SanitizeStyleRule(styleRule, decl); @@ -1176,7 +1176,7 @@ nsTreeSanitizer::SanitizeAttributes(mozilla::dom::Element* aElement, // Pass the CSS Loader object to the parser, to allow parser error // reports to include the outer window ID. nsCSSParser parser(document->CSSLoader()); - nsRefPtr rule; + RefPtr rule; nsAutoString value; aElement->GetAttr(attrNs, attrLocal, value); rv = parser.ParseStyleAttribute(value, @@ -1359,7 +1359,7 @@ nsTreeSanitizer::Sanitize(nsIDocument* aDocument) // in tree. #ifdef DEBUG NS_PRECONDITION(!aDocument->GetContainer(), "The document is in a shell."); - nsRefPtr root = aDocument->GetRootElement(); + RefPtr root = aDocument->GetRootElement(); NS_PRECONDITION(root->IsHTMLElement(nsGkAtoms::html), "Not HTML root."); #endif diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index 576990e8b1..ffd0c5af18 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -446,7 +446,7 @@ CollectWindowReports(nsGlobalWindow *aWindow, return NS_OK; } -typedef nsTArray< nsRefPtr > WindowArray; +typedef nsTArray< RefPtr > WindowArray; static PLDHashOperator @@ -928,7 +928,7 @@ nsWindowMemoryReporter::UnlinkGhostWindows() continue; } - nsRefPtr window = windowsById->Get(iter.Get()->GetKey()); + RefPtr window = windowsById->Get(iter.Get()->GetKey()); if (window) { window->RiskyUnlink(); } diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index 4b4389a931..285d77b07e 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -68,7 +68,7 @@ NS_IMPL_DOMTARGET_DEFAULTS(nsWindowRoot) NS_IMETHODIMP nsWindowRoot::RemoveEventListener(const nsAString& aType, nsIDOMEventListener* aListener, bool aUseCapture) { - if (nsRefPtr elm = GetExistingListenerManager()) { + if (RefPtr elm = GetExistingListenerManager()) { elm->RemoveEventListener(aType, aListener, aUseCapture); } return NS_OK; @@ -405,7 +405,7 @@ nsWindowRoot::EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) { // Collect strong references to all browsers in a separate array in // case aEnumFunc alters mWeakBrowsers. - nsTArray> tabParents; + nsTArray> tabParents; for (auto iter = mWeakBrowsers.ConstIter(); !iter.Done(); iter.Next()) { nsCOMPtr tabParent(do_QueryReferent(iter.Get()->GetKey())); if (TabParent* tab = TabParent::GetFrom(tabParent)) { diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index 203ef2c63b..1b5b64886e 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -84,7 +84,7 @@ protected: // Members nsCOMPtr mWindow; // We own the manager, which owns event listeners attached to us. - nsRefPtr mListenerManager; // [Strong] + RefPtr mListenerManager; // [Strong] nsCOMPtr mPopupNode; // [OWNER] nsCOMPtr mParent; diff --git a/dom/base/nsXHTMLContentSerializer.cpp b/dom/base/nsXHTMLContentSerializer.cpp index 0f2911b1cd..b516d2f218 100644 --- a/dom/base/nsXHTMLContentSerializer.cpp +++ b/dom/base/nsXHTMLContentSerializer.cpp @@ -44,7 +44,7 @@ static const int32_t kLongLineLen = 128; nsresult NS_NewXHTMLContentSerializer(nsIContentSerializer** aSerializer) { - nsRefPtr it = new nsXHTMLContentSerializer(); + RefPtr it = new nsXHTMLContentSerializer(); it.forget(aSerializer); return NS_OK; } @@ -882,7 +882,7 @@ nsXHTMLContentSerializer::IsElementPreformatted(nsIContent* aNode) if (!aNode->IsElement()) { return false; } - nsRefPtr styleContext = + RefPtr styleContext = nsComputedDOMStyle::GetStyleContextForElementNoFlush(aNode->AsElement(), nullptr, nullptr); if (styleContext) { diff --git a/dom/base/nsXMLContentSerializer.cpp b/dom/base/nsXMLContentSerializer.cpp index f1d75ce40d..437e74d86a 100644 --- a/dom/base/nsXMLContentSerializer.cpp +++ b/dom/base/nsXMLContentSerializer.cpp @@ -47,7 +47,7 @@ using namespace mozilla::dom; nsresult NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer) { - nsRefPtr it = new nsXMLContentSerializer(); + RefPtr it = new nsXMLContentSerializer(); it.forget(aSerializer); return NS_OK; } diff --git a/dom/base/nsXMLHttpRequest.cpp b/dom/base/nsXMLHttpRequest.cpp index 4cccf61bc8..8230c3d273 100644 --- a/dom/base/nsXMLHttpRequest.cpp +++ b/dom/base/nsXMLHttpRequest.cpp @@ -1331,7 +1331,7 @@ nsXMLHttpRequest::GetAllResponseHeaders(nsCString& aResponseHeaders) } if (nsCOMPtr httpChannel = GetCurrentHttpChannel()) { - nsRefPtr visitor = new nsHeaderVisitor(this, httpChannel); + RefPtr visitor = new nsHeaderVisitor(this, httpChannel); if (NS_SUCCEEDED(httpChannel->VisitResponseHeaders(visitor))) { aResponseHeaders = visitor->Headers(); } @@ -1464,7 +1464,7 @@ nsXMLHttpRequest::GetLoadGroup() const nsresult nsXMLHttpRequest::CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent) { - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); event.forget(aDOMEvent); (*aDOMEvent)->InitEvent(NS_LITERAL_STRING(READYSTATE_STR), @@ -1502,7 +1502,7 @@ nsXMLHttpRequest::DispatchProgressEvent(DOMEventTargetHelper* aTarget, init.mLoaded = aLoaded; init.mTotal = (aTotal == -1) ? 0 : aTotal; - nsRefPtr event = + RefPtr event = ProgressEvent::Constructor(aTarget, aType, init); event->SetTrusted(true); @@ -2875,7 +2875,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable& aBody) if (!IsSystemXHR()) { // Always create a nsCORSListenerProxy here even if it's // a same-origin request right now, since it could be redirected. - nsRefPtr corsListener = + RefPtr corsListener = new nsCORSListenerProxy(listener, mPrincipal, withCredentials); rv = corsListener->Init(mChannel, DataURIHandling::Allow); NS_ENSURE_SUCCESS(rv, rv); @@ -3372,7 +3372,7 @@ public: private: ~AsyncVerifyRedirectCallbackForwarder() {} - nsRefPtr mXHR; + RefPtr mXHR; }; NS_IMPL_CYCLE_COLLECTION(AsyncVerifyRedirectCallbackForwarder, mXHR) @@ -3420,7 +3420,7 @@ nsXMLHttpRequest::AsyncOnChannelRedirect(nsIChannel *aOldChannel, mNewRedirectChannel = aNewChannel; if (mChannelEventSink) { - nsRefPtr fwd = + RefPtr fwd = new AsyncVerifyRedirectCallbackForwarder(this); rv = mChannelEventSink->AsyncOnChannelRedirect(aOldChannel, @@ -3665,7 +3665,7 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) // ... user agents should prompt the end user for their username and password. if (!showPrompt) { - nsRefPtr prompt = new XMLHttpRequestAuthPrompt(); + RefPtr prompt = new XMLHttpRequestAuthPrompt(); if (!prompt) return NS_ERROR_OUT_OF_MEMORY; @@ -3726,7 +3726,7 @@ nsXMLHttpRequest::Upload() NS_IMETHODIMP nsXMLHttpRequest::GetUpload(nsIXMLHttpRequestUpload** aUpload) { - nsRefPtr upload = Upload(); + RefPtr upload = Upload(); upload.forget(aUpload); return NS_OK; } @@ -3815,7 +3815,7 @@ nsXMLHttpRequest::EnsureXPCOMifier() if (!mXPCOMifier) { mXPCOMifier = new nsXMLHttpRequestXPCOMifier(this); } - nsRefPtr newRef(mXPCOMifier); + RefPtr newRef(mXPCOMifier); return newRef.forget(); } @@ -4022,7 +4022,7 @@ ArrayBufferBuilder::mapToFileInPackage(const nsCString& aFile, nsresult rv; // Open Jar file to get related attributes of target file. - nsRefPtr zip = new nsZipArchive(); + RefPtr zip = new nsZipArchive(); rv = zip->OpenArchive(aJarFile); if (NS_FAILED(rv)) { return rv; diff --git a/dom/base/nsXMLHttpRequest.h b/dom/base/nsXMLHttpRequest.h index 6399f03479..293350154e 100644 --- a/dom/base/nsXMLHttpRequest.h +++ b/dom/base/nsXMLHttpRequest.h @@ -220,7 +220,7 @@ public: return nullptr; } - nsRefPtr req = new nsXMLHttpRequest(); + RefPtr req = new nsXMLHttpRequest(); req->Construct(principal->GetPrincipal(), global); req->InitParameters(aParams.mMozAnon, aParams.mMozSystem); return req.forget(); @@ -709,10 +709,10 @@ protected: // It is either a cached blob-response from the last call to GetResponse, // but is also explicitly set in OnStopRequest. - nsRefPtr mResponseBlob; + RefPtr mResponseBlob; // Non-null only when we are able to get a os-file representation of the // response, i.e. when loading from a file. - nsRefPtr mDOMBlob; + RefPtr mDOMBlob; // We stream data to mBlobSet when response type is "blob" or "moz-blob" // and mDOMBlob is null. nsAutoPtr mBlobSet; @@ -739,7 +739,7 @@ protected: uint32_t mState; - nsRefPtr mUpload; + RefPtr mUpload; int64_t mUploadTransferred; int64_t mUploadTotal; bool mUploadLengthComputable; @@ -873,7 +873,7 @@ public: NS_DECL_NSIINTERFACEREQUESTOR private: - nsRefPtr mXHR; + RefPtr mXHR; }; class nsXHRParseEndListener : public nsIDOMEventListener diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index c599904903..75b4cfaf06 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -950,7 +950,7 @@ GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor, { const nsID* iid = aIID->GetID(); - nsRefPtr result; + RefPtr result; aError = aRequestor->GetInterface(*iid, getter_AddRefs(result)); if (aError.Failed()) { return; @@ -2640,7 +2640,7 @@ ConvertExceptionToPromise(JSContext* cx, JS_ClearPendingException(cx); ErrorResult rv; - nsRefPtr promise = Promise::Reject(global, exn, rv); + RefPtr promise = Promise::Reject(global, exn, rv); if (rv.Failed()) { // We just give up. Make sure to not leak memory on the // ErrorResult, but then just put the original exception back. @@ -2767,7 +2767,7 @@ UnwrapArgImpl(JS::Handle src, return NS_OK; } - nsRefPtr wrappedJS; + RefPtr wrappedJS; nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, iid, getter_AddRefs(wrappedJS)); if (NS_FAILED(rv) || !wrappedJS) { return rv; diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 2ebb9affa6..c1ab4c921b 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -207,7 +207,7 @@ IsDOMObject(JSObject* obj) // Some callers don't want to set an exception when unwrapping fails // (for example, overload resolution uses unwrapping to tell what sort // of thing it's looking at). -// U must be something that a T* can be assigned to (e.g. T* or an nsRefPtr). +// U must be something that a T* can be assigned to (e.g. T* or an RefPtr). template MOZ_ALWAYS_INLINE nsresult UnwrapObject(JSObject* obj, U& value, prototypes::ID protoID, @@ -1501,7 +1501,7 @@ WrapObject(JSContext* cx, const nsCOMPtr& p, // Helper to make it possible to wrap directly out of an nsRefPtr template inline bool -WrapObject(JSContext* cx, const nsRefPtr& p, +WrapObject(JSContext* cx, const RefPtr& p, const nsIID* iid, JS::MutableHandle rval) { return WrapObject(cx, p.get(), iid, rval); @@ -1510,7 +1510,7 @@ WrapObject(JSContext* cx, const nsRefPtr& p, // Helper to make it possible to wrap directly out of an nsRefPtr template inline bool -WrapObject(JSContext* cx, const nsRefPtr& p, +WrapObject(JSContext* cx, const RefPtr& p, JS::MutableHandle rval) { return WrapObject(cx, p, nullptr, rval); @@ -2870,7 +2870,7 @@ private: }; JS::Rooted mReflector; - typename Conditional::value, nsRefPtr, OwnedNative>::Type mNative; + typename Conditional::value, RefPtr, OwnedNative>::Type mNative; }; template @@ -2879,7 +2879,7 @@ struct DeferredFinalizerImpl typedef typename Conditional::value, nsCOMPtr, typename Conditional::value, - nsRefPtr, + RefPtr, nsAutoPtr>::Type>::Type SmartPtr; typedef nsTArray SmartPtrArray; @@ -2893,7 +2893,7 @@ struct DeferredFinalizerImpl } template static inline void - AppendAndTake(nsTArray>& smartPtrArray, U* ptr) + AppendAndTake(nsTArray>& smartPtrArray, U* ptr) { smartPtrArray.AppendElement(dont_AddRef(ptr)); } @@ -3269,7 +3269,7 @@ WrappedJSToDictionary(nsISupports* aObject, T& aDictionary) template -inline nsRefPtr +inline RefPtr StrongOrRawPtr(already_AddRefed&& aPtr) { return aPtr.template downcast(); @@ -3292,7 +3292,7 @@ template struct StrongPtrForMember { typedef typename Conditional::value, - nsRefPtr, nsAutoPtr>::Type Type; + RefPtr, nsAutoPtr>::Type Type; }; inline diff --git a/dom/bindings/CallbackObject.cpp b/dom/bindings/CallbackObject.cpp index 57aef469e2..b405a66bd0 100644 --- a/dom/bindings/CallbackObject.cpp +++ b/dom/bindings/CallbackObject.cpp @@ -328,7 +328,7 @@ CallbackObjectHolderBase::ToXPCOMCallback(CallbackObject* aCallback, JS::Rooted callback(cx, aCallback->Callback()); JSAutoCompartment ac(cx, callback); - nsRefPtr wrappedJS; + RefPtr wrappedJS; nsresult rv = nsXPCWrappedJS::GetNewOrUsed(callback, aIID, getter_AddRefs(wrappedJS)); if (NS_FAILED(rv) || !wrappedJS) { diff --git a/dom/bindings/CallbackObject.h b/dom/bindings/CallbackObject.h index bb31d778fa..c5c43cae96 100644 --- a/dom/bindings/CallbackObject.h +++ b/dom/bindings/CallbackObject.h @@ -395,7 +395,7 @@ public: already_AddRefed ToXPCOMCallback() const { if (!HasWebIDLCallback()) { - nsRefPtr callback = GetXPCOMCallback(); + RefPtr callback = GetXPCOMCallback(); return callback.forget(); } @@ -410,7 +410,7 @@ public: already_AddRefed ToWebIDLCallback() const { if (HasWebIDLCallback()) { - nsRefPtr callback = GetWebIDLCallback(); + RefPtr callback = GetWebIDLCallback(); return callback.forget(); } return nullptr; diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 0e7294cee3..6a7fd82fda 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1097,7 +1097,7 @@ class CGHeaders(CGWrapper): # Dictionaries with interface members rely on the # actual class definition of that interface member # being visible in the binding header, because they - # store them in nsRefPtr and have inline + # store them in RefPtr and have inline # constructors/destructors. # # XXXbz maybe dictionaries with interface members @@ -1731,7 +1731,7 @@ class CGConstructNavigatorObject(CGAbstractMethod): ErrorResult rv; JS::Rooted v(aCx); { // Scope to make sure |result| goes out of scope while |v| is rooted - nsRefPtr result = ConstructNavigatorObjectHelper(aCx, global, rv); + RefPtr result = ConstructNavigatorObjectHelper(aCx, global, rv); rv.WouldReportJSException(); if (rv.Failed()) { ThrowMethodFailed(aCx, rv); @@ -3972,7 +3972,7 @@ class CastableObjectUnwrapper(): if descriptor.hasXPConnectImpls: self.substitution["codeOnFailure"] = string.Template( - "nsRefPtr<${type}> objPtr;\n" + + "RefPtr<${type}> objPtr;\n" + xpconnectUnwrap + "if (NS_FAILED(rv)) {\n" "${indentedCodeOnFailure}" @@ -4953,7 +4953,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, if descriptor.interface.isCallback(): name = descriptor.interface.identifier.name if type.nullable() or isCallbackReturnValue: - declType = CGGeneric("nsRefPtr<%s>" % name) + declType = CGGeneric("RefPtr<%s>" % name) else: declType = CGGeneric("OwningNonNull<%s>" % name) conversion = indent(CGCallbackTempRoot(name).define()) @@ -4973,7 +4973,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, # or an XPCOM interface. # Allow null pointers for nullable types and old-binding classes, and - # use an nsRefPtr or raw pointer for callback return values to make + # use an RefPtr or raw pointer for callback return values to make # them easier to return. argIsPointer = (type.nullable() or type.unroll().inner.isExternal() or isCallbackReturnValue) @@ -5006,7 +5006,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, holderType = None if argIsPointer: if forceOwningType: - declType = "nsRefPtr<" + typeName + ">" + declType = "RefPtr<" + typeName + ">" else: declType = typePtr else: @@ -5062,14 +5062,14 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, # Either external, or new-binding non-castable. We always have a # holder for these, because we don't actually know whether we have # to addref when unwrapping or not. So we just pass an - # getter_AddRefs(nsRefPtr) to XPConnect and if we'll need a release + # getter_AddRefs(RefPtr) to XPConnect and if we'll need a release # it'll put a non-null pointer in there. if forceOwningType: # Don't return a holderType in this case; our declName # will just own stuff. - templateBody += "nsRefPtr<" + typeName + "> ${holderName};\n" + templateBody += "RefPtr<" + typeName + "> ${holderName};\n" else: - holderType = "nsRefPtr<" + typeName + ">" + holderType = "RefPtr<" + typeName + ">" templateBody += ( "JS::Rooted source(cx, &${val}.toObject());\n" + "if (NS_FAILED(UnwrapArg<" + typeName + ">(source, getter_AddRefs(${holderName})))) {\n") @@ -5332,7 +5332,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, callback = type.unroll().callback name = callback.identifier.name if type.nullable(): - declType = CGGeneric("nsRefPtr<%s>" % name) + declType = CGGeneric("RefPtr<%s>" % name) else: declType = CGGeneric("OwningNonNull<%s>" % name) conversion = indent(CGCallbackTempRoot(name).define()) @@ -6488,7 +6488,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider, return result, None, None, None, conversion if returnType.isCallback(): name = returnType.unroll().callback.identifier.name - return CGGeneric("nsRefPtr<%s>" % name), None, None, None, None + return CGGeneric("RefPtr<%s>" % name), None, None, None, None if returnType.isAny(): if isMember: return CGGeneric("JS::Value"), None, None, None, None @@ -13176,7 +13176,7 @@ class CGNativeMember(ClassMethod): iface.identifier.name).prettyNativeType) if self.resultAlreadyAddRefed: if isMember: - holder = "nsRefPtr" + holder = "RefPtr" else: holder = "already_AddRefed" if memberReturnsNewObject(self.member) or isMember: @@ -13189,7 +13189,7 @@ class CGNativeMember(ClassMethod): else: result = CGWrapper(result, post="*") # Since we always force an owning type for callback return values, - # our ${declName} is an OwningNonNull or nsRefPtr. So we can just + # our ${declName} is an OwningNonNull or RefPtr. So we can just # .forget() to get our already_AddRefed. return result.define(), "nullptr", "return ${declName}.forget();\n" if type.isCallback(): @@ -13375,7 +13375,7 @@ class CGNativeMember(ClassMethod): iface.identifier.name == "Promise") if argIsPointer: if (optional or isMember) and forceOwningType: - typeDecl = "nsRefPtr<%s>" + typeDecl = "RefPtr<%s>" else: typeDecl = "%s*" else: @@ -13415,7 +13415,7 @@ class CGNativeMember(ClassMethod): forceOwningType = optional or isMember if type.nullable(): if forceOwningType: - declType = "nsRefPtr<%s>" + declType = "RefPtr<%s>" else: declType = "%s*" else: @@ -13982,7 +13982,7 @@ def genConstructorBody(descriptor, initCall=""): return nullptr; } // Build the C++ implementation. - nsRefPtr<${implClass}> impl = new ${implClass}(jsImplObj, globalHolder); + RefPtr<${implClass}> impl = new ${implClass}(jsImplObj, globalHolder); $*{initCall} return impl.forget(); """, @@ -14132,7 +14132,7 @@ class CGJSImplClass(CGBindingImplClass): $*{ccDecl} private: - nsRefPtr<${jsImplName}> mImpl; + RefPtr<${jsImplName}> mImpl; nsCOMPtr mParent; """, @@ -14240,7 +14240,7 @@ class CGJSImplClass(CGBindingImplClass): nsCOMPtr globalHolder = do_QueryInterface(global.GetAsSupports()); MOZ_ASSERT(globalHolder); JS::Rooted arg(cx, &args[1].toObject()); - nsRefPtr<${implName}> impl = new ${implName}(arg, globalHolder); + RefPtr<${implName}> impl = new ${implName}(arg, globalHolder); MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx)); return GetOrCreateDOMReflector(cx, impl, args.rval()); """, @@ -15970,7 +15970,7 @@ class CGEventMethod(CGNativeMember): # assignment because the underlying types may not match. # For example, the argument can be a # Sequence> while our - # member is an nsTArray>. So + # member is an nsTArray>. So # use AppendElements, which is actually a template on # the incoming type on nsTArray and does the right thing # for this case. @@ -16011,7 +16011,7 @@ class CGEventMethod(CGNativeMember): self.body = fill( """ - nsRefPtr<${nativeType}> e = new ${nativeType}(aOwner); + RefPtr<${nativeType}> e = new ${nativeType}(aOwner); bool trusted = e->Init(aOwner); e->InitEvent(${eventType}, ${eventInit}.mBubbles, ${eventInit}.mCancelable); $*{members} @@ -16214,7 +16214,7 @@ class CGEventClass(CGBindingImplClass): nativeType.pop(0) if nativeType[0] == "dom": nativeType.pop(0) - nativeType = CGWrapper(CGGeneric("::".join(nativeType)), pre="nsRefPtr<", post=">") + nativeType = CGWrapper(CGGeneric("::".join(nativeType)), pre="RefPtr<", post=">") elif type.isAny(): nativeType = CGGeneric("JS::Heap") elif type.isObject() or type.isSpiderMonkeyInterface(): diff --git a/dom/bindings/ErrorResult.h b/dom/bindings/ErrorResult.h index 5a09d71932..4bea3c86be 100644 --- a/dom/bindings/ErrorResult.h +++ b/dom/bindings/ErrorResult.h @@ -37,6 +37,16 @@ enum ErrNum { Err_Limit }; +// Debug-only compile-time table of the number of arguments of each error, for use in static_assert. +#if defined(DEBUG) && (defined(__clang__) || defined(__GNUC__)) +uint16_t constexpr ErrorFormatNumArgs[] = { +#define MSG_DEF(_name, _argc, _exn, _str) \ + _argc, +#include "mozilla/dom/Errors.msg" +#undef MSG_DEF +}; +#endif + uint16_t GetErrorArgCount(const ErrNum aErrorNumber); @@ -114,16 +124,16 @@ public: return rv; } - template - void ThrowTypeError(const dom::ErrNum errorNumber, Ts... messageArgs) + template + void ThrowTypeError(Ts... messageArgs) { - ThrowErrorWithMessage(errorNumber, NS_ERROR_TYPE_ERR, messageArgs...); + ThrowErrorWithMessage(NS_ERROR_TYPE_ERR, messageArgs...); } - template - void ThrowRangeError(const dom::ErrNum errorNumber, Ts... messageArgs) + template + void ThrowRangeError(Ts... messageArgs) { - ThrowErrorWithMessage(errorNumber, NS_ERROR_RANGE_ERR, messageArgs...); + ThrowErrorWithMessage(NS_ERROR_RANGE_ERR, messageArgs...); } void ReportErrorWithMessage(JSContext* cx); @@ -211,9 +221,14 @@ private: // and returns the arguments array from that Message. nsTArray& CreateErrorMessageHelper(const dom::ErrNum errorNumber, nsresult errorType); - template - void ThrowErrorWithMessage(const dom::ErrNum errorNumber, nsresult errorType, Ts... messageArgs) + template + void ThrowErrorWithMessage(nsresult errorType, Ts... messageArgs) { +#if defined(DEBUG) && (defined(__clang__) || defined(__GNUC__)) + static_assert(dom::ErrorFormatNumArgs[errorNumber] == sizeof...(messageArgs), + "Pass in the right number of arguments"); +#endif + if (IsJSException()) { // We have rooted our mJSException, and we don't have the info // needed to unroot here, so just bail. diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index 0fb5345197..c05d684bf5 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -68,6 +68,7 @@ MSG_DEF(MSG_FETCH_BODY_CONSUMED_ERROR, 0, JSEXN_TYPEERR, "Body has already been MSG_DEF(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR, 0, JSEXN_TYPEERR, "Response statusText may not contain newline or carriage return.") MSG_DEF(MSG_FETCH_FAILED, 0, JSEXN_TYPEERR, "NetworkError when attempting to fetch resource.") MSG_DEF(MSG_NO_BODY_ALLOWED_FOR_GET_AND_HEAD, 0, JSEXN_TYPEERR, "HEAD or GET Request cannot have a body.") +MSG_DEF(MSG_RESPONSE_NULL_STATUS_WITH_BODY, 0, JSEXN_TYPEERR, "Response body is given with a null body status.") MSG_DEF(MSG_DEFINE_NON_CONFIGURABLE_PROP_ON_WINDOW, 0, JSEXN_TYPEERR, "Not allowed to define a non-configurable property on the WindowProxy object") MSG_DEF(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR, 0, JSEXN_RANGEERR, "Invalid zoom and pan value.") MSG_DEF(MSG_INVALID_TRANSFORM_ANGLE_ERROR, 0, JSEXN_RANGEERR, "Invalid transform angle.") diff --git a/dom/bindings/Exceptions.cpp b/dom/bindings/Exceptions.cpp index e3575703f0..faa1faa98d 100644 --- a/dom/bindings/Exceptions.cpp +++ b/dom/bindings/Exceptions.cpp @@ -121,7 +121,7 @@ Throw(JSContext* aCx, nsresult aRv, const char* aMessage) } } - nsRefPtr finalException = CreateException(aCx, aRv, aMessage); + RefPtr finalException = CreateException(aCx, aRv, aMessage); MOZ_ASSERT(finalException); if (!ThrowExceptionObject(aCx, finalException)) { @@ -165,7 +165,7 @@ CreateException(JSContext* aCx, nsresult aRv, const char* aMessage) // If not, use the default. // aMessage can be null, so we can't use nsDependentCString on it. - nsRefPtr exception = + RefPtr exception = new Exception(nsCString(aMessage), aRv, EmptyCString(), nullptr, nullptr); return exception.forget(); diff --git a/dom/bindings/StructuredClone.cpp b/dom/bindings/StructuredClone.cpp index 64b17013e1..71b4f5c746 100644 --- a/dom/bindings/StructuredClone.cpp +++ b/dom/bindings/StructuredClone.cpp @@ -29,7 +29,7 @@ ReadStructuredCloneImageData(JSContext* aCx, JSStructuredCloneReader* aReader) JS::Rooted result(aCx); { // Construct the ImageData. - nsRefPtr imageData = new ImageData(width, height, + RefPtr imageData = new ImageData(width, height, dataArray.toObject()); // Wrap it in a JS::Value. if (!imageData->WrapObject(aCx, nullptr, &result)) { diff --git a/dom/bindings/ToJSValue.cpp b/dom/bindings/ToJSValue.cpp index 463835fad6..108a117993 100644 --- a/dom/bindings/ToJSValue.cpp +++ b/dom/bindings/ToJSValue.cpp @@ -43,7 +43,7 @@ ToJSValue(JSContext* aCx, nsresult aArgument, JS::MutableHandle aValue) { - nsRefPtr exception = CreateException(aCx, aArgument); + RefPtr exception = CreateException(aCx, aArgument); return ToJSValue(aCx, exception, aValue); } diff --git a/dom/bindings/ToJSValue.h b/dom/bindings/ToJSValue.h index b858910a1a..9ffde1e181 100644 --- a/dom/bindings/ToJSValue.h +++ b/dom/bindings/ToJSValue.h @@ -212,7 +212,7 @@ ToJSValue(JSContext* aCx, template MOZ_WARN_UNUSED_RESULT bool ToJSValue(JSContext* aCx, - const nsRefPtr& aArgument, + const RefPtr& aArgument, JS::MutableHandle aValue) { return ToJSValue(aCx, *aArgument.get(), aValue); diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index 57c6e149ba..eead656bb3 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -325,10 +325,10 @@ public: already_AddRefed ReceiveNonWrapperCacheInterface(); already_AddRefed ReceiveNullableNonWrapperCacheInterface(); - void ReceiveNonWrapperCacheInterfaceSequence(nsTArray >&); - void ReceiveNullableNonWrapperCacheInterfaceSequence(nsTArray >&); - void ReceiveNonWrapperCacheInterfaceNullableSequence(Nullable > >&); - void ReceiveNullableNonWrapperCacheInterfaceNullableSequence(Nullable > >&); + void ReceiveNonWrapperCacheInterfaceSequence(nsTArray >&); + void ReceiveNullableNonWrapperCacheInterfaceSequence(nsTArray >&); + void ReceiveNonWrapperCacheInterfaceNullableSequence(Nullable > >&); + void ReceiveNullableNonWrapperCacheInterfaceNullableSequence(Nullable > >&); already_AddRefed ReceiveOther(); already_AddRefed ReceiveNullableOther(); @@ -368,7 +368,7 @@ public: void SetNonNullCallbackInterface(TestCallbackInterface&); already_AddRefed GetNullableCallbackInterface(); void SetNullableCallbackInterface(TestCallbackInterface*); - void PassOptionalCallbackInterface(const Optional >&); + void PassOptionalCallbackInterface(const Optional >&); void PassOptionalNonNullCallbackInterface(const Optional >&); void PassOptionalCallbackInterfaceWithDefault(TestCallbackInterface*); @@ -390,28 +390,28 @@ public: void PassSequenceOfNullableInts(const Sequence >&); void PassOptionalSequenceOfNullableInts(const Optional > > &); void PassOptionalNullableSequenceOfNullableInts(const Optional > > > &); - void ReceiveCastableObjectSequence(nsTArray< nsRefPtr > &); - void ReceiveCallbackObjectSequence(nsTArray< nsRefPtr > &); - void ReceiveNullableCastableObjectSequence(nsTArray< nsRefPtr > &); - void ReceiveNullableCallbackObjectSequence(nsTArray< nsRefPtr > &); - void ReceiveCastableObjectNullableSequence(Nullable< nsTArray< nsRefPtr > >&); - void ReceiveNullableCastableObjectNullableSequence(Nullable< nsTArray< nsRefPtr > >&); - void ReceiveWeakCastableObjectSequence(nsTArray> &); - void ReceiveWeakNullableCastableObjectSequence(nsTArray> &); - void ReceiveWeakCastableObjectNullableSequence(Nullable< nsTArray> >&); - void ReceiveWeakNullableCastableObjectNullableSequence(Nullable< nsTArray> >&); + void ReceiveCastableObjectSequence(nsTArray< RefPtr > &); + void ReceiveCallbackObjectSequence(nsTArray< RefPtr > &); + void ReceiveNullableCastableObjectSequence(nsTArray< RefPtr > &); + void ReceiveNullableCallbackObjectSequence(nsTArray< RefPtr > &); + void ReceiveCastableObjectNullableSequence(Nullable< nsTArray< RefPtr > >&); + void ReceiveNullableCastableObjectNullableSequence(Nullable< nsTArray< RefPtr > >&); + void ReceiveWeakCastableObjectSequence(nsTArray> &); + void ReceiveWeakNullableCastableObjectSequence(nsTArray> &); + void ReceiveWeakCastableObjectNullableSequence(Nullable< nsTArray> >&); + void ReceiveWeakNullableCastableObjectNullableSequence(Nullable< nsTArray> >&); void PassCastableObjectSequence(const Sequence< OwningNonNull >&); - void PassNullableCastableObjectSequence(const Sequence< nsRefPtr > &); + void PassNullableCastableObjectSequence(const Sequence< RefPtr > &); void PassCastableObjectNullableSequence(const Nullable< Sequence< OwningNonNull > >&); - void PassNullableCastableObjectNullableSequence(const Nullable< Sequence< nsRefPtr > >&); + void PassNullableCastableObjectNullableSequence(const Nullable< Sequence< RefPtr > >&); void PassOptionalSequence(const Optional >&); void PassOptionalSequenceWithDefaultValue(const Sequence &); void PassOptionalNullableSequence(const Optional > >&); void PassOptionalNullableSequenceWithDefaultValue(const Nullable< Sequence >&); void PassOptionalNullableSequenceWithDefaultValue2(const Nullable< Sequence >&); void PassOptionalObjectSequence(const Optional > >&); - void PassExternalInterfaceSequence(const Sequence >&); - void PassNullableExternalInterfaceSequence(const Sequence >&); + void PassExternalInterfaceSequence(const Sequence >&); + void PassNullableExternalInterfaceSequence(const Sequence >&); void ReceiveStringSequence(nsTArray&); void PassStringSequence(const Sequence&); @@ -438,15 +438,15 @@ public: void PassOptionalMozMapOfNullableInts(const Optional > > &); void PassOptionalNullableMozMapOfNullableInts(const Optional > > > &); void PassCastableObjectMozMap(const MozMap< OwningNonNull >&); - void PassNullableCastableObjectMozMap(const MozMap< nsRefPtr > &); + void PassNullableCastableObjectMozMap(const MozMap< RefPtr > &); void PassCastableObjectNullableMozMap(const Nullable< MozMap< OwningNonNull > >&); - void PassNullableCastableObjectNullableMozMap(const Nullable< MozMap< nsRefPtr > >&); + void PassNullableCastableObjectNullableMozMap(const Nullable< MozMap< RefPtr > >&); void PassOptionalMozMap(const Optional >&); void PassOptionalNullableMozMap(const Optional > >&); void PassOptionalNullableMozMapWithDefaultValue(const Nullable< MozMap >&); void PassOptionalObjectMozMap(const Optional > >&); - void PassExternalInterfaceMozMap(const MozMap >&); - void PassNullableExternalInterfaceMozMap(const MozMap >&); + void PassExternalInterfaceMozMap(const MozMap >&); + void PassNullableExternalInterfaceMozMap(const MozMap >&); void PassStringMozMap(const MozMap&); void PassByteStringMozMap(const MozMap&); void PassMozMapOfMozMaps(const MozMap< MozMap >&); @@ -528,12 +528,12 @@ public: void PassCallback(TestCallback&); void PassNullableCallback(TestCallback*); void PassOptionalCallback(const Optional >&); - void PassOptionalNullableCallback(const Optional >&); + void PassOptionalNullableCallback(const Optional >&); void PassOptionalNullableCallbackWithDefaultValue(TestCallback*); already_AddRefed ReceiveCallback(); already_AddRefed ReceiveNullableCallback(); void PassNullableTreatAsNullCallback(TestTreatAsNullCallback*); - void PassOptionalNullableTreatAsNullCallback(const Optional >&); + void PassOptionalNullableTreatAsNullCallback(const Optional >&); void PassOptionalNullableTreatAsNullCallbackWithDefaultValue(TestTreatAsNullCallback*); void SetTreatAsNullCallback(TestTreatAsNullCallback&); already_AddRefed TreatAsNullCallback(); @@ -712,11 +712,11 @@ public: void PassPromise(Promise&); void PassNullablePromise(Promise*); void PassOptionalPromise(const Optional>&); - void PassOptionalNullablePromise(const Optional>&); + void PassOptionalNullablePromise(const Optional>&); void PassOptionalNullablePromiseWithDefaultValue(Promise*); void PassPromiseSequence(const Sequence>&); - void PassPromiseMozMap(const MozMap>&); - void PassNullablePromiseSequence(const Sequence> &); + void PassPromiseMozMap(const MozMap>&); + void PassNullablePromiseSequence(const Sequence> &); Promise* ReceivePromise(); already_AddRefed ReceiveAddrefedPromise(); @@ -1036,7 +1036,7 @@ private: void PassOptionalNullableArrayBuffer(Optional&) = delete; void PassOptionalEnum(Optional&) = delete; void PassOptionalCallback(JSContext*, Optional >&) = delete; - void PassOptionalNullableCallback(JSContext*, Optional >&) = delete; + void PassOptionalNullableCallback(JSContext*, Optional >&) = delete; void PassOptionalAny(Optional >&) = delete; // And test that string stuff is always const diff --git a/dom/bindings/test/TestInterfaceMaplike.cpp b/dom/bindings/test/TestInterfaceMaplike.cpp index 934867c1aa..04d2e2fdb9 100644 --- a/dom/bindings/test/TestInterfaceMaplike.cpp +++ b/dom/bindings/test/TestInterfaceMaplike.cpp @@ -36,7 +36,7 @@ TestInterfaceMaplike::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr r = new TestInterfaceMaplike(window); + RefPtr r = new TestInterfaceMaplike(window); return r.forget(); } diff --git a/dom/bindings/test/TestInterfaceMaplikeObject.cpp b/dom/bindings/test/TestInterfaceMaplikeObject.cpp index 564c99f9e4..49d0537232 100644 --- a/dom/bindings/test/TestInterfaceMaplikeObject.cpp +++ b/dom/bindings/test/TestInterfaceMaplikeObject.cpp @@ -37,7 +37,7 @@ TestInterfaceMaplikeObject::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr r = + RefPtr r = new TestInterfaceMaplikeObject(window); return r.forget(); } @@ -58,7 +58,7 @@ TestInterfaceMaplikeObject::GetParentObject() const void TestInterfaceMaplikeObject::SetInternal(const nsAString& aKey) { - nsRefPtr p(new TestInterfaceMaplike(mParent)); + RefPtr p(new TestInterfaceMaplike(mParent)); ErrorResult rv; TestInterfaceMaplikeObjectBinding::MaplikeHelpers::Set(this, aKey, *p, rv); } diff --git a/dom/bindings/test/TestInterfaceSetlike.cpp b/dom/bindings/test/TestInterfaceSetlike.cpp index abd3ab3fa1..043b1f38a2 100644 --- a/dom/bindings/test/TestInterfaceSetlike.cpp +++ b/dom/bindings/test/TestInterfaceSetlike.cpp @@ -37,7 +37,7 @@ TestInterfaceSetlike::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr r = new TestInterfaceSetlike(nullptr, window); + RefPtr r = new TestInterfaceSetlike(nullptr, window); return r.forget(); } diff --git a/dom/bindings/test/TestInterfaceSetlikeNode.cpp b/dom/bindings/test/TestInterfaceSetlikeNode.cpp index d57a883339..d3e9bd514f 100644 --- a/dom/bindings/test/TestInterfaceSetlikeNode.cpp +++ b/dom/bindings/test/TestInterfaceSetlikeNode.cpp @@ -37,7 +37,7 @@ TestInterfaceSetlikeNode::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr r = new TestInterfaceSetlikeNode(nullptr, window); + RefPtr r = new TestInterfaceSetlikeNode(nullptr, window); return r.forget(); } diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp index ba04f3ae12..9ce0e676ed 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp @@ -111,7 +111,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothA2dpManager::OnErrorProfileResultHandlerRunnable final @@ -133,7 +133,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; nsresult mRv; }; @@ -151,7 +151,7 @@ BluetoothA2dpManager::InitA2dpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!btInf)) { // If there's no HFP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -163,7 +163,7 @@ BluetoothA2dpManager::InitA2dpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!sBtA2dpInterface)) { // If there's no HFP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -257,7 +257,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothA2dpManager::CleanupA2dpResultHandlerRunnable final @@ -279,7 +279,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -293,7 +293,7 @@ BluetoothA2dpManager::DeinitA2dpInterface(BluetoothProfileResultHandler* aRes) } else if (aRes) { // We dispatch a runnable here to make the profile resource handler // behave as if A2DP was initialized. - nsRefPtr r = new CleanupA2dpResultHandlerRunnable(aRes); + RefPtr r = new CleanupA2dpResultHandlerRunnable(aRes); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch cleanup-result-handler runnable"); } @@ -436,7 +436,7 @@ BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -451,7 +451,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); Reset(); diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h index bca17e5467..641ede8069 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h @@ -65,7 +65,7 @@ private: const nsAString& aBdAddr) override; nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; // A2DP data member bool mA2dpConnected; diff --git a/dom/bluetooth/bluedroid/BluetoothAvrcpManager.cpp b/dom/bluetooth/bluedroid/BluetoothAvrcpManager.cpp index 2f8ffa4a8d..74d87d6e0b 100644 --- a/dom/bluetooth/bluedroid/BluetoothAvrcpManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothAvrcpManager.cpp @@ -151,7 +151,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothAvrcpManager::OnErrorProfileResultHandlerRunnable final @@ -173,7 +173,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; nsresult mRv; }; @@ -188,7 +188,7 @@ BluetoothAvrcpManager::InitAvrcpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!btInf)) { // If there's no HFP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -200,7 +200,7 @@ BluetoothAvrcpManager::InitAvrcpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!sBtAvrcpInterface)) { // If there's no AVRCP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -282,7 +282,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothAvrcpManager::CleanupAvrcpResultHandlerRunnable final @@ -309,7 +309,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -323,7 +323,7 @@ BluetoothAvrcpManager::DeinitAvrcpInterface(BluetoothProfileResultHandler* aRes) } else if (aRes) { // We dispatch a runnable here to make the profile resource handler // behave as if A2DP was initialized. - nsRefPtr r = new CleanupAvrcpResultHandlerRunnable(aRes); + RefPtr r = new CleanupAvrcpResultHandlerRunnable(aRes); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch cleanup-result-handler runnable"); } @@ -375,7 +375,7 @@ BluetoothAvrcpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -390,7 +390,7 @@ BluetoothAvrcpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); Reset(); diff --git a/dom/bluetooth/bluedroid/BluetoothAvrcpManager.h b/dom/bluetooth/bluedroid/BluetoothAvrcpManager.h index 59128d51f1..862aaa31f0 100644 --- a/dom/bluetooth/bluedroid/BluetoothAvrcpManager.h +++ b/dom/bluetooth/bluedroid/BluetoothAvrcpManager.h @@ -108,7 +108,7 @@ private: void PassthroughCmdNotification(int aId, int aKeyState) override; nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; bool mAvrcpConnected; nsString mAlbum; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp index 21f0060c4b..454de29383 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp @@ -145,7 +145,7 @@ BluetoothDaemonA2dpModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!res) { @@ -362,7 +362,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -427,7 +427,7 @@ public: private: BluetoothDaemonA2dpModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp index cf5cea195f..63e479a3c4 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp @@ -445,7 +445,7 @@ BluetoothDaemonAvrcpModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!res) { @@ -857,7 +857,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -926,7 +926,7 @@ public: private: BluetoothDaemonAvrcpModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp index 542c30703f..430f051362 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp @@ -772,7 +772,7 @@ BluetoothDaemonCoreModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!res) { diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp index ce77fd9838..01a57a5300 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp @@ -1480,7 +1480,7 @@ BluetoothDaemonGattModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!res) { @@ -2225,7 +2225,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -2292,7 +2292,7 @@ public: private: BluetoothDaemonGattModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp index d9e866a35a..f7df8873e8 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp @@ -714,7 +714,7 @@ BluetoothDaemonHandsfreeModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!res) { @@ -1480,7 +1480,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -1549,7 +1549,7 @@ public: private: BluetoothDaemonHandsfreeModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp index 2b8d6743c2..ba960b7c1e 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp @@ -141,7 +141,7 @@ private: DaemonSocketResultHandler* aRes); DaemonSocket* mConnection; - nsTArray> mResQ; + nsTArray> mResQ; }; BluetoothDaemonProtocol::BluetoothDaemonProtocol() @@ -279,7 +279,7 @@ BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU) return; } - nsRefPtr res = FetchResultHandler(header); + RefPtr res = FetchResultHandler(header); (this->*(HandleSvc[header.mService]))(header, aPDU, res); } @@ -302,7 +302,7 @@ BluetoothDaemonProtocol::FetchResultHandler( return nullptr; // Ignore notifications } - nsRefPtr userData = mResQ.ElementAt(0); + RefPtr userData = mResQ.ElementAt(0); mResQ.RemoveElementAt(0); return userData.forget(); @@ -432,7 +432,7 @@ public: private: BluetoothDaemonInterface* mInterface; - nsRefPtr mRes; + RefPtr mRes; bool mRegisteredSocketModule; }; @@ -996,7 +996,7 @@ BluetoothDaemonInterface::OnConnectSuccess(int aIndex) } break; case NTF_CHANNEL: { - nsRefPtr res = mResultHandlerQ.ElementAt(0); + RefPtr res = mResultHandlerQ.ElementAt(0); mResultHandlerQ.RemoveElementAt(0); // Init, step 4: Register Core module @@ -1028,7 +1028,7 @@ BluetoothDaemonInterface::OnConnectError(int aIndex) case LISTEN_SOCKET: if (!mResultHandlerQ.IsEmpty()) { // Signal error to caller - nsRefPtr res = mResultHandlerQ.ElementAt(0); + RefPtr res = mResultHandlerQ.ElementAt(0); mResultHandlerQ.RemoveElementAt(0); if (res) { @@ -1071,7 +1071,7 @@ BluetoothDaemonInterface::OnDisconnect(int aIndex) break; case LISTEN_SOCKET: if (!mResultHandlerQ.IsEmpty()) { - nsRefPtr res = mResultHandlerQ.ElementAt(0); + RefPtr res = mResultHandlerQ.ElementAt(0); mResultHandlerQ.RemoveElementAt(0); // Cleanup, step 5: Signal success to caller if (res) { diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h index ff76bc963a..aa42d70c63 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h @@ -153,12 +153,12 @@ private: void DispatchError(BluetoothResultHandler* aRes, nsresult aRv); nsCString mListenSocketName; - nsRefPtr mListenSocket; - nsRefPtr mCmdChannel; - nsRefPtr mNtfChannel; + RefPtr mListenSocket; + RefPtr mCmdChannel; + RefPtr mNtfChannel; nsAutoPtr mProtocol; - nsTArray > mResultHandlerQ; + nsTArray > mResultHandlerQ; nsAutoPtr mSocketInterface; nsAutoPtr mHandsfreeInterface; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp index c3e2196c10..e15de97703 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp @@ -39,7 +39,7 @@ BluetoothDaemonSetupModule::HandleSvc(const DaemonSocketPDUHeader& aHeader, return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!aRes) { diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp index db315474a6..5adab62011 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp @@ -180,7 +180,7 @@ BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader, return; } - nsRefPtr res = + RefPtr res = static_cast(aRes); if (!res) { diff --git a/dom/bluetooth/bluedroid/BluetoothGattManager.cpp b/dom/bluetooth/bluedroid/BluetoothGattManager.cpp index 29b7356353..21359e5733 100644 --- a/dom/bluetooth/bluedroid/BluetoothGattManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothGattManager.cpp @@ -39,13 +39,13 @@ namespace { bool BluetoothGattManager::mInShutdown = false; -static StaticAutoPtr > > sClients; -static StaticAutoPtr > > sServers; +static StaticAutoPtr > > sClients; +static StaticAutoPtr > > sServers; struct BluetoothGattClientReadCharState { bool mAuthRetry; - nsRefPtr mRunnable; + RefPtr mRunnable; void Assign(bool aAuthRetry, BluetoothReplyRunnable* aRunnable) @@ -66,7 +66,7 @@ struct BluetoothGattClientWriteCharState BluetoothGattWriteType mWriteType; nsTArray mWriteValue; bool mAuthRetry; - nsRefPtr mRunnable; + RefPtr mRunnable; void Assign(BluetoothGattWriteType aWriteType, const nsTArray& aWriteValue, @@ -91,7 +91,7 @@ struct BluetoothGattClientWriteCharState struct BluetoothGattClientReadDescState { bool mAuthRetry; - nsRefPtr mRunnable; + RefPtr mRunnable; void Assign(bool aAuthRetry, BluetoothReplyRunnable* aRunnable) @@ -111,7 +111,7 @@ struct BluetoothGattClientWriteDescState { nsTArray mWriteValue; bool mAuthRetry; - nsRefPtr mRunnable; + RefPtr mRunnable; void Assign(const nsTArray& aWriteValue, bool aAuthRetry, @@ -176,14 +176,14 @@ public: nsString mDeviceAddr; int mClientIf; int mConnId; - nsRefPtr mStartLeScanRunnable; - nsRefPtr mConnectRunnable; - nsRefPtr mDisconnectRunnable; - nsRefPtr mDiscoverRunnable; - nsRefPtr mReadRemoteRssiRunnable; - nsRefPtr mRegisterNotificationsRunnable; - nsRefPtr mDeregisterNotificationsRunnable; - nsRefPtr mUnregisterClientRunnable; + RefPtr mStartLeScanRunnable; + RefPtr mConnectRunnable; + RefPtr mDisconnectRunnable; + RefPtr mDiscoverRunnable; + RefPtr mReadRemoteRssiRunnable; + RefPtr mRegisterNotificationsRunnable; + RefPtr mDeregisterNotificationsRunnable; + RefPtr mUnregisterClientRunnable; BluetoothGattClientReadCharState mReadCharacteristicState; BluetoothGattClientWriteCharState mWriteCharacteristicState; @@ -219,9 +219,9 @@ public: nsString mAppUuid; int mServerIf; - nsRefPtr mConnectPeripheralRunnable; - nsRefPtr mDisconnectPeripheralRunnable; - nsRefPtr mUnregisterServerRunnable; + RefPtr mConnectPeripheralRunnable; + RefPtr mDisconnectPeripheralRunnable; + RefPtr mUnregisterServerRunnable; // Map connection id from device address nsDataHashtable mConnectionMap; @@ -235,13 +235,13 @@ NS_IMPL_ISUPPORTS0(BluetoothGattServer) class UuidComparator { public: - bool Equals(const nsRefPtr& aClient, + bool Equals(const RefPtr& aClient, const nsAString& aAppUuid) const { return aClient->mAppUuid.Equals(aAppUuid); } - bool Equals(const nsRefPtr& aServer, + bool Equals(const RefPtr& aServer, const nsAString& aAppUuid) const { return aServer->mAppUuid.Equals(aAppUuid); @@ -251,13 +251,13 @@ public: class InterfaceIdComparator { public: - bool Equals(const nsRefPtr& aClient, + bool Equals(const RefPtr& aClient, int aClientIf) const { return aClient->mClientIf == aClientIf; } - bool Equals(const nsRefPtr& aServer, + bool Equals(const RefPtr& aServer, int aServerIf) const { return aServer->mServerIf == aServerIf; @@ -267,7 +267,7 @@ public: class ConnIdComparator { public: - bool Equals(const nsRefPtr& aClient, + bool Equals(const RefPtr& aClient, int aConnId) const { return aClient->mConnId == aConnId; @@ -318,7 +318,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -344,11 +344,11 @@ BluetoothGattManager::InitGattInterface(BluetoothProfileResultHandler* aRes) } if (!sClients) { - sClients = new nsTArray >; + sClients = new nsTArray >; } if (!sServers) { - sServers = new nsTArray >; + sServers = new nsTArray >; } BluetoothGattManager* gattManager = BluetoothGattManager::Get(); @@ -385,7 +385,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothGattManager::CleanupResultHandlerRunnable final @@ -405,7 +405,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -419,7 +419,7 @@ BluetoothGattManager::DeinitGattInterface(BluetoothProfileResultHandler* aRes) } else if (aRes) { // We dispatch a runnable here to make the profile resource handler // behave as if GATT was initialized. - nsRefPtr r = new CleanupResultHandlerRunnable(aRes); + RefPtr r = new CleanupResultHandlerRunnable(aRes); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch cleanup-result-handler runnable"); } @@ -461,7 +461,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; class BluetoothGattManager::UnregisterClientResultHandler final @@ -504,7 +504,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -523,7 +523,7 @@ BluetoothGattManager::UnregisterClient(int aClientIf, return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); client->mUnregisterClientRunnable = aRunnable; sBluetoothGattInterface->UnregisterClient( @@ -559,7 +559,7 @@ public: BluetoothGattManager* gattManager = BluetoothGattManager::Get(); NS_ENSURE_TRUE_VOID(gattManager); - nsRefPtr result = + RefPtr result = new BluetoothVoidReplyRunnable(nullptr); gattManager->UnregisterClient(mClient->mClientIf, result); } @@ -569,7 +569,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; class BluetoothGattManager::StopLeScanResultHandler final @@ -589,7 +589,7 @@ public: BluetoothGattManager* gattManager = BluetoothGattManager::Get(); NS_ENSURE_TRUE_VOID(gattManager); - nsRefPtr result = + RefPtr result = new BluetoothVoidReplyRunnable(nullptr); gattManager->UnregisterClient(mClientIf, result); } @@ -603,7 +603,7 @@ public: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; int mClientIf; }; @@ -630,7 +630,7 @@ BluetoothGattManager::StartLeScan(const nsTArray& aServiceUuids, index = sClients->Length(); sClients->AppendElement(new BluetoothGattClient(appUuidStr, EmptyString())); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); client->mStartLeScanRunnable = aRunnable; BluetoothUuid appUuid; @@ -657,7 +657,7 @@ BluetoothGattManager::StopLeScan(const nsAString& aScanUuid, return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); sBluetoothGattInterface->Scan( client->mClientIf, false /* Stop */, @@ -696,7 +696,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -715,7 +715,7 @@ BluetoothGattManager::Connect(const nsAString& aAppUuid, sClients->AppendElement(new BluetoothGattClient(aAppUuid, aDeviceAddr)); } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); client->mConnectRunnable = aRunnable; if (client->mClientIf > 0) { @@ -766,7 +766,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -785,7 +785,7 @@ BluetoothGattManager::Disconnect(const nsAString& aAppUuid, return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); client->mDisconnectRunnable = aRunnable; sBluetoothGattInterface->Disconnect( @@ -814,7 +814,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -832,7 +832,7 @@ BluetoothGattManager::Discover(const nsAString& aAppUuid, return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mConnId > 0); MOZ_ASSERT(!client->mDiscoverRunnable); @@ -884,7 +884,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -904,7 +904,7 @@ BluetoothGattManager::ReadRemoteRssi(int aClientIf, return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); client->mReadRemoteRssiRunnable = aRunnable; sBluetoothGattInterface->ReadRemoteRssi( @@ -952,7 +952,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -971,7 +971,7 @@ BluetoothGattManager::RegisterNotifications( return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); // Reject the request if there is an ongoing request or client is already // disconnected @@ -1028,7 +1028,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -1047,7 +1047,7 @@ BluetoothGattManager::DeregisterNotifications( return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); // Reject the request if there is an ongoing request if (client->mDeregisterNotificationsRunnable) { @@ -1079,7 +1079,7 @@ public: ": %d", (int)aStatus); MOZ_ASSERT(mClient->mReadCharacteristicState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = mClient->mReadCharacteristicState.mRunnable; mClient->mReadCharacteristicState.Reset(); @@ -1089,7 +1089,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -1110,7 +1110,7 @@ BluetoothGattManager::ReadCharacteristicValue( return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); /** * Reject subsequent reading requests to follow ATT sequential protocol that @@ -1157,7 +1157,7 @@ public: ": %d", (int)aStatus); MOZ_ASSERT(mClient->mWriteCharacteristicState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = mClient->mWriteCharacteristicState.mRunnable; mClient->mWriteCharacteristicState.Reset(); @@ -1167,7 +1167,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -1190,7 +1190,7 @@ BluetoothGattManager::WriteCharacteristicValue( return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); /** * Reject subsequent writing requests to follow ATT sequential protocol that @@ -1240,7 +1240,7 @@ public: (int)aStatus); MOZ_ASSERT(mClient->mReadDescriptorState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = mClient->mReadDescriptorState.mRunnable; mClient->mReadDescriptorState.Reset(); @@ -1250,7 +1250,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -1272,7 +1272,7 @@ BluetoothGattManager::ReadDescriptorValue( return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); /** * Reject subsequent reading requests to follow ATT sequential protocol that @@ -1320,7 +1320,7 @@ public: (int)aStatus); MOZ_ASSERT(mClient->mWriteDescriptorState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = mClient->mWriteDescriptorState.mRunnable; mClient->mWriteDescriptorState.Reset(); @@ -1330,7 +1330,7 @@ public: } private: - nsRefPtr mClient; + RefPtr mClient; }; void @@ -1353,7 +1353,7 @@ BluetoothGattManager::WriteDescriptorValue( return; } - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); /** * Reject subsequent writing requests to follow ATT sequential protocol that @@ -1416,7 +1416,7 @@ public: } private: - nsRefPtr mServer; + RefPtr mServer; }; class BluetoothGattManager::ConnectPeripheralResultHandler final @@ -1448,7 +1448,7 @@ public: } private: - nsRefPtr mServer; + RefPtr mServer; nsString mDeviceAddr; }; @@ -1468,7 +1468,7 @@ BluetoothGattManager::ConnectPeripheral( index = sServers->Length(); sServers->AppendElement(new BluetoothGattServer(aAppUuid)); } - nsRefPtr server = (*sServers)[index]; + RefPtr server = (*sServers)[index]; /** * Early resolve or reject the request based on the current status before @@ -1541,7 +1541,7 @@ public: } private: - nsRefPtr mServer; + RefPtr mServer; }; void @@ -1560,7 +1560,7 @@ BluetoothGattManager::DisconnectPeripheral( DispatchReplyError(aRunnable, STATUS_PARM_INVALID); return; } - nsRefPtr server = (*sServers)[index]; + RefPtr server = (*sServers)[index]; if (NS_WARN_IF(server->mServerIf <= 0)) { DispatchReplyError(aRunnable, @@ -1633,7 +1633,7 @@ public: } private: - nsRefPtr mServer; + RefPtr mServer; }; void @@ -1651,7 +1651,7 @@ BluetoothGattManager::UnregisterServer(int aServerIf, return; } - nsRefPtr server = (*sServers)[index]; + RefPtr server = (*sServers)[index]; server->mUnregisterServerRunnable = aRunnable; sBluetoothGattInterface->UnregisterServer( @@ -1675,7 +1675,7 @@ BluetoothGattManager::RegisterClientNotification(BluetoothGattStatus aStatus, size_t index = sClients->IndexOf(uuid, 0 /* Start */, UuidComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); BluetoothService* bs = BluetoothService::Get(); NS_ENSURE_TRUE_VOID(bs); @@ -1806,7 +1806,7 @@ BluetoothGattManager::ConnectNotification(int aConnId, InterfaceIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); if (aStatus != GATT_STATUS_SUCCESS) { BT_LOGD("Connect failed: clientIf = %d, connId = %d, status = %d", @@ -1858,7 +1858,7 @@ BluetoothGattManager::DisconnectNotification(int aConnId, InterfaceIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); if (aStatus != GATT_STATUS_SUCCESS) { // Notify BluetoothGatt that the client remains connected @@ -1905,7 +1905,7 @@ BluetoothGattManager::SearchCompleteNotification(int aConnId, ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mDiscoverRunnable); if (aStatus != GATT_STATUS_SUCCESS) { @@ -1963,7 +1963,7 @@ BluetoothGattManager::GetCharacteristicNotification( ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mDiscoverRunnable); if (aStatus == GATT_STATUS_SUCCESS) { @@ -2017,7 +2017,7 @@ BluetoothGattManager::GetDescriptorNotification( ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mDiscoverRunnable); if (aStatus == GATT_STATUS_SUCCESS) { @@ -2064,7 +2064,7 @@ BluetoothGattManager::GetIncludedServiceNotification( ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mDiscoverRunnable); if (aStatus == GATT_STATUS_SUCCESS) { @@ -2137,7 +2137,7 @@ BluetoothGattManager::NotifyNotification( size_t index = sClients->IndexOf(aConnId, 0 /* Start */, ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); // Notify BluetoothGattCharacteristic to update characteristic value nsString path; @@ -2175,10 +2175,10 @@ BluetoothGattManager::ReadCharacteristicNotification( size_t index = sClients->IndexOf(aConnId, 0 /* Start */, ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mReadCharacteristicState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = client->mReadCharacteristicState.mRunnable; if (aStatus == GATT_STATUS_SUCCESS) { @@ -2236,10 +2236,10 @@ BluetoothGattManager::WriteCharacteristicNotification( size_t index = sClients->IndexOf(aConnId, 0 /* Start */, ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mWriteCharacteristicState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = client->mWriteCharacteristicState.mRunnable; if (aStatus == GATT_STATUS_SUCCESS) { @@ -2280,10 +2280,10 @@ BluetoothGattManager::ReadDescriptorNotification( size_t index = sClients->IndexOf(aConnId, 0 /* Start */, ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mReadDescriptorState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = client->mReadDescriptorState.mRunnable; if (aStatus == GATT_STATUS_SUCCESS) { @@ -2331,10 +2331,10 @@ BluetoothGattManager::WriteDescriptorNotification( size_t index = sClients->IndexOf(aConnId, 0 /* Start */, ConnIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); MOZ_ASSERT(client->mWriteDescriptorState.mRunnable); - nsRefPtr runnable = + RefPtr runnable = client->mWriteDescriptorState.mRunnable; if (aStatus == GATT_STATUS_SUCCESS) { @@ -2383,7 +2383,7 @@ BluetoothGattManager::ReadRemoteRssiNotification(int aClientIf, InterfaceIdComparator()); NS_ENSURE_TRUE_VOID(index != sClients->NoIndex); - nsRefPtr client = sClients->ElementAt(index); + RefPtr client = sClients->ElementAt(index); if (aStatus != GATT_STATUS_SUCCESS) { // operation failed BT_LOGD("ReadRemoteRssi failed: clientIf = %d, bdAddr = %s, rssi = %d, " \ @@ -2426,7 +2426,7 @@ BluetoothGattManager::RegisterServerNotification(BluetoothGattStatus aStatus, size_t index = sServers->IndexOf(uuid, 0 /* Start */, UuidComparator()); NS_ENSURE_TRUE_VOID(index != sServers->NoIndex); - nsRefPtr server = (*sServers)[index]; + RefPtr server = (*sServers)[index]; BluetoothService* bs = BluetoothService::Get(); NS_ENSURE_TRUE_VOID(bs); @@ -2479,7 +2479,7 @@ BluetoothGattManager::ConnectionNotification(int aConnId, InterfaceIdComparator()); NS_ENSURE_TRUE_VOID(index != sServers->NoIndex); - nsRefPtr server = (*sServers)[index]; + RefPtr server = (*sServers)[index]; // Update the connection map based on the connection status if (aConnected) { diff --git a/dom/bluetooth/bluedroid/BluetoothMapFolder.cpp b/dom/bluetooth/bluedroid/BluetoothMapFolder.cpp index 95d77e3e68..acf0a7894c 100644 --- a/dom/bluetooth/bluedroid/BluetoothMapFolder.cpp +++ b/dom/bluetooth/bluedroid/BluetoothMapFolder.cpp @@ -21,7 +21,7 @@ BluetoothMapFolder::BluetoothMapFolder(const nsAString& aFolderName, BluetoothMapFolder* BluetoothMapFolder::AddSubFolder(const nsAString& aFolderName) { - nsRefPtr folder = new BluetoothMapFolder(aFolderName, + RefPtr folder = new BluetoothMapFolder(aFolderName, this); mSubFolders.Put(nsString(aFolderName), folder); diff --git a/dom/bluetooth/bluedroid/BluetoothMapFolder.h b/dom/bluetooth/bluedroid/BluetoothMapFolder.h index 8df70e3816..bee1c1c235 100644 --- a/dom/bluetooth/bluedroid/BluetoothMapFolder.h +++ b/dom/bluetooth/bluedroid/BluetoothMapFolder.h @@ -33,7 +33,7 @@ public: private: ~BluetoothMapFolder(); nsString mName; - nsRefPtr mParent; + RefPtr mParent; nsRefPtrHashtable mSubFolders; }; diff --git a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h index e07d02581a..74dab9224b 100644 --- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h +++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.h @@ -117,7 +117,7 @@ private: * Current virtual folder path */ BluetoothMapFolder* mCurrentFolder; - nsRefPtr mRootFolder; + RefPtr mRootFolder; /* * Record the last command @@ -134,15 +134,15 @@ private: // If a connection has been established, mMasSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mMasSocket is non-null, mServerSocket must be null (and vice versa). - nsRefPtr mMasSocket; + RefPtr mMasSocket; // Server socket. Once an inbound connection is established, it will hand // over the ownership to mMasSocket, and get a new server socket while Listen() // is called. - nsRefPtr mMasServerSocket; + RefPtr mMasServerSocket; // Message notification service client socket - nsRefPtr mMnsSocket; + RefPtr mMnsSocket; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp index 7b56a251d0..7a8a938272 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp @@ -83,7 +83,7 @@ public: } nsString mDeviceAddress; - nsTArray> mBlobs; + nsTArray> mBlobs; }; NS_IMETHODIMP @@ -160,7 +160,7 @@ public: if (numRead > 0) { sBluetoothOppManager->CheckPutFinal(numRead); - nsRefPtr task = + RefPtr task = new SendSocketDataTask((uint8_t*)buf.forget(), numRead); if (NS_FAILED(NS_DispatchToMainThread(task))) { BT_WARNING("Failed to dispatch to main thread!"); @@ -191,7 +191,7 @@ public: } private: - nsRefPtr mSocket; + RefPtr mSocket; }; BluetoothOppManager::BluetoothOppManager() : mConnected(false) @@ -419,8 +419,8 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr impl = aActor->GetBlobImpl(); - nsRefPtr blob = Blob::Create(nullptr, impl); + RefPtr impl = aActor->GetBlobImpl(); + RefPtr blob = Blob::Create(nullptr, impl); return SendFile(aDeviceAddress, blob.get()); } @@ -798,7 +798,7 @@ BluetoothOppManager::RetrieveSentFileName() { mFileName.Truncate(); - nsRefPtr file = static_cast(mBlob.get())->ToFile(); + RefPtr file = static_cast(mBlob.get())->ToFile(); if (file) { file->GetName(mFileName); } @@ -1162,7 +1162,7 @@ BluetoothOppManager::ClientDataHandler(UnixSocketBuffer* aMessage) } } - nsRefPtr task = new ReadFileTask(mInputStream, + RefPtr task = new ReadFileTask(mInputStream, mRemoteMaxPacketLength); rv = mReadFileThread->Dispatch(task, NS_DISPATCH_NORMAL); if (NS_WARN_IF(rv.Failed())) { diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.h b/dom/bluetooth/bluedroid/BluetoothOppManager.h index 0381241ae5..624d16cc01 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.h +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.h @@ -204,7 +204,7 @@ private: nsAutoArrayPtr mReceivedDataBuffer; int mCurrentBlobIndex; - nsRefPtr mBlob; + RefPtr mBlob; nsTArray mBatches; /** @@ -215,18 +215,18 @@ private: nsCOMPtr mOutputStream; nsCOMPtr mInputStream; nsCOMPtr mMountLock; - nsRefPtr mDsFile; - nsRefPtr mDummyDsFile; + RefPtr mDsFile; + RefPtr mDummyDsFile; // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mServerSocket must be null (and vice versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server sockets. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mServerSocket; + RefPtr mServerSocket; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp b/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp index 19440cd8cd..7b8e0dc6f7 100644 --- a/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp @@ -747,8 +747,8 @@ bool BluetoothPbapManager::ReplyToPullPhonebook(BlobParent* aActor, uint16_t aPhonebookSize) { - nsRefPtr impl = aActor->GetBlobImpl(); - nsRefPtr blob = Blob::Create(nullptr, impl); + RefPtr impl = aActor->GetBlobImpl(); + RefPtr blob = Blob::Create(nullptr, impl); return ReplyToPullPhonebook(blob.get(), aPhonebookSize); } @@ -778,8 +778,8 @@ bool BluetoothPbapManager::ReplyToPullvCardListing(BlobParent* aActor, uint16_t aPhonebookSize) { - nsRefPtr impl = aActor->GetBlobImpl(); - nsRefPtr blob = Blob::Create(nullptr, impl); + RefPtr impl = aActor->GetBlobImpl(); + RefPtr blob = Blob::Create(nullptr, impl); return ReplyToPullvCardListing(blob.get(), aPhonebookSize); } @@ -808,8 +808,8 @@ BluetoothPbapManager::ReplyToPullvCardListing(Blob* aBlob, bool BluetoothPbapManager::ReplyToPullvCardEntry(BlobParent* aActor) { - nsRefPtr impl = aActor->GetBlobImpl(); - nsRefPtr blob = Blob::Create(nullptr, impl); + RefPtr impl = aActor->GetBlobImpl(); + RefPtr blob = Blob::Create(nullptr, impl); return ReplyToPullvCardEntry(blob.get()); } diff --git a/dom/bluetooth/bluedroid/BluetoothPbapManager.h b/dom/bluetooth/bluedroid/BluetoothPbapManager.h index 10ac87e103..97d5bf7933 100644 --- a/dom/bluetooth/bluedroid/BluetoothPbapManager.h +++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.h @@ -186,12 +186,12 @@ private: // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mServerSocket must be null (and vice versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server socket. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mServerSocket; + RefPtr mServerSocket; /** * The vCard data stream for current processing response diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index 397684cff5..4c821edd98 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -68,7 +68,7 @@ using namespace mozilla::ipc; USING_BLUETOOTH_NAMESPACE static BluetoothInterface* sBtInterface; -static nsTArray > sControllerArray; +static nsTArray > sControllerArray; /* * Static methods @@ -165,7 +165,7 @@ public: // Register all the bluedroid callbacks before enable() gets called. This is // required to register a2dp callbacks before a2dp media task starts up. // If any interface cannot be initialized, turn on bluetooth core anyway. - nsRefPtr res = + RefPtr res = new ProfileInitResultHandler(MOZ_ARRAY_LENGTH(sInitManager)); for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sInitManager); ++i) { @@ -651,7 +651,7 @@ public: int mDeviceCount; InfallibleTArray mDevicesPack; - nsRefPtr mRunnable; + RefPtr mRunnable; }; class BluetoothServiceBluedroid::GetRemoteDevicePropertiesResultHandler @@ -756,7 +756,7 @@ class BluetoothServiceBluedroid::DispatchReplyErrorResultHandler final { public: DispatchReplyErrorResultHandler( - nsTArray>& aRunnableArray, + nsTArray>& aRunnableArray, BluetoothReplyRunnable* aRunnable) : mRunnableArray(aRunnableArray) , mRunnable(aRunnable) @@ -773,7 +773,7 @@ public: } private: - nsTArray>& mRunnableArray; + nsTArray>& mRunnableArray; BluetoothReplyRunnable* mRunnable; }; @@ -930,7 +930,7 @@ BluetoothServiceBluedroid::GetServiceChannel( mGetRemoteServiceRecordArray.AppendElement( GetRemoteServiceRecordRequest(aDeviceAddress, uuid, aManager)); - nsRefPtr res = + RefPtr res = new GetRemoteServiceRecordResultHandler(mGetRemoteServiceRecordArray, aDeviceAddress, uuid); @@ -1025,7 +1025,7 @@ BluetoothServiceBluedroid::UpdateSdpRecords( mGetRemoteServicesArray.AppendElement( GetRemoteServicesRequest(aDeviceAddress, aManager)); - nsRefPtr res = + RefPtr res = new GetRemoteServicesResultHandler(mGetRemoteServicesArray, aDeviceAddress, aManager); @@ -1655,7 +1655,7 @@ BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState) // Cleanup Bluetooth interfaces after state becomes BT_STATE_OFF. This // will also stop the Bluetooth daemon and disable the adapter. - nsRefPtr res = + RefPtr res = new ProfileDeinitResultHandler(MOZ_ARRAY_LENGTH(sDeinitManager), mIsRestart); diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h index aab4be10c4..64045c353f 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h @@ -383,12 +383,12 @@ protected: bool mIsFirstTimeToggleOffBt; // Runnable arrays - nsTArray> mChangeAdapterStateRunnables; - nsTArray> mSetAdapterPropertyRunnables; - nsTArray> mChangeDiscoveryRunnables; - nsTArray> mFetchUuidsRunnables; - nsTArray> mCreateBondRunnables; - nsTArray> mRemoveBondRunnables; + nsTArray> mChangeAdapterStateRunnables; + nsTArray> mSetAdapterPropertyRunnables; + nsTArray> mChangeDiscoveryRunnables; + nsTArray> mFetchUuidsRunnables; + nsTArray> mCreateBondRunnables; + nsTArray> mRemoveBondRunnables; // Array of get device requests. Each request remembers // 1) remaining device count to receive properties, diff --git a/dom/bluetooth/bluedroid/BluetoothSocketMessageWatcher.h b/dom/bluetooth/bluedroid/BluetoothSocketMessageWatcher.h index 30b75c98ea..3e1ca68ad0 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocketMessageWatcher.h +++ b/dom/bluetooth/bluedroid/BluetoothSocketMessageWatcher.h @@ -78,7 +78,7 @@ private: int mClientFd; unsigned char mLen; uint8_t mBuf[MSG1_SIZE + MSG2_SIZE]; - nsRefPtr mRes; + RefPtr mRes; }; /* |SocketMessageWatcherTask| starts a SocketMessageWatcher diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp index 7170fb0f23..fad9506c08 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp @@ -269,7 +269,7 @@ BluetoothHfpManager::Init() nsresult rv = settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); NS_ENSURE_SUCCESS(rv, false); - nsRefPtr callback = new GetVolumeTask(); + RefPtr callback = new GetVolumeTask(); rv = settingsLock->Get(AUDIO_VOLUME_BT_SCO_ID, callback); NS_ENSURE_SUCCESS(rv, false); @@ -323,7 +323,7 @@ public: private: BluetoothHandsfreeInterface* mInterface; - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothHfpManager::InitResultHandlerRunnable final @@ -343,7 +343,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothHfpManager::OnErrorProfileResultHandlerRunnable final @@ -365,7 +365,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; nsresult mRv; }; @@ -377,7 +377,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!btInf)) { // If there's no backend interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -390,7 +390,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!interface)) { // If there's no HFP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -398,7 +398,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) return; } - nsRefPtr res = + RefPtr res = new CleanupInitResultHandler(interface, aRes); if (sBluetoothHfpInterface) { @@ -407,7 +407,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) } else { // If there's no HFP interface to cleanup first, we dispatch // a runnable that calls the profile result handler. - nsRefPtr r = new InitResultHandlerRunnable(res); + RefPtr r = new InitResultHandlerRunnable(res); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP init runnable"); } @@ -460,7 +460,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothHfpManager::DeinitResultHandlerRunnable final @@ -480,7 +480,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -492,7 +492,7 @@ BluetoothHfpManager::DeinitHfpInterface(BluetoothProfileResultHandler* aRes) } else if (aRes) { // We dispatch a runnable here to make the profile resource handler // behave as if HFP was initialized. - nsRefPtr r = new DeinitResultHandlerRunnable(aRes); + RefPtr r = new DeinitResultHandlerRunnable(aRes); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch cleanup-result-handler runnable"); } diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h index 7487aad92e..310c6d34d9 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h @@ -224,7 +224,7 @@ private: nsTArray mCurrentCallArray; nsAutoPtr mListener; - nsRefPtr mController; + RefPtr mController; // CDMA-specific variable Call mCdmaSecondCall; diff --git a/dom/bluetooth/bluetooth2/BluetoothHidManager.cpp b/dom/bluetooth/bluetooth2/BluetoothHidManager.cpp index 3f08e09b14..96c611fcc7 100644 --- a/dom/bluetooth/bluetooth2/BluetoothHidManager.cpp +++ b/dom/bluetooth/bluetooth2/BluetoothHidManager.cpp @@ -181,7 +181,7 @@ BluetoothHidManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -196,7 +196,7 @@ BluetoothHidManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } diff --git a/dom/bluetooth/bluetooth2/BluetoothHidManager.h b/dom/bluetooth/bluetooth2/BluetoothHidManager.h index 568c080dab..7cf1e537fa 100644 --- a/dom/bluetooth/bluetooth2/BluetoothHidManager.h +++ b/dom/bluetooth/bluetooth2/BluetoothHidManager.h @@ -39,7 +39,7 @@ private: // data member bool mConnected; nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluetooth2/BluetoothRilListener.h b/dom/bluetooth/bluetooth2/BluetoothRilListener.h index 1768528d68..407ce823c4 100644 --- a/dom/bluetooth/bluetooth2/BluetoothRilListener.h +++ b/dom/bluetooth/bluetooth2/BluetoothRilListener.h @@ -123,10 +123,10 @@ private: * * The length equals to number of total clients. */ - nsTArray > mMobileConnListeners; + nsTArray > mMobileConnListeners; - nsRefPtr mIccListener; - nsRefPtr mTelephonyListener; + RefPtr mIccListener; + RefPtr mTelephonyListener; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluez/BluetoothA2dpManager.cpp b/dom/bluetooth/bluez/BluetoothA2dpManager.cpp index 290481fba0..8b6b0003be 100644 --- a/dom/bluetooth/bluez/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothA2dpManager.cpp @@ -203,7 +203,7 @@ BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -218,7 +218,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); Reset(); diff --git a/dom/bluetooth/bluez/BluetoothA2dpManager.h b/dom/bluetooth/bluez/BluetoothA2dpManager.h index 89e468da0a..a917ab7559 100644 --- a/dom/bluetooth/bluez/BluetoothA2dpManager.h +++ b/dom/bluetooth/bluez/BluetoothA2dpManager.h @@ -47,7 +47,7 @@ private: void NotifyConnectionStatusChanged(); nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; // A2DP data member bool mA2dpConnected; diff --git a/dom/bluetooth/bluez/BluetoothAvrcpManager.cpp b/dom/bluetooth/bluez/BluetoothAvrcpManager.cpp index e2d7ccd1f5..385f3769c5 100644 --- a/dom/bluetooth/bluez/BluetoothAvrcpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothAvrcpManager.cpp @@ -145,7 +145,7 @@ BluetoothAvrcpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -160,7 +160,7 @@ BluetoothAvrcpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); Reset(); diff --git a/dom/bluetooth/bluez/BluetoothAvrcpManager.h b/dom/bluetooth/bluez/BluetoothAvrcpManager.h index 7341c65c65..7a7c4b8d9f 100644 --- a/dom/bluetooth/bluez/BluetoothAvrcpManager.h +++ b/dom/bluetooth/bluez/BluetoothAvrcpManager.h @@ -53,7 +53,7 @@ private: void NotifyConnectionStatusChanged(); nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; // AVRCP data member bool mAvrcpConnected; diff --git a/dom/bluetooth/bluez/BluetoothDBusService.cpp b/dom/bluetooth/bluez/BluetoothDBusService.cpp index ef480cdf6e..d7c89d330b 100644 --- a/dom/bluetooth/bluez/BluetoothDBusService.cpp +++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp @@ -343,7 +343,7 @@ static const int sWaitingForAdapterNameInterval = 1000; // unit: ms // // A queue for connect/disconnect request. See Bug 913372 for details. -static nsTArray > sControllerArray; +static nsTArray > sControllerArray; // // I/O-thread-only variables @@ -736,7 +736,7 @@ RunDBusCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable, // (technically) shouldn't hurt anything. However, on gonk, die. MOZ_ASSERT(!NS_IsMainThread()); // I/O thread #endif - nsRefPtr replyRunnable = + RefPtr replyRunnable = dont_AddRef(static_cast(aBluetoothReplyRunnable)); MOZ_ASSERT(replyRunnable, "Callback reply runnable is null!"); @@ -1188,7 +1188,7 @@ public: } MOZ_ASSERT(i != properties.Length(), "failed to get device name"); - nsRefPtr task = + RefPtr task = new DistributeBluetoothSignalTask(mSignal); NS_DispatchToMainThread(task); } @@ -1223,7 +1223,7 @@ AppendDeviceName(BluetoothSignal& aSignal) nsString devicePath = arr[0].value().get_nsString(); - nsRefPtr handler = + RefPtr handler = new AppendDeviceNameReplyHandler(nsCString(DBUS_DEVICE_IFACE), devicePath, aSignal); @@ -1302,7 +1302,7 @@ public: private: nsString mDeviceAddress; bool mConfirm; - nsRefPtr mRunnable; + RefPtr mRunnable; }; static DBusHandlerResult @@ -1645,7 +1645,7 @@ private: return false; } - nsRefPtr handler = + RefPtr handler = new RegisterAgentReplyHandler(aAgentVTable); MOZ_ASSERT(!sAdapterPath.IsEmpty()); @@ -1684,7 +1684,7 @@ public: MOZ_ASSERT(sDBusConnection); MOZ_ASSERT(!sAdapterPath.IsEmpty()); - nsRefPtr handler = + RefPtr handler = new AddReservedServiceRecordsReplyHandler(); const dbus_uint32_t* services = sServices; @@ -1993,7 +1993,7 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData) } BluetoothSignal signal(signalName, signalPath, v); - nsRefPtr task; + RefPtr task; if (signalInterface.EqualsLiteral(DBUS_SINK_IFACE)) { task = new SinkPropertyChangedHandler(signal); } else if (signalInterface.EqualsLiteral(DBUS_CTL_IFACE)) { @@ -2032,7 +2032,7 @@ OnDefaultAdapterReply(DBusMessage* aReply, void* aData) sAdapterPath = v.get_nsString(); - nsRefPtr b = new PrepareAdapterRunnable(); + RefPtr b = new PrepareAdapterRunnable(); if (NS_FAILED(NS_DispatchToMainThread(b))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2063,7 +2063,7 @@ public: if (sDBusConnection) { BT_WARNING("DBus connection has already been established."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(true); + RefPtr runnable = new BluetoothService::ToggleBtAck(true); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2074,7 +2074,7 @@ public: if (!dbus_connection_add_filter(mConnection->GetConnection(), EventFilter, nullptr, nullptr)) { BT_WARNING("Cannot create DBus Event Filter for DBus Thread!"); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2089,7 +2089,7 @@ public: sDBusConnection = mConnection.forget(); - nsRefPtr runnable = + RefPtr runnable = new BluetoothService::ToggleBtAck(true); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); @@ -2130,7 +2130,7 @@ public: #ifdef MOZ_WIDGET_GONK if (!sBluedroid.Enable()) { BT_WARNING("Bluetooth not available."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2142,7 +2142,7 @@ public: nsresult rv = connection->EstablishDBusConnection(); if (NS_FAILED(rv)) { BT_WARNING("Failed to establish connection to BlueZ daemon"); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2179,7 +2179,7 @@ BluetoothDBusService::StartInternal(BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(!aRunnable); - nsRefPtr runnable = new StartBluetoothRunnable(); + RefPtr runnable = new StartBluetoothRunnable(); nsresult rv = DispatchToBtThread(runnable); if (NS_FAILED(rv)) { BT_WARNING("Failed to dispatch to BT thread!"); @@ -2207,7 +2207,7 @@ public: bool isEnabled = false; #endif - nsRefPtr runnable = + RefPtr runnable = new BluetoothService::ToggleBtAck(isEnabled); nsresult rv = NS_DispatchToMainThread(runnable); if (NS_FAILED(rv)) { @@ -2229,7 +2229,7 @@ public: if (!sDBusConnection) { BT_WARNING("DBus connection has not been established."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2270,7 +2270,7 @@ public: // We can only dispatch to the BT thread if we're on the main // thread. Thus we dispatch our runnable to the main thread // from where it will forward itself to the BT thread. - nsRefPtr runnable = new DisableBluetoothRunnable(); + RefPtr runnable = new DisableBluetoothRunnable(); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to BT thread!"); } @@ -2309,7 +2309,7 @@ BluetoothDBusService::StopInternal(BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(!aRunnable); - nsRefPtr runnable = new StopBluetoothRunnable(); + RefPtr runnable = new StopBluetoothRunnable(); nsresult rv = DispatchToBtThread(runnable); if (NS_FAILED(rv)) { BT_WARNING("Failed to dispatch to BT thread!"); @@ -2377,7 +2377,7 @@ protected: mAdapterPath = value.get_nsString(); // Acquire another reference to this reply handler - nsRefPtr handler = this; + RefPtr handler = this; bool success = sDBusConnection->SendWithReply( DefaultAdapterPathReplyHandler::Callback, handler.get(), 1000, @@ -2422,7 +2422,7 @@ protected: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; nsString mAdapterPath; }; @@ -2440,7 +2440,7 @@ public: MOZ_ASSERT(!NS_IsMainThread()); // I/O thread MOZ_ASSERT(sDBusConnection); - nsRefPtr handler = + RefPtr handler = new DefaultAdapterPathReplyHandler(mRunnable); bool success = sDBusConnection->SendWithReply( @@ -2454,7 +2454,7 @@ public: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -2489,7 +2489,7 @@ OnSendDiscoveryMessageReply(DBusMessage *aReply, void *aData) errorStr.AssignLiteral("SendDiscovery failed"); } - nsRefPtr runnable = + RefPtr runnable = dont_AddRef( static_cast(aData)); @@ -2528,7 +2528,7 @@ public: private: const nsCString mMessageName; - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -2780,7 +2780,7 @@ protected: mObjectPath = GetObjectPathFromAddress(sAdapterPath, mDeviceAddresses[mProcessedDeviceAddresses]); - nsRefPtr handler = this; + RefPtr handler = this; bool success = sDBusConnection->SendWithReply( BluetoothArrayOfDevicePropertiesReplyHandler::Callback, @@ -2801,7 +2801,7 @@ private: const nsTArray mDeviceAddresses; nsTArray::size_type mProcessedDeviceAddresses; const FilterFunc mFilterFunc; - nsRefPtr mRunnable; + RefPtr mRunnable; BluetoothValue mValues; }; @@ -2826,8 +2826,8 @@ public: } private: - nsRefPtr mHandler; - nsRefPtr mRunnable; + RefPtr mHandler; + RefPtr mRunnable; }; nsresult @@ -2960,7 +2960,7 @@ public: private: BluetoothObjectType mType; const nsCString mName; - nsRefPtr mRunnable; + RefPtr mRunnable; }; class SetUInt32PropertyTask : public SetPropertyTask @@ -3119,7 +3119,7 @@ public: private: const nsCString mDeviceAddress; int mTimeout; - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -3180,7 +3180,7 @@ protected: errorStr.AssignLiteral("RemoveDevice failed"); } - nsRefPtr runnable = + RefPtr runnable = dont_AddRef( static_cast(aData)); @@ -3189,7 +3189,7 @@ protected: private: const nsString mDeviceAddress; - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -3270,7 +3270,7 @@ public: private: const nsString mDeviceAddress; const nsCString mPinCode; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void @@ -3360,7 +3360,7 @@ public: private: nsString mDeviceAddress; uint32_t mPasskey; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void @@ -3567,7 +3567,7 @@ public: channel = dbus_returns_int32(aReply); } - nsRefPtr r = + RefPtr r = new OnGetServiceChannelRunnable(mDeviceAddress, mServiceUUID, channel, mBluetoothProfileManager); nsresult rv = NS_DispatchToMainThread(r); @@ -3605,7 +3605,7 @@ public: nsString objectPath = GetObjectPathFromAddress(sAdapterPath, mDeviceAddress); - nsRefPtr handler = + RefPtr handler = new OnGetServiceChannelReplyHandler(mDeviceAddress, mServiceUUID, mBluetoothProfileManager); @@ -3657,7 +3657,7 @@ BluetoothDBusService::GetServiceChannel(const nsAString& aDeviceAddress, // Even though we are on the main thread already, we need to dispatch a // runnable here. OnGetServiceChannel needs mRunnable to be set, which // happens after GetServiceChannel returns. - nsRefPtr r = new OnGetServiceChannelRunnable(aDeviceAddress, + RefPtr r = new OnGetServiceChannelRunnable(aDeviceAddress, aServiceUUID, 1, aManager); @@ -3708,7 +3708,7 @@ protected: { MOZ_ASSERT(!NS_IsMainThread()); // I/O thread - nsRefPtr r( + RefPtr r( static_cast(aData)); NS_DispatchToMainThread(r); } @@ -3938,7 +3938,7 @@ private: int64_t mMediaNumber; int64_t mTotalMediaCount; int64_t mDuration; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void @@ -4065,7 +4065,7 @@ private: int64_t mDuration; int64_t mPosition; ControlPlayStatus mPlayStatus; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.cpp b/dom/bluetooth/bluez/BluetoothHfpManager.cpp index 54f1a5eed4..0324e32bf8 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp @@ -477,7 +477,7 @@ BluetoothHfpManager::Init() nsresult rv = settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); NS_ENSURE_SUCCESS(rv, false); - nsRefPtr callback = new GetVolumeTask(); + RefPtr callback = new GetVolumeTask(); rv = settingsLock->Get(AUDIO_VOLUME_BT_SCO_ID, callback); NS_ENSURE_SUCCESS(rv, false); @@ -1503,7 +1503,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex, } mCurrentCallArray[aCallIndex].mNumber = aNumber; - nsRefPtr sendRingTask; + RefPtr sendRingTask; nsString address; switch (aCallState) { @@ -2091,7 +2091,7 @@ BluetoothHfpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -2110,7 +2110,7 @@ BluetoothHfpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.h b/dom/bluetooth/bluez/BluetoothHfpManager.h index b5f11b32ec..df8ce22e43 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.h +++ b/dom/bluetooth/bluez/BluetoothHfpManager.h @@ -207,21 +207,21 @@ private: nsTArray mCurrentCallArray; nsAutoPtr mListener; #endif - nsRefPtr mController; - nsRefPtr mScoRunnable; + RefPtr mController; + RefPtr mScoRunnable; // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mHandsfreeSocket and mHeadsetSocket must be null (and // vice versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server sockets. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mHandsfreeSocket; - nsRefPtr mHeadsetSocket; - nsRefPtr mScoSocket; + RefPtr mHandsfreeSocket; + RefPtr mHeadsetSocket; + RefPtr mScoSocket; mozilla::ipc::SocketConnectionStatus mScoSocketStatus; #ifdef MOZ_B2G_RIL diff --git a/dom/bluetooth/bluez/BluetoothOppManager.cpp b/dom/bluetooth/bluez/BluetoothOppManager.cpp index 324fd05773..06496a058f 100644 --- a/dom/bluetooth/bluez/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp @@ -83,7 +83,7 @@ public: } nsString mDeviceAddress; - nsTArray> mBlobs; + nsTArray> mBlobs; }; NS_IMETHODIMP @@ -155,7 +155,7 @@ public: if (numRead > 0) { sBluetoothOppManager->CheckPutFinal(numRead); - nsRefPtr task = + RefPtr task = new SendSocketDataTask((uint8_t*)buf.forget(), numRead); if (NS_FAILED(NS_DispatchToMainThread(task))) { BT_WARNING("Failed to dispatch to main thread!"); @@ -190,7 +190,7 @@ public: } private: - nsRefPtr mSocket; + RefPtr mSocket; }; BluetoothOppManager::BluetoothOppManager() @@ -394,8 +394,8 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr impl = aActor->GetBlobImpl(); - nsRefPtr blob = Blob::Create(nullptr, impl); + RefPtr impl = aActor->GetBlobImpl(); + RefPtr blob = Blob::Create(nullptr, impl); return SendFile(aDeviceAddress, blob); } @@ -779,7 +779,7 @@ BluetoothOppManager::RetrieveSentFileName() { mFileName.Truncate(); - nsRefPtr file = mBlob->ToFile(); + RefPtr file = mBlob->ToFile(); if (file) { file->GetName(mFileName); } @@ -1142,7 +1142,7 @@ BluetoothOppManager::ClientDataHandler(UnixSocketBuffer* aMessage) } } - nsRefPtr task = new ReadFileTask(mInputStream, + RefPtr task = new ReadFileTask(mInputStream, mRemoteMaxPacketLength); rv = mReadFileThread->Dispatch(task, NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) { diff --git a/dom/bluetooth/bluez/BluetoothOppManager.h b/dom/bluetooth/bluez/BluetoothOppManager.h index 95f2af411d..10b5e959f3 100644 --- a/dom/bluetooth/bluez/BluetoothOppManager.h +++ b/dom/bluetooth/bluez/BluetoothOppManager.h @@ -193,7 +193,7 @@ private: nsAutoArrayPtr mReceivedDataBuffer; int mCurrentBlobIndex; - nsRefPtr mBlob; + RefPtr mBlob; nsTArray mBatches; /** @@ -204,20 +204,20 @@ private: nsCOMPtr mOutputStream; nsCOMPtr mInputStream; nsCOMPtr mMountLock; - nsRefPtr mDsFile; - nsRefPtr mDummyDsFile; + RefPtr mDsFile; + RefPtr mDummyDsFile; // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mRfcommSocket and mL2capSocket must be null (and vice // versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server sockets. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mRfcommSocket; - nsRefPtr mL2capSocket; + RefPtr mRfcommSocket; + RefPtr mL2capSocket; BluetoothSocketType mSocketType; diff --git a/dom/bluetooth/common/BluetoothHidManager.cpp b/dom/bluetooth/common/BluetoothHidManager.cpp index bc19620683..7ca142b32b 100644 --- a/dom/bluetooth/common/BluetoothHidManager.cpp +++ b/dom/bluetooth/common/BluetoothHidManager.cpp @@ -183,7 +183,7 @@ BluetoothHidManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -198,7 +198,7 @@ BluetoothHidManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } diff --git a/dom/bluetooth/common/BluetoothHidManager.h b/dom/bluetooth/common/BluetoothHidManager.h index 62fdf29495..46ac13615a 100644 --- a/dom/bluetooth/common/BluetoothHidManager.h +++ b/dom/bluetooth/common/BluetoothHidManager.h @@ -41,7 +41,7 @@ private: // data member bool mConnected; nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/common/BluetoothProfileController.cpp b/dom/bluetooth/common/BluetoothProfileController.cpp index 647a36e9d9..20b7c0a5ef 100644 --- a/dom/bluetooth/common/BluetoothProfileController.cpp +++ b/dom/bluetooth/common/BluetoothProfileController.cpp @@ -46,7 +46,7 @@ protected: mController = nullptr; } - nsRefPtr mController; + RefPtr mController; }; BluetoothProfileController::BluetoothProfileController( diff --git a/dom/bluetooth/common/BluetoothProfileController.h b/dom/bluetooth/common/BluetoothProfileController.h index 0183130681..a9387cd5dd 100644 --- a/dom/bluetooth/common/BluetoothProfileController.h +++ b/dom/bluetooth/common/BluetoothProfileController.h @@ -138,7 +138,7 @@ private: const bool mConnect; nsString mDeviceAddress; - nsRefPtr mRunnable; + RefPtr mRunnable; BluetoothProfileControllerCallback mCallback; bool mCurrentProfileFinished; diff --git a/dom/bluetooth/common/BluetoothReplyRunnable.h b/dom/bluetooth/common/BluetoothReplyRunnable.h index 92599a1e75..98e0d315d2 100644 --- a/dom/bluetooth/common/BluetoothReplyRunnable.h +++ b/dom/bluetooth/common/BluetoothReplyRunnable.h @@ -66,7 +66,7 @@ private: * TODO: remove mDOMRequest once all methods adopt Promise. */ nsCOMPtr mDOMRequest; - nsRefPtr mPromise; + RefPtr mPromise; BluetoothStatus mErrorStatus; nsString mErrorString; diff --git a/dom/bluetooth/common/BluetoothRilListener.h b/dom/bluetooth/common/BluetoothRilListener.h index cb0e27cb7e..ffe9e1a614 100644 --- a/dom/bluetooth/common/BluetoothRilListener.h +++ b/dom/bluetooth/common/BluetoothRilListener.h @@ -129,10 +129,10 @@ private: * * The length equals to number of total clients. */ - nsTArray > mMobileConnListeners; + nsTArray > mMobileConnListeners; - nsRefPtr mIccListener; - nsRefPtr mTelephonyListener; + RefPtr mIccListener; + RefPtr mTelephonyListener; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/common/BluetoothService.cpp b/dom/bluetooth/common/BluetoothService.cpp index 0d04024f98..e9abeb6a47 100644 --- a/dom/bluetooth/common/BluetoothService.cpp +++ b/dom/bluetooth/common/BluetoothService.cpp @@ -390,7 +390,7 @@ BluetoothService::StartBluetooth(bool aIsStartup, } } else { BT_WARNING("Bluetooth has already been enabled before."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(true); + RefPtr runnable = new BluetoothService::ToggleBtAck(true); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -421,7 +421,7 @@ BluetoothService::StopBluetooth(bool aIsStartup, } } else { BT_WARNING("Bluetooth has already been enabled/disabled before."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -482,7 +482,7 @@ BluetoothService::HandleStartup() nsresult rv = settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr callback = new StartupTask(); + RefPtr callback = new StartupTask(); rv = settingsLock->Get(BLUETOOTH_ENABLED_SETTING, callback); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/bluetooth/common/BluetoothService.h b/dom/bluetooth/common/BluetoothService.h index 0c3429a970..11e0599f3a 100644 --- a/dom/bluetooth/common/BluetoothService.h +++ b/dom/bluetooth/common/BluetoothService.h @@ -129,7 +129,7 @@ public: static already_AddRefed FactoryCreate() { - nsRefPtr service = Get(); + RefPtr service = Get(); return service.forget(); } diff --git a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp index 13d8fa804d..435330a44a 100644 --- a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp +++ b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp @@ -96,7 +96,7 @@ public: * Create a new discovery handle and wrap it to return. Each * discovery handle is one-time-use only. */ - nsRefPtr discoveryHandle = + RefPtr discoveryHandle = BluetoothDiscoveryHandle::Create(mAdapter->GetParentObject()); if (!ToJSValue(cx, discoveryHandle, aValue)) { JS_ClearPendingException(cx); @@ -116,7 +116,7 @@ public: } private: - nsRefPtr mAdapter; + RefPtr mAdapter; }; class StartLeScanTask final : public BluetoothReplyRunnable @@ -148,7 +148,7 @@ public: * Create a new discovery handle and wrap it to return. Each * discovery handle is one-time-use only. */ - nsRefPtr discoveryHandle = + RefPtr discoveryHandle = BluetoothDiscoveryHandle::Create(mAdapter->GetParentObject(), mServiceUuids, v.get_nsString()); @@ -171,7 +171,7 @@ public: } private: - nsRefPtr mAdapter; + RefPtr mAdapter; nsTArray mServiceUuids; }; @@ -207,7 +207,7 @@ protected: } private: - nsRefPtr mAdapter; + RefPtr mAdapter; nsString mScanUuid; }; @@ -235,7 +235,7 @@ public: const InfallibleTArray& values = v.get_ArrayOfBluetoothNamedValue(); - nsTArray > devices; + nsTArray > devices; for (uint32_t i = 0; i < values.Length(); i++) { const BluetoothValue properties = values[i].value(); if (properties.type() != BluetoothValue::TArrayOfBluetoothNamedValue) { @@ -243,7 +243,7 @@ public: SetError(NS_LITERAL_STRING("BluetoothReplyTypeError")); return false; } - nsRefPtr d = + RefPtr d = BluetoothDevice::Create(mAdapterPtr->GetOwner(), properties); devices.AppendElement(d); @@ -275,7 +275,7 @@ public: } private: - nsRefPtr mAdapterPtr; + RefPtr mAdapterPtr; }; class GetScoConnectionStatusTask : public BluetoothReplyRunnable @@ -361,7 +361,7 @@ BluetoothAdapter::Cleanup() nsString uuid; for (uint32_t i = 0; i < mLeScanHandleArray.Length(); ++i) { mLeScanHandleArray[i]->GetLeScanUuid(uuid); - nsRefPtr results = + RefPtr results = new BluetoothVoidReplyRunnable(nullptr); bs->StopLeScanInternal(uuid, results); } @@ -397,7 +397,7 @@ BluetoothAdapter::GetPairedDeviceProperties( BluetoothService* bs = BluetoothService::Get(); NS_ENSURE_TRUE_VOID(bs); - nsRefPtr results = + RefPtr results = new BluetoothVoidReplyRunnable(nullptr); nsresult rv = @@ -472,7 +472,7 @@ BluetoothAdapter::Create(nsPIDOMWindow* aWindow, const BluetoothValue& aValue) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - nsRefPtr adapter = new BluetoothAdapter(aWindow, aValue); + RefPtr adapter = new BluetoothAdapter(aWindow, aValue); return adapter.forget(); } @@ -522,7 +522,7 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData) init.mCancelable = false; init.mAddress = address; init.mStatus = status; - nsRefPtr event = + RefPtr event = BluetoothStatusChangedEvent::Constructor(this, aData.name(), init); DispatchTrustedEvent(event); } else if (aData.name().EqualsLiteral(PAIRING_ABORTED_ID) || @@ -576,7 +576,7 @@ BluetoothAdapter::StartDiscovery(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -615,7 +615,7 @@ BluetoothAdapter::StopDiscovery(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -646,7 +646,7 @@ BluetoothAdapter::StartLeScan(const nsTArray& aServiceUuids, return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mState == BluetoothAdapterState::Enabled, @@ -656,7 +656,7 @@ BluetoothAdapter::StartLeScan(const nsTArray& aServiceUuids, BluetoothService* bs = BluetoothService::Get(); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); - nsRefPtr result = + RefPtr result = new StartLeScanTask(this, promise, aServiceUuids); bs->StartLeScanInternal(aServiceUuids, result); @@ -673,7 +673,7 @@ BluetoothAdapter::StopLeScan(BluetoothDiscoveryHandle& aDiscoveryHandle, return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mState == BluetoothAdapterState::Enabled, @@ -690,7 +690,7 @@ BluetoothAdapter::StopLeScan(BluetoothDiscoveryHandle& aDiscoveryHandle, nsString scanUuid; aDiscoveryHandle.GetLeScanUuid(scanUuid); - nsRefPtr result = + RefPtr result = new StopLeScanTask(this, promise, scanUuid); bs->StopLeScanInternal(scanUuid, result); @@ -706,7 +706,7 @@ BluetoothAdapter::SetName(const nsAString& aName, ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -745,7 +745,7 @@ BluetoothAdapter::SetDiscoverable(bool aDiscoverable, ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -785,8 +785,8 @@ BluetoothAdapter::GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new GetDevicesTask(this, request); BluetoothService* bs = BluetoothService::Get(); @@ -805,7 +805,7 @@ BluetoothAdapter::GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv) void BluetoothAdapter::GetPairedDevices( - nsTArray >& aDevices) + nsTArray >& aDevices) { for (uint32_t i = 0; i < mDevices.Length(); ++i) { if (mDevices[i]->Paired()) { @@ -824,7 +824,7 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress, return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -877,7 +877,7 @@ BluetoothAdapter::Enable(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -895,7 +895,7 @@ BluetoothAdapter::Enable(ErrorResult& aRv) SetAdapterState(BluetoothAdapterState::Enabling); // Wrap runnable to handle result - nsRefPtr result = + RefPtr result = new BluetoothVoidReplyRunnable(nullptr, promise); if (NS_FAILED(bs->EnableDisable(true, result))) { @@ -916,7 +916,7 @@ BluetoothAdapter::Disable(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); /** @@ -934,7 +934,7 @@ BluetoothAdapter::Disable(ErrorResult& aRv) SetAdapterState(BluetoothAdapterState::Disabling); // Wrap runnable to handle result - nsRefPtr result = + RefPtr result = new BluetoothVoidReplyRunnable(nullptr, promise); if (NS_FAILED(bs->EnableDisable(false, result))) { @@ -1087,7 +1087,7 @@ BluetoothAdapter::HandleDeviceFound(const BluetoothValue& aValue) MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue); // Create a temporary discovered BluetoothDevice to check existence - nsRefPtr discoveredDevice = + RefPtr discoveredDevice = BluetoothDevice::Create(GetOwner(), aValue); size_t index = mDevices.IndexOf(discoveredDevice); @@ -1130,7 +1130,7 @@ BluetoothAdapter::HandleLeDeviceFound(const BluetoothValue& aValue) // Create an individual scanned BluetoothDevice for each LeDeviceEvent even // the device exists in adapter's devices array - nsRefPtr scannedDevice = + RefPtr scannedDevice = BluetoothDevice::Create(GetOwner(), aValue); // Notify application of scanned devices via discovery handle @@ -1237,7 +1237,7 @@ BluetoothAdapter::HandlePullPhonebookReq(const BluetoothValue& aValue) init.mHandle = BluetoothPbapRequestHandle::Create(GetOwner()); - nsRefPtr event = + RefPtr event = BluetoothPhonebookPullingEvent::Constructor(this, NS_LITERAL_STRING(PULL_PHONEBOOK_REQ_ID), init); DispatchTrustedEvent(event); @@ -1271,7 +1271,7 @@ BluetoothAdapter::HandlePullVCardEntryReq(const BluetoothValue& aValue) init.mHandle = BluetoothPbapRequestHandle::Create(GetOwner()); - nsRefPtr event = + RefPtr event = BluetoothVCardPullingEvent::Constructor(this, NS_LITERAL_STRING(PULL_VCARD_ENTRY_REQ_ID), init); DispatchTrustedEvent(event); @@ -1315,7 +1315,7 @@ BluetoothAdapter::HandlePullVCardListingReq(const BluetoothValue& aValue) init.mHandle = BluetoothPbapRequestHandle::Create(GetOwner()); - nsRefPtr event = + RefPtr event = BluetoothVCardListingEvent::Constructor(this, NS_LITERAL_STRING(PULL_VCARD_LISTING_REQ_ID), init); DispatchTrustedEvent(event); @@ -1346,7 +1346,7 @@ BluetoothAdapter::DispatchAttributeEvent(const Sequence& aTypes) BluetoothAttributeEventInit init; init.mAttrs = aTypes; - nsRefPtr event = + RefPtr event = BluetoothAttributeEvent::Constructor( this, NS_LITERAL_STRING(ATTRIBUTE_CHANGED_ID), init); @@ -1370,7 +1370,7 @@ BluetoothAdapter::DispatchAttributeEvent(const nsTArray& aTypes) RootedDictionary init(cx); init.mAttrs = value; - nsRefPtr event = + RefPtr event = BluetoothAttributeEvent::Constructor(this, NS_LITERAL_STRING("attributechanged"), init); @@ -1381,7 +1381,7 @@ void BluetoothAdapter::DispatchDeviceEvent(const nsAString& aType, const BluetoothDeviceEventInit& aInit) { - nsRefPtr event = + RefPtr event = BluetoothDeviceEvent::Constructor(this, aType, aInit); DispatchTrustedEvent(event); } @@ -1389,7 +1389,7 @@ BluetoothAdapter::DispatchDeviceEvent(const nsAString& aType, void BluetoothAdapter::DispatchEmptyEvent(const nsAString& aType) { - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); nsresult rv = event->InitEvent(aType, false, false); NS_ENSURE_SUCCESS_VOID(rv); @@ -1408,8 +1408,8 @@ BluetoothAdapter::Connect(BluetoothDevice& aDevice, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); nsAutoString address; @@ -1441,8 +1441,8 @@ BluetoothAdapter::Disconnect(BluetoothDevice& aDevice, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); nsAutoString address; @@ -1472,8 +1472,8 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1514,8 +1514,8 @@ BluetoothAdapter::StopSendingFile( return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1538,8 +1538,8 @@ BluetoothAdapter::ConfirmReceivingFile(const nsAString& aDeviceAddress, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1561,8 +1561,8 @@ BluetoothAdapter::ConnectSco(ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1584,8 +1584,8 @@ BluetoothAdapter::DisconnectSco(ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1607,8 +1607,8 @@ BluetoothAdapter::IsScoConnected(ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new GetScoConnectionStatusTask(request); BluetoothService* bs = BluetoothService::Get(); @@ -1631,8 +1631,8 @@ BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1659,8 +1659,8 @@ BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1687,8 +1687,8 @@ BluetoothAdapter::ToggleCalls(ErrorResult& aRv) return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1715,8 +1715,8 @@ BluetoothAdapter::SendMediaMetaData( return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -1745,8 +1745,8 @@ BluetoothAdapter::SendMediaPlayStatus( return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr results = + RefPtr request = new DOMRequest(win); + RefPtr results = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); diff --git a/dom/bluetooth/common/webapi/BluetoothAdapter.h b/dom/bluetooth/common/webapi/BluetoothAdapter.h index 882bda5cb2..6f0a8ade95 100644 --- a/dom/bluetooth/common/webapi/BluetoothAdapter.h +++ b/dom/bluetooth/common/webapi/BluetoothAdapter.h @@ -123,7 +123,7 @@ public: * * @param aDevices [out] Devices array to return */ - void GetPairedDevices(nsTArray >& aDevices); + void GetPairedDevices(nsTArray >& aDevices); // Connection related methods already_AddRefed @@ -432,12 +432,12 @@ private: * end of its life. When |GetGattServer| is called after the adapter has been * enabled again, a new GATT server object will be created. */ - nsRefPtr mGattServer; + RefPtr mGattServer; /** * Handle to fire pairing requests of different pairing types. */ - nsRefPtr mPairingReqs; + RefPtr mPairingReqs; /** * Handle to fire 'ondevicefound' event handler for discovered device. @@ -446,7 +446,7 @@ private: * starts discovery, and is reset to nullptr when discovery is stopped by * some adapter. */ - nsRefPtr mDiscoveryHandleInUse; + RefPtr mDiscoveryHandleInUse; /** * Handles to fire 'ondevicefound' event handler for scanned device @@ -454,7 +454,7 @@ private: * Each non-stopped LeScan process has a LeScan handle which is * responsible to dispatch LeDeviceEvent. */ - nsTArray > mLeScanHandleArray; + nsTArray > mLeScanHandleArray; /** * nsRefPtr array of BluetoothDevices created by this adapter. The array is @@ -472,7 +472,7 @@ private: * this new discovery starts. * 3) adapter unpaired with a device: The unpaired device will be removed. */ - nsTArray > mDevices; + nsTArray > mDevices; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/common/webapi/BluetoothClassOfDevice.cpp b/dom/bluetooth/common/webapi/BluetoothClassOfDevice.cpp index deead30e0a..38196ba6ce 100644 --- a/dom/bluetooth/common/webapi/BluetoothClassOfDevice.cpp +++ b/dom/bluetooth/common/webapi/BluetoothClassOfDevice.cpp @@ -90,7 +90,7 @@ BluetoothClassOfDevice::Create(nsPIDOMWindow* aOwner) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aOwner); - nsRefPtr cod = new BluetoothClassOfDevice(aOwner); + RefPtr cod = new BluetoothClassOfDevice(aOwner); return cod.forget(); } diff --git a/dom/bluetooth/common/webapi/BluetoothDevice.cpp b/dom/bluetooth/common/webapi/BluetoothDevice.cpp index 8ad62d7b7e..47a81f393e 100644 --- a/dom/bluetooth/common/webapi/BluetoothDevice.cpp +++ b/dom/bluetooth/common/webapi/BluetoothDevice.cpp @@ -90,7 +90,7 @@ public: } private: - nsRefPtr mDevice; + RefPtr mDevice; }; BluetoothDevice::BluetoothDevice(nsPIDOMWindow* aWindow, @@ -181,7 +181,7 @@ BluetoothDevice::FetchUuids(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); // Ensure BluetoothService is available @@ -204,7 +204,7 @@ BluetoothDevice::Create(nsPIDOMWindow* aWindow, MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - nsRefPtr device = new BluetoothDevice(aWindow, aValue); + RefPtr device = new BluetoothDevice(aWindow, aValue); return device.forget(); } @@ -308,7 +308,7 @@ BluetoothDevice::DispatchAttributeEvent(const Sequence& aTypes) BluetoothAttributeEventInit init; init.mAttrs = aTypes; - nsRefPtr event = + RefPtr event = BluetoothAttributeEvent::Constructor( this, NS_LITERAL_STRING(ATTRIBUTE_CHANGED_ID), init); diff --git a/dom/bluetooth/common/webapi/BluetoothDevice.h b/dom/bluetooth/common/webapi/BluetoothDevice.h index 914976923c..175ccdb11b 100644 --- a/dom/bluetooth/common/webapi/BluetoothDevice.h +++ b/dom/bluetooth/common/webapi/BluetoothDevice.h @@ -173,7 +173,7 @@ private: /** * Class of device (CoD) that describes this device's capabilities. */ - nsRefPtr mCod; + RefPtr mCod; /** * Human-readable name of this device. @@ -198,7 +198,7 @@ private: /** * GATT client object to interact with the remote device. */ - nsRefPtr mGatt; + RefPtr mGatt; }; END_BLUETOOTH_NAMESPACE @@ -208,16 +208,16 @@ END_BLUETOOTH_NAMESPACE * * Allows customizing the template code for a given set of template arguments. * With this function template, nsTArray can handle comparison of - * 'nsRefPtr' properly, including IndexOf() and Contains(); + * 'RefPtr' properly, including IndexOf() and Contains(); */ template <> -class nsDefaultComparator , - nsRefPtr> { +class nsDefaultComparator , + RefPtr> { public: bool Equals( - const nsRefPtr& aDeviceA, - const nsRefPtr& aDeviceB) const + const RefPtr& aDeviceA, + const RefPtr& aDeviceB) const { nsString addressA, addressB; aDeviceA->GetAddress(addressA); @@ -232,15 +232,15 @@ class nsDefaultComparator , * * Allows customizing the template code for a given set of template arguments. * With this function template, nsTArray can handle comparison between - * 'nsRefPtr' and nsString properly, including IndexOf() and + * 'RefPtr' and nsString properly, including IndexOf() and * Contains(); */ template <> -class nsDefaultComparator , +class nsDefaultComparator , nsString> { public: bool Equals( - const nsRefPtr& aDevice, + const RefPtr& aDevice, const nsString& aAddress) const { nsString deviceAddress; diff --git a/dom/bluetooth/common/webapi/BluetoothDiscoveryHandle.cpp b/dom/bluetooth/common/webapi/BluetoothDiscoveryHandle.cpp index da2681eb93..6c76b8a5ca 100644 --- a/dom/bluetooth/common/webapi/BluetoothDiscoveryHandle.cpp +++ b/dom/bluetooth/common/webapi/BluetoothDiscoveryHandle.cpp @@ -49,7 +49,7 @@ BluetoothDiscoveryHandle::Create(nsPIDOMWindow* aWindow) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - nsRefPtr handle = + RefPtr handle = new BluetoothDiscoveryHandle(aWindow); return handle.forget(); } @@ -63,7 +63,7 @@ BluetoothDiscoveryHandle::Create( MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - nsRefPtr handle = + RefPtr handle = new BluetoothDiscoveryHandle(aWindow, aServiceUuids, aLeScanUuid); return handle.forget(); } @@ -76,7 +76,7 @@ BluetoothDiscoveryHandle::DispatchDeviceEvent(BluetoothDevice* aDevice) BluetoothDeviceEventInit init; init.mDevice = aDevice; - nsRefPtr event = + RefPtr event = BluetoothDeviceEvent::Constructor(this, NS_LITERAL_STRING("devicefound"), init); @@ -116,7 +116,7 @@ BluetoothDiscoveryHandle::DispatchLeDeviceEvent(BluetoothDevice* aLeDevice, // - the service UUID in the scan record matches one of the given UUIDs. // - the given UUIDs is empty. if (matched || mServiceUuids.IsEmpty()) { - nsRefPtr event = + RefPtr event = BluetoothLeDeviceEvent::Constructor(this, NS_LITERAL_STRING("devicefound"), aLeDevice, diff --git a/dom/bluetooth/common/webapi/BluetoothGatt.cpp b/dom/bluetooth/common/webapi/BluetoothGatt.cpp index 3e26decd73..4ff11f1486 100644 --- a/dom/bluetooth/common/webapi/BluetoothGatt.cpp +++ b/dom/bluetooth/common/webapi/BluetoothGatt.cpp @@ -67,7 +67,7 @@ BluetoothGatt::~BluetoothGatt() NS_ENSURE_TRUE_VOID(bs); if (mClientIf > 0) { - nsRefPtr result = + RefPtr result = new BluetoothVoidReplyRunnable(nullptr); bs->UnregisterGattClientInternal(mClientIf, result); } @@ -84,7 +84,7 @@ BluetoothGatt::DisconnectFromOwner() NS_ENSURE_TRUE_VOID(bs); if (mClientIf > 0) { - nsRefPtr result = + RefPtr result = new BluetoothVoidReplyRunnable(nullptr); bs->UnregisterGattClientInternal(mClientIf, result); } @@ -101,7 +101,7 @@ BluetoothGatt::Connect(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT( @@ -136,7 +136,7 @@ BluetoothGatt::Disconnect(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT( @@ -185,7 +185,7 @@ BluetoothGatt::ReadRemoteRssi(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT( @@ -211,7 +211,7 @@ BluetoothGatt::DiscoverServices(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT( @@ -240,7 +240,7 @@ BluetoothGatt::UpdateConnectionState(BluetoothConnectionState aState) mConnectionState = aState; // Dispatch connectionstatechanged event to application - nsRefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); + RefPtr event = NS_NewDOMEvent(this, nullptr, nullptr); nsresult rv = event->InitEvent(NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID), @@ -287,7 +287,7 @@ BluetoothGatt::HandleIncludedServicesDiscovered(const BluetoothValue& aValue) values[0].value().get_BluetoothGattServiceId()); NS_ENSURE_TRUE_VOID(index != mServices.NoIndex); - nsRefPtr service = mServices.ElementAt(index); + RefPtr service = mServices.ElementAt(index); service->AssignIncludedServices( values[1].value().get_ArrayOfBluetoothGattServiceId()); } @@ -311,7 +311,7 @@ BluetoothGatt::HandleCharacteristicsDiscovered(const BluetoothValue& aValue) values[0].value().get_BluetoothGattServiceId()); NS_ENSURE_TRUE_VOID(index != mServices.NoIndex); - nsRefPtr service = mServices.ElementAt(index); + RefPtr service = mServices.ElementAt(index); service->AssignCharacteristics( values[1].value().get_ArrayOfBluetoothGattCharAttribute()); } @@ -337,7 +337,7 @@ BluetoothGatt::HandleDescriptorsDiscovered(const BluetoothValue& aValue) values[0].value().get_BluetoothGattServiceId()); NS_ENSURE_TRUE_VOID(index != mServices.NoIndex); - nsRefPtr service = mServices.ElementAt(index); + RefPtr service = mServices.ElementAt(index); service->AssignDescriptors(values[1].value().get_BluetoothGattId(), values[2].value().get_ArrayOfBluetoothGattId()); } @@ -358,18 +358,18 @@ BluetoothGatt::HandleCharacteristicChanged(const BluetoothValue& aValue) size_t index = mServices.IndexOf(ids[0].value().get_BluetoothGattServiceId()); NS_ENSURE_TRUE_VOID(index != mServices.NoIndex); - nsRefPtr service = mServices.ElementAt(index); - nsTArray> chars; + RefPtr service = mServices.ElementAt(index); + nsTArray> chars; service->GetCharacteristics(chars); index = chars.IndexOf(ids[1].value().get_BluetoothGattId()); NS_ENSURE_TRUE_VOID(index != chars.NoIndex); - nsRefPtr characteristic = chars.ElementAt(index); + RefPtr characteristic = chars.ElementAt(index); // Dispatch characteristicchanged event to application BluetoothGattCharacteristicEventInit init; init.mCharacteristic = characteristic; - nsRefPtr event = + RefPtr event = BluetoothGattCharacteristicEvent::Constructor( this, NS_LITERAL_STRING(GATT_CHARACTERISTIC_CHANGED_ID), diff --git a/dom/bluetooth/common/webapi/BluetoothGatt.h b/dom/bluetooth/common/webapi/BluetoothGatt.h index ce6864aac2..8048ecf414 100644 --- a/dom/bluetooth/common/webapi/BluetoothGatt.h +++ b/dom/bluetooth/common/webapi/BluetoothGatt.h @@ -40,7 +40,7 @@ public: return mConnectionState; } - void GetServices(nsTArray>& aServices) const + void GetServices(nsTArray>& aServices) const { aServices = mServices; } @@ -181,7 +181,7 @@ private: /** * Array of discovered services from the remote GATT server. */ - nsTArray> mServices; + nsTArray> mServices; /** * Indicate whether there is ongoing discoverServices request or not. diff --git a/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp b/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp index 54c296cf8d..2a0fbd5f85 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp +++ b/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp @@ -92,7 +92,7 @@ BluetoothGattCharacteristic::StartNotifications(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BluetoothService* bs = BluetoothService::Get(); @@ -115,7 +115,7 @@ BluetoothGattCharacteristic::StopNotifications(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BluetoothService* bs = BluetoothService::Get(); @@ -239,7 +239,7 @@ public: } private: - nsRefPtr mCharacteristic; + RefPtr mCharacteristic; }; already_AddRefed @@ -251,7 +251,7 @@ BluetoothGattCharacteristic::ReadValue(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mProperties & GATT_CHAR_PROP_BIT_READ, @@ -278,7 +278,7 @@ BluetoothGattCharacteristic::WriteValue(const ArrayBuffer& aValue, return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mProperties & diff --git a/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.h b/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.h index ff6eff4004..a69cbff21c 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.h +++ b/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.h @@ -46,7 +46,7 @@ public: } void GetDescriptors( - nsTArray>& aDescriptors) const + nsTArray>& aDescriptors) const { aDescriptors = mDescriptors; } @@ -127,12 +127,12 @@ private: /** * Service that this characteristic belongs to. */ - nsRefPtr mService; + RefPtr mService; /** * Array of discovered descriptors for this characteristic. */ - nsTArray> mDescriptors; + nsTArray> mDescriptors; /** * GattId of this GATT characteristic which contains @@ -169,16 +169,16 @@ END_BLUETOOTH_NAMESPACE * * Allows customizing the template code for a given set of template arguments. * With this function template, nsTArray can handle comparison between - * 'nsRefPtr' and 'BluetoothGattId' properly, + * 'RefPtr' and 'BluetoothGattId' properly, * including IndexOf() and Contains(); */ template <> class nsDefaultComparator < - nsRefPtr, + RefPtr, mozilla::dom::bluetooth::BluetoothGattId> { public: bool Equals( - const nsRefPtr& aChar, + const RefPtr& aChar, const mozilla::dom::bluetooth::BluetoothGattId& aCharId) const { return aChar->GetCharacteristicId() == aCharId; diff --git a/dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp b/dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp index ebe8f6c10b..46f097108c 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp +++ b/dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp @@ -159,7 +159,7 @@ public: } private: - nsRefPtr mDescriptor; + RefPtr mDescriptor; }; already_AddRefed @@ -171,7 +171,7 @@ BluetoothGattDescriptor::ReadValue(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BluetoothService* bs = BluetoothService::Get(); @@ -197,7 +197,7 @@ BluetoothGattDescriptor::WriteValue( return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); aValue.ComputeLengthAndData(); diff --git a/dom/bluetooth/common/webapi/BluetoothGattDescriptor.h b/dom/bluetooth/common/webapi/BluetoothGattDescriptor.h index 24f7da5d5e..5e33f4446d 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattDescriptor.h +++ b/dom/bluetooth/common/webapi/BluetoothGattDescriptor.h @@ -76,7 +76,7 @@ private: /** * Characteristic that this descriptor belongs to. */ - nsRefPtr mCharacteristic; + RefPtr mCharacteristic; /** * GattId of this GATT descriptor which contains diff --git a/dom/bluetooth/common/webapi/BluetoothGattServer.cpp b/dom/bluetooth/common/webapi/BluetoothGattServer.cpp index 0940573b3f..3f4718d3f5 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattServer.cpp +++ b/dom/bluetooth/common/webapi/BluetoothGattServer.cpp @@ -80,7 +80,7 @@ BluetoothGattServer::Notify(const BluetoothSignal& aData) init.mStatus = arr[0].value().get_bool(); init.mAddress = arr[1].value().get_nsString(); - nsRefPtr event = + RefPtr event = BluetoothStatusChangedEvent::Constructor( this, NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID), init); @@ -129,7 +129,7 @@ BluetoothGattServer::Connect(const nsAString& aAddress, ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE); @@ -159,7 +159,7 @@ BluetoothGattServer::Disconnect(const nsAString& aAddress, ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE); diff --git a/dom/bluetooth/common/webapi/BluetoothGattService.cpp b/dom/bluetooth/common/webapi/BluetoothGattService.cpp index 91fd66a4f8..e70ac4ed93 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattService.cpp +++ b/dom/bluetooth/common/webapi/BluetoothGattService.cpp @@ -80,7 +80,7 @@ BluetoothGattService::AssignDescriptors( size_t index = mCharacteristics.IndexOf(aCharacteristicId); NS_ENSURE_TRUE_VOID(index != mCharacteristics.NoIndex); - nsRefPtr characteristic = + RefPtr characteristic = mCharacteristics.ElementAt(index); characteristic->AssignDescriptors(aDescriptorIds); } diff --git a/dom/bluetooth/common/webapi/BluetoothGattService.h b/dom/bluetooth/common/webapi/BluetoothGattService.h index 7b8fbbe617..a95ea3b401 100644 --- a/dom/bluetooth/common/webapi/BluetoothGattService.h +++ b/dom/bluetooth/common/webapi/BluetoothGattService.h @@ -48,13 +48,13 @@ public: } void GetIncludedServices( - nsTArray>& aIncludedServices) const + nsTArray>& aIncludedServices) const { aIncludedServices = mIncludedServices; } void GetCharacteristics( - nsTArray>& aCharacteristics) const + nsTArray>& aCharacteristics) const { aCharacteristics = mCharacteristics; } @@ -148,12 +148,12 @@ private: /** * Array of discovered included services for this service. */ - nsTArray> mIncludedServices; + nsTArray> mIncludedServices; /** * Array of discovered characteristics for this service. */ - nsTArray> mCharacteristics; + nsTArray> mCharacteristics; }; END_BLUETOOTH_NAMESPACE @@ -163,16 +163,16 @@ END_BLUETOOTH_NAMESPACE * * Allows customizing the template code for a given set of template arguments. * With this function template, nsTArray can handle comparison between - * 'nsRefPtr' and 'BluetoothGattServiceId' properly, + * 'RefPtr' and 'BluetoothGattServiceId' properly, * including IndexOf() and Contains(); */ template <> class nsDefaultComparator < - nsRefPtr, + RefPtr, mozilla::dom::bluetooth::BluetoothGattServiceId> { public: bool Equals( - const nsRefPtr& aService, + const RefPtr& aService, const mozilla::dom::bluetooth::BluetoothGattServiceId& aServiceId) const { return aService->GetServiceId() == aServiceId; diff --git a/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp b/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp index f2e255c7d9..e7f33cac15 100644 --- a/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp +++ b/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp @@ -66,7 +66,7 @@ BluetoothLeDeviceEvent::Constructor( const int16_t aRssi, const nsTArray& aScanRecord) { - nsRefPtr e = new BluetoothLeDeviceEvent(aOwner); + RefPtr e = new BluetoothLeDeviceEvent(aOwner); bool trusted = e->Init(aOwner); e->InitEvent(aType, false, false); e->mDevice = aDevice; @@ -87,7 +87,7 @@ BluetoothLeDeviceEvent::Constructor( nsCOMPtr owner = do_QueryInterface(aGlobal.GetAsSupports()); - nsRefPtr e = new BluetoothLeDeviceEvent(owner); + RefPtr e = new BluetoothLeDeviceEvent(owner); bool trusted = e->Init(owner); e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable); e->mDevice = aEventInitDict.mDevice; diff --git a/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.h b/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.h index 55bde20048..8dd093c188 100644 --- a/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.h +++ b/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.h @@ -25,7 +25,7 @@ protected: virtual ~BluetoothLeDeviceEvent(); explicit BluetoothLeDeviceEvent(mozilla::dom::EventTarget* aOwner); - nsRefPtr mDevice; + RefPtr mDevice; int16_t mRssi; JS::Heap mScanRecord; diff --git a/dom/bluetooth/common/webapi/BluetoothManager.cpp b/dom/bluetooth/common/webapi/BluetoothManager.cpp index 0ccfc77c43..e92ab24624 100644 --- a/dom/bluetooth/common/webapi/BluetoothManager.cpp +++ b/dom/bluetooth/common/webapi/BluetoothManager.cpp @@ -103,7 +103,7 @@ class GetAdaptersTask : public BluetoothReplyRunnable } private: - nsRefPtr mManager; + RefPtr mManager; }; BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow) @@ -118,7 +118,7 @@ BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow) BluetoothService* bs = BluetoothService::Get(); NS_ENSURE_TRUE_VOID(bs); - nsRefPtr result = new GetAdaptersTask(this); + RefPtr result = new GetAdaptersTask(this); NS_ENSURE_SUCCESS_VOID(bs->GetAdaptersInternal(result)); } @@ -151,7 +151,7 @@ BluetoothManager::AppendAdapter(const BluetoothValue& aValue) // Create a new BluetoothAdapter and append it to adapters array const InfallibleTArray& values = aValue.get_ArrayOfBluetoothNamedValue(); - nsRefPtr adapter = + RefPtr adapter = BluetoothAdapter::Create(GetOwner(), values); mAdapters.AppendElement(adapter); @@ -164,7 +164,7 @@ BluetoothManager::AppendAdapter(const BluetoothValue& aValue) } void -BluetoothManager::GetAdapters(nsTArray >& aAdapters) +BluetoothManager::GetAdapters(nsTArray >& aAdapters) { aAdapters = mAdapters; } @@ -176,7 +176,7 @@ BluetoothManager::Create(nsPIDOMWindow* aWindow) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - nsRefPtr manager = new BluetoothManager(aWindow); + RefPtr manager = new BluetoothManager(aWindow); return manager.forget(); } @@ -236,7 +236,7 @@ void BluetoothManager::DispatchAdapterEvent(const nsAString& aType, const BluetoothAdapterEventInit& aInit) { - nsRefPtr event = + RefPtr event = BluetoothAdapterEvent::Constructor(this, aType, aInit); DispatchTrustedEvent(event); } @@ -254,7 +254,7 @@ BluetoothManager::DispatchAttributeEvent() // Notify application of default adapter change BluetoothAttributeEventInit init; init.mAttrs = types; - nsRefPtr event = + RefPtr event = BluetoothAttributeEvent::Constructor( this, NS_LITERAL_STRING(ATTRIBUTE_CHANGED_ID), init); diff --git a/dom/bluetooth/common/webapi/BluetoothManager.h b/dom/bluetooth/common/webapi/BluetoothManager.h index 4f33b4f34f..dce208b02d 100644 --- a/dom/bluetooth/common/webapi/BluetoothManager.h +++ b/dom/bluetooth/common/webapi/BluetoothManager.h @@ -50,7 +50,7 @@ public: * * @param aAdapters [out] Adapters array to return */ - void GetAdapters(nsTArray >& aAdapters); + void GetAdapters(nsTArray >& aAdapters); /**************************************************************************** * Others @@ -135,7 +135,7 @@ private: /** * The adapters array. */ - nsTArray > mAdapters; + nsTArray > mAdapters; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/common/webapi/BluetoothPairingHandle.cpp b/dom/bluetooth/common/webapi/BluetoothPairingHandle.cpp index d8bfc48633..6cef4d1336 100644 --- a/dom/bluetooth/common/webapi/BluetoothPairingHandle.cpp +++ b/dom/bluetooth/common/webapi/BluetoothPairingHandle.cpp @@ -57,7 +57,7 @@ BluetoothPairingHandle::Create(nsPIDOMWindow* aOwner, { MOZ_ASSERT(aOwner && !aDeviceAddress.IsEmpty() && !aType.IsEmpty()); - nsRefPtr handle = + RefPtr handle = new BluetoothPairingHandle(aOwner, aDeviceAddress, aType, aPasskey); return handle.forget(); @@ -72,7 +72,7 @@ BluetoothPairingHandle::SetPinCode(const nsAString& aPinCode, ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mType.EqualsLiteral(PAIRING_REQ_TYPE_ENTERPINCODE), @@ -97,7 +97,7 @@ BluetoothPairingHandle::Accept(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BT_ENSURE_TRUE_REJECT(mType.EqualsLiteral(PAIRING_REQ_TYPE_CONFIRMATION) || @@ -128,7 +128,7 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv) return nullptr; } - nsRefPtr promise = Promise::Create(global, aRv); + RefPtr promise = Promise::Create(global, aRv); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); BluetoothService* bs = BluetoothService::Get(); diff --git a/dom/bluetooth/common/webapi/BluetoothPairingListener.cpp b/dom/bluetooth/common/webapi/BluetoothPairingListener.cpp index 0f5e97ab66..2f2e7e2d31 100644 --- a/dom/bluetooth/common/webapi/BluetoothPairingListener.cpp +++ b/dom/bluetooth/common/webapi/BluetoothPairingListener.cpp @@ -35,7 +35,7 @@ BluetoothPairingListener::Create(nsPIDOMWindow* aWindow) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - nsRefPtr handle = + RefPtr handle = new BluetoothPairingListener(aWindow); return handle.forget(); @@ -55,7 +55,7 @@ BluetoothPairingListener::DispatchPairingEvent(const nsAString& aName, { MOZ_ASSERT(!aName.IsEmpty() && !aAddress.IsEmpty() && !aType.IsEmpty()); - nsRefPtr handle = + RefPtr handle = BluetoothPairingHandle::Create(GetOwner(), aAddress, aType, @@ -65,7 +65,7 @@ BluetoothPairingListener::DispatchPairingEvent(const nsAString& aName, init.mDeviceName = aName; init.mHandle = handle; - nsRefPtr event = + RefPtr event = BluetoothPairingEvent::Constructor(this, aType, init); diff --git a/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.cpp b/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.cpp index 7375b7ee50..6b445763ea 100644 --- a/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.cpp +++ b/dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.cpp @@ -40,7 +40,7 @@ BluetoothPbapRequestHandle::Create(nsPIDOMWindow* aOwner) { MOZ_ASSERT(aOwner); - nsRefPtr handle = + RefPtr handle = new BluetoothPbapRequestHandle(aOwner); return handle.forget(); @@ -56,8 +56,8 @@ BluetoothPbapRequestHandle::ReplyTovCardPulling(Blob& aBlob, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr result = + RefPtr request = new DOMRequest(win); + RefPtr result = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -99,8 +99,8 @@ BluetoothPbapRequestHandle::ReplyToPhonebookPulling(Blob& aBlob, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr result = + RefPtr request = new DOMRequest(win); + RefPtr result = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); @@ -142,8 +142,8 @@ BluetoothPbapRequestHandle::ReplyTovCardListing(Blob& aBlob, return nullptr; } - nsRefPtr request = new DOMRequest(win); - nsRefPtr result = + RefPtr request = new DOMRequest(win); + RefPtr result = new BluetoothVoidReplyRunnable(request); BluetoothService* bs = BluetoothService::Get(); diff --git a/dom/bluetooth/ipc/BluetoothChild.cpp b/dom/bluetooth/ipc/BluetoothChild.cpp index b211d2a739..781f7e3667 100644 --- a/dom/bluetooth/ipc/BluetoothChild.cpp +++ b/dom/bluetooth/ipc/BluetoothChild.cpp @@ -160,7 +160,7 @@ BluetoothRequestChild::Recv__delete__(const BluetoothReply& aReply) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mReplyRunnable); - nsRefPtr replyRunnable; + RefPtr replyRunnable; mReplyRunnable.swap(replyRunnable); if (replyRunnable) { diff --git a/dom/bluetooth/ipc/BluetoothChild.h b/dom/bluetooth/ipc/BluetoothChild.h index 2330416892..b068a572d4 100644 --- a/dom/bluetooth/ipc/BluetoothChild.h +++ b/dom/bluetooth/ipc/BluetoothChild.h @@ -85,7 +85,7 @@ class BluetoothRequestChild : public PBluetoothRequestChild { friend class mozilla::dom::bluetooth::BluetoothChild; - nsRefPtr mReplyRunnable; + RefPtr mReplyRunnable; public: BluetoothRequestChild(BluetoothReplyRunnable* aReplyRunnable); diff --git a/dom/bluetooth/ipc/BluetoothParent.h b/dom/bluetooth/ipc/BluetoothParent.h index bef542435f..1d8dd3fdf6 100644 --- a/dom/bluetooth/ipc/BluetoothParent.h +++ b/dom/bluetooth/ipc/BluetoothParent.h @@ -51,7 +51,7 @@ class BluetoothParent : public PBluetoothParent Dead }; - nsRefPtr mService; + RefPtr mService; ShutdownState mShutdownState; bool mReceivedStopNotifying; bool mSentBeginShutdown; @@ -108,7 +108,7 @@ class BluetoothRequestParent : public PBluetoothRequestParent friend class ReplyRunnable; - nsRefPtr mService; + RefPtr mService; nsRevocableEventPtr mReplyRunnable; #ifdef DEBUG diff --git a/dom/bluetooth2/bluedroid/BluetoothA2dpManager.cpp b/dom/bluetooth2/bluedroid/BluetoothA2dpManager.cpp index b1d6401bd5..c0a1c851e9 100644 --- a/dom/bluetooth2/bluedroid/BluetoothA2dpManager.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothA2dpManager.cpp @@ -153,7 +153,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothA2dpManager::InitA2dpResultHandler final @@ -196,7 +196,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothA2dpManager::OnErrorProfileResultHandlerRunnable final @@ -218,7 +218,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; nsresult mRv; }; @@ -236,7 +236,7 @@ BluetoothA2dpManager::InitA2dpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!btInf)) { // If there's no backend interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -248,7 +248,7 @@ BluetoothA2dpManager::InitA2dpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!sBtA2dpInterface)) { // If there's no A2DP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -365,7 +365,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothA2dpManager::CleanupA2dpResultHandler final @@ -399,7 +399,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothA2dpManager::CleanupA2dpResultHandlerRunnable final @@ -426,7 +426,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -440,7 +440,7 @@ BluetoothA2dpManager::DeinitA2dpInterface(BluetoothProfileResultHandler* aRes) } else if (aRes) { // We dispatch a runnable here to make the profile resource handler // behave as if A2DP was initialized. - nsRefPtr r = new CleanupA2dpResultHandlerRunnable(aRes); + RefPtr r = new CleanupA2dpResultHandlerRunnable(aRes); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch cleanup-result-handler runnable"); } @@ -577,7 +577,7 @@ BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -592,7 +592,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); Reset(); diff --git a/dom/bluetooth2/bluedroid/BluetoothA2dpManager.h b/dom/bluetooth2/bluedroid/BluetoothA2dpManager.h index 27ff2f3ae5..8f9ad75484 100644 --- a/dom/bluetooth2/bluedroid/BluetoothA2dpManager.h +++ b/dom/bluetooth2/bluedroid/BluetoothA2dpManager.h @@ -123,7 +123,7 @@ private: void PassthroughCmdNotification(int aId, int aKeyState) override; nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; // A2DP data member bool mA2dpConnected; diff --git a/dom/bluetooth2/bluedroid/BluetoothDaemonA2dpInterface.cpp b/dom/bluetooth2/bluedroid/BluetoothDaemonA2dpInterface.cpp index e676e2be57..843915d5be 100644 --- a/dom/bluetooth2/bluedroid/BluetoothDaemonA2dpInterface.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothDaemonA2dpInterface.cpp @@ -151,7 +151,7 @@ BluetoothDaemonA2dpModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = already_AddRefed( static_cast(aUserData)); @@ -320,7 +320,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -385,7 +385,7 @@ public: private: BluetoothDaemonA2dpModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth2/bluedroid/BluetoothDaemonAvrcpInterface.cpp b/dom/bluetooth2/bluedroid/BluetoothDaemonAvrcpInterface.cpp index a7feebadd7..3102e47635 100644 --- a/dom/bluetooth2/bluedroid/BluetoothDaemonAvrcpInterface.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothDaemonAvrcpInterface.cpp @@ -450,7 +450,7 @@ BluetoothDaemonAvrcpModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = already_AddRefed( static_cast(aUserData)); @@ -863,7 +863,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -931,7 +931,7 @@ public: private: BluetoothDaemonAvrcpModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth2/bluedroid/BluetoothDaemonHandsfreeInterface.cpp b/dom/bluetooth2/bluedroid/BluetoothDaemonHandsfreeInterface.cpp index 2ed0f7a92d..11b22be967 100644 --- a/dom/bluetooth2/bluedroid/BluetoothDaemonHandsfreeInterface.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothDaemonHandsfreeInterface.cpp @@ -607,7 +607,7 @@ BluetoothDaemonHandsfreeModule::HandleRsp( return; } - nsRefPtr res = + RefPtr res = already_AddRefed( static_cast(aUserData)); @@ -991,7 +991,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; void @@ -1057,7 +1057,7 @@ public: private: BluetoothDaemonHandsfreeModule* mModule; - nsRefPtr mRes; + RefPtr mRes; }; void diff --git a/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.cpp index aded08ac9b..b840d43cb7 100644 --- a/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.cpp @@ -134,7 +134,7 @@ protected: return; } - nsRefPtr res = + RefPtr res = already_AddRefed( static_cast(aUserData)); @@ -935,7 +935,7 @@ private: return; } - nsRefPtr res = + RefPtr res = already_AddRefed( static_cast(aUserData)); @@ -1894,7 +1894,7 @@ public: private: BluetoothDaemonInterface* mInterface; - nsRefPtr mRes; + RefPtr mRes; bool mRegisteredSocketModule; }; @@ -1928,7 +1928,7 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel) } break; case NTF_CHANNEL: { - nsRefPtr res = mResultHandlerQ.ElementAt(0); + RefPtr res = mResultHandlerQ.ElementAt(0); mResultHandlerQ.RemoveElementAt(0); // Init, step 4: Register Core module @@ -1960,7 +1960,7 @@ BluetoothDaemonInterface::OnConnectError(enum Channel aChannel) mListenSocket->Close(); case LISTEN_SOCKET: { // Signal error to caller - nsRefPtr res = mResultHandlerQ.ElementAt(0); + RefPtr res = mResultHandlerQ.ElementAt(0); mResultHandlerQ.RemoveElementAt(0); if (res) { @@ -1987,7 +1987,7 @@ BluetoothDaemonInterface::OnDisconnect(enum Channel aChannel) mListenSocket->Close(); break; case LISTEN_SOCKET: { - nsRefPtr res = mResultHandlerQ.ElementAt(0); + RefPtr res = mResultHandlerQ.ElementAt(0); mResultHandlerQ.RemoveElementAt(0); // Cleanup, step 5: Signal success to caller diff --git a/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.h b/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.h index 13c28fa025..e9ee93c2e2 100644 --- a/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.h +++ b/dom/bluetooth2/bluedroid/BluetoothDaemonInterface.h @@ -128,12 +128,12 @@ private: void DispatchError(BluetoothResultHandler* aRes, BluetoothStatus aStatus); nsCString mListenSocketName; - nsRefPtr mListenSocket; - nsRefPtr mCmdChannel; - nsRefPtr mNtfChannel; + RefPtr mListenSocket; + RefPtr mCmdChannel; + RefPtr mNtfChannel; nsAutoPtr mProtocol; - nsTArray > mResultHandlerQ; + nsTArray > mResultHandlerQ; nsAutoPtr mSocketInterface; nsAutoPtr mHandsfreeInterface; diff --git a/dom/bluetooth2/bluedroid/BluetoothDaemonSocketInterface.cpp b/dom/bluetooth2/bluedroid/BluetoothDaemonSocketInterface.cpp index 0a590553e2..727bb22362 100644 --- a/dom/bluetooth2/bluedroid/BluetoothDaemonSocketInterface.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothDaemonSocketInterface.cpp @@ -174,7 +174,7 @@ BluetoothDaemonSocketModule::HandleSvc(const BluetoothDaemonPDUHeader& aHeader, return; } - nsRefPtr res = + RefPtr res = already_AddRefed( static_cast(aUserData)); diff --git a/dom/bluetooth2/bluedroid/BluetoothHALHelpers.h b/dom/bluetooth2/bluedroid/BluetoothHALHelpers.h index af250e9dcb..cd1a1709ab 100644 --- a/dom/bluetooth2/bluedroid/BluetoothHALHelpers.h +++ b/dom/bluetooth2/bluedroid/BluetoothHALHelpers.h @@ -930,7 +930,7 @@ public: } private: - nsRefPtr mObj; + RefPtr mObj; void (Obj::*mMethod)(); }; @@ -956,7 +956,7 @@ public: } private: - nsRefPtr mObj; + RefPtr mObj; Res (Obj::*mMethod)(Arg1); Tin1 mArg1; }; @@ -989,7 +989,7 @@ public: } private: - nsRefPtr mObj; + RefPtr mObj; Res (Obj::*mMethod)(Arg1, Arg2, Arg3); Tin1 mArg1; Tin2 mArg2; @@ -1009,7 +1009,7 @@ public: static already_AddRefed Create(Res (ObjectType::*aMethod)()) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); return runnable.forget(); } @@ -1017,7 +1017,7 @@ public: static void Dispatch(Res (ObjectType::*aMethod)()) { - nsRefPtr runnable = Create(aMethod); + RefPtr runnable = Create(aMethod); if (!runnable) { BT_WARNING("BluetoothNotificationHALRunnable0::Create failed"); @@ -1067,7 +1067,7 @@ public: static already_AddRefed Create( Res (ObjectType::*aMethod)(Arg1), const T1& aIn1) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->ConvertAndSet(aIn1))) { return nullptr; @@ -1079,7 +1079,7 @@ public: static void Dispatch(Res (ObjectType::*aMethod)(Arg1), const T1& aIn1) { - nsRefPtr runnable = Create(aMethod, aIn1); + RefPtr runnable = Create(aMethod, aIn1); if (!runnable) { BT_WARNING("BluetoothNotificationHALRunnable1::Create failed"); @@ -1143,7 +1143,7 @@ public: static already_AddRefed Create( Res (ObjectType::*aMethod)(Arg1, Arg2), const T1& aIn1, const T2& aIn2) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2))) { return nullptr; @@ -1156,7 +1156,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2), const T1& aIn1, const T2& aIn2) { - nsRefPtr runnable = Create(aMethod, aIn1, aIn2); + RefPtr runnable = Create(aMethod, aIn1, aIn2); if (!runnable) { BT_WARNING("BluetoothNotificationHALRunnable2::Create failed"); @@ -1227,7 +1227,7 @@ public: Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3), const T1& aIn1, const T2& aIn2, const T3& aIn3) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2, aIn3))) { return nullptr; @@ -1240,7 +1240,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3), const T1& aIn1, const T2& aIn2, const T3& aIn3) { - nsRefPtr runnable = Create(aMethod, aIn1, aIn2, aIn3); + RefPtr runnable = Create(aMethod, aIn1, aIn2, aIn3); if (!runnable) { BT_WARNING("BluetoothNotificationHALRunnable3::Create failed"); @@ -1316,7 +1316,7 @@ public: Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4), const T1& aIn1, const T2& aIn2, const T3& aIn3, const T4& aIn4) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2, aIn3, aIn4))) { return nullptr; @@ -1329,7 +1329,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4), const T1& aIn1, const T2& aIn2, const T3& aIn3, const T4& aIn4) { - nsRefPtr runnable = Create(aMethod, aIn1, aIn2, aIn3, aIn4); + RefPtr runnable = Create(aMethod, aIn1, aIn2, aIn3, aIn4); if (!runnable) { BT_WARNING("BluetoothNotificationHALRunnable4::Create failed"); @@ -1413,7 +1413,7 @@ public: const T1& aIn1, const T2& aIn2, const T3& aIn3, const T4& aIn4, const T5& aIn5) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2, aIn3, aIn4, aIn5))) { return nullptr; @@ -1427,7 +1427,7 @@ public: const T1& aIn1, const T2& aIn2, const T3& aIn3, const T4& aIn4, const T5& aIn5) { - nsRefPtr runnable = Create(aMethod, + RefPtr runnable = Create(aMethod, aIn1, aIn2, aIn3, aIn4, aIn5); if (!runnable) { BT_WARNING("BluetoothNotificationHALRunnable5::Create failed"); diff --git a/dom/bluetooth2/bluedroid/BluetoothOppManager.cpp b/dom/bluetooth2/bluedroid/BluetoothOppManager.cpp index bcc164385f..e8c692b895 100644 --- a/dom/bluetooth2/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothOppManager.cpp @@ -140,7 +140,7 @@ public: if (numRead > 0) { sBluetoothOppManager->CheckPutFinal(numRead); - nsRefPtr task = + RefPtr task = new SendSocketDataTask((uint8_t*)buf.forget(), numRead); if (NS_FAILED(NS_DispatchToMainThread(task))) { BT_WARNING("Failed to dispatch to main thread!"); @@ -171,7 +171,7 @@ public: } private: - nsRefPtr mSocket; + RefPtr mSocket; }; BluetoothOppManager::BluetoothOppManager() : mConnected(false) @@ -350,7 +350,7 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr impl = aActor->GetBlobImpl(); + RefPtr impl = aActor->GetBlobImpl(); nsCOMPtr blob = new File(nullptr, impl); return SendFile(aDeviceAddress, blob.get()); @@ -1072,7 +1072,7 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage) } } - nsRefPtr task = new ReadFileTask(mInputStream, + RefPtr task = new ReadFileTask(mInputStream, mRemoteMaxPacketLength); rv = mReadFileThread->Dispatch(task, NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) { diff --git a/dom/bluetooth2/bluedroid/BluetoothOppManager.h b/dom/bluetooth2/bluedroid/BluetoothOppManager.h index 9fc0e5dff2..8eb8e88281 100644 --- a/dom/bluetooth2/bluedroid/BluetoothOppManager.h +++ b/dom/bluetooth2/bluedroid/BluetoothOppManager.h @@ -213,18 +213,18 @@ private: nsCOMPtr mOutputStream; nsCOMPtr mInputStream; nsCOMPtr mMountLock; - nsRefPtr mDsFile; - nsRefPtr mDummyDsFile; + RefPtr mDsFile; + RefPtr mDummyDsFile; // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mServerSocket must be null (and vice versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server sockets. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mServerSocket; + RefPtr mServerSocket; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth2/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth2/bluedroid/BluetoothServiceBluedroid.cpp index 018d7d2cbc..f686e12bff 100644 --- a/dom/bluetooth2/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothServiceBluedroid.cpp @@ -80,16 +80,16 @@ static InfallibleTArray sAdapterBondedAddressArray; static nsDataHashtable sPairingNameTable; static BluetoothInterface* sBtInterface; -static nsTArray > sControllerArray; +static nsTArray > sControllerArray; static InfallibleTArray sRemoteDevicesPack; static nsTArray sRequestedDeviceCountArray; -static nsTArray > sChangeAdapterStateRunnableArray; -static nsTArray > sChangeDiscoveryRunnableArray; -static nsTArray > sSetPropertyRunnableArray; -static nsTArray > sGetDeviceRunnableArray; -static nsTArray > sFetchUuidsRunnableArray; -static nsTArray > sBondingRunnableArray; -static nsTArray > sUnbondingRunnableArray; +static nsTArray > sChangeAdapterStateRunnableArray; +static nsTArray > sChangeDiscoveryRunnableArray; +static nsTArray > sSetPropertyRunnableArray; +static nsTArray > sGetDeviceRunnableArray; +static nsTArray > sFetchUuidsRunnableArray; +static nsTArray > sBondingRunnableArray; +static nsTArray > sUnbondingRunnableArray; /** * Static callback functions @@ -196,7 +196,7 @@ public: // Register all the bluedroid callbacks before enable() get called // It is required to register a2dp callbacks before a2dp media task starts up. // If any interface cannot be initialized, turn on bluetooth core anyway. - nsRefPtr res = + RefPtr res = new ProfileInitResultHandler(MOZ_ARRAY_LENGTH(sInitManager)); for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sInitManager); ++i) { @@ -690,7 +690,7 @@ public: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -726,7 +726,7 @@ public: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -1300,7 +1300,7 @@ BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState) BluetoothValue(props)); // Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF. - nsRefPtr res = + RefPtr res = new ProfileDeinitResultHandler(MOZ_ARRAY_LENGTH(sDeinitManager)); for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sDeinitManager); ++i) { diff --git a/dom/bluetooth2/bluedroid/BluetoothSocket.cpp b/dom/bluetooth2/bluedroid/BluetoothSocket.cpp index 71fb9bb74f..7efecc37e2 100644 --- a/dom/bluetooth2/bluedroid/BluetoothSocket.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothSocket.cpp @@ -295,7 +295,7 @@ DroidSocketImpl::Accept(int aFd) SetFd(aFd); mConnectionStatus = SOCKET_IS_CONNECTED; - nsRefPtr r = + RefPtr r = new SocketIOEventRunnable( this, SocketIOEventRunnable::CONNECT_SUCCESS); NS_DispatchToMainThread(r); @@ -439,7 +439,7 @@ DroidSocketImpl::OnSocketCanAcceptWithoutBlocking(int aFd) */ RemoveWatchers(READ_WATCHER); - nsRefPtr t = new AcceptRunnable(this, aFd); + RefPtr t = new AcceptRunnable(this, aFd); NS_DispatchToMainThread(t); } @@ -484,7 +484,7 @@ DroidSocketImpl::OnSocketCanConnectWithoutBlocking(int aFd) mConnectionStatus = SOCKET_IS_CONNECTED; - nsRefPtr r = + RefPtr r = new SocketIOEventRunnable( this, SocketIOEventRunnable::CONNECT_SUCCESS); NS_DispatchToMainThread(r); diff --git a/dom/bluetooth2/bluedroid/BluetoothSocketMessageWatcher.h b/dom/bluetooth2/bluedroid/BluetoothSocketMessageWatcher.h index 59270e63fd..34da72e701 100644 --- a/dom/bluetooth2/bluedroid/BluetoothSocketMessageWatcher.h +++ b/dom/bluetooth2/bluedroid/BluetoothSocketMessageWatcher.h @@ -75,7 +75,7 @@ private: int mClientFd; unsigned char mLen; uint8_t mBuf[MSG1_SIZE + MSG2_SIZE]; - nsRefPtr mRes; + RefPtr mRes; }; /* |SocketMessageWatcherTask| starts a SocketMessageWatcher diff --git a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp index 7c06c302a1..48eeaf6e21 100644 --- a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp @@ -252,7 +252,7 @@ BluetoothHfpManager::Init() nsresult rv = settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); NS_ENSURE_SUCCESS(rv, false); - nsRefPtr callback = new GetVolumeTask(); + RefPtr callback = new GetVolumeTask(); rv = settingsLock->Get(AUDIO_VOLUME_BT_SCO_ID, callback); NS_ENSURE_SUCCESS(rv, false); @@ -306,7 +306,7 @@ public: private: BluetoothHandsfreeInterface* mInterface; - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothHfpManager::InitResultHandlerRunnable final @@ -326,7 +326,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothHfpManager::OnErrorProfileResultHandlerRunnable final @@ -348,7 +348,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; nsresult mRv; }; @@ -360,7 +360,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!btInf)) { // If there's no backend interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -373,7 +373,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) if (NS_WARN_IF(!interface)) { // If there's no HFP interface, we dispatch a runnable // that calls the profile result handler. - nsRefPtr r = + RefPtr r = new OnErrorProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP OnError runnable"); @@ -381,7 +381,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) return; } - nsRefPtr res = + RefPtr res = new CleanupInitResultHandler(interface, aRes); if (sBluetoothHfpInterface) { @@ -390,7 +390,7 @@ BluetoothHfpManager::InitHfpInterface(BluetoothProfileResultHandler* aRes) } else { // If there's no HFP interface to cleanup first, we dispatch // a runnable that calls the profile result handler. - nsRefPtr r = new InitResultHandlerRunnable(res); + RefPtr r = new InitResultHandlerRunnable(res); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch HFP init runnable"); } @@ -440,7 +440,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; class BluetoothHfpManager::DeinitResultHandlerRunnable final @@ -460,7 +460,7 @@ public: } private: - nsRefPtr mRes; + RefPtr mRes; }; // static @@ -472,7 +472,7 @@ BluetoothHfpManager::DeinitHfpInterface(BluetoothProfileResultHandler* aRes) } else if (aRes) { // We dispatch a runnable here to make the profile resource handler // behave as if HFP was initialized. - nsRefPtr r = new DeinitResultHandlerRunnable(aRes); + RefPtr r = new DeinitResultHandlerRunnable(aRes); if (NS_FAILED(NS_DispatchToMainThread(r))) { BT_LOGR("Failed to dispatch cleanup-result-handler runnable"); } diff --git a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.h b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.h index 5fd106f8f1..386f049f0a 100644 --- a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.h +++ b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.h @@ -205,7 +205,7 @@ private: nsTArray mCurrentCallArray; nsAutoPtr mListener; - nsRefPtr mController; + RefPtr mController; // CDMA-specific variable Call mCdmaSecondCall; diff --git a/dom/bluetooth2/bluez/BluetoothA2dpManager.cpp b/dom/bluetooth2/bluez/BluetoothA2dpManager.cpp index cbf2abe9fc..14a6e564af 100644 --- a/dom/bluetooth2/bluez/BluetoothA2dpManager.cpp +++ b/dom/bluetooth2/bluez/BluetoothA2dpManager.cpp @@ -219,7 +219,7 @@ BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -234,7 +234,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); Reset(); diff --git a/dom/bluetooth2/bluez/BluetoothA2dpManager.h b/dom/bluetooth2/bluez/BluetoothA2dpManager.h index 4b27290ef9..7019ba5f53 100644 --- a/dom/bluetooth2/bluez/BluetoothA2dpManager.h +++ b/dom/bluetooth2/bluez/BluetoothA2dpManager.h @@ -65,7 +65,7 @@ private: void NotifyConnectionStatusChanged(); nsString mDeviceAddress; - nsRefPtr mController; + RefPtr mController; // A2DP data member bool mA2dpConnected; diff --git a/dom/bluetooth2/bluez/BluetoothDBusService.cpp b/dom/bluetooth2/bluez/BluetoothDBusService.cpp index 4e42c7812d..fdcc3112a1 100644 --- a/dom/bluetooth2/bluez/BluetoothDBusService.cpp +++ b/dom/bluetooth2/bluez/BluetoothDBusService.cpp @@ -342,7 +342,7 @@ static const int sWaitingForAdapterNameInterval = 1000; // unit: ms // // A queue for connect/disconnect request. See Bug 913372 for details. -static nsTArray > sControllerArray; +static nsTArray > sControllerArray; // // I/O-thread-only variables @@ -740,7 +740,7 @@ RunDBusCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable, // (technically) shouldn't hurt anything. However, on gonk, die. MOZ_ASSERT(!NS_IsMainThread()); // I/O thread #endif - nsRefPtr replyRunnable = + RefPtr replyRunnable = dont_AddRef(static_cast< BluetoothReplyRunnable* >(aBluetoothReplyRunnable)); MOZ_ASSERT(replyRunnable, "Callback reply runnable is null!"); @@ -1192,7 +1192,7 @@ public: } MOZ_ASSERT(i != properties.Length(), "failed to get device name"); - nsRefPtr task = + RefPtr task = new DistributeBluetoothSignalTask(mSignal); NS_DispatchToMainThread(task); } @@ -1227,7 +1227,7 @@ AppendDeviceName(BluetoothSignal& aSignal) nsString devicePath = arr[0].value().get_nsString(); - nsRefPtr handler = + RefPtr handler = new AppendDeviceNameReplyHandler(nsCString(DBUS_DEVICE_IFACE), devicePath, aSignal); @@ -1306,7 +1306,7 @@ public: private: nsString mDeviceAddress; bool mConfirm; - nsRefPtr mRunnable; + RefPtr mRunnable; }; static DBusHandlerResult @@ -1647,7 +1647,7 @@ private: return false; } - nsRefPtr handler = + RefPtr handler = new RegisterAgentReplyHandler(aAgentVTable); MOZ_ASSERT(!sAdapterPath.IsEmpty()); @@ -1686,7 +1686,7 @@ public: MOZ_ASSERT(sDBusConnection); MOZ_ASSERT(!sAdapterPath.IsEmpty()); - nsRefPtr handler = + RefPtr handler = new AddReservedServiceRecordsReplyHandler(); const dbus_uint32_t* services = sServices; @@ -1993,7 +1993,7 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData) } BluetoothSignal signal(signalName, signalPath, v); - nsRefPtr task; + RefPtr task; if (signalInterface.EqualsLiteral(DBUS_SINK_IFACE)) { task = new SinkPropertyChangedHandler(signal); } else if (signalInterface.EqualsLiteral(DBUS_CTL_IFACE)) { @@ -2032,7 +2032,7 @@ OnDefaultAdapterReply(DBusMessage* aReply, void* aData) sAdapterPath = v.get_nsString(); - nsRefPtr b = new PrepareAdapterRunnable(); + RefPtr b = new PrepareAdapterRunnable(); if (NS_FAILED(NS_DispatchToMainThread(b))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2063,7 +2063,7 @@ public: if (sDBusConnection) { BT_WARNING("DBus connection has already been established."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(true); + RefPtr runnable = new BluetoothService::ToggleBtAck(true); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2074,7 +2074,7 @@ public: if (!dbus_connection_add_filter(mConnection->GetConnection(), EventFilter, nullptr, nullptr)) { BT_WARNING("Cannot create DBus Event Filter for DBus Thread!"); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2089,7 +2089,7 @@ public: sDBusConnection = mConnection.forget(); - nsRefPtr runnable = + RefPtr runnable = new BluetoothService::ToggleBtAck(true); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); @@ -2129,7 +2129,7 @@ public: #ifdef MOZ_WIDGET_GONK if (!sBluedroid.Enable()) { BT_WARNING("Bluetooth not available."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2141,7 +2141,7 @@ public: nsresult rv = connection->EstablishDBusConnection(); if (NS_FAILED(rv)) { BT_WARNING("Failed to establish connection to BlueZ daemon"); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2178,7 +2178,7 @@ BluetoothDBusService::StartInternal(BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(!aRunnable); - nsRefPtr runnable = new StartBluetoothRunnable(); + RefPtr runnable = new StartBluetoothRunnable(); nsresult rv = DispatchToBtThread(runnable); if (NS_FAILED(rv)) { BT_WARNING("Failed to dispatch to BT thread!"); @@ -2206,7 +2206,7 @@ public: bool isEnabled = false; #endif - nsRefPtr runnable = + RefPtr runnable = new BluetoothService::ToggleBtAck(isEnabled); nsresult rv = NS_DispatchToMainThread(runnable); if (NS_FAILED(rv)) { @@ -2228,7 +2228,7 @@ public: if (!sDBusConnection) { BT_WARNING("DBus connection has not been established."); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); + RefPtr runnable = new BluetoothService::ToggleBtAck(false); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to main thread!"); } @@ -2269,7 +2269,7 @@ public: // We can only dispatch to the BT thread if we're on the main // thread. Thus we dispatch our runnable to the main thread // from where it will forward itself to the BT thread. - nsRefPtr runnable = new DisableBluetoothRunnable(); + RefPtr runnable = new DisableBluetoothRunnable(); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { BT_WARNING("Failed to dispatch to BT thread!"); } @@ -2308,7 +2308,7 @@ BluetoothDBusService::StopInternal(BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(!aRunnable); - nsRefPtr runnable = new StopBluetoothRunnable(); + RefPtr runnable = new StopBluetoothRunnable(); nsresult rv = DispatchToBtThread(runnable); if (NS_FAILED(rv)) { BT_WARNING("Failed to dispatch to BT thread!"); @@ -2376,7 +2376,7 @@ protected: mAdapterPath = value.get_nsString(); // Acquire another reference to this reply handler - nsRefPtr handler = this; + RefPtr handler = this; bool success = sDBusConnection->SendWithReply( DefaultAdapterPathReplyHandler::Callback, handler.get(), 1000, @@ -2421,7 +2421,7 @@ protected: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; nsString mAdapterPath; }; @@ -2439,7 +2439,7 @@ public: MOZ_ASSERT(!NS_IsMainThread()); // I/O thread MOZ_ASSERT(sDBusConnection); - nsRefPtr handler = + RefPtr handler = new DefaultAdapterPathReplyHandler(mRunnable); bool success = sDBusConnection->SendWithReply( @@ -2453,7 +2453,7 @@ public: } private: - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -2488,7 +2488,7 @@ OnSendDiscoveryMessageReply(DBusMessage *aReply, void *aData) errorStr.AssignLiteral("SendDiscovery failed"); } - nsRefPtr runnable = + RefPtr runnable = dont_AddRef(static_cast(aData)); DispatchBluetoothReply(runnable.get(), BluetoothValue(true), errorStr); @@ -2526,7 +2526,7 @@ public: private: const nsCString mMessageName; - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -2777,7 +2777,7 @@ protected: mObjectPath = GetObjectPathFromAddress(sAdapterPath, mDeviceAddresses[mProcessedDeviceAddresses]); - nsRefPtr handler = this; + RefPtr handler = this; bool success = sDBusConnection->SendWithReply( BluetoothArrayOfDevicePropertiesReplyHandler::Callback, @@ -2798,7 +2798,7 @@ private: const nsTArray mDeviceAddresses; nsTArray::size_type mProcessedDeviceAddresses; const FilterFunc mFilterFunc; - nsRefPtr mRunnable; + RefPtr mRunnable; BluetoothValue mValues; }; @@ -2823,8 +2823,8 @@ public: } private: - nsRefPtr mHandler; - nsRefPtr mRunnable; + RefPtr mHandler; + RefPtr mRunnable; }; nsresult @@ -2957,7 +2957,7 @@ public: private: BluetoothObjectType mType; const nsCString mName; - nsRefPtr mRunnable; + RefPtr mRunnable; }; class SetUInt32PropertyTask : public SetPropertyTask @@ -3116,7 +3116,7 @@ public: private: const nsCString mDeviceAddress; int mTimeout; - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -3177,7 +3177,7 @@ protected: errorStr.AssignLiteral("RemoveDevice failed"); } - nsRefPtr runnable = + RefPtr runnable = dont_AddRef( static_cast(aData)); @@ -3186,7 +3186,7 @@ protected: private: const nsString mDeviceAddress; - nsRefPtr mRunnable; + RefPtr mRunnable; }; nsresult @@ -3267,7 +3267,7 @@ public: private: const nsString mDeviceAddress; const nsCString mPinCode; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void @@ -3341,7 +3341,7 @@ public: private: nsString mDeviceAddress; uint32_t mPasskey; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void @@ -3565,7 +3565,7 @@ public: channel = dbus_returns_int32(aReply); } - nsRefPtr r = new OnGetServiceChannelRunnable(mDeviceAddress, + RefPtr r = new OnGetServiceChannelRunnable(mDeviceAddress, mServiceUUID, channel, mBluetoothProfileManager); @@ -3604,7 +3604,7 @@ public: nsString objectPath = GetObjectPathFromAddress(sAdapterPath, mDeviceAddress); - nsRefPtr handler = + RefPtr handler = new OnGetServiceChannelReplyHandler(mDeviceAddress, mServiceUUID, mBluetoothProfileManager); @@ -3656,7 +3656,7 @@ BluetoothDBusService::GetServiceChannel(const nsAString& aDeviceAddress, // Even though we are on the main thread already, we need to dispatch a // runnable here. OnGetServiceChannel needs mRunnable to be set, which // happens after GetServiceChannel returns. - nsRefPtr r = new OnGetServiceChannelRunnable(aDeviceAddress, + RefPtr r = new OnGetServiceChannelRunnable(aDeviceAddress, aServiceUUID, 1, aManager); @@ -3707,7 +3707,7 @@ protected: { MOZ_ASSERT(!NS_IsMainThread()); // I/O thread - nsRefPtr r( + RefPtr r( static_cast(aData)); NS_DispatchToMainThread(r); } @@ -3937,7 +3937,7 @@ private: int64_t mMediaNumber; int64_t mTotalMediaCount; int64_t mDuration; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void @@ -4068,7 +4068,7 @@ private: int64_t mDuration; int64_t mPosition; ControlPlayStatus mPlayStatus; - nsRefPtr mRunnable; + RefPtr mRunnable; }; void diff --git a/dom/bluetooth2/bluez/BluetoothHfpManager.cpp b/dom/bluetooth2/bluez/BluetoothHfpManager.cpp index ea6a98dbaf..bf9c16bf07 100644 --- a/dom/bluetooth2/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth2/bluez/BluetoothHfpManager.cpp @@ -451,7 +451,7 @@ BluetoothHfpManager::Init() nsresult rv = settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); NS_ENSURE_SUCCESS(rv, false); - nsRefPtr callback = new GetVolumeTask(); + RefPtr callback = new GetVolumeTask(); rv = settingsLock->Get(AUDIO_VOLUME_BT_SCO_ID, callback); NS_ENSURE_SUCCESS(rv, false); @@ -1468,7 +1468,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex, } mCurrentCallArray[aCallIndex].mNumber = aNumber; - nsRefPtr sendRingTask; + RefPtr sendRingTask; nsString address; switch (aCallState) { @@ -2037,7 +2037,7 @@ BluetoothHfpManager::OnConnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } @@ -2056,7 +2056,7 @@ BluetoothHfpManager::OnDisconnect(const nsAString& aErrorStr) */ NS_ENSURE_TRUE_VOID(mController); - nsRefPtr controller = mController.forget(); + RefPtr controller = mController.forget(); controller->NotifyCompletion(aErrorStr); } diff --git a/dom/bluetooth2/bluez/BluetoothHfpManager.h b/dom/bluetooth2/bluez/BluetoothHfpManager.h index 15e86511e1..bd3aae69cf 100644 --- a/dom/bluetooth2/bluez/BluetoothHfpManager.h +++ b/dom/bluetooth2/bluez/BluetoothHfpManager.h @@ -210,21 +210,21 @@ private: nsTArray mCurrentCallArray; nsAutoPtr mListener; #endif - nsRefPtr mController; - nsRefPtr mScoRunnable; + RefPtr mController; + RefPtr mScoRunnable; // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mHandsfreeSocket and mHeadsetSocket must be null (and // vice versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server sockets. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mHandsfreeSocket; - nsRefPtr mHeadsetSocket; - nsRefPtr mScoSocket; + RefPtr mHandsfreeSocket; + RefPtr mHeadsetSocket; + RefPtr mScoSocket; mozilla::ipc::SocketConnectionStatus mScoSocketStatus; #ifdef MOZ_B2G_RIL diff --git a/dom/bluetooth2/bluez/BluetoothOppManager.cpp b/dom/bluetooth2/bluez/BluetoothOppManager.cpp index a77d3cbc48..b0c5ba67d3 100644 --- a/dom/bluetooth2/bluez/BluetoothOppManager.cpp +++ b/dom/bluetooth2/bluez/BluetoothOppManager.cpp @@ -146,7 +146,7 @@ public: if (numRead > 0) { sBluetoothOppManager->CheckPutFinal(numRead); - nsRefPtr task = + RefPtr task = new SendSocketDataTask((uint8_t*)buf.forget(), numRead); if (NS_FAILED(NS_DispatchToMainThread(task))) { BT_WARNING("Failed to dispatch to main thread!"); @@ -181,7 +181,7 @@ public: } private: - nsRefPtr mSocket; + RefPtr mSocket; }; BluetoothOppManager::BluetoothOppManager() : mConnected(false) @@ -372,7 +372,7 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr impl = aActor->GetBlobImpl(); + RefPtr impl = aActor->GetBlobImpl(); nsCOMPtr blob = new File(nullptr, impl); return SendFile(aDeviceAddress, blob.get()); @@ -1093,7 +1093,7 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage) } } - nsRefPtr task = new ReadFileTask(mInputStream, + RefPtr task = new ReadFileTask(mInputStream, mRemoteMaxPacketLength); rv = mReadFileThread->Dispatch(task, NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) { diff --git a/dom/bluetooth2/bluez/BluetoothOppManager.h b/dom/bluetooth2/bluez/BluetoothOppManager.h index cbe4937907..2ee2ca3c07 100644 --- a/dom/bluetooth2/bluez/BluetoothOppManager.h +++ b/dom/bluetooth2/bluez/BluetoothOppManager.h @@ -209,20 +209,20 @@ private: nsCOMPtr mOutputStream; nsCOMPtr mInputStream; nsCOMPtr mMountLock; - nsRefPtr mDsFile; - nsRefPtr mDummyDsFile; + RefPtr mDsFile; + RefPtr mDummyDsFile; // If a connection has been established, mSocket will be the socket // communicating with the remote socket. We maintain the invariant that if // mSocket is non-null, mRfcommSocket and mL2capSocket must be null (and vice // versa). - nsRefPtr mSocket; + RefPtr mSocket; // Server sockets. Once an inbound connection is established, it will hand // over the ownership to mSocket, and get a new server socket while Listen() // is called. - nsRefPtr mRfcommSocket; - nsRefPtr mL2capSocket; + RefPtr mRfcommSocket; + RefPtr mL2capSocket; // This holds the time when OPP manager fail to get service channel and // prepare to refresh SDP records. diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp index 8aba8cad40..2618cbc14f 100644 --- a/dom/broadcastchannel/BroadcastChannel.cpp +++ b/dom/broadcastchannel/BroadcastChannel.cpp @@ -173,7 +173,7 @@ public: PBackgroundChild* backgroundManager = mActor->Manager(); MOZ_ASSERT(backgroundManager); - const nsTArray>& blobImpls = mData->BlobImpls(); + const nsTArray>& blobImpls = mData->BlobImpls(); if (!blobImpls.IsEmpty()) { message.blobsChild().SetCapacity(blobImpls.Length()); @@ -201,8 +201,8 @@ public: private: ~BCPostMessageRunnable() {} - nsRefPtr mActor; - nsRefPtr mData; + RefPtr mActor; + RefPtr mData; }; NS_IMPL_ISUPPORTS(BCPostMessageRunnable, nsICancelableRunnable, nsIRunnable) @@ -233,7 +233,7 @@ public: private: ~CloseRunnable() {} - nsRefPtr mBC; + RefPtr mBC; }; NS_IMPL_ISUPPORTS(CloseRunnable, nsICancelableRunnable, nsIRunnable) @@ -267,7 +267,7 @@ public: private: ~TeardownRunnable() {} - nsRefPtr mActor; + RefPtr mActor; }; NS_IMPL_ISUPPORTS(TeardownRunnable, nsICancelableRunnable, nsIRunnable) @@ -336,7 +336,7 @@ BroadcastChannel::IsEnabled(JSContext* aCx, JSObject* aGlobal) MOZ_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); - nsRefPtr runnable = + RefPtr runnable = new PrefEnabledRunnable(workerPrivate); runnable->Dispatch(workerPrivate->GetJSContext()); @@ -433,7 +433,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal, workerPrivate = GetWorkerPrivateFromContext(cx); MOZ_ASSERT(workerPrivate); - nsRefPtr runnable = + RefPtr runnable = new InitializeRunnable(workerPrivate, origin, principalInfo, privateBrowsing, aRv); runnable->Dispatch(cx); @@ -443,7 +443,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr bc = + RefPtr bc = new BroadcastChannel(window, principalInfo, origin, aChannel, privateBrowsing); @@ -496,7 +496,7 @@ BroadcastChannel::PostMessageInternal(JSContext* aCx, JS::Handle aMessage, ErrorResult& aRv) { - nsRefPtr data = new BroadcastChannelMessage(); + RefPtr data = new BroadcastChannelMessage(); data->Write(aCx, aMessage, aRv); if (NS_WARN_IF(aRv.Failed())) { @@ -510,7 +510,7 @@ void BroadcastChannel::PostMessageData(BroadcastChannelMessage* aData) { if (mActor) { - nsRefPtr runnable = + RefPtr runnable = new BCPostMessageRunnable(mActor, aData); if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { @@ -536,7 +536,7 @@ BroadcastChannel::Close() // StateClosed and we shutdown the actor asynchrounsly. mState = StateClosed; - nsRefPtr runnable = new CloseRunnable(this); + RefPtr runnable = new CloseRunnable(this); if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { NS_WARNING("Failed to dispatch to the current thread!"); @@ -597,7 +597,7 @@ BroadcastChannel::Shutdown() if (mActor) { mActor->SetParent(nullptr); - nsRefPtr runnable = new TeardownRunnable(mActor); + RefPtr runnable = new TeardownRunnable(mActor); NS_DispatchToCurrentThread(runnable); mActor = nullptr; diff --git a/dom/broadcastchannel/BroadcastChannel.h b/dom/broadcastchannel/BroadcastChannel.h index 7da0f4af81..dc0d84adf7 100644 --- a/dom/broadcastchannel/BroadcastChannel.h +++ b/dom/broadcastchannel/BroadcastChannel.h @@ -12,7 +12,7 @@ #include "nsIIPCBackgroundChildCreateCallback.h" #include "nsIObserver.h" #include "nsTArray.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" class nsPIDOMWindow; @@ -110,8 +110,8 @@ private: return mIsKeptAlive; } - nsRefPtr mActor; - nsTArray> mPendingMessages; + RefPtr mActor; + nsTArray> mPendingMessages; nsAutoPtr mWorkerFeature; diff --git a/dom/broadcastchannel/BroadcastChannelChild.cpp b/dom/broadcastchannel/BroadcastChannelChild.cpp index f19c01ff18..a32ae53587 100644 --- a/dom/broadcastchannel/BroadcastChannelChild.cpp +++ b/dom/broadcastchannel/BroadcastChannelChild.cpp @@ -42,12 +42,12 @@ BroadcastChannelChild::RecvNotify(const ClonedMessageData& aData) { // Make sure to retrieve all blobs from the message before returning to avoid // leaking their actors. - nsTArray> blobs; + nsTArray> blobs; if (!aData.blobsChild().IsEmpty()) { blobs.SetCapacity(aData.blobsChild().Length()); for (uint32_t i = 0, len = aData.blobsChild().Length(); i < len; ++i) { - nsRefPtr impl = + RefPtr impl = static_cast(aData.blobsChild()[i])->GetBlobImpl(); blobs.AppendElement(impl); @@ -108,7 +108,7 @@ BroadcastChannelChild::RecvNotify(const ClonedMessageData& aData) init.mData = value; ErrorResult rv; - nsRefPtr event = + RefPtr event = MessageEvent::Constructor(mBC, NS_LITERAL_STRING("message"), init, rv); if (rv.Failed()) { NS_WARNING("Failed to create a MessageEvent object."); diff --git a/dom/broadcastchannel/BroadcastChannelParent.cpp b/dom/broadcastchannel/BroadcastChannelParent.cpp index 296f1470f1..e0bcbd83ac 100644 --- a/dom/broadcastchannel/BroadcastChannelParent.cpp +++ b/dom/broadcastchannel/BroadcastChannelParent.cpp @@ -93,7 +93,7 @@ BroadcastChannelParent::CheckAndDeliver(const ClonedMessageData& aData, // Ricreate the BlobParent for this new message. for (uint32_t i = 0, len = newData.blobsParent().Length(); i < len; ++i) { - nsRefPtr impl = + RefPtr impl = static_cast(newData.blobsParent()[i])->GetBlobImpl(); PBlobParent* blobParent = diff --git a/dom/broadcastchannel/BroadcastChannelParent.h b/dom/broadcastchannel/BroadcastChannelParent.h index 9b9cb76e09..f9019aa9e4 100644 --- a/dom/broadcastchannel/BroadcastChannelParent.h +++ b/dom/broadcastchannel/BroadcastChannelParent.h @@ -45,7 +45,7 @@ private: virtual void ActorDestroy(ActorDestroyReason aWhy) override; - nsRefPtr mService; + RefPtr mService; nsCString mOrigin; nsString mChannel; bool mPrivateBrowsing; diff --git a/dom/broadcastchannel/BroadcastChannelService.cpp b/dom/broadcastchannel/BroadcastChannelService.cpp index 988530c70e..d0a3b754fd 100644 --- a/dom/broadcastchannel/BroadcastChannelService.cpp +++ b/dom/broadcastchannel/BroadcastChannelService.cpp @@ -50,7 +50,7 @@ BroadcastChannelService::GetOrCreate() { AssertIsOnBackgroundThread(); - nsRefPtr instance = sInstance; + RefPtr instance = sInstance; if (!instance) { instance = new BroadcastChannelService(); } @@ -89,12 +89,12 @@ BroadcastChannelService::PostMessage(BroadcastChannelParent* aParent, MOZ_ASSERT(mAgents.Contains(aParent)); // We need to keep the array alive for the life-time of this operation. - nsTArray> blobs; + nsTArray> blobs; if (!aData.blobsParent().IsEmpty()) { blobs.SetCapacity(aData.blobsParent().Length()); for (uint32_t i = 0, len = aData.blobsParent().Length(); i < len; ++i) { - nsRefPtr impl = + RefPtr impl = static_cast(aData.blobsParent()[i])->GetBlobImpl(); MOZ_ASSERT(impl); blobs.AppendElement(impl); diff --git a/dom/browser-element/BrowserElementAudioChannel.cpp b/dom/browser-element/BrowserElementAudioChannel.cpp index 955f1deb0f..8aa5f73183 100644 --- a/dom/browser-element/BrowserElementAudioChannel.cpp +++ b/dom/browser-element/BrowserElementAudioChannel.cpp @@ -52,7 +52,7 @@ BrowserElementAudioChannel::Create(nsPIDOMWindow* aWindow, AudioChannel aAudioChannel, ErrorResult& aRv) { - nsRefPtr ac = + RefPtr ac = new BrowserElementAudioChannel(aWindow, aFrameLoader, aAPI, aAudioChannel); aRv = ac->Initialize(); @@ -171,7 +171,7 @@ class BaseRunnable : public nsRunnable protected: nsCOMPtr mParentWindow; nsCOMPtr mFrameWindow; - nsRefPtr mRequest; + RefPtr mRequest; AudioChannel mAudioChannel; virtual void DoWork(AudioChannelService* aService, @@ -188,7 +188,7 @@ public: NS_IMETHODIMP Run() override { - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); MOZ_ASSERT(service); AutoJSAPI jsapi; @@ -321,7 +321,7 @@ BrowserElementAudioChannel::GetVolume(ErrorResult& aRv) return request.forget().downcast(); } - nsRefPtr domRequest = new DOMRequest(GetOwner()); + RefPtr domRequest = new DOMRequest(GetOwner()); nsCOMPtr runnable = new GetVolumeRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel); @@ -348,12 +348,12 @@ BrowserElementAudioChannel::SetVolume(float aVolume, ErrorResult& aRv) return request.forget().downcast(); } - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); MOZ_ASSERT(service); service->SetAudioChannelVolume(mFrameWindow, mAudioChannel, aVolume); - nsRefPtr domRequest = new DOMRequest(GetOwner()); + RefPtr domRequest = new DOMRequest(GetOwner()); nsCOMPtr runnable = new FireSuccessRunnable(GetOwner(), mFrameWindow, domRequest, @@ -380,7 +380,7 @@ BrowserElementAudioChannel::GetMuted(ErrorResult& aRv) return request.forget().downcast(); } - nsRefPtr domRequest = new DOMRequest(GetOwner()); + RefPtr domRequest = new DOMRequest(GetOwner()); nsCOMPtr runnable = new GetMutedRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel); @@ -407,12 +407,12 @@ BrowserElementAudioChannel::SetMuted(bool aMuted, ErrorResult& aRv) return request.forget().downcast(); } - nsRefPtr service = AudioChannelService::GetOrCreate(); + RefPtr service = AudioChannelService::GetOrCreate(); MOZ_ASSERT(service); service->SetAudioChannelMuted(mFrameWindow, mAudioChannel, aMuted); - nsRefPtr domRequest = new DOMRequest(GetOwner()); + RefPtr domRequest = new DOMRequest(GetOwner()); nsCOMPtr runnable = new FireSuccessRunnable(GetOwner(), mFrameWindow, domRequest, @@ -429,7 +429,7 @@ BrowserElementAudioChannel::IsActive(ErrorResult& aRv) AssertIsInMainProcess(); if (mState != eStateUnknown) { - nsRefPtr domRequest = new DOMRequest(GetOwner()); + RefPtr domRequest = new DOMRequest(GetOwner()); nsCOMPtr runnable = new IsActiveRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel, @@ -450,7 +450,7 @@ BrowserElementAudioChannel::IsActive(ErrorResult& aRv) return request.forget().downcast(); } - nsRefPtr domRequest = new DOMRequest(GetOwner()); + RefPtr domRequest = new DOMRequest(GetOwner()); nsCOMPtr runnable = new IsActiveRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel); diff --git a/dom/browser-element/BrowserElementParent.cpp b/dom/browser-element/BrowserElementParent.cpp index 5d25537da9..d41ca73a5f 100644 --- a/dom/browser-element/BrowserElementParent.cpp +++ b/dom/browser-element/BrowserElementParent.cpp @@ -40,13 +40,13 @@ CreateIframe(Element* aOpenerFrameElement, const nsAString& aName, bool aRemote) nsNodeInfoManager *nodeInfoManager = aOpenerFrameElement->OwnerDoc()->NodeInfoManager(); - nsRefPtr nodeInfo = + RefPtr nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::iframe, /* aPrefix = */ nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE); - nsRefPtr popupFrameElement = + RefPtr popupFrameElement = static_cast( NS_NewHTMLIFrameElement(nodeInfo.forget(), mozilla::dom::NOT_FROM_PARSER)); @@ -97,12 +97,12 @@ DispatchCustomDOMEvent(Element* aFrameElement, const nsAString& aEventName, { NS_ENSURE_TRUE(aFrameElement, false); nsIPresShell *shell = aFrameElement->OwnerDoc()->GetShell(); - nsRefPtr presContext; + RefPtr presContext; if (shell) { presContext = shell->GetPresContext(); } - nsRefPtr event = + RefPtr event = NS_NewDOMCustomEvent(aFrameElement, presContext, nullptr); ErrorResult res; @@ -209,7 +209,7 @@ BrowserElementParent::OpenWindowOOP(TabParent* aOpenerTabParent, nsCOMPtr openerFrameElement = aOpenerTabParent->GetOwnerElement(); NS_ENSURE_TRUE(openerFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED); - nsRefPtr popupFrameElement = + RefPtr popupFrameElement = CreateIframe(openerFrameElement, aName, /* aRemote = */ true); // Normally an diff --git a/dom/workers/test/serviceworkers/fetch/hsts/hsts_test.js b/dom/workers/test/serviceworkers/fetch/hsts/hsts_test.js new file mode 100644 index 0000000000..ab54164ed2 --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/hsts/hsts_test.js @@ -0,0 +1,11 @@ +self.addEventListener("fetch", function(event) { + if (event.request.url.indexOf("index.html") >= 0) { + event.respondWith(fetch("realindex.html")); + } else if (event.request.url.indexOf("image-20px.png") >= 0) { + if (event.request.url.indexOf("https://") == 0) { + event.respondWith(fetch("image-40px.png")); + } else { + event.respondWith(Response.error()); + } + } +}); diff --git a/dom/workers/test/serviceworkers/fetch/hsts/image-20px.png b/dom/workers/test/serviceworkers/fetch/hsts/image-20px.png new file mode 100644 index 0000000000000000000000000000000000000000..ae6a8a6b88403959c75efce931b0bf4293efc956 GIT binary patch literal 87 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE;=oTrOph(&MmkMjpU%%3$Q@ydZf kW_Mm0(}F7pCT1xxd^;`67yW*X5Ktw9r>mdKI;Vst0D!m{_W%F@ literal 0 HcmV?d00001 diff --git a/dom/workers/test/serviceworkers/fetch/hsts/image-40px.png b/dom/workers/test/serviceworkers/fetch/hsts/image-40px.png new file mode 100644 index 0000000000000000000000000000000000000000..fe391dc8a2d797360651fe8cf77161a3fc891194 GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEPM$7~ArY-_&utWBP~c%$*z@jL z8rOSWjTbX5i}z1sXJLKaupmKJKx7SbQ&Xu!zy>}Ju4{~r2dxw|BEXUllDQ? + diff --git a/dom/workers/test/serviceworkers/fetch/hsts/realindex.html b/dom/workers/test/serviceworkers/fetch/hsts/realindex.html new file mode 100644 index 0000000000..aaa255aad3 --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/hsts/realindex.html @@ -0,0 +1,4 @@ + + diff --git a/dom/workers/test/serviceworkers/fetch/hsts/register.html b/dom/workers/test/serviceworkers/fetch/hsts/register.html new file mode 100644 index 0000000000..bcdc146aec --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/hsts/register.html @@ -0,0 +1,14 @@ + + diff --git a/dom/workers/test/serviceworkers/fetch/hsts/register.html^headers^ b/dom/workers/test/serviceworkers/fetch/hsts/register.html^headers^ new file mode 100644 index 0000000000..a46bf65bd9 --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/hsts/register.html^headers^ @@ -0,0 +1,2 @@ +Cache-Control: no-cache +Strict-Transport-Security: max-age=60 diff --git a/dom/workers/test/serviceworkers/fetch/hsts/unregister.html b/dom/workers/test/serviceworkers/fetch/hsts/unregister.html new file mode 100644 index 0000000000..1f13508fa7 --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/hsts/unregister.html @@ -0,0 +1,12 @@ + + diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini index aaa955898c..baa737cd1b 100644 --- a/dom/workers/test/serviceworkers/mochitest.ini +++ b/dom/workers/test/serviceworkers/mochitest.ini @@ -42,6 +42,15 @@ support-files = fetch/context/sharedworker.js fetch/context/parentsharedworker.js fetch/context/xml.xml + fetch/hsts/hsts_test.js + fetch/hsts/embedder.html + fetch/hsts/image.html + fetch/hsts/image-20px.png + fetch/hsts/image-40px.png + fetch/hsts/realindex.html + fetch/hsts/register.html + fetch/hsts/register.html^headers^ + fetch/hsts/unregister.html fetch/https/index.html fetch/https/register.html fetch/https/unregister.html @@ -254,3 +263,5 @@ skip-if = toolkit == "android" || toolkit == "gonk" [test_eventsource_intercept.html] [test_not_intercept_plugin.html] [test_file_blob_upload.html] +[test_hsts_upgrade_intercept.html] +skip-if = e10s # Bug 1214305 diff --git a/dom/workers/test/serviceworkers/test_hsts_upgrade_intercept.html b/dom/workers/test/serviceworkers/test_hsts_upgrade_intercept.html new file mode 100644 index 0000000000..ea2c1fe8ef --- /dev/null +++ b/dom/workers/test/serviceworkers/test_hsts_upgrade_intercept.html @@ -0,0 +1,66 @@ + + + + + Test that an HSTS upgraded request can be intercepted by a service worker + + + + +

+
+ +
+

+
+
+
+
diff --git a/dom/workers/test/sharedWorker_lifetime.js b/dom/workers/test/sharedWorker_lifetime.js
new file mode 100644
index 0000000000..3d9a837bba
--- /dev/null
+++ b/dom/workers/test/sharedWorker_lifetime.js
@@ -0,0 +1,5 @@
+onconnect = function(e) {
+  setTimeout(function() {
+    e.ports[0].postMessage("Still alive!");
+  }, 500);
+}
diff --git a/dom/workers/test/test_sharedWorker_lifetime.html b/dom/workers/test/test_sharedWorker_lifetime.html
new file mode 100644
index 0000000000..26bb78836c
--- /dev/null
+++ b/dom/workers/test/test_sharedWorker_lifetime.html
@@ -0,0 +1,32 @@
+
+
+
+  
+    Test for MessagePort and SharedWorkers
+    
+    
+  
+  
+    
+  
+
diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp
index 447dd1fda3..2d7a8f1e9c 100644
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -217,7 +217,7 @@ nsBindingManager::RemovedFromDocumentInternal(nsIContent* aContent,
 {
   NS_PRECONDITION(aOldDocument != nullptr, "no old document");
 
-  nsRefPtr binding = aContent->GetXBLBinding();
+  RefPtr binding = aContent->GetXBLBinding();
   if (binding) {
     // The binding manager may have been destroyed before a runnable
     // has had a chance to reach this point. If so, we bail out on calling
@@ -272,7 +272,7 @@ nsresult
 nsBindingManager::ClearBinding(nsIContent* aContent)
 {
   // Hold a ref to the binding so it won't die when we remove it from our table
-  nsRefPtr binding =
+  RefPtr binding =
     aContent ? aContent->GetXBLBinding() : nullptr;
 
   if (!binding) {
@@ -320,7 +320,7 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc,
     return NS_ERROR_FAILURE;
 
   // Load the binding doc.
-  nsRefPtr info;
+  RefPtr info;
   xblService->LoadBindingDocumentInfo(nullptr, aBoundDoc, aURL,
                                       aOriginPrincipal, true,
                                       getter_AddRefs(info));
@@ -374,7 +374,7 @@ nsBindingManager::PostProcessAttachedQueueEvent()
 void
 nsBindingManager::PostPAQEventCallback(nsITimer* aTimer, void* aClosure)
 {
-  nsRefPtr mgr = 
+  RefPtr mgr = 
     already_AddRefed(static_cast(aClosure));
   mgr->PostProcessAttachedQueueEvent();
   NS_RELEASE(aTimer);
@@ -431,7 +431,7 @@ nsBindingManager::ProcessAttachedQueue(uint32_t aSkipSize)
   // Excute constructors. Do this from high index to low
   while (mAttachedStack.Length() > aSkipSize) {
     uint32_t lastItem = mAttachedStack.Length() - 1;
-    nsRefPtr binding = mAttachedStack.ElementAt(lastItem);
+    RefPtr binding = mAttachedStack.ElementAt(lastItem);
     mAttachedStack.RemoveElementAt(lastItem);
     if (binding) {
       binding->ExecuteAttachedHandler();
diff --git a/dom/xbl/nsBindingManager.h b/dom/xbl/nsBindingManager.h
index 732aeb2641..805d7b7240 100644
--- a/dom/xbl/nsBindingManager.h
+++ b/dom/xbl/nsBindingManager.h
@@ -28,7 +28,7 @@ class nsXBLDocumentInfo;
 class nsIStreamListener;
 class nsXBLBinding;
 template class nsRefPtr;
-typedef nsTArray > nsBindingList;
+typedef nsTArray > nsBindingList;
 class nsIPrincipal;
 class nsITimer;
 
@@ -199,7 +199,7 @@ protected:
 
   // Our posted event to process the attached queue, if any
   friend class nsRunnableMethod;
-  nsRefPtr< nsRunnableMethod > mProcessAttachedQueueEvent;
+  RefPtr< nsRunnableMethod > mProcessAttachedQueueEvent;
 
   // Our document.  This is a weak ref; the document owns us
   nsIDocument* mDocument;
diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp
index 0b563864ac..849214cebb 100644
--- a/dom/xbl/nsXBLBinding.cpp
+++ b/dom/xbl/nsXBLBinding.cpp
@@ -759,7 +759,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
             continue;
           }
 
-          nsRefPtr docInfo =
+          RefPtr docInfo =
             static_cast(::JS_GetPrivate(proto));
           if (!docInfo) {
             // Not the proto we seek
diff --git a/dom/xbl/nsXBLBinding.h b/dom/xbl/nsXBLBinding.h
index 9780025c08..97a9f50e64 100644
--- a/dom/xbl/nsXBLBinding.h
+++ b/dom/xbl/nsXBLBinding.h
@@ -166,7 +166,7 @@ protected:
 
   nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
   nsCOMPtr mContent; // Strong. Our anonymous content stays around with us.
-  nsRefPtr mNextBinding; // Strong. The derived binding owns the base class bindings.
+  RefPtr mNextBinding; // Strong. The derived binding owns the base class bindings.
 
   nsIContent* mBoundElement; // [WEAK] We have a reference, but we don't own it.
 
@@ -176,9 +176,9 @@ protected:
   // attribute. These points must be up-to-date with respect to their parent's
   // children, even if their parent has another binding attached to it,
   // preventing us from rendering their contents directly.
-  nsRefPtr mDefaultInsertionPoint;
-  nsTArray > mInsertionPoints;
-  nsRefPtr mAnonymousContentList;
+  RefPtr mDefaultInsertionPoint;
+  nsTArray > mInsertionPoints;
+  RefPtr mAnonymousContentList;
 
   mozilla::dom::XBLChildrenElement* FindInsertionPointForInternal(nsIContent* aChild);
 };
diff --git a/dom/xbl/nsXBLContentSink.cpp b/dom/xbl/nsXBLContentSink.cpp
index efa675c6ee..4d5c9fb74f 100644
--- a/dom/xbl/nsXBLContentSink.cpp
+++ b/dom/xbl/nsXBLContentSink.cpp
@@ -39,7 +39,7 @@ NS_NewXBLContentSink(nsIXMLContentSink** aResult,
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
-  nsRefPtr it = new nsXBLContentSink();
+  RefPtr it = new nsXBLContentSink();
   nsresult rv = it->Init(aDoc, aURI, aContainer);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -389,7 +389,7 @@ nsXBLContentSink::OnOpenContainer(const char16_t **aAtts,
     ENSURE_XBL_STATE(mState == eXBL_InDocument);
 
     NS_ASSERTION(mDocument, "Must have a document!");
-    nsRefPtr info = new nsXBLDocumentInfo(mDocument);
+    RefPtr info = new nsXBLDocumentInfo(mDocument);
 
     // We keep a weak ref. We're creating a cycle between doc/binding manager/doc info.
     mDocInfo = info;
@@ -867,7 +867,7 @@ nsXBLContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
   // Note that this needs to match the code in nsXBLPrototypeBinding::ReadContentNode.
 
   *aAppendContent = true;
-  nsRefPtr prototype = new nsXULPrototypeElement();
+  RefPtr prototype = new nsXULPrototypeElement();
 
   prototype->mNodeInfo = aNodeInfo;
 
@@ -921,7 +921,7 @@ nsXBLContentSink::AddAttributesToXULPrototype(const char16_t **aAtts,
       attrs[i].mName.SetTo(localName);
     }
     else {
-      nsRefPtr ni;
+      RefPtr ni;
       ni = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                          nsIDOMNode::ATTRIBUTE_NODE);
       attrs[i].mName.SetTo(ni);
diff --git a/dom/xbl/nsXBLDocumentInfo.cpp b/dom/xbl/nsXBLDocumentInfo.cpp
index 6c7f834c84..600b32201a 100644
--- a/dom/xbl/nsXBLDocumentInfo.cpp
+++ b/dom/xbl/nsXBLDocumentInfo.cpp
@@ -248,7 +248,7 @@ nsXBLDocumentInfo::ReadPrototypeBindings(nsIURI* aURI, nsXBLDocumentInfo** aDocI
 
   nsCOMPtr doc = do_QueryInterface(domdoc);
   NS_ASSERTION(doc, "Must have a document!");
-  nsRefPtr docInfo = new nsXBLDocumentInfo(doc);
+  RefPtr docInfo = new nsXBLDocumentInfo(doc);
 
   while (1) {
     uint8_t flags;
diff --git a/dom/xbl/nsXBLEventHandler.cpp b/dom/xbl/nsXBLEventHandler.cpp
index d8844bc0d3..9833519266 100644
--- a/dom/xbl/nsXBLEventHandler.cpp
+++ b/dom/xbl/nsXBLEventHandler.cpp
@@ -165,7 +165,7 @@ already_AddRefed
 NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
                       nsIAtom* aEventType)
 {
-  nsRefPtr handler;
+  RefPtr handler;
 
   switch (nsContentUtils::GetEventClassID(nsDependentAtomString(aEventType))) {
     case eDragEventClass:
diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp
index 3557068434..14093d8ccc 100644
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -395,7 +395,7 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
           nsAutoString value;
           aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
           if (!value.IsEmpty()) {
-            nsRefPtr textContent =
+            RefPtr textContent =
               new nsTextNode(realElement->NodeInfo()->NodeInfoManager());
 
             textContent->SetText(value, true);
@@ -549,7 +549,7 @@ SetAttrs(nsISupports* aKey, nsXBLAttributeEntry* aEntry, void* aClosure)
                                              kNameSpaceID_XUL) &&
              dst == nsGkAtoms::value && !value.IsEmpty())) {
 
-          nsRefPtr textContent =
+          RefPtr textContent =
             new nsTextNode(realElement->NodeInfo()->NodeInfoManager());
 
           textContent->SetText(value, false);
@@ -804,7 +804,7 @@ nsXBLPrototypeBinding::CreateKeyHandlers()
       }
 
       if (i == count) {
-        nsRefPtr newHandler =
+        RefPtr newHandler =
           new nsXBLKeyEventHandler(eventAtom, phase, type);
         mKeyHandlers.AppendObject(newHandler);
         handler = newHandler;
@@ -1245,7 +1245,7 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream,
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr tagAtom = do_GetAtom(tag);
-  nsRefPtr nodeInfo =
+  RefPtr nodeInfo =
     aNim->GetNodeInfo(tagAtom, prefixAtom, namespaceID, nsIDOMNode::ELEMENT_NODE);
 
   uint32_t attrCount;
@@ -1258,7 +1258,7 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream,
   if (namespaceID == kNameSpaceID_XUL) {
     nsIURI* documentURI = aDocument->GetDocumentURI();
 
-    nsRefPtr prototype = new nsXULPrototypeElement();
+    RefPtr prototype = new nsXULPrototypeElement();
 
     prototype->mNodeInfo = nodeInfo;
 
@@ -1291,7 +1291,7 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream,
         if (!prefix.IsEmpty())
           prefixAtom = do_GetAtom(prefix);
 
-        nsRefPtr ni =
+        RefPtr ni =
           aNim->GetNodeInfo(nameAtom, prefixAtom,
                             namespaceID, nsIDOMNode::ATTRIBUTE_NODE);
         attrs[i].mName.SetTo(ni);
diff --git a/dom/xbl/nsXBLPrototypeHandler.cpp b/dom/xbl/nsXBLPrototypeHandler.cpp
index dad3ff4562..5a8a405ada 100644
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -304,7 +304,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
   MOZ_ASSERT(!js::IsCrossCompartmentWrapper(genericHandler));
 
   // Build a scope chain in the XBL scope.
-  nsRefPtr targetElement = do_QueryObject(scriptTarget);
+  RefPtr targetElement = do_QueryObject(scriptTarget);
   JS::AutoObjectVector scopeChain(cx);
   ok = nsJSUtils::GetScopeChainForElement(cx, targetElement, scopeChain);
   NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
@@ -314,7 +314,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
                                                           scopeChain));
   NS_ENSURE_TRUE(bound, NS_ERROR_FAILURE);
 
-  nsRefPtr handlerCallback =
+  RefPtr handlerCallback =
     new EventHandlerNonNull(nullptr, bound, /* aIncumbentGlobal = */ nullptr);
 
   TypedEventHandler typedHandler(handlerCallback);
diff --git a/dom/xbl/nsXBLPrototypeHandler.h b/dom/xbl/nsXBLPrototypeHandler.h
index 18b85fbeab..1e550fd427 100644
--- a/dom/xbl/nsXBLPrototypeHandler.h
+++ b/dom/xbl/nsXBLPrototypeHandler.h
@@ -241,7 +241,7 @@ protected:
   // Prototype handlers are chained. We own the next handler in the chain.
   nsXBLPrototypeHandler* mNextHandler;
   nsCOMPtr mEventName; // The type of the event, e.g., "keypress"
-  nsRefPtr mHandler;
+  RefPtr mHandler;
   nsXBLPrototypeBinding* mPrototypeBinding; // the binding owns us
 };
 
diff --git a/dom/xbl/nsXBLPrototypeResources.cpp b/dom/xbl/nsXBLPrototypeResources.cpp
index 306bf5ee7e..f3146b2166 100644
--- a/dom/xbl/nsXBLPrototypeResources.cpp
+++ b/dom/xbl/nsXBLPrototypeResources.cpp
@@ -80,7 +80,7 @@ nsXBLPrototypeResources::FlushSkinSheets()
   // encounter.  (If they aren't skin sheets, it doesn't matter, since
   // they'll still be in the chrome cache.
 
-  nsTArray> oldSheets;
+  nsTArray> oldSheets;
 
   oldSheets.SwapElements(mStyleSheetList);
 
@@ -91,7 +91,7 @@ nsXBLPrototypeResources::FlushSkinSheets()
 
     nsIURI* uri = oldSheet->GetSheetURI();
 
-    nsRefPtr newSheet;
+    RefPtr newSheet;
     if (IsChromeURI(uri)) {
       if (NS_FAILED(cssLoader->LoadSheetSync(uri, getter_AddRefs(newSheet))))
         continue;
diff --git a/dom/xbl/nsXBLPrototypeResources.h b/dom/xbl/nsXBLPrototypeResources.h
index 3a761940f6..4305a09e25 100644
--- a/dom/xbl/nsXBLPrototypeResources.h
+++ b/dom/xbl/nsXBLPrototypeResources.h
@@ -60,13 +60,13 @@ public:
 
 private:
   // A loader object. Exists only long enough to load resources, and then it dies.
-  nsRefPtr mLoader;
+  RefPtr mLoader;
 
   // A list of loaded stylesheets for this binding.
-  nsTArray> mStyleSheetList;
+  nsTArray> mStyleSheetList;
 
   // The list of stylesheets converted to a rule processor.
-  nsRefPtr mRuleProcessor;
+  RefPtr mRuleProcessor;
 };
 
 #endif
diff --git a/dom/xbl/nsXBLResourceLoader.cpp b/dom/xbl/nsXBLResourceLoader.cpp
index ba2d7701b2..8a9bae9f75 100644
--- a/dom/xbl/nsXBLResourceLoader.cpp
+++ b/dom/xbl/nsXBLResourceLoader.cpp
@@ -120,7 +120,7 @@ nsXBLResourceLoader::LoadResources(bool* aResult)
       // Now kick off the image load...
       // Passing nullptr for pretty much everything -- cause we don't care!
       // XXX: initialDocumentURI is nullptr! 
-      nsRefPtr req;
+      RefPtr req;
       nsContentUtils::LoadImage(url, doc, docPrincipal, docURL,
                                 doc->GetReferrerPolicy(), nullptr,
                                 nsIRequest::LOAD_BACKGROUND, EmptyString(),
@@ -139,7 +139,7 @@ nsXBLResourceLoader::LoadResources(bool* aResult)
           CheckLoadURIWithPrincipal(docPrincipal, url,
                                     nsIScriptSecurityManager::ALLOW_CHROME);
         if (NS_SUCCEEDED(rv)) {
-          nsRefPtr sheet;
+          RefPtr sheet;
           rv = cssLoader->LoadSheetSync(url, getter_AddRefs(sheet));
           NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!");
           if (NS_SUCCEEDED(rv))
diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp
index a24df56051..4e0e5f0d72 100644
--- a/dom/xbl/nsXBLService.cpp
+++ b/dom/xbl/nsXBLService.cpp
@@ -336,7 +336,7 @@ nsXBLStreamListener::HandleEvent(nsIDOMEvent* aEvent)
 
     // Put our doc info in the doc table.
     nsBindingManager *xblDocBindingManager = bindingDocument->BindingManager();
-    nsRefPtr info =
+    RefPtr info =
       xblDocBindingManager->GetXBLDocumentInfo(documentURI);
     xblDocBindingManager->RemoveXBLDocumentInfo(info); // Break the self-imposed cycle.
     if (!info) {
@@ -449,7 +449,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL,
   }
 
   bool ready;
-  nsRefPtr newBinding;
+  RefPtr newBinding;
   if (NS_FAILED(rv = GetBinding(aContent, aURL, false, aOriginPrincipal,
                                 &ready, getter_AddRefs(newBinding)))) {
     return rv;
@@ -553,7 +553,7 @@ nsXBLService::AttachGlobalKeyHandler(EventTarget* aTarget)
   nsCOMPtr elt(do_QueryInterface(contentNode));
 
   // Create the key handler
-  nsRefPtr handler =
+  RefPtr handler =
     NS_NewXBLWindowKeyHandler(elt, piTarget);
 
   // listen to these events
@@ -721,7 +721,7 @@ nsXBLService::GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
 
   nsCOMPtr boundDocument = aBoundElement->OwnerDoc();
 
-  nsRefPtr docInfo;
+  RefPtr docInfo;
   nsresult rv = LoadBindingDocumentInfo(aBoundElement, boundDocument, aURI,
                                         aOriginPrincipal,
                                         false, getter_AddRefs(docInfo));
@@ -813,7 +813,7 @@ nsXBLService::GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
     }
   }
 
-  nsRefPtr baseBinding;
+  RefPtr baseBinding;
   if (baseBindingURI) {
     nsCOMPtr child = protoBinding->GetBindingElement();
     rv = GetBinding(aBoundElement, baseBindingURI, aPeekOnly,
@@ -861,7 +861,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
                    NS_ERROR_XBL_BLOCKED);
   }
 
-  nsRefPtr info;
+  RefPtr info;
 
   nsCOMPtr documentURI;
   nsresult rv = aBindingURI->CloneIgnoringRef(getter_AddRefs(documentURI));
diff --git a/dom/xbl/nsXBLWindowKeyHandler.cpp b/dom/xbl/nsXBLWindowKeyHandler.cpp
index 84a5b31f66..10dcfe537b 100644
--- a/dom/xbl/nsXBLWindowKeyHandler.cpp
+++ b/dom/xbl/nsXBLWindowKeyHandler.cpp
@@ -39,8 +39,8 @@ using namespace mozilla::dom;
 class nsXBLSpecialDocInfo : public nsIObserver
 {
 public:
-  nsRefPtr mHTMLBindings;
-  nsRefPtr mUserHTMLBindings;
+  RefPtr mHTMLBindings;
+  RefPtr mUserHTMLBindings;
 
   static const char sHTMLBindingStr[];
   static const char sUserHTMLBindingStr[];
@@ -600,7 +600,7 @@ nsXBLWindowKeyHandler::GetElement(bool* aIsDisabled)
 already_AddRefed
 NS_NewXBLWindowKeyHandler(nsIDOMElement* aElement, EventTarget* aTarget)
 {
-  nsRefPtr result =
+  RefPtr result =
     new nsXBLWindowKeyHandler(aElement, aTarget);
   return result.forget();
 }
diff --git a/dom/xml/CDATASection.cpp b/dom/xml/CDATASection.cpp
index 873a7a891a..fcc6a4adea 100644
--- a/dom/xml/CDATASection.cpp
+++ b/dom/xml/CDATASection.cpp
@@ -34,7 +34,7 @@ CDATASection::IsNodeOfType(uint32_t aFlags) const
 nsGenericDOMDataNode*
 CDATASection::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
 {
-  nsRefPtr ni = aNodeInfo;
+  RefPtr ni = aNodeInfo;
   CDATASection *it = new CDATASection(ni.forget());
   if (it && aCloneText) {
     it->mText = mText;
diff --git a/dom/xml/ProcessingInstruction.cpp b/dom/xml/ProcessingInstruction.cpp
index bacdbfe5f9..0bea3acbc4 100644
--- a/dom/xml/ProcessingInstruction.cpp
+++ b/dom/xml/ProcessingInstruction.cpp
@@ -26,18 +26,18 @@ NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
   MOZ_ASSERT(target);
 
   if (target == nsGkAtoms::xml_stylesheet) {
-    nsRefPtr pi =
+    RefPtr pi =
       new XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
     return pi.forget();
   }
 
-  nsRefPtr ni;
+  RefPtr ni;
   ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::processingInstructionTagName,
                                      nullptr, kNameSpaceID_None,
                                      nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
                                      target);
 
-  nsRefPtr instance =
+  RefPtr instance =
     new ProcessingInstruction(ni.forget(), aData);
 
   return instance.forget();
@@ -101,7 +101,7 @@ ProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
 {
   nsAutoString data;
   nsGenericDOMDataNode::GetData(data);
-  nsRefPtr ni = aNodeInfo;
+  RefPtr ni = aNodeInfo;
   return new ProcessingInstruction(ni.forget(), data);
 }
 
diff --git a/dom/xml/XMLDocument.cpp b/dom/xml/XMLDocument.cpp
index d93a782fc8..5774c25a91 100644
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -179,7 +179,7 @@ nsresult
 NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData,
                   bool aIsPlainDocument)
 {
-  nsRefPtr doc = new XMLDocument();
+  RefPtr doc = new XMLDocument();
 
   nsresult rv = doc->Init();
 
@@ -384,7 +384,7 @@ XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
   // be loaded.  Note that we need to hold a strong ref to |principal|
   // here, because ResetToURI will null out our node principal before
   // setting the new one.
-  nsRefPtr elm(mListenerManager);
+  RefPtr elm(mListenerManager);
   mListenerManager = nullptr;
 
   // When we are called from JS we can find the load group for the page,
@@ -602,7 +602,7 @@ XMLDocument::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
   NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
                "Can't import this document into another document!");
 
-  nsRefPtr clone = new XMLDocument();
+  RefPtr clone = new XMLDocument();
   nsresult rv = CloneDocHelper(clone);
   NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xml/XMLStylesheetProcessingInstruction.cpp b/dom/xml/XMLStylesheetProcessingInstruction.cpp
index a721f98871..fcb5a8bc73 100644
--- a/dom/xml/XMLStylesheetProcessingInstruction.cpp
+++ b/dom/xml/XMLStylesheetProcessingInstruction.cpp
@@ -188,7 +188,7 @@ XMLStylesheetProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeI
 {
   nsAutoString data;
   nsGenericDOMDataNode::GetData(data);
-  nsRefPtr ni = aNodeInfo;
+  RefPtr ni = aNodeInfo;
   return new XMLStylesheetProcessingInstruction(ni.forget(), data);
 }
 
diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp
index 7b2c2029ae..e3421808d8 100644
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -86,7 +86,7 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult,
   if (nullptr == aResult) {
     return NS_ERROR_NULL_POINTER;
   }
-  nsRefPtr it = new nsXMLContentSink();
+  RefPtr it = new nsXMLContentSink();
 
   nsresult rv = it->Init(aDoc, aURI, aContainer, aChannel);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -204,7 +204,7 @@ nsXMLContentSink::MaybePrettyPrint()
     mCSSLoader->SetEnabled(true);
   }
 
-  nsRefPtr printer;
+  RefPtr printer;
   nsresult rv = NS_NewXMLPrettyPrinter(getter_AddRefs(printer));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -464,8 +464,8 @@ nsXMLContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
   *aAppendContent = true;
   nsresult rv = NS_OK;
 
-  nsRefPtr ni = aNodeInfo;
-  nsRefPtr content;
+  RefPtr ni = aNodeInfo;
+  RefPtr content;
   rv = NS_NewElement(getter_AddRefs(content), ni.forget(), aFromParser);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -799,7 +799,7 @@ nsXMLContentSink::FlushText(bool aReleaseTextNode)
         mTextLength = 0;
       }
     } else {
-      nsRefPtr textContent = new nsTextNode(mNodeInfoManager);
+      RefPtr textContent = new nsTextNode(mNodeInfoManager);
 
       mLastTextNode = textContent;
 
@@ -984,7 +984,7 @@ nsXMLContentSink::HandleStartElement(const char16_t *aName,
     return NS_OK;
   }
 
-  nsRefPtr nodeInfo;
+  RefPtr nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                            nsIDOMNode::ELEMENT_NODE);
 
@@ -1133,7 +1133,7 @@ nsXMLContentSink::HandleComment(const char16_t *aName)
 {
   FlushText();
 
-  nsRefPtr comment = new Comment(mNodeInfoManager);
+  RefPtr comment = new Comment(mNodeInfoManager);
   comment->SetText(nsDependentString(aName), false);
   nsresult rv = AddContentAsLeaf(comment);
   DidAddContent();
@@ -1153,7 +1153,7 @@ nsXMLContentSink::HandleCDataSection(const char16_t *aData,
 
   FlushText();
 
-  nsRefPtr cdata = new CDATASection(mNodeInfoManager);
+  RefPtr cdata = new CDATASection(mNodeInfoManager);
   cdata->SetText(aData, aLength, false);
   nsresult rv = AddContentAsLeaf(cdata);
   DidAddContent();
diff --git a/dom/xml/nsXMLFragmentContentSink.cpp b/dom/xml/nsXMLFragmentContentSink.cpp
index 77502b2057..2f16ba5193 100644
--- a/dom/xml/nsXMLFragmentContentSink.cpp
+++ b/dom/xml/nsXMLFragmentContentSink.cpp
@@ -168,7 +168,7 @@ nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode)
 NS_IMETHODIMP 
 nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
 {
-  nsRefPtr kungFuDeathGrip(mParser);
+  RefPtr kungFuDeathGrip(mParser);
 
   // Drop our reference to the parser to get rid of a circular
   // reference.
@@ -267,7 +267,7 @@ nsXMLFragmentContentSink::HandleProcessingInstruction(const char16_t *aTarget,
   const nsDependentString target(aTarget);
   const nsDependentString data(aData);
 
-  nsRefPtr node =
+  RefPtr node =
     NS_NewXMLProcessingInstruction(mNodeInfoManager, target, data);
 
   // no special processing here.  that should happen when the fragment moves into the document
diff --git a/dom/xml/nsXMLPrettyPrinter.cpp b/dom/xml/nsXMLPrettyPrinter.cpp
index 91fcf6f727..9f0f8c5e12 100644
--- a/dom/xml/nsXMLPrettyPrinter.cpp
+++ b/dom/xml/nsXMLPrettyPrinter.cpp
@@ -149,14 +149,14 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument,
         GetSystemPrincipal(getter_AddRefs(sysPrincipal));
 
     // Load the bindings.
-    nsRefPtr unused;
+    RefPtr unused;
     bool ignored;
     rv = xblService->LoadBindings(rootCont, bindingUri, sysPrincipal,
                                   getter_AddRefs(unused), &ignored);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Fire an event at the bound element to pass it |resultFragment|.
-    nsRefPtr event =
+    RefPtr event =
       NS_NewDOMCustomEvent(rootCont, nullptr, nullptr);
     MOZ_ASSERT(event);
     nsCOMPtr resultFragmentVariant = new nsVariant();
diff --git a/dom/xslt/xpath/XPathEvaluator.cpp b/dom/xslt/xpath/XPathEvaluator.cpp
index 99016ccac3..e7170373dd 100644
--- a/dom/xslt/xpath/XPathEvaluator.cpp
+++ b/dom/xslt/xpath/XPathEvaluator.cpp
@@ -104,7 +104,7 @@ XPathEvaluator::Evaluate(const nsAString & aExpression,
     }
 
     nsCOMPtr inResult = do_QueryInterface(aInResult);
-    nsRefPtr result =
+    RefPtr result =
         expression->Evaluate(*node, aType,
                              static_cast(inResult.get()), rv);
     if (rv.Failed()) {
@@ -174,7 +174,7 @@ already_AddRefed
 XPathEvaluator::Constructor(const GlobalObject& aGlobal,
                             ErrorResult& rv)
 {
-    nsRefPtr newObj = new XPathEvaluator(nullptr);
+    RefPtr newObj = new XPathEvaluator(nullptr);
     return newObj.forget();
 }
 
diff --git a/dom/xslt/xpath/XPathEvaluator.h b/dom/xslt/xpath/XPathEvaluator.h
index 5432492b1f..e2a0ca46b3 100644
--- a/dom/xslt/xpath/XPathEvaluator.h
+++ b/dom/xslt/xpath/XPathEvaluator.h
@@ -75,7 +75,7 @@ private:
                          ErrorResult& aRv);
 
     nsWeakPtr mDocument;
-    nsRefPtr mRecycler;
+    RefPtr mRecycler;
 };
 
 inline nsISupports*
diff --git a/dom/xslt/xpath/XPathExpression.cpp b/dom/xslt/xpath/XPathExpression.cpp
index 33b0566617..8c812a9bbb 100644
--- a/dom/xslt/xpath/XPathExpression.cpp
+++ b/dom/xslt/xpath/XPathExpression.cpp
@@ -49,7 +49,7 @@ private:
     uint32_t mContextPosition;
     uint32_t mContextSize;
     nsresult mLastError;
-    nsRefPtr mRecycler;
+    RefPtr mRecycler;
 };
 
 XPathExpression::XPathExpression(nsAutoPtr&& aExpression,
@@ -152,7 +152,7 @@ XPathExpression::EvaluateWithContext(nsINode& aContextNode,
 
     EvalContextImpl eContext(*contextNode, aContextPosition, aContextSize,
                              mRecycler);
-    nsRefPtr exprResult;
+    RefPtr exprResult;
     aRv = mExpression->evaluate(&eContext, getter_AddRefs(exprResult));
     if (aRv.Failed()) {
         return nullptr;
@@ -180,7 +180,7 @@ XPathExpression::EvaluateWithContext(nsINode& aContextNode,
         }
     }
 
-    nsRefPtr xpathResult = aInResult;
+    RefPtr xpathResult = aInResult;
     if (!xpathResult) {
         xpathResult = new XPathResult(&aContextNode);
     }
diff --git a/dom/xslt/xpath/XPathExpression.h b/dom/xslt/xpath/XPathExpression.h
index 8bd9b59764..bfe478bdb4 100644
--- a/dom/xslt/xpath/XPathExpression.h
+++ b/dom/xslt/xpath/XPathExpression.h
@@ -63,7 +63,7 @@ public:
 
 private:
     nsAutoPtr mExpression;
-    nsRefPtr mRecycler;
+    RefPtr mRecycler;
     nsWeakPtr mDocument;
     bool mCheckDocument;
 };
diff --git a/dom/xslt/xpath/XPathResult.cpp b/dom/xslt/xpath/XPathResult.cpp
index f3ea155c60..33315c942f 100644
--- a/dom/xslt/xpath/XPathResult.cpp
+++ b/dom/xslt/xpath/XPathResult.cpp
@@ -302,7 +302,7 @@ XPathResult::GetExprResult(txAExprResult** aExprResult)
         return NS_ERROR_DOM_INVALID_STATE_ERR;
     }
 
-    nsRefPtr nodeSet = new txNodeSet(nullptr);
+    RefPtr nodeSet = new txNodeSet(nullptr);
     if (!nodeSet) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
diff --git a/dom/xslt/xpath/XPathResult.h b/dom/xslt/xpath/XPathResult.h
index 268e21df98..9fe8125ba3 100644
--- a/dom/xslt/xpath/XPathResult.h
+++ b/dom/xslt/xpath/XPathResult.h
@@ -191,7 +191,7 @@ private:
     void Invalidate(const nsIContent* aChangeRoot);
 
     nsCOMPtr mParent;
-    nsRefPtr mResult;
+    RefPtr mResult;
     nsCOMArray mResultNodes;
     nsCOMPtr mDocument;
     nsWeakPtr mContextNode;
diff --git a/dom/xslt/xpath/txCoreFunctionCall.cpp b/dom/xslt/xpath/txCoreFunctionCall.cpp
index eb0d136d71..acb86b766d 100644
--- a/dom/xslt/xpath/txCoreFunctionCall.cpp
+++ b/dom/xslt/xpath/txCoreFunctionCall.cpp
@@ -86,7 +86,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
     switch (mType) {
         case COUNT:
         {
-            nsRefPtr nodes;
+            RefPtr nodes;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -96,11 +96,11 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
         }
         case ID:
         {
-            nsRefPtr exprResult;
+            RefPtr exprResult;
             rv = mParams[0]->evaluate(aContext, getter_AddRefs(exprResult));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr resultSet;
+            RefPtr resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -148,7 +148,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
         case NAMESPACE_URI:
         {
             // Check for optional arg
-            nsRefPtr nodes;
+            RefPtr nodes;
             if (!mParams.IsEmpty()) {
                 rv = evaluateToNodeSet(mParams[0], aContext,
                                        getter_AddRefs(nodes));
@@ -221,7 +221,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 
         case CONCAT:
         {
-            nsRefPtr strRes;
+            RefPtr strRes;
             rv = aContext->recycler()->getStringResult(getter_AddRefs(strRes));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -267,7 +267,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
                                                   resultStr);
             }
 
-            nsRefPtr strRes;
+            RefPtr strRes;
             rv = aContext->recycler()->getStringResult(getter_AddRefs(strRes));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -319,7 +319,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
         }
         case STRING:
         {
-            nsRefPtr strRes;
+            RefPtr strRes;
             rv = aContext->recycler()->getStringResult(getter_AddRefs(strRes));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -470,7 +470,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
                 return NS_OK;
             }
             
-            nsRefPtr strRes;
+            RefPtr strRes;
             rv = aContext->recycler()->getStringResult(getter_AddRefs(strRes));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -563,7 +563,7 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
         }
         case SUM:
         {
-            nsRefPtr nodes;
+            RefPtr nodes;
             nsresult rv = evaluateToNodeSet(mParams[0], aContext,
                                             getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xpath/txExpr.cpp b/dom/xslt/xpath/txExpr.cpp
index afce103da5..01c1ff6d3e 100644
--- a/dom/xslt/xpath/txExpr.cpp
+++ b/dom/xslt/xpath/txExpr.cpp
@@ -8,7 +8,7 @@
 nsresult
 Expr::evaluateToBool(txIEvalContext* aContext, bool& aResult)
 {
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -20,7 +20,7 @@ Expr::evaluateToBool(txIEvalContext* aContext, bool& aResult)
 nsresult
 Expr::evaluateToString(txIEvalContext* aContext, nsString& aResult)
 {
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txExpr.h b/dom/xslt/xpath/txExpr.h
index 474a459a9e..78a72d5b51 100644
--- a/dom/xslt/xpath/txExpr.h
+++ b/dom/xslt/xpath/txExpr.h
@@ -679,7 +679,7 @@ public:
     TX_DECL_EXPR
 
 private:
-    nsRefPtr mValue;
+    RefPtr mValue;
 };
 
 /**
diff --git a/dom/xslt/xpath/txExprResult.h b/dom/xslt/xpath/txExprResult.h
index 04cf5e4d2d..73e2f0772c 100644
--- a/dom/xslt/xpath/txExprResult.h
+++ b/dom/xslt/xpath/txExprResult.h
@@ -83,7 +83,7 @@ public:
 
 private:
     nsAutoRefCnt mRefCnt;
-    nsRefPtr mRecycler;
+    RefPtr mRecycler;
 };
 
 #define TX_DECL_EXPRRESULT                                        \
diff --git a/dom/xslt/xpath/txFilterExpr.cpp b/dom/xslt/xpath/txFilterExpr.cpp
index 7117f72907..155210557c 100644
--- a/dom/xslt/xpath/txFilterExpr.cpp
+++ b/dom/xslt/xpath/txFilterExpr.cpp
@@ -26,19 +26,19 @@ FilterExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 {
     *aResult = nullptr;
 
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = expr->evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
     NS_ENSURE_TRUE(exprRes->getResultType() == txAExprResult::NODESET,
                    NS_ERROR_XSLT_NODESET_EXPECTED);
 
-    nsRefPtr nodes =
+    RefPtr nodes =
         static_cast(static_cast(exprRes));
     // null out exprRes so that we can test for shared-ness
     exprRes = nullptr;
 
-    nsRefPtr nonShared;
+    RefPtr nonShared;
     rv = aContext->recycler()->getNonSharedNodeSet(nodes,
                                                    getter_AddRefs(nonShared));
     NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xpath/txForwardContext.h b/dom/xslt/xpath/txForwardContext.h
index 2b75cca6ee..19e06f8d11 100644
--- a/dom/xslt/xpath/txForwardContext.h
+++ b/dom/xslt/xpath/txForwardContext.h
@@ -26,7 +26,7 @@ public:
 private:
     txIMatchContext* mInner;
     const txXPathNode& mContextNode;
-    nsRefPtr mContextSet;
+    RefPtr mContextSet;
 };
 
 #endif // __TX_XPATH_CONTEXT
diff --git a/dom/xslt/xpath/txFunctionCall.cpp b/dom/xslt/xpath/txFunctionCall.cpp
index a37ebf7bd5..aa8f51fc79 100644
--- a/dom/xslt/xpath/txFunctionCall.cpp
+++ b/dom/xslt/xpath/txFunctionCall.cpp
@@ -25,7 +25,7 @@ FunctionCall::evaluateToNumber(Expr* aExpr, txIEvalContext* aContext,
                                double* aResult)
 {
     NS_ASSERTION(aExpr, "missing expression");
-    nsRefPtr exprResult;
+    RefPtr exprResult;
     nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprResult));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -45,7 +45,7 @@ FunctionCall::evaluateToNodeSet(Expr* aExpr, txIEvalContext* aContext,
     NS_ASSERTION(aExpr, "Missing expression to evaluate");
     *aResult = nullptr;
 
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txLocationStep.cpp b/dom/xslt/xpath/txLocationStep.cpp
index 1898ce39b4..ad70a53274 100644
--- a/dom/xslt/xpath/txLocationStep.cpp
+++ b/dom/xslt/xpath/txLocationStep.cpp
@@ -30,7 +30,7 @@ LocationStep::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
     NS_ASSERTION(aContext, "internal error");
     *aResult = nullptr;
 
-    nsRefPtr nodes;
+    RefPtr nodes;
     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txNamedAttributeStep.cpp b/dom/xslt/xpath/txNamedAttributeStep.cpp
index f4c9a5a7c7..e042b37aff 100644
--- a/dom/xslt/xpath/txNamedAttributeStep.cpp
+++ b/dom/xslt/xpath/txNamedAttributeStep.cpp
@@ -24,7 +24,7 @@ txNamedAttributeStep::evaluate(txIEvalContext* aContext,
 {
     *aResult = nullptr;
 
-    nsRefPtr nodes;
+    RefPtr nodes;
     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txNodeSetContext.h b/dom/xslt/xpath/txNodeSetContext.h
index 12700fa191..2c133cf33b 100644
--- a/dom/xslt/xpath/txNodeSetContext.h
+++ b/dom/xslt/xpath/txNodeSetContext.h
@@ -38,7 +38,7 @@ public:
     TX_DECL_EVAL_CONTEXT;
 
 protected:
-    nsRefPtr mContextSet;
+    RefPtr mContextSet;
     uint32_t mPosition;
     txIMatchContext* mInner;
 };
diff --git a/dom/xslt/xpath/txNumberExpr.cpp b/dom/xslt/xpath/txNumberExpr.cpp
index d0e427c644..1defe905bb 100644
--- a/dom/xslt/xpath/txNumberExpr.cpp
+++ b/dom/xslt/xpath/txNumberExpr.cpp
@@ -14,7 +14,7 @@ txNumberExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 {
     *aResult = nullptr;
 
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = mRightExpr->evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txPathExpr.cpp b/dom/xslt/xpath/txPathExpr.cpp
index a73aecf6e7..ac4a16b020 100644
--- a/dom/xslt/xpath/txPathExpr.cpp
+++ b/dom/xslt/xpath/txPathExpr.cpp
@@ -52,14 +52,14 @@ PathExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
     // We need to evaluate the first step with the current context since it
     // can depend on the context size and position. For example:
     // key('books', concat('book', position()))
-    nsRefPtr res;
+    RefPtr res;
     nsresult rv = mItems[0].expr->evaluate(aContext, getter_AddRefs(res));
     NS_ENSURE_SUCCESS(rv, rv);
 
     NS_ENSURE_TRUE(res->getResultType() == txAExprResult::NODESET,
                    NS_ERROR_XSLT_NODESET_EXPECTED);
 
-    nsRefPtr nodes = static_cast
+    RefPtr nodes = static_cast
                                            (static_cast
                                                        (res));
     if (nodes->isEmpty()) {
@@ -73,12 +73,12 @@ PathExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
     uint32_t i, len = mItems.Length();
     for (i = 1; i < len; ++i) {
         PathExprItem& pxi = mItems[i];
-        nsRefPtr tmpNodes;
+        RefPtr tmpNodes;
         txNodeSetContext eContext(nodes, aContext);
         while (eContext.hasNext()) {
             eContext.next();
 
-            nsRefPtr resNodes;
+            RefPtr resNodes;
             if (pxi.pathOp == DESCENDANT_OP) {
                 rv = aContext->recycler()->getNodeSet(getter_AddRefs(resNodes));
                 NS_ENSURE_SUCCESS(rv, rv);
@@ -88,7 +88,7 @@ PathExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
                 NS_ENSURE_SUCCESS(rv, rv);
             }
             else {
-                nsRefPtr res;
+                RefPtr res;
                 rv = pxi.expr->evaluate(&eContext, getter_AddRefs(res));
                 NS_ENSURE_SUCCESS(rv, rv);
 
@@ -103,7 +103,7 @@ PathExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 
             if (tmpNodes) {
                 if (!resNodes->isEmpty()) {
-                    nsRefPtr oldSet;
+                    RefPtr oldSet;
                     oldSet.swap(tmpNodes);
                     rv = aContext->recycler()->
                         getNonSharedNodeSet(oldSet, getter_AddRefs(tmpNodes));
@@ -142,7 +142,7 @@ PathExpr::evalDescendants(Expr* aStep, const txXPathNode& aNode,
                           txIMatchContext* aContext, txNodeSet* resNodes)
 {
     txSingleNodeContext eContext(aNode, aContext);
-    nsRefPtr res;
+    RefPtr res;
     nsresult rv = aStep->evaluate(&eContext, getter_AddRefs(res));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -153,7 +153,7 @@ PathExpr::evalDescendants(Expr* aStep, const txXPathNode& aNode,
 
     txNodeSet* oldSet = static_cast
                                    (static_cast(res));
-    nsRefPtr newSet;
+    RefPtr newSet;
     rv = aContext->recycler()->getNonSharedNodeSet(oldSet,
                                                    getter_AddRefs(newSet));
     NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xpath/txPredicateList.cpp b/dom/xslt/xpath/txPredicateList.cpp
index be9c419b50..937d4148f1 100644
--- a/dom/xslt/xpath/txPredicateList.cpp
+++ b/dom/xslt/xpath/txPredicateList.cpp
@@ -30,7 +30,7 @@ PredicateList::evaluatePredicates(txNodeSet* nodes,
         int32_t index = 0;
         while (predContext.hasNext()) {
             predContext.next();
-            nsRefPtr exprResult;
+            RefPtr exprResult;
             rv = mPredicates[i]->evaluate(&predContext,
                                           getter_AddRefs(exprResult));
             NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xpath/txPredicatedNodeTest.cpp b/dom/xslt/xpath/txPredicatedNodeTest.cpp
index d5243abae7..4726f48f28 100644
--- a/dom/xslt/xpath/txPredicatedNodeTest.cpp
+++ b/dom/xslt/xpath/txPredicatedNodeTest.cpp
@@ -25,7 +25,7 @@ txPredicatedNodeTest::matches(const txXPathNode& aNode,
     }
 
     txSingleNodeContext context(aNode, aContext);
-    nsRefPtr res;
+    RefPtr res;
     nsresult rv = mPredicate->evaluate(&context, getter_AddRefs(res));
     NS_ENSURE_SUCCESS(rv, false);
 
diff --git a/dom/xslt/xpath/txRelationalExpr.cpp b/dom/xslt/xpath/txRelationalExpr.cpp
index f1d54edd12..5621ede7bb 100644
--- a/dom/xslt/xpath/txRelationalExpr.cpp
+++ b/dom/xslt/xpath/txRelationalExpr.cpp
@@ -27,7 +27,7 @@ RelationalExpr::compareResults(txIEvalContext* aContext, txAExprResult* aLeft,
         }
 
         txNodeSet* nodeSet = static_cast(aLeft);
-        nsRefPtr strResult;
+        RefPtr strResult;
         rv = aContext->recycler()->getStringResult(getter_AddRefs(strResult));
         NS_ENSURE_SUCCESS(rv, false);
 
@@ -52,7 +52,7 @@ RelationalExpr::compareResults(txIEvalContext* aContext, txAExprResult* aLeft,
         }
 
         txNodeSet* nodeSet = static_cast(aRight);
-        nsRefPtr strResult;
+        RefPtr strResult;
         rv = aContext->recycler()->getStringResult(getter_AddRefs(strResult));
         NS_ENSURE_SUCCESS(rv, false);
 
@@ -147,11 +147,11 @@ nsresult
 RelationalExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 {
     *aResult = nullptr;
-    nsRefPtr lResult;
+    RefPtr lResult;
     nsresult rv = mLeftExpr->evaluate(aContext, getter_AddRefs(lResult));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsRefPtr rResult;
+    RefPtr rResult;
     rv = mRightExpr->evaluate(aContext, getter_AddRefs(rResult));
     NS_ENSURE_SUCCESS(rv, rv);
     
diff --git a/dom/xslt/xpath/txResultRecycler.cpp b/dom/xslt/xpath/txResultRecycler.cpp
index b0f55b6cfc..0db095001c 100644
--- a/dom/xslt/xpath/txResultRecycler.cpp
+++ b/dom/xslt/xpath/txResultRecycler.cpp
@@ -35,7 +35,7 @@ void
 txResultRecycler::recycle(txAExprResult* aResult)
 {
     NS_ASSERTION(aResult->mRefCnt == 0, "In-use txAExprResult recycled");
-    nsRefPtr kungFuDeathGrip;
+    RefPtr kungFuDeathGrip;
     aResult->mRecycler.swap(kungFuDeathGrip);
 
     nsresult rv = NS_OK;
diff --git a/dom/xslt/xpath/txResultRecycler.h b/dom/xslt/xpath/txResultRecycler.h
index 4d04b8f261..eec7d75e8f 100644
--- a/dom/xslt/xpath/txResultRecycler.h
+++ b/dom/xslt/xpath/txResultRecycler.h
@@ -72,9 +72,9 @@ private:
     txStack mStringResults;
     txStack mNodeSetResults;
     txStack mNumberResults;
-    nsRefPtr mEmptyStringResult;
-    nsRefPtr mTrueResult;
-    nsRefPtr mFalseResult;
+    RefPtr mEmptyStringResult;
+    RefPtr mTrueResult;
+    RefPtr mFalseResult;
 };
 
 #endif //txResultRecycler_h__
diff --git a/dom/xslt/xpath/txUnaryExpr.cpp b/dom/xslt/xpath/txUnaryExpr.cpp
index acc2c22cb9..95682b5b25 100644
--- a/dom/xslt/xpath/txUnaryExpr.cpp
+++ b/dom/xslt/xpath/txUnaryExpr.cpp
@@ -18,7 +18,7 @@ UnaryExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 {
     *aResult = nullptr;
 
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = expr->evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txUnionExpr.cpp b/dom/xslt/xpath/txUnionExpr.cpp
index 27c0ffb8e2..0bde2c38a4 100644
--- a/dom/xslt/xpath/txUnionExpr.cpp
+++ b/dom/xslt/xpath/txUnionExpr.cpp
@@ -26,13 +26,13 @@ nsresult
 UnionExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
 {
     *aResult = nullptr;
-    nsRefPtr nodes;
+    RefPtr nodes;
     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t i, len = mExpressions.Length();
     for (i = 0; i < len; ++i) {
-        nsRefPtr exprResult;
+        RefPtr exprResult;
         rv = mExpressions[i]->evaluate(aContext, getter_AddRefs(exprResult));
         NS_ENSURE_SUCCESS(rv, rv);
 
@@ -41,7 +41,7 @@ UnionExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
             return NS_ERROR_XSLT_NODESET_EXPECTED;
         }
 
-        nsRefPtr resultSet, ownedSet;
+        RefPtr resultSet, ownedSet;
         resultSet = static_cast
                                (static_cast(exprResult));
         exprResult = nullptr;
diff --git a/dom/xslt/xpath/txXPCOMExtensionFunction.cpp b/dom/xslt/xpath/txXPCOMExtensionFunction.cpp
index cce74a2678..d38a6a8740 100644
--- a/dom/xslt/xpath/txXPCOMExtensionFunction.cpp
+++ b/dom/xslt/xpath/txXPCOMExtensionFunction.cpp
@@ -430,7 +430,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
         switch (type) {
             case eNODESET:
             {
-                nsRefPtr nodes;
+                RefPtr nodes;
                 rv = evaluateToNodeSet(expr, aContext, getter_AddRefs(nodes));
                 NS_ENSURE_SUCCESS(rv, rv);
 
@@ -479,7 +479,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
             }
             case eOBJECT:
             {
-              nsRefPtr exprRes;
+              RefPtr exprRes;
               rv = expr->evaluate(aContext, getter_AddRefs(exprRes));
               NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xpath/txXPathObjectAdaptor.h b/dom/xslt/xpath/txXPathObjectAdaptor.h
index 8a5ad9e0ed..d3826a1bf7 100644
--- a/dom/xslt/xpath/txXPathObjectAdaptor.h
+++ b/dom/xslt/xpath/txXPathObjectAdaptor.h
@@ -39,7 +39,7 @@ protected:
 
     virtual ~txXPathObjectAdaptor() {}
 
-    nsRefPtr mValue;
+    RefPtr mValue;
 };
 
 #endif // txXPathObjectAdaptor_h__
diff --git a/dom/xslt/xpath/txXPathOptimizer.cpp b/dom/xslt/xpath/txXPathOptimizer.cpp
index 57d265ebc5..efe363d466 100644
--- a/dom/xslt/xpath/txXPathOptimizer.cpp
+++ b/dom/xslt/xpath/txXPathOptimizer.cpp
@@ -70,9 +70,9 @@ txXPathOptimizer::optimize(Expr* aInExpr, Expr** aOutExpr)
     Expr::ExprType exprType = aInExpr->getType();
     if (exprType != Expr::LITERAL_EXPR &&
         !aInExpr->isSensitiveTo(Expr::ANY_CONTEXT)) {
-        nsRefPtr recycler = new txResultRecycler;
+        RefPtr recycler = new txResultRecycler;
         txEarlyEvalContext context(recycler);
-        nsRefPtr exprRes;
+        RefPtr exprRes;
 
         // Don't throw if this fails since it could be that the expression
         // is or contains an error-expression.
diff --git a/dom/xslt/xslt/txDocumentFunctionCall.cpp b/dom/xslt/xslt/txDocumentFunctionCall.cpp
index a0cbea67b5..3ea7a83b24 100644
--- a/dom/xslt/xslt/txDocumentFunctionCall.cpp
+++ b/dom/xslt/xslt/txDocumentFunctionCall.cpp
@@ -74,7 +74,7 @@ DocumentFunctionCall::evaluate(txIEvalContext* aContext,
     txExecutionState* es =
         static_cast(aContext->getPrivateContext());
 
-    nsRefPtr nodeSet;
+    RefPtr nodeSet;
     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodeSet));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -83,7 +83,7 @@ DocumentFunctionCall::evaluate(txIEvalContext* aContext,
         return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
     }
 
-    nsRefPtr exprResult1;
+    RefPtr exprResult1;
     rv = mParams[0]->evaluate(aContext, getter_AddRefs(exprResult1));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -93,7 +93,7 @@ DocumentFunctionCall::evaluate(txIEvalContext* aContext,
     if (mParams.Length() == 2) {
         // We have 2 arguments, get baseURI from the first node
         // in the resulting nodeset
-        nsRefPtr nodeSet2;
+        RefPtr nodeSet2;
         rv = evaluateToNodeSet(mParams[1],
                                aContext, getter_AddRefs(nodeSet2));
         NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xslt/txEXSLTFunctions.cpp b/dom/xslt/xslt/txEXSLTFunctions.cpp
index 3e1da34fc4..c643caf125 100644
--- a/dom/xslt/xslt/txEXSLTFunctions.cpp
+++ b/dom/xslt/xslt/txEXSLTFunctions.cpp
@@ -110,7 +110,7 @@ createDocFragment(txIEvalContext *aContext)
 
     const txXPathNode& document = es->getSourceDocument();
     nsIDocument *doc = txXPathNativeNode::getDocument(document);
-    nsRefPtr fragment =
+    RefPtr fragment =
       new DocumentFragment(doc->NodeInfoManager());
 
     return fragment.forget();
@@ -129,7 +129,7 @@ createAndAddToResult(nsIAtom* aName, const nsSubstring& aValue,
                                              nullptr, kNameSpaceID_None);
     NS_ENSURE_TRUE(elem, NS_ERROR_NULL_POINTER);
 
-    nsRefPtr text = new nsTextNode(doc->NodeInfoManager());
+    RefPtr text = new nsTextNode(doc->NodeInfoManager());
 
     nsresult rv = text->SetText(aValue, false);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -253,7 +253,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
     switch (mType) {
         case NODE_SET:
         {
-            nsRefPtr exprResult;
+            RefPtr exprResult;
             rv = mParams[0]->evaluate(aContext, getter_AddRefs(exprResult));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -261,7 +261,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
                 exprResult.swap(*aResult);
             }
             else {
-                nsRefPtr resultSet;
+                RefPtr resultSet;
                 rv = aContext->recycler()->
                     getNodeSet(getter_AddRefs(resultSet));
                 NS_ENSURE_SUCCESS(rv, rv);
@@ -301,12 +301,12 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         }
         case OBJECT_TYPE:
         {
-            nsRefPtr exprResult;
+            RefPtr exprResult;
             nsresult rv = mParams[0]->evaluate(aContext,
                                                getter_AddRefs(exprResult));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr strRes;
+            RefPtr strRes;
             rv = aContext->recycler()->getStringResult(getter_AddRefs(strRes));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -320,17 +320,17 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         case DIFFERENCE:
         case INTERSECTION:
         {
-            nsRefPtr nodes1;
+            RefPtr nodes1;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes1));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr nodes2;
+            RefPtr nodes2;
             rv = evaluateToNodeSet(mParams[1], aContext,
                                    getter_AddRefs(nodes2));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr resultSet;
+            RefPtr resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -357,12 +357,12 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         }
         case DISTINCT:
         {
-            nsRefPtr nodes;
+            RefPtr nodes;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr resultSet;
+            RefPtr resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -386,12 +386,12 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         }
         case HAS_SAME_NODE:
         {
-            nsRefPtr nodes1;
+            RefPtr nodes1;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes1));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr nodes2;
+            RefPtr nodes2;
             rv = evaluateToNodeSet(mParams[1], aContext,
                                    getter_AddRefs(nodes2));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -412,12 +412,12 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         case LEADING:
         case TRAILING:
         {
-            nsRefPtr nodes1;
+            RefPtr nodes1;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes1));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr nodes2;
+            RefPtr nodes2;
             rv = evaluateToNodeSet(mParams[1], aContext,
                                    getter_AddRefs(nodes2));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -429,7 +429,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
                 return NS_OK;
             }
 
-            nsRefPtr resultSet;
+            RefPtr resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -452,7 +452,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         }
         case CONCAT:
         {
-            nsRefPtr nodes;
+            RefPtr nodes;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -486,10 +486,10 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
             }
 
             // Set up holders for the result
-            nsRefPtr docFrag = createDocFragment(aContext);
+            RefPtr docFrag = createDocFragment(aContext);
             NS_ENSURE_STATE(docFrag);
 
-            nsRefPtr resultSet;
+            RefPtr resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
@@ -559,7 +559,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         case MAX:
         case MIN:
         {
-            nsRefPtr nodes;
+            RefPtr nodes;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -593,7 +593,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
         case HIGHEST:
         case LOWEST:
         {
-            nsRefPtr nodes;
+            RefPtr nodes;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -604,7 +604,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
                 return NS_OK;
             }
 
-            nsRefPtr resultSet;
+            RefPtr resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xslt/txExecutionState.h b/dom/xslt/xslt/txExecutionState.h
index b5bfa562c1..64fda56a88 100644
--- a/dom/xslt/xslt/txExecutionState.h
+++ b/dom/xslt/xslt/txExecutionState.h
@@ -149,7 +149,7 @@ public:
 
     nsAutoPtr mTemplateParams;
 
-    nsRefPtr mStylesheet;
+    RefPtr mStylesheet;
 
 private:
     txStack mReturnStack;
@@ -161,7 +161,7 @@ private:
     txInstruction* mNextInstruction;
     txVariableMap* mLocalVariables;
     txVariableMap mGlobalVariableValues;
-    nsRefPtr mGlobalVarPlaceholderValue;
+    RefPtr mGlobalVarPlaceholderValue;
     int32_t mRecursionDepth;
 
     AutoInfallibleTArray mTemplateRules;
@@ -173,7 +173,7 @@ private:
 
     txLoadedDocumentsHash mLoadedDocuments;
     txKeyHash mKeyHash;
-    nsRefPtr mRecycler;
+    RefPtr mRecycler;
     bool mDisableLoads;
 
     static const int32_t kMaxRecursionDepth;
diff --git a/dom/xslt/xslt/txGenerateIdFunctionCall.cpp b/dom/xslt/xslt/txGenerateIdFunctionCall.cpp
index b0335d20e2..215bc42da7 100644
--- a/dom/xslt/xslt/txGenerateIdFunctionCall.cpp
+++ b/dom/xslt/xslt/txGenerateIdFunctionCall.cpp
@@ -60,7 +60,7 @@ GenerateIdFunctionCall::evaluate(txIEvalContext* aContext,
         return NS_OK;
     }
 
-    nsRefPtr nodes;
+    RefPtr nodes;
     rv = evaluateToNodeSet(mParams[0], aContext,
                            getter_AddRefs(nodes));
     NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xslt/txInstructions.cpp b/dom/xslt/xslt/txInstructions.cpp
index 9e7133cd8c..7ad789a9c7 100644
--- a/dom/xslt/xslt/txInstructions.cpp
+++ b/dom/xslt/xslt/txInstructions.cpp
@@ -167,7 +167,7 @@ txCheckParam::execute(txExecutionState& aEs)
 {
     nsresult rv = NS_OK;
     if (aEs.mTemplateParams) {
-        nsRefPtr exprRes;
+        RefPtr exprRes;
         aEs.mTemplateParams->getVariable(mName, getter_AddRefs(exprRes));
         if (exprRes) {
             rv = aEs.bindVariable(mName, exprRes);
@@ -373,7 +373,7 @@ txCopyOf::txCopyOf(nsAutoPtr&& aSelect)
 nsresult
 txCopyOf::execute(txExecutionState& aEs)
 {
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = mSelect->evaluate(aEs.getEvalContext(),
                                     getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -500,7 +500,7 @@ txLREAttribute::txLREAttribute(int32_t aNamespaceID, nsIAtom* aLocalName,
 nsresult
 txLREAttribute::execute(txExecutionState& aEs)
 {
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = mValue->evaluate(aEs.getEvalContext(),
                                    getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -615,7 +615,7 @@ txPushNewContext::~txPushNewContext()
 nsresult
 txPushNewContext::execute(txExecutionState& aEs)
 {
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = mSelect->evaluate(aEs.getEvalContext(),
                                     getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -645,7 +645,7 @@ txPushNewContext::execute(txExecutionState& aEs)
                                    aEs.getEvalContext());
         NS_ENSURE_SUCCESS(rv, rv);
     }
-    nsRefPtr sortedNodes;
+    RefPtr sortedNodes;
     rv = sorter.sortNodeSet(nodes, &aEs, getter_AddRefs(sortedNodes));
     NS_ENSURE_SUCCESS(rv, rv);
     
@@ -766,7 +766,7 @@ txSetParam::execute(txExecutionState& aEs)
         NS_ENSURE_TRUE(aEs.mTemplateParams, NS_ERROR_OUT_OF_MEMORY);
     }
 
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     if (mValue) {
         rv = mValue->evaluate(aEs.getEvalContext(),
                               getter_AddRefs(exprRes));
@@ -795,7 +795,7 @@ nsresult
 txSetVariable::execute(txExecutionState& aEs)
 {
     nsresult rv = NS_OK;
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     if (mValue) {
         rv = mValue->evaluate(aEs.getEvalContext(), getter_AddRefs(exprRes));
         NS_ENSURE_SUCCESS(rv, rv);
@@ -929,7 +929,7 @@ txValueOf::txValueOf(nsAutoPtr&& aExpr, bool aDOE)
 nsresult
 txValueOf::execute(txExecutionState& aEs)
 {
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = mExpr->evaluate(aEs.getEvalContext(),
                                   getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
diff --git a/dom/xslt/xslt/txInstructions.h b/dom/xslt/xslt/txInstructions.h
index dab21729da..55138a600a 100644
--- a/dom/xslt/xslt/txInstructions.h
+++ b/dom/xslt/xslt/txInstructions.h
@@ -79,7 +79,7 @@ public:
 
     nsAutoPtr mName;
     nsAutoPtr mNamespace;
-    nsRefPtr mMappings;
+    RefPtr mMappings;
 };
 
 class txCallTemplate : public txInstruction
@@ -352,7 +352,7 @@ public:
 
     nsAutoPtr mName;
     nsAutoPtr mNamespace;
-    nsRefPtr mMappings;
+    RefPtr mMappings;
 };
 
 class txStartLREElement : public txInstruction
diff --git a/dom/xslt/xslt/txKey.h b/dom/xslt/xslt/txKey.h
index cd7e0ebe1b..90a15f2f05 100644
--- a/dom/xslt/xslt/txKey.h
+++ b/dom/xslt/xslt/txKey.h
@@ -56,7 +56,7 @@ public:
     enum { ALLOW_MEMMOVE = true };
     
     txKeyValueHashKey mKey;
-    nsRefPtr mNodeSet;
+    RefPtr mNodeSet;
 };
 
 typedef nsTHashtable txKeyValueHash;
@@ -205,7 +205,7 @@ private:
     const txOwningExpandedNameMap& mKeys;
     
     // Empty nodeset returned if no key is found
-    nsRefPtr mEmptyNodeSet;
+    RefPtr mEmptyNodeSet;
 };
 
 
diff --git a/dom/xslt/xslt/txKeyFunctionCall.cpp b/dom/xslt/xslt/txKeyFunctionCall.cpp
index 9ae5a7e2e9..ae76275ffd 100644
--- a/dom/xslt/xslt/txKeyFunctionCall.cpp
+++ b/dom/xslt/xslt/txKeyFunctionCall.cpp
@@ -54,14 +54,14 @@ txKeyFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
     rv = keyName.init(keyQName, mMappings, false);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsRefPtr exprResult;
+    RefPtr exprResult;
     rv = mParams[1]->evaluate(aContext, getter_AddRefs(exprResult));
     NS_ENSURE_SUCCESS(rv, rv);
 
     txXPathTreeWalker walker(aContext->getContextNode());
     walker.moveToRoot();
 
-    nsRefPtr res;
+    RefPtr res;
     txNodeSet* nodeSet;
     if (exprResult->getResultType() == txAExprResult::NODESET &&
         (nodeSet = static_cast
@@ -75,7 +75,7 @@ txKeyFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
             nsAutoString val;
             txXPathNodeUtils::appendNodeValue(nodeSet->get(i), val);
 
-            nsRefPtr nodes;
+            RefPtr nodes;
             rv = es->getKeyNodes(keyName, walker.getCurrentPosition(), val,
                                  i == 0, getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
@@ -346,7 +346,7 @@ nsresult txXSLKey::testNode(const txXPathNode& aNode,
             nsresult rv = aEs.pushEvalContext(evalContext);
             NS_ENSURE_SUCCESS(rv, rv);
 
-            nsRefPtr exprResult;
+            RefPtr exprResult;
             rv = mKeys[currKey].useExpr->evaluate(evalContext,
                                                   getter_AddRefs(exprResult));
 
diff --git a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
index a5f8d95e17..2250f1e56f 100644
--- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
+++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
@@ -89,7 +89,7 @@ public:
     virtual nsISupports *GetTarget() override { return nullptr; }
 
 private:
-    nsRefPtr mCompiler;
+    RefPtr mCompiler;
     nsCOMPtr    mListener;
     nsCOMPtr            mParser;
     bool mCheckedForXML;
@@ -379,7 +379,7 @@ public:
                        ReferrerPolicy aReferrerPolicy);
 
 private:
-    nsRefPtr mProcessor;
+    RefPtr mProcessor;
     nsCOMPtr mLoaderDocument;
 
     // This exists solely to suppress a warning from nsDerivedSafe
@@ -479,7 +479,7 @@ txCompileObserver::startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler,
     nsCOMPtr parser = do_CreateInstance(kCParserCID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsRefPtr sink = new txStylesheetSink(aCompiler, parser);
+    RefPtr sink = new txStylesheetSink(aCompiler, parser);
     NS_ENSURE_TRUE(sink, NS_ERROR_OUT_OF_MEMORY);
 
     channel->SetNotificationCallbacks(sink);
@@ -501,11 +501,11 @@ TX_LoadSheet(nsIURI* aUri, txMozillaXSLTProcessor* aProcessor,
     aUri->GetSpec(spec);
     MOZ_LOG(txLog::xslt, LogLevel::Info, ("TX_LoadSheet: %s\n", spec.get()));
 
-    nsRefPtr observer =
+    RefPtr observer =
         new txCompileObserver(aProcessor, aLoaderDocument);
     NS_ENSURE_TRUE(observer, NS_ERROR_OUT_OF_MEMORY);
 
-    nsRefPtr compiler =
+    RefPtr compiler =
         new txStylesheetCompiler(NS_ConvertUTF8toUTF16(spec), aReferrerPolicy,
                                  observer);
     NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);
@@ -597,7 +597,7 @@ private:
     {
     }
 
-    nsRefPtr mProcessor;
+    RefPtr mProcessor;
 };
 
 txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor)
@@ -709,11 +709,11 @@ TX_CompileStylesheet(nsINode* aNode, txMozillaXSLTProcessor* aProcessor,
     uri->GetSpec(spec);
     NS_ConvertUTF8toUTF16 stylesheetURI(spec);
 
-    nsRefPtr obs =
+    RefPtr obs =
         new txSyncCompileObserver(aProcessor);
     NS_ENSURE_TRUE(obs, NS_ERROR_OUT_OF_MEMORY);
 
-    nsRefPtr compiler =
+    RefPtr compiler =
         new txStylesheetCompiler(stylesheetURI, doc->GetReferrerPolicy(), obs);
     NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);
 
diff --git a/dom/xslt/xslt/txMozillaTextOutput.cpp b/dom/xslt/xslt/txMozillaTextOutput.cpp
index a3e81d2313..476a7688be 100644
--- a/dom/xslt/xslt/txMozillaTextOutput.cpp
+++ b/dom/xslt/xslt/txMozillaTextOutput.cpp
@@ -75,7 +75,7 @@ txMozillaTextOutput::endDocument(nsresult aResult)
 {
     NS_ENSURE_TRUE(mDocument && mTextParent, NS_ERROR_FAILURE);
 
-    nsRefPtr text = new nsTextNode(mDocument->NodeInfoManager());
+    RefPtr text = new nsTextNode(mDocument->NodeInfoManager());
     
     text->SetText(mText, false);
     nsresult rv = mTextParent->AppendChildTo(text, true);
diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp
index b5d0d67258..1171d63a92 100644
--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
+++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
@@ -195,7 +195,7 @@ txMozillaXMLOutput::comment(const nsString& aData)
 
     TX_ENSURE_CURRENTNODE;
 
-    nsRefPtr comment = new Comment(mNodeInfoManager);
+    RefPtr comment = new Comment(mNodeInfoManager);
 
     rv = comment->SetText(aData, false);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -523,7 +523,7 @@ txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
     mOpenedElementIsHTML = false;
 
     // Create the element
-    nsRefPtr ni =
+    RefPtr ni =
         mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID,
                                       nsIDOMNode::ELEMENT_NODE);
 
@@ -594,7 +594,7 @@ txMozillaXMLOutput::closePrevious(bool aFlushText)
             rv = createTxWrapper();
             NS_ENSURE_SUCCESS(rv, rv);
         }
-        nsRefPtr text = new nsTextNode(mNodeInfoManager);
+        RefPtr text = new nsTextNode(mNodeInfoManager);
 
         rv = text->SetText(mText, false);
         NS_ENSURE_SUCCESS(rv, rv);
@@ -921,7 +921,7 @@ txMozillaXMLOutput::createHTMLElement(nsIAtom* aName,
 
     *aResult = nullptr;
 
-    nsRefPtr ni;
+    RefPtr ni;
     ni = mNodeInfoManager->GetNodeInfo(aName, nullptr,
                                        kNameSpaceID_XHTML,
                                        nsIDOMNode::ELEMENT_NODE);
diff --git a/dom/xslt/xslt/txMozillaXMLOutput.h b/dom/xslt/xslt/txMozillaXMLOutput.h
index 70156fc182..a54425b9f1 100644
--- a/dom/xslt/xslt/txMozillaXMLOutput.h
+++ b/dom/xslt/xslt/txMozillaXMLOutput.h
@@ -96,13 +96,13 @@ private:
                                         // until then the opened element is
                                         // kept in mOpenedElement
     nsCOMPtr mOpenedElement;
-    nsRefPtr mNodeInfoManager;
+    RefPtr mNodeInfoManager;
 
     nsCOMArray mCurrentNodeStack;
 
     nsCOMPtr mNonAddedNode;
 
-    nsRefPtr mNotifier;
+    RefPtr mNotifier;
 
     uint32_t mTreeDepth, mBadChildLevel;
     nsCString mRefreshString;
diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
index d159179f96..011f268b0f 100644
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -286,7 +286,7 @@ public:
 
 private:
     nsCOMPtr mValue;
-    nsRefPtr mTxValue;
+    RefPtr mTxValue;
 };
 
 inline void
@@ -484,7 +484,7 @@ txMozillaXSLTProcessor::AddXSLTParam(const nsString& aName,
         return NS_ERROR_FAILURE;
     }
 
-    nsRefPtr value;
+    RefPtr value;
     if (!aSelect.IsVoid()) {
 
         // Set up context
@@ -536,7 +536,7 @@ txMozillaXSLTProcessor::AddXSLTParam(const nsString& aName,
 
 class nsTransformBlockerEvent : public nsRunnable {
 public:
-  nsRefPtr mProcessor;
+  RefPtr mProcessor;
 
   explicit nsTransformBlockerEvent(txMozillaXSLTProcessor* processor)
     : mProcessor(processor)
@@ -807,7 +807,7 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI,
 
             nsCOMPtr xpathResult = do_QueryInterface(supports);
             if (xpathResult) {
-                nsRefPtr result;
+                RefPtr result;
                 nsresult rv = xpathResult->GetExprResult(getter_AddRefs(result));
                 NS_ENSURE_SUCCESS(rv, rv);
 
@@ -940,7 +940,7 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI,
     nsCOMPtr localName = do_GetAtom(aLocalName);
     txExpandedName varName(nsId, localName);
 
-    nsRefPtr txValue;
+    RefPtr txValue;
     rv = txVariable::Convert(value, getter_AddRefs(txValue));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1289,7 +1289,7 @@ txMozillaXSLTProcessor::WrapObject(JSContext* aCx, JS::Handle aGivenP
 txMozillaXSLTProcessor::Constructor(const GlobalObject& aGlobal,
                                     mozilla::ErrorResult& aRv)
 {
-    nsRefPtr processor =
+    RefPtr processor =
         new txMozillaXSLTProcessor(aGlobal.GetAsSupports());
     return processor.forget();
 }
@@ -1487,7 +1487,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
 
             nsCOMPtr nodeList = do_QueryInterface(supports);
             if (nodeList) {
-                nsRefPtr nodeSet = new txNodeSet(nullptr);
+                RefPtr nodeSet = new txNodeSet(nullptr);
                 if (!nodeSet) {
                     return NS_ERROR_OUT_OF_MEMORY;
                 }
@@ -1559,7 +1559,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
 
             nsISupports** values = static_cast(array);
 
-            nsRefPtr nodeSet = new txNodeSet(nullptr);
+            RefPtr nodeSet = new txNodeSet(nullptr);
             if (!nodeSet) {
                 NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, values);
 
diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.h b/dom/xslt/xslt/txMozillaXSLTProcessor.h
index af840f0857..6fa2ab1338 100644
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.h
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.h
@@ -168,7 +168,7 @@ private:
 
     nsCOMPtr mOwner;
 
-    nsRefPtr mStylesheet;
+    RefPtr mStylesheet;
     nsIDocument* mStylesheetDocument; // weak
     nsCOMPtr mEmbeddedStylesheetRoot;
 
@@ -179,7 +179,7 @@ private:
     nsCOMPtr mObserver;
     txOwningExpandedNameMap mVariables;
     txNamespaceMap mParamNamespaceMap;
-    nsRefPtr mRecycler;
+    RefPtr mRecycler;
 
     uint32_t mFlags;
 };
diff --git a/dom/xslt/xslt/txNodeSorter.cpp b/dom/xslt/xslt/txNodeSorter.cpp
index 848835148e..68881f6f30 100644
--- a/dom/xslt/xslt/txNodeSorter.cpp
+++ b/dom/xslt/xslt/txNodeSorter.cpp
@@ -132,7 +132,7 @@ txNodeSorter::sortNodeSet(txNodeSet* aNodes, txExecutionState* aEs,
 
     *aResult = nullptr;
 
-    nsRefPtr sortedNodes;
+    RefPtr sortedNodes;
     nsresult rv = aEs->recycler()->getNodeSet(getter_AddRefs(sortedNodes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xslt/txStylesheetCompiler.cpp b/dom/xslt/xslt/txStylesheetCompiler.cpp
index 99d4e4ecf5..61b3318a78 100644
--- a/dom/xslt/xslt/txStylesheetCompiler.cpp
+++ b/dom/xslt/xslt/txStylesheetCompiler.cpp
@@ -772,7 +772,7 @@ txStylesheetCompilerState::loadIncludedStylesheet(const nsAString& aURI)
     
     txACompileObserver* observer = static_cast(this);
 
-    nsRefPtr compiler =
+    RefPtr compiler =
         new txStylesheetCompiler(aURI, mStylesheet, &mToplevelIterator,
                                  mReferrerPolicy, observer);
     NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);
@@ -809,7 +809,7 @@ txStylesheetCompilerState::loadImportedStylesheet(const nsAString& aURI,
 
     txACompileObserver* observer = static_cast(this);
 
-    nsRefPtr compiler =
+    RefPtr compiler =
         new txStylesheetCompiler(aURI, mStylesheet, &iter, mReferrerPolicy,
                                  observer);
     NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);
@@ -1083,7 +1083,7 @@ findFunction(nsIAtom* aName, int32_t aNamespaceID,
 extern bool
 TX_XSLTFunctionAvailable(nsIAtom* aName, int32_t aNameSpaceID)
 {
-    nsRefPtr compiler =
+    RefPtr compiler =
         new txStylesheetCompiler(EmptyString(),
                                  mozilla::net::RP_Default, nullptr);
     NS_ENSURE_TRUE(compiler, false);
diff --git a/dom/xslt/xslt/txStylesheetCompiler.h b/dom/xslt/xslt/txStylesheetCompiler.h
index b5be244c68..7fb0f05d60 100644
--- a/dom/xslt/xslt/txStylesheetCompiler.h
+++ b/dom/xslt/xslt/txStylesheetCompiler.h
@@ -38,7 +38,7 @@ public:
     bool mPreserveWhitespace;
     bool mForwardsCompatibleParsing;
     nsString mBaseURI;
-    nsRefPtr mMappings;
+    RefPtr mMappings;
     nsTArray mInstructionNamespaces;
     int32_t mDepth;
 };
@@ -156,7 +156,7 @@ public:
     static void shutdown();
 
 
-    nsRefPtr mStylesheet;
+    RefPtr mStylesheet;
     txHandlerTable* mHandlerTable;
     nsAutoPtr mElementContext;
     txPushNewContext* mSorter;
@@ -166,7 +166,7 @@ public:
     uint16_t mDisAllowed;
 
 protected:
-    nsRefPtr mObserver;
+    RefPtr mObserver;
     nsTArray mInScopeVariables;
     nsTArray mChildCompilerList;
     // embed info, target information is the ID
diff --git a/dom/xslt/xslt/txXPathResultComparator.cpp b/dom/xslt/xslt/txXPathResultComparator.cpp
index b1ed4e2172..e21a9af696 100644
--- a/dom/xslt/xslt/txXPathResultComparator.cpp
+++ b/dom/xslt/xslt/txXPathResultComparator.cpp
@@ -197,7 +197,7 @@ txResultNumberComparator::createSortableValue(Expr *aExpr,
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    nsRefPtr exprRes;
+    RefPtr exprRes;
     nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprRes));
     NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xslt/txXSLTFunctions.h b/dom/xslt/xslt/txXSLTFunctions.h
index 9efe4d3dba..1bc0f9961e 100644
--- a/dom/xslt/xslt/txXSLTFunctions.h
+++ b/dom/xslt/xslt/txXSLTFunctions.h
@@ -46,7 +46,7 @@ public:
     TX_DECL_FUNCTION
 
 private:
-    nsRefPtr mMappings;
+    RefPtr mMappings;
 };
 
 /**
@@ -77,7 +77,7 @@ private:
     };
     
     txStylesheet* mStylesheet;
-    nsRefPtr mMappings;
+    RefPtr mMappings;
 };
 
 /**
@@ -155,7 +155,7 @@ public:
 
 private:
     eType mType;
-    nsRefPtr mMappings; // Used to resolve prefixes
+    RefPtr mMappings; // Used to resolve prefixes
 };
 
 #endif
diff --git a/dom/xslt/xslt/txXSLTNumber.cpp b/dom/xslt/xslt/txXSLTNumber.cpp
index d6f16e0e72..f9ca733d8f 100644
--- a/dom/xslt/xslt/txXSLTNumber.cpp
+++ b/dom/xslt/xslt/txXSLTNumber.cpp
@@ -88,7 +88,7 @@ txXSLTNumber::getValueList(Expr* aValueExpr, txPattern* aCountPattern,
 
     // If the value attribute exists then use that
     if (aValueExpr) {
-        nsRefPtr result;
+        RefPtr result;
         rv = aValueExpr->evaluate(aContext, getter_AddRefs(result));
         NS_ENSURE_SUCCESS(rv, rv);
 
diff --git a/dom/xslt/xslt/txXSLTPatterns.cpp b/dom/xslt/xslt/txXSLTPatterns.cpp
index a61ad00163..7d43e5db94 100644
--- a/dom/xslt/xslt/txXSLTPatterns.cpp
+++ b/dom/xslt/xslt/txXSLTPatterns.cpp
@@ -326,7 +326,7 @@ bool txKeyPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
     nsAutoPtr contextDoc(txXPathNodeUtils::getOwnerDocument(aNode));
     NS_ENSURE_TRUE(contextDoc, false);
 
-    nsRefPtr nodes;
+    RefPtr nodes;
     nsresult rv = es->getKeyNodes(mName, *contextDoc, mValue, true,
                                   getter_AddRefs(nodes));
     NS_ENSURE_SUCCESS(rv, false);
@@ -409,7 +409,7 @@ bool txStepPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
      */
 
     // Create the context node set for evaluating the predicates
-    nsRefPtr nodes;
+    RefPtr nodes;
     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
     NS_ENSURE_SUCCESS(rv, false);
 
@@ -424,7 +424,7 @@ bool txStepPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
     }
 
     Expr* predicate = mPredicates[0];
-    nsRefPtr newNodes;
+    RefPtr newNodes;
     rv = aContext->recycler()->getNodeSet(getter_AddRefs(newNodes));
     NS_ENSURE_SUCCESS(rv, false);
 
@@ -435,7 +435,7 @@ bool txStepPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
         txNodeSetContext predContext(nodes, aContext);
         while (predContext.hasNext()) {
             predContext.next();
-            nsRefPtr exprResult;
+            RefPtr exprResult;
             rv = predicate->evaluate(&predContext, getter_AddRefs(exprResult));
             NS_ENSURE_SUCCESS(rv, false);
 
@@ -469,7 +469,7 @@ bool txStepPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
         predicate = mPredicates[i];
     }
     txForwardContext evalContext(aContext, aNode, nodes);
-    nsRefPtr exprResult;
+    RefPtr exprResult;
     rv = predicate->evaluate(&evalContext, getter_AddRefs(exprResult));
     NS_ENSURE_SUCCESS(rv, false);
 
diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
index 2465f29ac3..eafd31a5dc 100644
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -893,7 +893,7 @@ XULDocument::ExecuteOnBroadcastHandlerFor(Element* aBroadcaster,
 
         nsCOMPtr shell = GetShell();
         if (shell) {
-            nsRefPtr aPresContext = shell->GetPresContext();
+            RefPtr aPresContext = shell->GetPresContext();
 
             // Handle the DOM event
             nsEventStatus status = nsEventStatus_eIgnore;
@@ -1178,7 +1178,7 @@ XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
 {
     nsCOMPtr attrAtom(do_GetAtom(aAttribute));
     void* attrValue = new nsString(aValue);
-    nsRefPtr list = new nsContentList(this,
+    RefPtr list = new nsContentList(this,
                                             MatchAttribute,
                                             nsContentUtils::DestroyMatchString,
                                             attrValue,
@@ -1221,7 +1221,7 @@ XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
       }
     }
 
-    nsRefPtr list = new nsContentList(this,
+    RefPtr list = new nsContentList(this,
                                             MatchAttribute,
                                             nsContentUtils::DestroyMatchString,
                                             attrValue,
@@ -1247,7 +1247,7 @@ XULDocument::Persist(const nsAString& aID,
     nsCOMPtr tag;
     int32_t nameSpaceID;
 
-    nsRefPtr ni = element->GetExistingAttrNameFromQName(aAttr);
+    RefPtr ni = element->GetExistingAttrNameFromQName(aAttr);
     nsresult rv;
     if (ni) {
         tag = ni->NameAtom();
@@ -1999,7 +1999,7 @@ XULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
 
     // Create a XUL content sink, a parser, and kick off a load for
     // the overlay.
-    nsRefPtr sink = new XULContentSinkImpl();
+    RefPtr sink = new XULContentSinkImpl();
     if (!sink) return NS_ERROR_OUT_OF_MEMORY;
 
     rv = sink->Init(this, mCurrentPrototype);
@@ -2288,7 +2288,7 @@ XULDocument::PrepareToWalk()
         piInsertionPoint = indexOfRoot;
     }
 
-    const nsTArray >& processingInstructions =
+    const nsTArray >& processingInstructions =
         mCurrentPrototype->GetProcessingInstructions();
 
     uint32_t total = processingInstructions.Length();
@@ -2304,7 +2304,7 @@ XULDocument::PrepareToWalk()
 
     // Do one-time initialization if we're preparing to walk the
     // master document's prototype.
-    nsRefPtr root;
+    RefPtr root;
 
     if (mState == eState_Master) {
         // Add the root element
@@ -2346,7 +2346,7 @@ XULDocument::CreateAndInsertPI(const nsXULPrototypePI* aProtoPI,
     NS_PRECONDITION(aProtoPI, "null ptr");
     NS_PRECONDITION(aParent, "null ptr");
 
-    nsRefPtr node =
+    RefPtr node =
         NS_NewXMLProcessingInstruction(mNodeInfoManager, aProtoPI->mTarget,
                                        aProtoPI->mData);
 
@@ -2806,7 +2806,7 @@ XULDocument::ResumeWalk()
                 nsXULPrototypeElement* protoele =
                     static_cast(childproto);
 
-                nsRefPtr child;
+                RefPtr child;
 
                 if (!processingOverlayHookupNodes) {
                     rv = CreateElementFromPrototype(protoele,
@@ -2894,7 +2894,7 @@ XULDocument::ResumeWalk()
                     // This does mean that text nodes that are direct children
                     // of  get ignored.
 
-                    nsRefPtr text =
+                    RefPtr text =
                         new nsTextNode(mNodeInfoManager);
 
                     nsXULPrototypeText* textproto =
@@ -3580,7 +3580,7 @@ XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
                 NS_ConvertUTF16toUTF8(aPrototype->mNodeInfo->QualifiedName()).get()));
     }
 
-    nsRefPtr result;
+    RefPtr result;
 
     if (aPrototype->mNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) {
         // If it's a XUL element, it'll be lightweight until somebody
@@ -3593,13 +3593,13 @@ XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
         // what. So we need to copy everything out of the prototype
         // into the element.  Get a nodeinfo from our nodeinfo manager
         // for this node.
-        nsRefPtr newNodeInfo;
+        RefPtr newNodeInfo;
         newNodeInfo = mNodeInfoManager->GetNodeInfo(aPrototype->mNodeInfo->NameAtom(),
                                                     aPrototype->mNodeInfo->GetPrefixAtom(),
                                                     aPrototype->mNodeInfo->NamespaceID(),
                                                     nsIDOMNode::ELEMENT_NODE);
         if (!newNodeInfo) return NS_ERROR_OUT_OF_MEMORY;
-        nsRefPtr xtfNi = newNodeInfo;
+        RefPtr xtfNi = newNodeInfo;
         rv = NS_NewElement(getter_AddRefs(result), newNodeInfo.forget(),
                            NOT_FROM_PARSER);
         if (NS_FAILED(rv))
@@ -3620,7 +3620,7 @@ XULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype,
 {
     nsresult rv;
 
-    nsRefPtr element;
+    RefPtr element;
     rv = CreateElementFromPrototype(aPrototype, getter_AddRefs(element), false);
     if (NS_FAILED(rv)) return rv;
 
@@ -3767,7 +3767,7 @@ XULDocument::AddPrototypeSheets()
     for (int32_t i = 0; i < sheets.Count(); i++) {
         nsCOMPtr uri = sheets[i];
 
-        nsRefPtr incompleteSheet;
+        RefPtr incompleteSheet;
         rv = CSSLoader()->LoadSheet(uri,
                                     mCurrentPrototype->DocumentPrincipal(),
                                     EmptyCString(), this,
diff --git a/dom/xul/XULDocument.h b/dom/xul/XULDocument.h
index 1c83509712..3c2d3d7e40 100644
--- a/dom/xul/XULDocument.h
+++ b/dom/xul/XULDocument.h
@@ -343,7 +343,7 @@ protected:
      * An array of style sheets, that will be added (preserving order) to the
      * document after all of them are loaded (in DoneWalking).
      */
-    nsTArray> mOverlaySheets;
+    nsTArray> mOverlaySheets;
 
     nsCOMPtr     mCommandDispatcher; // [OWNER] of the focus tracker
 
@@ -517,7 +517,7 @@ protected:
     {
     protected:
         XULDocument* mDocument;              // [WEAK]
-        nsRefPtr mObservesElement; // [OWNER]
+        RefPtr mObservesElement; // [OWNER]
         bool mResolved;
 
     public:
@@ -610,19 +610,19 @@ protected:
      * The current prototype that we are walking to construct the
      * content model.
      */
-    nsRefPtr mCurrentPrototype;
+    RefPtr mCurrentPrototype;
 
     /**
      * The master document (outermost, .xul) prototype, from which
      * all subdocuments get their security principals.
      */
-    nsRefPtr mMasterPrototype;
+    RefPtr mMasterPrototype;
 
     /**
      * Owning references to all of the prototype documents that were
      * used to construct this document.
      */
-    nsTArray< nsRefPtr > mPrototypes;
+    nsTArray< RefPtr > mPrototypes;
 
     /**
      * Prepare to walk the current prototype.
@@ -689,7 +689,7 @@ protected:
 
     class CachedChromeStreamListener : public nsIStreamListener {
     protected:
-        nsRefPtr mDocument;
+        RefPtr mDocument;
         bool mProtoLoaded;
 
         virtual ~CachedChromeStreamListener();
@@ -708,8 +708,8 @@ protected:
 
     class ParserObserver : public nsIRequestObserver {
     protected:
-        nsRefPtr mDocument;
-        nsRefPtr mPrototype;
+        RefPtr mDocument;
+        RefPtr mPrototype;
         virtual ~ParserObserver();
 
     public:
diff --git a/dom/xul/nsXULContentSink.cpp b/dom/xul/nsXULContentSink.cpp
index f10f9ffbd4..dd9351c487 100644
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -110,7 +110,7 @@ XULContentSinkImpl::ContextStack::Pop(State* aState)
 
 
 nsresult
-XULContentSinkImpl::ContextStack::GetTopNode(nsRefPtr& aNode)
+XULContentSinkImpl::ContextStack::GetTopNode(RefPtr& aNode)
 {
     if (mDepth == 0)
         return NS_ERROR_UNEXPECTED;
@@ -362,7 +362,7 @@ XULContentSinkImpl::FlushText(bool aCreateTextNode)
         if (! aCreateTextNode)
             break;
 
-        nsRefPtr node;
+        RefPtr node;
         rv = mContextStack.GetTopNode(node);
         if (NS_FAILED(rv)) return rv;
 
@@ -423,7 +423,7 @@ XULContentSinkImpl::NormalizeAttributeString(const char16_t *aExpatName,
         return NS_OK;
     }
 
-    nsRefPtr ni;
+    RefPtr ni;
     ni = mNodeInfoManager->GetNodeInfo(localName, prefix,
                                        nameSpaceID,
                                        nsIDOMNode::ATTRIBUTE_NODE);
@@ -474,7 +474,7 @@ XULContentSinkImpl::HandleStartElement(const char16_t *aName,
   nsContentUtils::SplitExpatName(aName, getter_AddRefs(prefix),
                                  getter_AddRefs(localName), &nameSpaceID);
 
-  nsRefPtr nodeInfo;
+  RefPtr nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                            nsIDOMNode::ELEMENT_NODE);
   
@@ -509,7 +509,7 @@ XULContentSinkImpl::HandleEndElement(const char16_t *aName)
     // the parser's little mind all over the planet.
     nsresult rv;
 
-    nsRefPtr node;
+    RefPtr node;
     rv = mContextStack.GetTopNode(node);
 
     if (NS_FAILED(rv)) {
@@ -632,7 +632,7 @@ XULContentSinkImpl::HandleProcessingInstruction(const char16_t *aTarget,
     const nsDependentString data(aData);
 
     // Note: the created nsXULPrototypePI has mRefCnt == 1
-    nsRefPtr pi = new nsXULPrototypePI();
+    RefPtr pi = new nsXULPrototypePI();
     if (!pi)
         return NS_ERROR_OUT_OF_MEMORY;
 
@@ -936,7 +936,7 @@ XULContentSinkImpl::OpenScript(const char16_t** aAttributes,
       nsCOMPtr globalObject;
       if (doc)
           globalObject = do_QueryInterface(doc->GetWindow());
-      nsRefPtr script =
+      RefPtr script =
           new nsXULPrototypeScript(aLineNumber, version);
       if (! script)
           return NS_ERROR_OUT_OF_MEMORY;
diff --git a/dom/xul/nsXULContentSink.h b/dom/xul/nsXULContentSink.h
index 793685ddd4..0a597334b0 100644
--- a/dom/xul/nsXULContentSink.h
+++ b/dom/xul/nsXULContentSink.h
@@ -90,7 +90,7 @@ protected:
     nsresult AddText(const char16_t* aText, int32_t aLength);
 
 
-    nsRefPtr mNodeInfoManager;
+    RefPtr mNodeInfoManager;
 
     nsresult NormalizeAttributeString(const char16_t *aExpatName,
                                       nsAttrName &aName);
@@ -108,7 +108,7 @@ protected:
     class ContextStack {
     protected:
         struct Entry {
-            nsRefPtr mNode;
+            RefPtr mNode;
             // a LOT of nodes have children; preallocate for 8
             nsPrototypeArray    mChildren;
             State               mState;
@@ -128,7 +128,7 @@ protected:
         nsresult Push(nsXULPrototypeNode* aNode, State aState);
         nsresult Pop(State* aState);
 
-        nsresult GetTopNode(nsRefPtr& aNode);
+        nsresult GetTopNode(RefPtr& aNode);
         nsresult GetTopChildren(nsPrototypeArray** aChildren);
 
         void Clear();
@@ -142,7 +142,7 @@ protected:
     nsWeakPtr              mDocument;             // [OWNER]
     nsCOMPtr       mDocumentURL;          // [OWNER]
 
-    nsRefPtr mPrototype;  // [OWNER]
+    RefPtr mPrototype;  // [OWNER]
 
     // We use regular pointer b/c of funky exports on nsIParser:
     nsParserBase*         mParser;               // [OWNER]
diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp
index 8296d31141..81a87d45ff 100644
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -227,8 +227,8 @@ already_AddRefed
 nsXULElement::Create(nsXULPrototypeElement* aPrototype, mozilla::dom::NodeInfo *aNodeInfo,
                      bool aIsScriptable, bool aIsRoot)
 {
-    nsRefPtr ni = aNodeInfo;
-    nsRefPtr element = new nsXULElement(ni.forget());
+    RefPtr ni = aNodeInfo;
+    RefPtr element = new nsXULElement(ni.forget());
     if (element) {
         if (aPrototype->mHasIdAttribute) {
             element->SetHasID();
@@ -279,7 +279,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
-    nsRefPtr nodeInfo;
+    RefPtr nodeInfo;
     if (aDocument) {
         mozilla::dom::NodeInfo* ni = aPrototype->mNodeInfo;
         nodeInfo = aDocument->NodeInfoManager()->
@@ -289,7 +289,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
         nodeInfo = aPrototype->mNodeInfo;
     }
 
-    nsRefPtr element = Create(aPrototype, nodeInfo,
+    RefPtr element = Create(aPrototype, nodeInfo,
                                             aIsScriptable, aIsRoot);
     element.forget(aResult);
 
@@ -299,7 +299,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
 nsresult
 NS_NewXULElement(Element** aResult, already_AddRefed&& aNodeInfo)
 {
-    nsRefPtr ni = aNodeInfo;
+    RefPtr ni = aNodeInfo;
 
     NS_PRECONDITION(ni, "need nodeinfo for non-proto Create");
 
@@ -317,7 +317,7 @@ void
 NS_TrustedNewXULElement(nsIContent** aResult,
                         already_AddRefed&& aNodeInfo)
 {
-    nsRefPtr ni = aNodeInfo;
+    RefPtr ni = aNodeInfo;
     NS_PRECONDITION(ni, "need nodeinfo for non-proto Create");
 
     // Create an nsXULElement with the specified namespace and tag.
@@ -366,8 +366,8 @@ nsXULElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
 {
     *aResult = nullptr;
 
-    nsRefPtr ni = aNodeInfo;
-    nsRefPtr element = new nsXULElement(ni.forget());
+    RefPtr ni = aNodeInfo;
+    RefPtr element = new nsXULElement(ni.forget());
 
     // XXX TODO: set up RDF generic builder n' stuff if there is a
     // 'datasources' attribute? This is really kind of tricky,
@@ -385,13 +385,13 @@ nsXULElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
 
         // Style rules need to be cloned.
         if (originalValue->Type() == nsAttrValue::eCSSStyleRule) {
-            nsRefPtr ruleClone =
+            RefPtr ruleClone =
                 originalValue->GetCSSStyleRuleValue()->Clone();
 
             nsString stringValue;
             originalValue->ToString(stringValue);
 
-            nsRefPtr styleRule = do_QueryObject(ruleClone);
+            RefPtr styleRule = do_QueryObject(ruleClone);
             attrValue.SetTo(styleRule, &stringValue);
         } else {
             attrValue.SetTo(*originalValue);
@@ -439,7 +439,7 @@ nsXULElement::GetElementsByAttribute(const nsAString& aAttribute,
 {
     nsCOMPtr attrAtom(do_GetAtom(aAttribute));
     void* attrValue = new nsString(aValue);
-    nsRefPtr list =
+    RefPtr list =
         new nsContentList(this,
                           XULDocument::MatchAttribute,
                           nsContentUtils::DestroyMatchString,
@@ -481,7 +481,7 @@ nsXULElement::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
     }
 
     void* attrValue = new nsString(aValue);
-    nsRefPtr list =
+    RefPtr list =
         new nsContentList(this,
                           XULDocument::MatchAttribute,
                           nsContentUtils::DestroyMatchString,
@@ -1609,7 +1609,7 @@ nsXULElement::GetFrameLoader()
     if (!slots)
         return nullptr;
 
-    nsRefPtr loader = slots->mFrameLoader;
+    RefPtr loader = slots->mFrameLoader;
     return loader.forget();
 }
 
@@ -1741,7 +1741,7 @@ nsXULElement::ClickWithInputSource(uint16_t aInputSource)
         nsCOMPtr shell = doc->GetShell();
         if (shell) {
             // strong ref to PresContext so events don't destroy it
-            nsRefPtr context = shell->GetPresContext();
+            RefPtr context = shell->GetPresContext();
 
             bool isCallerChrome = nsContentUtils::IsCallerChrome();
 
@@ -1861,13 +1861,13 @@ nsXULElement::MakeHeavyweight(nsXULPrototypeElement* aPrototype)
 
         // Style rules need to be cloned.
         if (protoattr->mValue.Type() == nsAttrValue::eCSSStyleRule) {
-            nsRefPtr ruleClone =
+            RefPtr ruleClone =
                 protoattr->mValue.GetCSSStyleRuleValue()->Clone();
 
             nsString stringValue;
             protoattr->mValue.ToString(stringValue);
 
-            nsRefPtr styleRule = do_QueryObject(ruleClone);
+            RefPtr styleRule = do_QueryObject(ruleClone);
             attrValue.SetTo(styleRule, &stringValue);
         } else {
             attrValue.SetTo(protoattr->mValue);
@@ -2164,7 +2164,7 @@ nsXULPrototypeAttribute::~nsXULPrototypeAttribute()
 nsresult
 nsXULPrototypeElement::Serialize(nsIObjectOutputStream* aStream,
                                  nsXULPrototypeDocument* aProtoDoc,
-                                 const nsTArray> *aNodeInfos)
+                                 const nsTArray> *aNodeInfos)
 {
     nsresult rv;
 
@@ -2188,7 +2188,7 @@ nsXULPrototypeElement::Serialize(nsIObjectOutputStream* aStream,
     nsAutoString attributeValue;
     uint32_t i;
     for (i = 0; i < mNumAttributes; ++i) {
-        nsRefPtr ni;
+        RefPtr ni;
         if (mAttributes[i].mName.IsAtom()) {
             ni = mNodeInfo->NodeInfoManager()->
                 GetNodeInfo(mAttributes[i].mName.Atom(), nullptr,
@@ -2276,7 +2276,7 @@ nsresult
 nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
                                    nsXULPrototypeDocument* aProtoDoc,
                                    nsIURI* aDocumentURI,
-                                   const nsTArray> *aNodeInfos)
+                                   const nsTArray> *aNodeInfos)
 {
     NS_PRECONDITION(aNodeInfos, "missing nodeinfo array");
 
@@ -2332,7 +2332,7 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
             if (NS_WARN_IF(NS_FAILED(rv))) return rv;
             Type childType = (Type)number;
 
-            nsRefPtr child;
+            RefPtr child;
 
             switch (childType) {
             case eType_Element:
@@ -2355,7 +2355,7 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
                 break;
             case eType_Script: {
                 // language version/options obtained during deserialization.
-                nsRefPtr script = new nsXULPrototypeScript(0, 0);
+                RefPtr script = new nsXULPrototypeScript(0, 0);
 
                 rv = aStream->ReadBoolean(&script->mOutOfLine);
                 if (NS_WARN_IF(NS_FAILED(rv))) return rv;
@@ -2435,7 +2435,7 @@ nsXULPrototypeElement::SetAttrAt(uint32_t aPos, const nsAString& aValue,
     } else if (mAttributes[aPos].mName.Equals(nsGkAtoms::style)) {
         mHasStyleAttribute = true;
         // Parse the element's 'style' attribute
-        nsRefPtr rule;
+        RefPtr rule;
 
         nsCSSParser parser;
 
@@ -2509,7 +2509,7 @@ nsXULPrototypeScript::~nsXULPrototypeScript()
 nsresult
 nsXULPrototypeScript::Serialize(nsIObjectOutputStream* aStream,
                                 nsXULPrototypeDocument* aProtoDoc,
-                                const nsTArray> *aNodeInfos)
+                                const nsTArray> *aNodeInfos)
 {
     NS_ENSURE_TRUE(aProtoDoc, NS_ERROR_UNEXPECTED);
     AutoSafeJSContext cx;
@@ -2591,7 +2591,7 @@ nsresult
 nsXULPrototypeScript::Deserialize(nsIObjectInputStream* aStream,
                                   nsXULPrototypeDocument* aProtoDoc,
                                   nsIURI* aDocumentURI,
-                                  const nsTArray> *aNodeInfos)
+                                  const nsTArray> *aNodeInfos)
 {
     nsresult rv;
     NS_ASSERTION(!mSrcLoading || mSrcLoadWaiters != nullptr ||
@@ -2689,7 +2689,7 @@ nsXULPrototypeScript::DeserializeOutOfLine(nsIObjectInputStream* aInput,
 
 class NotifyOffThreadScriptCompletedRunnable : public nsRunnable
 {
-    nsRefPtr mReceiver;
+    RefPtr mReceiver;
     void *mToken;
 
 public:
@@ -2725,7 +2725,7 @@ OffThreadScriptReceiverCallback(void *aToken, void *aCallbackData)
     // Be careful not to adjust the refcount on the receiver, as this callback
     // may be invoked off the main thread.
     nsIOffThreadScriptReceiver* aReceiver = static_cast(aCallbackData);
-    nsRefPtr notify =
+    RefPtr notify =
         new NotifyOffThreadScriptCompletedRunnable(
             already_AddRefed(aReceiver), aToken);
     NS_DispatchToMainThread(notify);
@@ -2820,7 +2820,7 @@ nsXULPrototypeScript::Set(JSScript* aObject)
 nsresult
 nsXULPrototypeText::Serialize(nsIObjectOutputStream* aStream,
                               nsXULPrototypeDocument* aProtoDoc,
-                              const nsTArray> *aNodeInfos)
+                              const nsTArray> *aNodeInfos)
 {
     nsresult rv;
 
@@ -2839,7 +2839,7 @@ nsresult
 nsXULPrototypeText::Deserialize(nsIObjectInputStream* aStream,
                                 nsXULPrototypeDocument* aProtoDoc,
                                 nsIURI* aDocumentURI,
-                                const nsTArray> *aNodeInfos)
+                                const nsTArray> *aNodeInfos)
 {
     nsresult rv = aStream->ReadString(mValue);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -2856,7 +2856,7 @@ nsXULPrototypeText::Deserialize(nsIObjectInputStream* aStream,
 nsresult
 nsXULPrototypePI::Serialize(nsIObjectOutputStream* aStream,
                             nsXULPrototypeDocument* aProtoDoc,
-                            const nsTArray> *aNodeInfos)
+                            const nsTArray> *aNodeInfos)
 {
     nsresult rv;
 
@@ -2879,7 +2879,7 @@ nsresult
 nsXULPrototypePI::Deserialize(nsIObjectInputStream* aStream,
                               nsXULPrototypeDocument* aProtoDoc,
                               nsIURI* aDocumentURI,
-                              const nsTArray> *aNodeInfos)
+                              const nsTArray> *aNodeInfos)
 {
     nsresult rv;
 
diff --git a/dom/xul/nsXULElement.h b/dom/xul/nsXULElement.h
index e3fc7b9a50..9b4008f754 100644
--- a/dom/xul/nsXULElement.h
+++ b/dom/xul/nsXULElement.h
@@ -44,7 +44,7 @@ class nsIObjectInputStream;
 class nsIObjectOutputStream;
 class nsIOffThreadScriptReceiver;
 class nsXULPrototypeNode;
-typedef nsTArray > nsPrototypeArray;
+typedef nsTArray > nsPrototypeArray;
 
 namespace mozilla {
 class EventChainPreVisitor;
@@ -118,11 +118,11 @@ public:
 
     virtual nsresult Serialize(nsIObjectOutputStream* aStream,
                                nsXULPrototypeDocument* aProtoDoc,
-                               const nsTArray> *aNodeInfos) = 0;
+                               const nsTArray> *aNodeInfos) = 0;
     virtual nsresult Deserialize(nsIObjectInputStream* aStream,
                                  nsXULPrototypeDocument* aProtoDoc,
                                  nsIURI* aDocumentURI,
-                                 const nsTArray> *aNodeInfos) = 0;
+                                 const nsTArray> *aNodeInfos) = 0;
 
 #ifdef NS_BUILD_REFCNT_LOGGING
     virtual const char* ClassName() = 0;
@@ -183,11 +183,11 @@ public:
 
     virtual nsresult Serialize(nsIObjectOutputStream* aStream,
                                nsXULPrototypeDocument* aProtoDoc,
-                               const nsTArray> *aNodeInfos) override;
+                               const nsTArray> *aNodeInfos) override;
     virtual nsresult Deserialize(nsIObjectInputStream* aStream,
                                  nsXULPrototypeDocument* aProtoDoc,
                                  nsIURI* aDocumentURI,
-                                 const nsTArray> *aNodeInfos) override;
+                                 const nsTArray> *aNodeInfos) override;
 
     nsresult SetAttrAt(uint32_t aPos, const nsAString& aValue, nsIURI* aDocumentURI);
 
@@ -198,7 +198,7 @@ public:
 
     nsPrototypeArray         mChildren;
 
-    nsRefPtr mNodeInfo;
+    RefPtr mNodeInfo;
 
     uint32_t                 mNumAttributes:29;
     uint32_t                 mHasIdAttribute:1;
@@ -226,13 +226,13 @@ public:
 
     virtual nsresult Serialize(nsIObjectOutputStream* aStream,
                                nsXULPrototypeDocument* aProtoDoc,
-                               const nsTArray> *aNodeInfos) override;
+                               const nsTArray> *aNodeInfos) override;
     nsresult SerializeOutOfLine(nsIObjectOutputStream* aStream,
                                 nsXULPrototypeDocument* aProtoDoc);
     virtual nsresult Deserialize(nsIObjectInputStream* aStream,
                                  nsXULPrototypeDocument* aProtoDoc,
                                  nsIURI* aDocumentURI,
-                                 const nsTArray> *aNodeInfos) override;
+                                 const nsTArray> *aNodeInfos) override;
     nsresult DeserializeOutOfLine(nsIObjectInputStream* aInput,
                                   nsXULPrototypeDocument* aProtoDoc);
 
@@ -305,11 +305,11 @@ public:
 
     virtual nsresult Serialize(nsIObjectOutputStream* aStream,
                                nsXULPrototypeDocument* aProtoDoc,
-                               const nsTArray> *aNodeInfos) override;
+                               const nsTArray> *aNodeInfos) override;
     virtual nsresult Deserialize(nsIObjectInputStream* aStream,
                                  nsXULPrototypeDocument* aProtoDoc,
                                  nsIURI* aDocumentURI,
-                                 const nsTArray> *aNodeInfos) override;
+                                 const nsTArray> *aNodeInfos) override;
 
     nsString                 mValue;
 };
@@ -333,11 +333,11 @@ public:
 
     virtual nsresult Serialize(nsIObjectOutputStream* aStream,
                                nsXULPrototypeDocument* aProtoDoc,
-                               const nsTArray> *aNodeInfos) override;
+                               const nsTArray> *aNodeInfos) override;
     virtual nsresult Deserialize(nsIObjectInputStream* aStream,
                                  nsXULPrototypeDocument* aProtoDoc,
                                  nsIURI* aDocumentURI,
-                                 const nsTArray> *aNodeInfos) override;
+                                 const nsTArray> *aNodeInfos) override;
 
     nsString                 mTarget;
     nsString                 mData;
@@ -638,7 +638,7 @@ protected:
 
         void Traverse(nsCycleCollectionTraversalCallback &cb);
 
-        nsRefPtr mFrameLoader;
+        RefPtr mFrameLoader;
     };
 
     virtual nsINode::nsSlots* CreateSlots() override;
diff --git a/dom/xul/nsXULPopupListener.cpp b/dom/xul/nsXULPopupListener.cpp
index 213d99473e..829547fc7a 100644
--- a/dom/xul/nsXULPopupListener.cpp
+++ b/dom/xul/nsXULPopupListener.cpp
@@ -234,7 +234,7 @@ nsXULPopupListener::FireFocusOnTargetContent(nsIDOMNode* aTargetNode)
 
     // strong reference to keep this from going away between events
     // XXXbz between what events?  We don't use this local at all!
-    nsRefPtr context = shell->GetPresContext();
+    RefPtr context = shell->GetPresContext();
  
     nsCOMPtr content = do_QueryInterface(aTargetNode);
     nsIFrame* targetFrame = content->GetPrimaryFrame();
diff --git a/dom/xul/nsXULPrototypeCache.cpp b/dom/xul/nsXULPrototypeCache.cpp
index d75dc7cd5b..9e609e4733 100644
--- a/dom/xul/nsXULPrototypeCache.cpp
+++ b/dom/xul/nsXULPrototypeCache.cpp
@@ -150,7 +150,7 @@ nsXULPrototypeCache::GetPrototype(nsIURI* aURI)
     if (NS_FAILED(rv))
         return nullptr;
 
-    nsRefPtr newProto;
+    RefPtr newProto;
     rv = NS_NewXULPrototypeDocument(getter_AddRefs(newProto));
     if (NS_FAILED(rv))
         return nullptr;
@@ -226,7 +226,7 @@ nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
 {
     nsIURI* uri = aDocumentInfo->DocumentURI();
 
-    nsRefPtr info;
+    RefPtr info;
     mXBLDocTable.Get(uri, getter_AddRefs(info));
     if (!info) {
         mXBLDocTable.Put(uri, aDocumentInfo);
@@ -235,7 +235,7 @@ nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
 }
 
 static PLDHashOperator
-FlushSkinXBL(nsIURI* aKey, nsRefPtr& aDocInfo, void* aClosure)
+FlushSkinXBL(nsIURI* aKey, RefPtr& aDocInfo, void* aClosure)
 {
   nsAutoCString str;
   aKey->GetPath(str);
@@ -250,7 +250,7 @@ FlushSkinXBL(nsIURI* aKey, nsRefPtr& aDocInfo, void* aClosure
 }
 
 static PLDHashOperator
-FlushSkinSheets(nsIURI* aKey, nsRefPtr& aSheet, void* aClosure)
+FlushSkinSheets(nsIURI* aKey, RefPtr& aSheet, void* aClosure)
 {
   nsAutoCString str;
   aSheet->GetSheetURI()->GetPath(str);
@@ -265,7 +265,7 @@ FlushSkinSheets(nsIURI* aKey, nsRefPtr& aSheet, void* aClosure)
 }
 
 static PLDHashOperator
-FlushScopedSkinStylesheets(nsIURI* aKey, nsRefPtr &aDocInfo, void* aClosure)
+FlushScopedSkinStylesheets(nsIURI* aKey, RefPtr &aDocInfo, void* aClosure)
 {
   aDocInfo->FlushSkinStylesheets();
   return PL_DHASH_NEXT;
@@ -624,7 +624,7 @@ nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
 }
 
 static PLDHashOperator
-MarkXBLInCCGeneration(nsIURI* aKey, nsRefPtr &aDocInfo,
+MarkXBLInCCGeneration(nsIURI* aKey, RefPtr &aDocInfo,
                       void* aClosure)
 {
     uint32_t* gen = static_cast(aClosure);
@@ -633,7 +633,7 @@ MarkXBLInCCGeneration(nsIURI* aKey, nsRefPtr &aDocInfo,
 }
 
 static PLDHashOperator
-MarkXULInCCGeneration(nsIURI* aKey, nsRefPtr &aDoc,
+MarkXULInCCGeneration(nsIURI* aKey, RefPtr &aDoc,
                       void* aClosure)
 {
     uint32_t* gen = static_cast(aClosure);
diff --git a/dom/xul/nsXULPrototypeDocument.cpp b/dom/xul/nsXULPrototypeDocument.cpp
index 5e08695815..3b4638b2ac 100644
--- a/dom/xul/nsXULPrototypeDocument.cpp
+++ b/dom/xul/nsXULPrototypeDocument.cpp
@@ -91,7 +91,7 @@ NS_IMETHODIMP
 NS_NewXULPrototypeDocument(nsXULPrototypeDocument** aResult)
 {
     *aResult = nullptr;
-    nsRefPtr doc =
+    RefPtr doc =
       new nsXULPrototypeDocument();
 
     nsresult rv = doc->Init();
@@ -153,7 +153,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
        return NS_ERROR_OUT_OF_MEMORY;
 
     // mozilla::dom::NodeInfo table
-    nsTArray> nodeInfos;
+    nsTArray> nodeInfos;
 
     tmp = aStream->Read32(&count);
     if (NS_FAILED(tmp)) {
@@ -185,7 +185,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
           rv = tmp;
         }
 
-        nsRefPtr nodeInfo;
+        RefPtr nodeInfo;
         // Using UINT16_MAX here as we don't know which nodeinfos will be
         // used for attributes and which for elements. And that doesn't really
         // matter.
@@ -207,7 +207,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
         }
 
         if ((nsXULPrototypeNode::Type)type == nsXULPrototypeNode::eType_PI) {
-            nsRefPtr pi = new nsXULPrototypePI();
+            RefPtr pi = new nsXULPrototypePI();
             if (! pi) {
                rv = NS_ERROR_OUT_OF_MEMORY;
                break;
@@ -243,7 +243,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
 
 static nsresult
 GetNodeInfos(nsXULPrototypeElement* aPrototype,
-             nsTArray>& aArray)
+             nsTArray>& aArray)
 {
     if (aArray.IndexOf(aPrototype->mNodeInfo) == aArray.NoIndex) {
         aArray.AppendElement(aPrototype->mNodeInfo);
@@ -252,7 +252,7 @@ GetNodeInfos(nsXULPrototypeElement* aPrototype,
     // Search attributes
     uint32_t i;
     for (i = 0; i < aPrototype->mNumAttributes; ++i) {
-        nsRefPtr ni;
+        RefPtr ni;
         nsAttrName* name = &aPrototype->mAttributes[i].mName;
         if (name->IsAtom()) {
             ni = aPrototype->mNodeInfo->NodeInfoManager()->
@@ -320,7 +320,7 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream)
 #endif
 
     // mozilla::dom::NodeInfo table
-    nsTArray> nodeInfos;
+    nsTArray> nodeInfos;
     if (mRoot) {
       tmp = GetNodeInfos(mRoot, nodeInfos);
       if (NS_FAILED(tmp)) {
@@ -432,7 +432,7 @@ nsXULPrototypeDocument::AddProcessingInstruction(nsXULPrototypePI* aPI)
     return NS_OK;
 }
 
-const nsTArray >&
+const nsTArray >&
 nsXULPrototypeDocument::GetProcessingInstructions() const
 {
     return mProcessingInstructions;
diff --git a/dom/xul/nsXULPrototypeDocument.h b/dom/xul/nsXULPrototypeDocument.h
index b3933e4b77..609080c6fa 100644
--- a/dom/xul/nsXULPrototypeDocument.h
+++ b/dom/xul/nsXULPrototypeDocument.h
@@ -70,7 +70,7 @@ public:
      * @note GetProcessingInstructions retains the ownership (the PI
      *       protos only get deleted when the proto document is deleted)
      */
-    const nsTArray >& GetProcessingInstructions() const;
+    const nsTArray >& GetProcessingInstructions() const;
 
     /**
      * Access the array of style overlays for this document.
@@ -119,14 +119,14 @@ public:
 
 protected:
     nsCOMPtr mURI;
-    nsRefPtr mRoot;
-    nsTArray > mProcessingInstructions;
+    RefPtr mRoot;
+    nsTArray > mProcessingInstructions;
     nsCOMArray mStyleSheetReferences;
 
     bool mLoaded;
-    nsTArray< nsRefPtr > mPrototypeWaiters;
+    nsTArray< RefPtr > mPrototypeWaiters;
 
-    nsRefPtr mNodeInfoManager;
+    RefPtr mNodeInfoManager;
 
     uint32_t mCCGeneration;
     uint32_t mGCNumber;
diff --git a/dom/xul/templates/nsInstantiationNode.cpp b/dom/xul/templates/nsInstantiationNode.cpp
index ad6c621066..6c7f8614ef 100644
--- a/dom/xul/templates/nsInstantiationNode.cpp
+++ b/dom/xul/templates/nsInstantiationNode.cpp
@@ -59,7 +59,7 @@ nsInstantiationNode::Propagate(InstantiationSet& aInstantiations,
             if (node) {
                 nsCOMPtr resource = do_QueryInterface(node);
                 if (resource) {
-                    nsRefPtr nextresult =
+                    RefPtr nextresult =
                         new nsXULTemplateResultRDF(mQuery, *inst, resource);
                     if (! nextresult)
                         return NS_ERROR_OUT_OF_MEMORY;
diff --git a/dom/xul/templates/nsRDFBinding.h b/dom/xul/templates/nsRDFBinding.h
index e8ac6df703..307b7a9454 100644
--- a/dom/xul/templates/nsRDFBinding.h
+++ b/dom/xul/templates/nsRDFBinding.h
@@ -160,7 +160,7 @@ class nsBindingValues
 protected:
 
     // the binding set
-    nsRefPtr mBindings;
+    RefPtr mBindings;
 
     /*
      * A set of values for variable bindings. To look up a binding value,
diff --git a/dom/xul/templates/nsXMLBinding.h b/dom/xul/templates/nsXMLBinding.h
index 79d479ab3f..e728135989 100644
--- a/dom/xul/templates/nsXMLBinding.h
+++ b/dom/xul/templates/nsXMLBinding.h
@@ -83,14 +83,14 @@ class nsXMLBindingValues
 protected:
 
   // the binding set
-  nsRefPtr mBindings;
+  RefPtr mBindings;
 
   /**
    * A set of values for variable bindings. To look up a binding value,
    * scan through the binding set in mBindings for the right target atom.
    * Its index will correspond to the index in this array.
    */
-  nsTArray > mValues;
+  nsTArray > mValues;
 
 public:
 
diff --git a/dom/xul/templates/nsXULContentBuilder.cpp b/dom/xul/templates/nsXULContentBuilder.cpp
index 0a078dc3ae..a98e32989a 100644
--- a/dom/xul/templates/nsXULContentBuilder.cpp
+++ b/dom/xul/templates/nsXULContentBuilder.cpp
@@ -618,7 +618,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
                 rv = SubstituteText(aChild, attrValue, value);
                 if (NS_FAILED(rv)) return rv;
 
-                nsRefPtr content =
+                RefPtr content =
                   new nsTextNode(mRoot->NodeInfo()->NodeInfoManager());
 
                 content->SetText(value, false);
@@ -819,7 +819,7 @@ nsXULContentBuilder::AddPersistentAttributes(Element* aTemplateNode,
         nsCOMPtr tag;
         int32_t nameSpaceID;
 
-        nsRefPtr ni =
+        RefPtr ni =
             aTemplateNode->GetExistingAttrNameFromQName(attribute);
         if (ni) {
             tag = ni->NameAtom();
@@ -1354,7 +1354,7 @@ nsXULContentBuilder::CreateElement(int32_t aNameSpaceID,
     if (! doc)
         return NS_ERROR_NOT_INITIALIZED;
 
-    nsRefPtr nodeInfo =
+    RefPtr nodeInfo =
         doc->NodeInfoManager()->GetNodeInfo(aTag, nullptr, aNameSpaceID,
                                             nsIDOMNode::ELEMENT_NODE);
 
diff --git a/dom/xul/templates/nsXULTemplateBuilder.cpp b/dom/xul/templates/nsXULTemplateBuilder.cpp
index 1405e70d26..d1d55232ac 100644
--- a/dom/xul/templates/nsXULTemplateBuilder.cpp
+++ b/dom/xul/templates/nsXULTemplateBuilder.cpp
@@ -1121,7 +1121,7 @@ nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
                                      nsIContent* aPreviousSibling)
 {
     if (mRoot && nsContentUtils::ContentIsDescendantOf(mRoot, aChild)) {
-        nsRefPtr kungFuDeathGrip(this);
+        RefPtr kungFuDeathGrip(this);
 
         if (mQueryProcessor)
             mQueryProcessor->Done();
@@ -1156,7 +1156,7 @@ nsXULTemplateBuilder::NodeWillBeDestroyed(const nsINode* aNode)
 {
     // The call to RemoveObserver could release the last reference to
     // |this|, so hold another reference.
-    nsRefPtr kungFuDeathGrip(this);
+    RefPtr kungFuDeathGrip(this);
 
     // Break circular references
     if (mQueryProcessor)
diff --git a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
index dddaef2826..e2c01b3336 100644
--- a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
@@ -363,7 +363,7 @@ nsXULTemplateQueryProcessorRDF::CompileQuery(nsIXULTemplateBuilder* aBuilder,
                                              nsIAtom* aMemberVariable,
                                              nsISupports** _retval)
 {
-    nsRefPtr query = new nsRDFQuery(this);
+    RefPtr query = new nsRDFQuery(this);
     if (!query)
         return NS_ERROR_OUT_OF_MEMORY;
 
@@ -559,7 +559,7 @@ nsXULTemplateQueryProcessorRDF::AddBinding(nsIDOMNode* aRuleNode,
     if (NS_FAILED(rv))
         return rv;
 
-    nsRefPtr bindings = mRuleToBindingsMap.GetWeak(aRuleNode);
+    RefPtr bindings = mRuleToBindingsMap.GetWeak(aRuleNode);
     if (!bindings) {
         bindings = new RDFBindingSet();
         mRuleToBindingsMap.Put(aRuleNode, bindings);
@@ -581,7 +581,7 @@ nsXULTemplateQueryProcessorRDF::TranslateRef(nsISupports* aDatasource,
     nsCOMPtr uri;
     gRDFService->GetUnicodeResource(aRefString, getter_AddRefs(uri));
 
-    nsRefPtr refresult = new nsXULTemplateResultRDF(uri);
+    RefPtr refresult = new nsXULTemplateResultRDF(uri);
     if (! refresult)
         return NS_ERROR_OUT_OF_MEMORY;
 
diff --git a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.h b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
index 535d27db81..b5fc4479a1 100644
--- a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
@@ -41,7 +41,7 @@ class nsXULTemplateQueryProcessorRDF final : public nsIXULTemplateQueryProcessor
                                              public nsIRDFObserver
 {
 public:
-    typedef nsTArray > ResultArray;
+    typedef nsTArray > ResultArray;
 
     nsXULTemplateQueryProcessorRDF();
 
diff --git a/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp b/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
index 946676ab9a..b648441af4 100644
--- a/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
@@ -255,7 +255,7 @@ nsXULTemplateQueryProcessorXML::CompileQuery(nsIXULTemplateBuilder* aBuilder,
         return rv.StealNSResult();
     }
 
-    nsRefPtr query =
+    RefPtr query =
         new nsXMLQuery(this, aMemberVariable, Move(compiledexpr));
 
     for (nsIContent* condition = content->GetFirstChild();
@@ -319,14 +319,14 @@ nsXULTemplateQueryProcessorXML::GenerateResults(nsISupports* aDatasource,
         return NS_ERROR_FAILURE;
 
     ErrorResult rv;
-    nsRefPtr exprresults =
+    RefPtr exprresults =
         expr->Evaluate(*context, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE,
                        nullptr, rv);
     if (rv.Failed()) {
         return rv.StealNSResult();
     }
 
-    nsRefPtr results =
+    RefPtr results =
         new nsXULTemplateResultSetXML(xmlquery, exprresults.forget(),
                                       xmlquery->GetBindingSet());
 
@@ -344,7 +344,7 @@ nsXULTemplateQueryProcessorXML::AddBinding(nsIDOMNode* aRuleNode,
     if (mGenerationStarted)
         return NS_ERROR_FAILURE;
 
-    nsRefPtr bindings = mRuleToBindingsMap.GetWeak(aRuleNode);
+    RefPtr bindings = mRuleToBindingsMap.GetWeak(aRuleNode);
     if (!bindings) {
         bindings = new nsXMLBindingSet();
         mRuleToBindingsMap.Put(aRuleNode, bindings);
@@ -384,7 +384,7 @@ nsXULTemplateQueryProcessorXML::TranslateRef(nsISupports* aDatasource,
     if (!rootElement)
         return NS_OK;
     
-    nsRefPtr result = new nsXULTemplateResultXML(nullptr, rootElement, nullptr);
+    RefPtr result = new nsXULTemplateResultXML(nullptr, rootElement, nullptr);
     result.forget(aRef);
 
     return NS_OK;
diff --git a/dom/xul/templates/nsXULTemplateQueryProcessorXML.h b/dom/xul/templates/nsXULTemplateQueryProcessorXML.h
index 8d2d6bd8e0..1b41cb6246 100644
--- a/dom/xul/templates/nsXULTemplateQueryProcessorXML.h
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorXML.h
@@ -77,7 +77,7 @@ class nsXMLQuery final : public nsISupports
 
     nsAutoPtr mResultsExpr;
 
-    nsRefPtr mRequiredBindings;
+    RefPtr mRequiredBindings;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsXMLQuery, NS_IXMLQUERY_IID)
@@ -90,10 +90,10 @@ private:
     nsCOMPtr mQuery;
 
     // the binding set created from  nodes
-    nsRefPtr mBindingSet;
+    RefPtr mBindingSet;
 
     // set of results contained in this enumerator
-    nsRefPtr mResults;
+    RefPtr mResults;
 
     // current position within the list of results
     uint32_t mPosition;
@@ -158,7 +158,7 @@ private:
 
     nsCOMPtr mRoot;
 
-    nsRefPtr mEvaluator;
+    RefPtr mEvaluator;
 
     nsCOMPtr mTemplateBuilder;
 
diff --git a/dom/xul/templates/nsXULTemplateResultSetRDF.cpp b/dom/xul/templates/nsXULTemplateResultSetRDF.cpp
index 38c3f461a9..1ab9a79597 100644
--- a/dom/xul/templates/nsXULTemplateResultSetRDF.cpp
+++ b/dom/xul/templates/nsXULTemplateResultSetRDF.cpp
@@ -65,7 +65,7 @@ nsXULTemplateResultSetRDF::GetNext(nsISupports **aResult)
     if (!mCurrent || !mCheckedNext)
         return NS_ERROR_FAILURE;
 
-    nsRefPtr nextresult =
+    RefPtr nextresult =
         new nsXULTemplateResultRDF(mQuery, mCurrent->mInstantiation, mResource);
     if (!nextresult)
         return NS_ERROR_OUT_OF_MEMORY;
diff --git a/dom/xul/templates/nsXULTemplateResultStorage.h b/dom/xul/templates/nsXULTemplateResultStorage.h
index 3efad0a033..c17d265aae 100644
--- a/dom/xul/templates/nsXULTemplateResultStorage.h
+++ b/dom/xul/templates/nsXULTemplateResultStorage.h
@@ -28,7 +28,7 @@ protected:
 
     ~nsXULTemplateResultStorage();
 
-    nsRefPtr mResultSet;
+    RefPtr mResultSet;
 
     nsCOMArray mValues;
 
diff --git a/editor/composer/nsComposerCommandsUpdater.cpp b/editor/composer/nsComposerCommandsUpdater.cpp
index 0f8ac56aa9..161584101d 100644
--- a/editor/composer/nsComposerCommandsUpdater.cpp
+++ b/editor/composer/nsComposerCommandsUpdater.cpp
@@ -385,7 +385,7 @@ nsComposerCommandsUpdater::Notify(nsITimer *timer)
 nsresult
 NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult)
 {
-  nsRefPtr newThang = new nsComposerCommandsUpdater;
+  RefPtr newThang = new nsComposerCommandsUpdater;
   newThang.forget(aInstancePtrResult);
   return NS_OK;
 }
diff --git a/editor/composer/nsComposerDocumentCommands.cpp b/editor/composer/nsComposerDocumentCommands.cpp
index b903c1e080..2ee7a8d6a8 100644
--- a/editor/composer/nsComposerDocumentCommands.cpp
+++ b/editor/composer/nsComposerDocumentCommands.cpp
@@ -87,7 +87,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
   nsCOMPtr editor = do_QueryInterface(refCon);
   NS_ENSURE_TRUE(editor, NS_ERROR_INVALID_ARG);
 
-  nsRefPtr presContext;
+  RefPtr presContext;
   nsresult rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
@@ -134,7 +134,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
   NS_ENSURE_SUCCESS(rv, rv);
 
   // get pres context
-  nsRefPtr presContext;
+  RefPtr presContext;
   rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
diff --git a/editor/composer/nsEditingSession.cpp b/editor/composer/nsEditingSession.cpp
index 1a104de3cf..3174f3c824 100644
--- a/editor/composer/nsEditingSession.cpp
+++ b/editor/composer/nsEditingSession.cpp
@@ -412,7 +412,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
 
   // Hide selection changes during initialization, in order to hide this
   // from web pages.
-  nsRefPtr fs = presShell->FrameSelection();
+  RefPtr fs = presShell->FrameSelection();
   NS_ENSURE_TRUE(fs, NS_ERROR_FAILURE);
   mozilla::dom::AutoHideSelectionChanges hideSelectionChanges(fs);
 
diff --git a/editor/composer/nsEditingSession.h b/editor/composer/nsEditingSession.h
index a4aa866fae..7c9c1f9cb6 100644
--- a/editor/composer/nsEditingSession.h
+++ b/editor/composer/nsEditingSession.h
@@ -127,7 +127,7 @@ protected:
 
   // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
   // MORE THAN ONE EDITOR PER EDITING SESSION
-  nsRefPtr mStateMaintainer;
+  RefPtr mStateMaintainer;
 
   // Save the editor type so we can create the editor after loading uri
   nsCString       mEditorType;
diff --git a/editor/composer/nsEditorSpellCheck.cpp b/editor/composer/nsEditorSpellCheck.cpp
index f20a66f9e5..36a1bad99b 100644
--- a/editor/composer/nsEditorSpellCheck.cpp
+++ b/editor/composer/nsEditorSpellCheck.cpp
@@ -151,7 +151,7 @@ public:
 private:
   ~DictionaryFetcher() {}
 
-  nsRefPtr mSpellCheck;
+  RefPtr mSpellCheck;
 };
 NS_IMPL_ISUPPORTS(DictionaryFetcher, nsIContentPrefCallback2)
 
@@ -348,7 +348,7 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
 
     nsCOMPtr domSelection;
     aEditor->GetSelection(getter_AddRefs(domSelection));
-    nsRefPtr selection = static_cast(domSelection.get());
+    RefPtr selection = static_cast(domSelection.get());
     NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
     int32_t count = 0;
@@ -357,7 +357,7 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (count > 0) {
-      nsRefPtr range = selection->GetRangeAt(0);
+      RefPtr range = selection->GetRangeAt(0);
       NS_ENSURE_STATE(range);
 
       bool collapsed = false;
@@ -368,7 +368,7 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
         // We don't want to touch the range in the selection,
         // so create a new copy of it.
 
-        nsRefPtr rangeBounds = range->CloneRange();
+        RefPtr rangeBounds = range->CloneRange();
 
         // Make sure the new range spans complete words.
 
@@ -399,7 +399,7 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
     // However, if it does fail, we still need to call the callback since we
     // discard the failure.  Do it asynchronously so that the caller is always
     // guaranteed async behavior.
-    nsRefPtr caller = new CallbackCaller(aCallback);
+    RefPtr caller = new CallbackCaller(aCallback);
     NS_ENSURE_STATE(caller);
     rv = NS_DispatchToMainThread(caller);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -586,7 +586,7 @@ nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary)
 {
   NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
 
-  nsRefPtr kungFuDeathGrip = this;
+  RefPtr kungFuDeathGrip = this;
 
   // The purpose of mUpdateDictionaryRunning is to avoid doing all of this if
   // UpdateCurrentDictionary's helper method DictionaryFetched, which calls us,
@@ -670,7 +670,7 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditorSpellCheckCallback* aCallba
 {
   nsresult rv;
 
-  nsRefPtr kungFuDeathGrip = this;
+  RefPtr kungFuDeathGrip = this;
 
   // Get language with html5 algorithm
   nsCOMPtr rootContent;
@@ -700,7 +700,7 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditorSpellCheckCallback* aCallba
     return NS_ERROR_FAILURE;
   }
 
-  nsRefPtr fetcher =
+  RefPtr fetcher =
     new DictionaryFetcher(this, aCallback, mDictionaryFetcherGroup);
   rootContent->GetLang(fetcher->mRootContentLang);
   nsCOMPtr doc = rootContent->GetCurrentDoc();
@@ -755,7 +755,7 @@ nsresult
 nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
 {
   MOZ_ASSERT(aFetcher);
-  nsRefPtr kungFuDeathGrip = this;
+  RefPtr kungFuDeathGrip = this;
 
   // Important: declare the holder after the callback caller so that the former
   // is destructed first so that it's not active when the callback is called.
diff --git a/editor/libeditor/CreateElementTxn.cpp b/editor/libeditor/CreateElementTxn.cpp
index 906b46606d..a72908dc51 100644
--- a/editor/libeditor/CreateElementTxn.cpp
+++ b/editor/libeditor/CreateElementTxn.cpp
@@ -92,7 +92,7 @@ CreateElementTxn::DoTransaction()
     return NS_OK;
   }
 
-  nsRefPtr selection = mEditor->GetSelection();
+  RefPtr selection = mEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   rv = selection->CollapseNative(mParent, mParent->IndexOf(mNewNode) + 1);
diff --git a/editor/libeditor/DeleteRangeTxn.cpp b/editor/libeditor/DeleteRangeTxn.cpp
index 883d8fe47b..58ce18a97f 100644
--- a/editor/libeditor/DeleteRangeTxn.cpp
+++ b/editor/libeditor/DeleteRangeTxn.cpp
@@ -97,7 +97,7 @@ DeleteRangeTxn::DoTransaction()
   bool bAdjustSelection;
   mEditor->ShouldTxnSetSelection(&bAdjustSelection);
   if (bAdjustSelection) {
-    nsRefPtr selection = mEditor->GetSelection();
+    RefPtr selection = mEditor->GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     res = selection->Collapse(startParent, startOffset);
     NS_ENSURE_SUCCESS(res, res);
@@ -145,10 +145,10 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsINode* aNode,
       numToDel = aEndOffset - aStartOffset;
     }
 
-    nsRefPtr charDataNode =
+    RefPtr charDataNode =
       static_cast(aNode);
 
-    nsRefPtr txn =
+    RefPtr txn =
       new DeleteTextTxn(*mEditor, *charDataNode, aStartOffset, numToDel,
                         mRangeUpdater);
 
@@ -164,7 +164,7 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsINode* aNode,
 
   nsresult res = NS_OK;
   for (int32_t i = aStartOffset; i < aEndOffset; ++i) {
-    nsRefPtr txn = new DeleteNodeTxn();
+    RefPtr txn = new DeleteNodeTxn();
     res = txn->Init(mEditor, child, mRangeUpdater);
     if (NS_SUCCEEDED(res)) {
       AppendChild(txn);
@@ -195,9 +195,9 @@ DeleteRangeTxn::CreateTxnsToDeleteContent(nsINode* aNode,
     }
 
     if (numToDelete) {
-      nsRefPtr dataNode =
+      RefPtr dataNode =
         static_cast(aNode);
-      nsRefPtr txn = new DeleteTextTxn(*mEditor, *dataNode,
+      RefPtr txn = new DeleteTextTxn(*mEditor, *dataNode,
           start, numToDelete, mRangeUpdater);
 
       nsresult res = txn->Init();
@@ -222,7 +222,7 @@ DeleteRangeTxn::CreateTxnsToDeleteNodesBetween()
     nsCOMPtr node = iter->GetCurrentNode();
     NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
-    nsRefPtr txn = new DeleteNodeTxn();
+    RefPtr txn = new DeleteNodeTxn();
 
     res = txn->Init(mEditor, node, mRangeUpdater);
     NS_ENSURE_SUCCESS(res, res);
diff --git a/editor/libeditor/DeleteRangeTxn.h b/editor/libeditor/DeleteRangeTxn.h
index 9b5c3af429..680762e215 100644
--- a/editor/libeditor/DeleteRangeTxn.h
+++ b/editor/libeditor/DeleteRangeTxn.h
@@ -63,7 +63,7 @@ protected:
 protected:
 
   /** p1 in the range */
-  nsRefPtr mRange;
+  RefPtr mRange;
 
   /** the editor for this transaction */
   nsEditor* mEditor;
diff --git a/editor/libeditor/DeleteTextTxn.cpp b/editor/libeditor/DeleteTextTxn.cpp
index 158653ec4a..11b5dd73c7 100644
--- a/editor/libeditor/DeleteTextTxn.cpp
+++ b/editor/libeditor/DeleteTextTxn.cpp
@@ -68,7 +68,7 @@ DeleteTextTxn::DoTransaction()
 
   // Only set selection to deletion point if editor gives permission
   if (mEditor.GetShouldTxnSetSelection()) {
-    nsRefPtr selection = mEditor.GetSelection();
+    RefPtr selection = mEditor.GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     res = selection->Collapse(mCharData, mOffset);
     NS_ASSERTION(NS_SUCCEEDED(res),
diff --git a/editor/libeditor/DeleteTextTxn.h b/editor/libeditor/DeleteTextTxn.h
index 1cfb9bc925..a57c16d027 100644
--- a/editor/libeditor/DeleteTextTxn.h
+++ b/editor/libeditor/DeleteTextTxn.h
@@ -55,7 +55,7 @@ protected:
   nsEditor& mEditor;
 
   /** the CharacterData node to operate upon */
-  nsRefPtr mCharData;
+  RefPtr mCharData;
 
   /** the offset into mCharData where the deletion is to take place */
   uint32_t mOffset;
diff --git a/editor/libeditor/EditAggregateTxn.cpp b/editor/libeditor/EditAggregateTxn.cpp
index 2a790a3df9..421e6e54d5 100644
--- a/editor/libeditor/EditAggregateTxn.cpp
+++ b/editor/libeditor/EditAggregateTxn.cpp
@@ -107,7 +107,7 @@ NS_IMETHODIMP EditAggregateTxn::AppendChild(EditTxn *aTxn)
     return NS_ERROR_NULL_POINTER;
   }
 
-  nsRefPtr *slot = mChildren.AppendElement();
+  RefPtr *slot = mChildren.AppendElement();
   if (!slot) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
diff --git a/editor/libeditor/EditAggregateTxn.h b/editor/libeditor/EditAggregateTxn.h
index 26459b5c5a..740dc75296 100644
--- a/editor/libeditor/EditAggregateTxn.h
+++ b/editor/libeditor/EditAggregateTxn.h
@@ -43,7 +43,7 @@ public:
 protected:
   virtual ~EditAggregateTxn();
 
-  nsTArray< nsRefPtr > mChildren;
+  nsTArray< RefPtr > mChildren;
   nsCOMPtr mName;
 };
 
diff --git a/editor/libeditor/IMETextTxn.cpp b/editor/libeditor/IMETextTxn.cpp
index e105f83883..3b5d960473 100644
--- a/editor/libeditor/IMETextTxn.cpp
+++ b/editor/libeditor/IMETextTxn.cpp
@@ -79,7 +79,7 @@ IMETextTxn::UndoTransaction()
 {
   // Get the selection first so we'll fail before making any changes if we
   // can't get it
-  nsRefPtr selection = mEditor.GetSelection();
+  RefPtr selection = mEditor.GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   nsresult res = mTextNode->DeleteData(mOffset, mStringToInsert.Length());
@@ -106,7 +106,7 @@ IMETextTxn::Merge(nsITransaction* aTransaction, bool* aDidMerge)
   }
 
   // If aTransaction is another IMETextTxn then absorb it
-  nsRefPtr otherTxn = do_QueryObject(aTransaction);
+  RefPtr otherTxn = do_QueryObject(aTransaction);
   if (otherTxn) {
     // We absorb the next IME transaction by adopting its insert string
     mStringToInsert = otherTxn->mStringToInsert;
@@ -167,7 +167,7 @@ IMETextTxn::SetIMESelection(nsEditor& aEditor,
                             uint32_t aLengthOfCompositionString,
                             const TextRangeArray* aRanges)
 {
-  nsRefPtr selection = aEditor.GetSelection();
+  RefPtr selection = aEditor.GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv = selection->StartBatchChanges();
@@ -238,7 +238,7 @@ IMETextTxn::SetIMESelection(nsEditor& aEditor,
       continue;
     }
 
-    nsRefPtr clauseRange;
+    RefPtr clauseRange;
     int32_t startOffset = static_cast(
       aOffsetInNode +
         std::min(textRange.mStartOffset, aLengthOfCompositionString));
diff --git a/editor/libeditor/IMETextTxn.h b/editor/libeditor/IMETextTxn.h
index 65b7f1c1a4..700968acd5 100644
--- a/editor/libeditor/IMETextTxn.h
+++ b/editor/libeditor/IMETextTxn.h
@@ -66,7 +66,7 @@ private:
   nsresult SetSelectionForRanges();
 
   /** The text element to operate upon */
-  nsRefPtr mTextNode;
+  RefPtr mTextNode;
 
   /** The offsets into mTextNode where the insertion should be placed */
   uint32_t mOffset;
@@ -74,7 +74,7 @@ private:
   uint32_t mReplaceLength;
 
   /** The range list **/
-  nsRefPtr mRanges;
+  RefPtr mRanges;
 
   /** The text to insert into mTextNode at mOffset */
   nsString mStringToInsert;
diff --git a/editor/libeditor/InsertNodeTxn.cpp b/editor/libeditor/InsertNodeTxn.cpp
index 141ac6470b..bb9d793602 100644
--- a/editor/libeditor/InsertNodeTxn.cpp
+++ b/editor/libeditor/InsertNodeTxn.cpp
@@ -64,7 +64,7 @@ InsertNodeTxn::DoTransaction()
 
   // Only set selection to insertion point if editor gives permission
   if (mEditor.GetShouldTxnSetSelection()) {
-    nsRefPtr selection = mEditor.GetSelection();
+    RefPtr selection = mEditor.GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     // Place the selection just after the inserted element
     selection->Collapse(mParent, mOffset + 1);
diff --git a/editor/libeditor/InsertTextTxn.cpp b/editor/libeditor/InsertTextTxn.cpp
index bd5343772e..5230c44127 100644
--- a/editor/libeditor/InsertTextTxn.cpp
+++ b/editor/libeditor/InsertTextTxn.cpp
@@ -53,7 +53,7 @@ InsertTextTxn::DoTransaction()
 
   // Only set selection to insertion point if editor gives permission
   if (mEditor.GetShouldTxnSetSelection()) {
-    nsRefPtr selection = mEditor.GetSelection();
+    RefPtr selection = mEditor.GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     res = selection->Collapse(mTextNode,
                               mOffset + mStringToInsert.Length());
@@ -83,7 +83,7 @@ InsertTextTxn::Merge(nsITransaction* aTransaction, bool* aDidMerge)
 
   // If aTransaction is a InsertTextTxn, and if the selection hasn't changed,
   // then absorb it
-  nsRefPtr otherInsTxn = do_QueryObject(aTransaction);
+  RefPtr otherInsTxn = do_QueryObject(aTransaction);
   if (otherInsTxn && IsSequentialInsert(*otherInsTxn)) {
     nsAutoString otherData;
     otherInsTxn->GetData(otherData);
diff --git a/editor/libeditor/InsertTextTxn.h b/editor/libeditor/InsertTextTxn.h
index 235a9746ca..2073d1a7ca 100644
--- a/editor/libeditor/InsertTextTxn.h
+++ b/editor/libeditor/InsertTextTxn.h
@@ -59,7 +59,7 @@ private:
   bool IsSequentialInsert(InsertTextTxn& aOtherTxn);
 
   /** The Text node to operate upon */
-  nsRefPtr mTextNode;
+  RefPtr mTextNode;
 
   /** The offset into mTextNode where the insertion is to take place */
   uint32_t mOffset;
diff --git a/editor/libeditor/PlaceholderTxn.cpp b/editor/libeditor/PlaceholderTxn.cpp
index 168b20ce94..3250e5b568 100644
--- a/editor/libeditor/PlaceholderTxn.cpp
+++ b/editor/libeditor/PlaceholderTxn.cpp
@@ -76,7 +76,7 @@ NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
   NS_ENSURE_TRUE(mStartSel, NS_ERROR_NULL_POINTER);
 
   // now restore selection
-  nsRefPtr selection = mEditor->GetSelection();
+  RefPtr selection = mEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   return mStartSel->RestoreSelection(selection);
 }
@@ -89,7 +89,7 @@ NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
   NS_ENSURE_SUCCESS(res, res);
 
   // now restore selection
-  nsRefPtr selection = mEditor->GetSelection();
+  RefPtr selection = mEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   return mEndSel.RestoreSelection(selection);
 }
@@ -123,7 +123,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, bool *aDidMerg
   // we are absorbing all txn's if mAbsorb is lit.
   if (mAbsorb)
   {
-    nsRefPtr otherTxn = do_QueryObject(aTransaction);
+    RefPtr otherTxn = do_QueryObject(aTransaction);
     if (otherTxn) {
       // special handling for IMETextTxn's: they need to merge with any previous
       // IMETextTxn in this placeholder, if possible.
@@ -254,7 +254,7 @@ NS_IMETHODIMP PlaceholderTxn::Commit()
 
 nsresult PlaceholderTxn::RememberEndingSelection()
 {
-  nsRefPtr selection = mEditor->GetSelection();
+  RefPtr selection = mEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   mEndSel.SaveSelection(selection);
   return NS_OK;
diff --git a/editor/libeditor/SplitNodeTxn.cpp b/editor/libeditor/SplitNodeTxn.cpp
index 6a1d5767a8..f5b8ed87e6 100644
--- a/editor/libeditor/SplitNodeTxn.cpp
+++ b/editor/libeditor/SplitNodeTxn.cpp
@@ -59,7 +59,7 @@ SplitNodeTxn::DoTransaction()
   // Insert the new node
   rv = mEditor.SplitNodeImpl(*mExistingRightNode, mOffset, *mNewLeftNode);
   if (mEditor.GetShouldTxnSetSelection()) {
-    nsRefPtr selection = mEditor.GetSelection();
+    RefPtr selection = mEditor.GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     rv = selection->Collapse(mNewLeftNode, mOffset);
   }
diff --git a/editor/libeditor/TypeInState.cpp b/editor/libeditor/TypeInState.cpp
index bd4d370709..16545b792d 100644
--- a/editor/libeditor/TypeInState.cpp
+++ b/editor/libeditor/TypeInState.cpp
@@ -83,7 +83,7 @@ NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection
   // XXX:
   // XXX: This code temporarily fixes the problem where clicking the mouse in
   // XXX: the same location clears the type-in-state.
-  nsRefPtr selection = static_cast(aSelection);
+  RefPtr selection = static_cast(aSelection);
 
   if (aSelection) {
     int32_t rangeCount = selection->RangeCount();
diff --git a/editor/libeditor/nsEditor.cpp b/editor/libeditor/nsEditor.cpp
index 5fa3b7129d..cd12515158 100644
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -530,7 +530,7 @@ nsEditor::GetIsSelectionEditable(bool *aIsSelectionEditable)
   NS_ENSURE_ARG_POINTER(aIsSelectionEditable);
 
   // get current selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // XXX we just check that the anchor node is editable at the moment
@@ -717,14 +717,14 @@ nsEditor::DoTransaction(nsITransaction* aTxn)
     // XXX: re-entry during initial reflow. - kin
 
     // get the selection and start a batch change
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
     selection->StartBatchChanges();
 
     nsresult res;
     if (mTxnMgr) {
-      nsRefPtr txnMgr = mTxnMgr;
+      RefPtr txnMgr = mTxnMgr;
       res = txnMgr->DoTransaction(aTxn);
     } else {
       res = aTxn->DoTransaction();
@@ -811,7 +811,7 @@ nsEditor::Undo(uint32_t aCount)
     return NS_OK;
   }
 
-  nsRefPtr txnMgr = mTxnMgr;
+  RefPtr txnMgr = mTxnMgr;
   for (uint32_t i = 0; i < aCount; ++i) {
     nsresult rv = txnMgr->UndoTransaction();
     NS_ENSURE_SUCCESS(rv, rv);
@@ -851,7 +851,7 @@ nsEditor::Redo(uint32_t aCount)
     return NS_OK;
   }
 
-  nsRefPtr txnMgr = mTxnMgr;
+  RefPtr txnMgr = mTxnMgr;
   for (uint32_t i = 0; i < aCount; ++i) {
     nsresult rv = txnMgr->RedoTransaction();
     NS_ENSURE_SUCCESS(rv, rv);
@@ -885,7 +885,7 @@ nsEditor::BeginTransaction()
   BeginUpdateViewBatch();
 
   if (mTxnMgr) {
-    nsRefPtr txnMgr = mTxnMgr;
+    RefPtr txnMgr = mTxnMgr;
     txnMgr->BeginBatch(nullptr);
   }
 
@@ -896,7 +896,7 @@ NS_IMETHODIMP
 nsEditor::EndTransaction()
 {
   if (mTxnMgr) {
-    nsRefPtr txnMgr = mTxnMgr;
+    RefPtr txnMgr = mTxnMgr;
     txnMgr->EndBatch(false);
   }
 
@@ -924,7 +924,7 @@ nsEditor::BeginPlaceHolderTransaction(nsIAtom *aName)
     BeginUpdateViewBatch();
     mPlaceHolderTxn = nullptr;
     mPlaceHolderName = aName;
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
     if (selection) {
       mSelState = new nsSelectionState();
       mSelState->SaveSelection(selection);
@@ -941,7 +941,7 @@ nsEditor::EndPlaceHolderTransaction()
   NS_PRECONDITION(mPlaceHolderBatch > 0, "zero or negative placeholder batch count when ending batch!");
   if (mPlaceHolderBatch == 1)
   {
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
 
     // By making the assumption that no reflow happens during the calls
     // to EndUpdateViewBatch and ScrollSelectionIntoView, we are able to
@@ -956,7 +956,7 @@ nsEditor::EndPlaceHolderTransaction()
     {
       // Hide the caret here to avoid hiding it twice, once in EndUpdateViewBatch
       // and once in ScrollSelectionIntoView.
-      nsRefPtr caret;
+      RefPtr caret;
       nsCOMPtr presShell = GetPresShell();
 
       if (presShell)
@@ -1044,7 +1044,7 @@ NS_IMETHODIMP nsEditor::SelectAll()
   if (!mDocWeak) { return NS_ERROR_NOT_INITIALIZED; }
   ForceCompositionEnd();
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
   return SelectEntireDocument(selection);
 }
@@ -1054,7 +1054,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
   if (!mDocWeak) { return NS_ERROR_NOT_INITIALIZED; }
 
   // get the selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   // get the root element
@@ -1089,7 +1089,7 @@ nsEditor::EndOfDocument()
   NS_ENSURE_TRUE(mDocWeak, NS_ERROR_NOT_INITIALIZED);
 
   // get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // get the root element
@@ -1200,7 +1200,7 @@ nsEditor::SetAttribute(nsIDOMElement* aElement, const nsAString& aAttribute,
   NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
   nsCOMPtr attribute = do_GetAtom(aAttribute);
 
-  nsRefPtr txn =
+  RefPtr txn =
     CreateTxnForSetAttribute(*element, *attribute, aValue);
   return DoTransaction(txn);
 }
@@ -1233,7 +1233,7 @@ nsEditor::RemoveAttribute(nsIDOMElement* aElement, const nsAString& aAttribute)
   NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
   nsCOMPtr attribute = do_GetAtom(aAttribute);
 
-  nsRefPtr txn =
+  RefPtr txn =
     CreateTxnForRemoveAttribute(*element, *attribute);
   return DoTransaction(txn);
 }
@@ -1356,7 +1356,7 @@ nsEditor::CreateNode(nsIAtom* aTag,
 
   nsCOMPtr ret;
 
-  nsRefPtr txn =
+  RefPtr txn =
     CreateTxnForCreateElement(*aTag, *aParent, aPosition);
   nsresult res = DoTransaction(txn);
   if (NS_SUCCEEDED(res)) {
@@ -1395,7 +1395,7 @@ nsEditor::InsertNode(nsIContent& aNode, nsINode& aParent, int32_t aPosition)
                              aPosition);
   }
 
-  nsRefPtr txn = CreateTxnForInsertNode(aNode, aParent,
+  RefPtr txn = CreateTxnForInsertNode(aNode, aParent,
                                                        aPosition);
   nsresult res = DoTransaction(txn);
 
@@ -1433,7 +1433,7 @@ nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult)
     listener->WillSplitNode(aNode.AsDOMNode(), aOffset);
   }
 
-  nsRefPtr txn = CreateTxnForSplitNode(aNode, aOffset);
+  RefPtr txn = CreateTxnForSplitNode(aNode, aOffset);
   aResult = DoTransaction(txn);
 
   nsCOMPtr newNode = aResult.Failed() ? nullptr
@@ -1486,7 +1486,7 @@ nsEditor::JoinNodes(nsINode& aLeftNode, nsINode& aRightNode)
   }
 
   nsresult result;
-  nsRefPtr txn = CreateTxnForJoinNode(aLeftNode, aRightNode);
+  RefPtr txn = CreateTxnForJoinNode(aLeftNode, aRightNode);
   if (txn)  {
     result = DoTransaction(txn);
   }
@@ -1521,7 +1521,7 @@ nsEditor::DeleteNode(nsINode* aNode)
     listener->WillDeleteNode(aNode->AsDOMNode());
   }
 
-  nsRefPtr txn;
+  RefPtr txn;
   nsresult res = CreateTxnForDeleteNode(aNode, getter_AddRefs(txn));
   if (NS_SUCCEEDED(res))  {
     res = DoTransaction(txn);
@@ -1795,7 +1795,7 @@ public:
   }
 
 private:
-  nsRefPtr mEditor;
+  RefPtr mEditor;
   nsCOMPtr mTarget;
   bool mIsComposing;
 };
@@ -2212,8 +2212,8 @@ nsEditor::CloneAttributes(Element* aDest, Element* aSource)
   bool destInBody = GetRoot()->Contains(aDest);
 
   // Clear existing attributes
-  nsRefPtr destAttributes = aDest->Attributes();
-  while (nsRefPtr attr = destAttributes->Item(0)) {
+  RefPtr destAttributes = aDest->Attributes();
+  while (RefPtr attr = destAttributes->Item(0)) {
     if (destInBody) {
       RemoveAttribute(static_cast(GetAsDOMNode(aDest)),
                       attr->NodeName());
@@ -2224,10 +2224,10 @@ nsEditor::CloneAttributes(Element* aDest, Element* aSource)
   }
 
   // Set just the attributes that the source element has
-  nsRefPtr sourceAttributes = aSource->Attributes();
+  RefPtr sourceAttributes = aSource->Attributes();
   uint32_t sourceCount = sourceAttributes->Length();
   for (uint32_t i = 0; i < sourceCount; i++) {
-    nsRefPtr attr = sourceAttributes->Item(i);
+    RefPtr attr = sourceAttributes->Item(i);
     nsAutoString value;
     attr->GetValue(value);
     if (destInBody) {
@@ -2359,7 +2359,7 @@ nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
     CheckedInt newOffset;
     if (!node->IsNodeOfType(nsINode::eTEXT)) {
       // create a text node
-      nsRefPtr newNode = aDoc->CreateTextNode(EmptyString());
+      RefPtr newNode = aDoc->CreateTextNode(EmptyString());
       // then we insert it into the dom tree
       res = InsertNode(*newNode, *node, offset);
       NS_ENSURE_SUCCESS(res, res);
@@ -2386,7 +2386,7 @@ nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
     } else {
       // we are inserting text into a non-text node.  first we have to create a
       // textnode (this also populates it with the text)
-      nsRefPtr newNode = aDoc->CreateTextNode(aStringToInsert);
+      RefPtr newNode = aDoc->CreateTextNode(aStringToInsert);
       // then we insert it into the dom tree
       res = InsertNode(*newNode, *node, offset);
       NS_ENSURE_SUCCESS(res, res);
@@ -2406,7 +2406,7 @@ nsEditor::InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
                                      Text& aTextNode,
                                      int32_t aOffset, bool aSuppressIME)
 {
-  nsRefPtr txn;
+  RefPtr txn;
   bool isIMETransaction = false;
   int32_t replacedOffset = 0;
   int32_t replacedLength = 0;
@@ -2583,7 +2583,7 @@ already_AddRefed
 nsEditor::CreateTxnForInsertText(const nsAString& aStringToInsert,
                                  Text& aTextNode, int32_t aOffset)
 {
-  nsRefPtr txn = new InsertTextTxn(aTextNode, aOffset,
+  RefPtr txn = new InsertTextTxn(aTextNode, aOffset,
                                                   aStringToInsert, *this);
   return txn.forget();
 }
@@ -2593,7 +2593,7 @@ nsresult
 nsEditor::DeleteText(nsGenericDOMDataNode& aCharData, uint32_t aOffset,
                      uint32_t aLength)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     CreateTxnForDeleteText(aCharData, aOffset, aLength);
   NS_ENSURE_STATE(txn);
 
@@ -2623,7 +2623,7 @@ already_AddRefed
 nsEditor::CreateTxnForDeleteText(nsGenericDOMDataNode& aCharData,
                                  uint32_t aOffset, uint32_t aLength)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     new DeleteTextTxn(*this, aCharData, aOffset, aLength, &mRangeUpdater);
 
   nsresult res = txn->Init();
@@ -2635,14 +2635,14 @@ nsEditor::CreateTxnForDeleteText(nsGenericDOMDataNode& aCharData,
 already_AddRefed
 nsEditor::CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset)
 {
-  nsRefPtr txn = new SplitNodeTxn(*this, aNode, aOffset);
+  RefPtr txn = new SplitNodeTxn(*this, aNode, aOffset);
   return txn.forget();
 }
 
 already_AddRefed
 nsEditor::CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode)
 {
-  nsRefPtr txn = new JoinNodeTxn(*this, aLeftNode, aRightNode);
+  RefPtr txn = new JoinNodeTxn(*this, aLeftNode, aRightNode);
 
   NS_ENSURE_SUCCESS(txn->CheckValidity(), nullptr);
 
@@ -2661,7 +2661,7 @@ nsEditor::SplitNodeImpl(nsIContent& aExistingRightNode,
                         nsIContent& aNewLeftNode)
 {
   // Get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // Remember some selection points, if selection is set
@@ -2751,7 +2751,7 @@ nsEditor::SplitNodeImpl(nsIContent& aExistingRightNode,
 }
 
 struct SavedRange {
-  nsRefPtr mSelection;
+  RefPtr mSelection;
   nsCOMPtr mStartNode;
   nsCOMPtr mEndNode;
   int32_t mStartOffset;
@@ -2788,7 +2788,7 @@ nsEditor::JoinNodesImpl(nsINode* aNodeToKeep,
     }
 
     for (uint32_t j = 0; j < range.mSelection->RangeCount(); ++j) {
-      nsRefPtr r = range.mSelection->GetRangeAt(j);
+      RefPtr r = range.mSelection->GetRangeAt(j);
       if (!r->IsPositioned()) {
         continue;
       }
@@ -2858,7 +2858,7 @@ nsEditor::JoinNodesImpl(nsINode* aNodeToKeep,
 
   bool shouldSetSelection = GetShouldTxnSetSelection();
 
-  nsRefPtr previousSelection;
+  RefPtr previousSelection;
   for (size_t i = 0; i < savedRanges.Length(); ++i) {
     // And adjust the selection if needed.
     SavedRange& range = savedRanges[i];
@@ -2892,7 +2892,7 @@ nsEditor::JoinNodesImpl(nsINode* aNodeToKeep,
       range.mEndOffset += firstNodeLength;
     }
 
-    nsRefPtr newRange;
+    RefPtr newRange;
     nsresult rv = nsRange::CreateRange(range.mStartNode, range.mStartOffset,
                                        range.mEndNode, range.mEndOffset,
                                        getter_AddRefs(newRange));
@@ -2903,7 +2903,7 @@ nsEditor::JoinNodesImpl(nsINode* aNodeToKeep,
 
   if (shouldSetSelection) {
     // Editor wants us to set selection at join point.
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     selection->Collapse(aNodeToKeep, AssertedCast(firstNodeLength));
   }
@@ -3395,7 +3395,7 @@ IsElementVisible(dom::Element* aElement)
   // display:none subtree, or it might be that we're just dealing with
   // lazy frame construction and it hasn't happened yet.  Check which
   // one it is.
-  nsRefPtr styleContext =
+  RefPtr styleContext =
     nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement,
                                                          nullptr, nullptr);
   if (styleContext) {
@@ -3736,7 +3736,7 @@ nsEditor::IsPreformatted(nsIDOMNode *aNode, bool *aResult)
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
 
   // Look at the node (and its parent if it's not an element), and grab its style context
-  nsRefPtr elementStyle;
+  RefPtr elementStyle;
   if (!content->IsElement()) {
     content = content->GetParent();
   }
@@ -3943,7 +3943,7 @@ nsEditor::BeginUpdateViewBatch()
   {
     // Turn off selection updates and notifications.
 
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
 
     if (selection) {
       selection->StartBatchChanges();
@@ -3970,7 +3970,7 @@ nsresult nsEditor::EndUpdateViewBatch()
   {
     // Turn selection updating and notifications back on.
 
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
     if (selection) {
       selection->EndBatchChanges();
     }
@@ -3992,9 +3992,9 @@ nsEditor::DeleteSelectionImpl(EDirection aAction,
 {
   MOZ_ASSERT(aStripWrappers == eStrip || aStripWrappers == eNoStrip);
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
-  nsRefPtr txn;
+  RefPtr txn;
   nsCOMPtr deleteNode;
   int32_t deleteCharOffset = 0, deleteCharLength = 0;
   nsresult res = CreateTxnForDeleteSelection(aAction, getter_AddRefs(txn),
@@ -4049,7 +4049,7 @@ nsEditor::DeleteSelectionAndCreateElement(nsIAtom& aTag)
   nsresult res = DeleteSelectionAndPrepareToCreateNode();
   NS_ENSURE_SUCCESS(res, nullptr);
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, nullptr);
 
   nsCOMPtr node = selection->GetAnchorNode();
@@ -4092,7 +4092,7 @@ nsresult
 nsEditor::DeleteSelectionAndPrepareToCreateNode()
 {
   nsresult res;
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   MOZ_ASSERT(selection->GetAnchorFocusRange());
 
@@ -4188,7 +4188,7 @@ already_AddRefed
 nsEditor::CreateTxnForSetAttribute(Element& aElement, nsIAtom& aAttribute,
                                    const nsAString& aValue)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     new ChangeAttributeTxn(aElement, aAttribute, &aValue);
 
   return txn.forget();
@@ -4198,7 +4198,7 @@ nsEditor::CreateTxnForSetAttribute(Element& aElement, nsIAtom& aAttribute,
 already_AddRefed
 nsEditor::CreateTxnForRemoveAttribute(Element& aElement, nsIAtom& aAttribute)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     new ChangeAttributeTxn(aElement, aAttribute, nullptr);
 
   return txn.forget();
@@ -4210,7 +4210,7 @@ nsEditor::CreateTxnForCreateElement(nsIAtom& aTag,
                                     nsINode& aParent,
                                     int32_t aPosition)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     new CreateElementTxn(*this, aTag, aParent, aPosition);
 
   return txn.forget();
@@ -4222,7 +4222,7 @@ nsEditor::CreateTxnForInsertNode(nsIContent& aNode,
                                  nsINode& aParent,
                                  int32_t aPosition)
 {
-  nsRefPtr txn = new InsertNodeTxn(aNode, aParent, aPosition,
+  RefPtr txn = new InsertNodeTxn(aNode, aParent, aPosition,
                                                   *this);
   return txn.forget();
 }
@@ -4232,7 +4232,7 @@ nsEditor::CreateTxnForDeleteNode(nsINode* aNode, DeleteNodeTxn** aTxn)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
 
-  nsRefPtr txn = new DeleteNodeTxn();
+  RefPtr txn = new DeleteNodeTxn();
 
   nsresult res = txn->Init(this, aNode, &mRangeUpdater);
   NS_ENSURE_SUCCESS(res, res);
@@ -4247,7 +4247,7 @@ nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert)
   MOZ_ASSERT(mIMETextNode);
   // During handling IME composition, mComposition must have been initialized.
   // TODO: We can simplify IMETextTxn::Init() with TextComposition class.
-  nsRefPtr txn = new IMETextTxn(*mIMETextNode, mIMETextOffset,
+  RefPtr txn = new IMETextTxn(*mIMETextNode, mIMETextOffset,
                                             mIMETextLength,
                                             mComposition->GetRanges(),
                                             aStringToInsert, *this);
@@ -4258,7 +4258,7 @@ nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert)
 NS_IMETHODIMP
 nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
 {
-  nsRefPtr txn = new AddStyleSheetTxn();
+  RefPtr txn = new AddStyleSheetTxn();
 
   nsresult rv = txn->Init(this, aSheet);
   if (NS_SUCCEEDED(rv))
@@ -4274,7 +4274,7 @@ nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aT
 NS_IMETHODIMP
 nsEditor::CreateTxnForRemoveStyleSheet(CSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
 {
-  nsRefPtr txn = new RemoveStyleSheetTxn();
+  RefPtr txn = new RemoveStyleSheetTxn();
 
   nsresult rv = txn->Init(this, aSheet);
   if (NS_SUCCEEDED(rv))
@@ -4296,7 +4296,7 @@ nsEditor::CreateTxnForDeleteSelection(EDirection aAction,
   MOZ_ASSERT(aTxn);
   *aTxn = nullptr;
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   // Check whether the selection is collapsed and we should do nothing:
@@ -4305,16 +4305,16 @@ nsEditor::CreateTxnForDeleteSelection(EDirection aAction,
   }
 
   // allocate the out-param transaction
-  nsRefPtr aggTxn = new EditAggregateTxn();
+  RefPtr aggTxn = new EditAggregateTxn();
 
   for (uint32_t rangeIdx = 0; rangeIdx < selection->RangeCount(); ++rangeIdx) {
-    nsRefPtr range = selection->GetRangeAt(rangeIdx);
+    RefPtr range = selection->GetRangeAt(rangeIdx);
     NS_ENSURE_STATE(range);
 
     // Same with range as with selection; if it is collapsed and action
     // is eNone, do nothing.
     if (!range->Collapsed()) {
-      nsRefPtr txn = new DeleteRangeTxn();
+      RefPtr txn = new DeleteRangeTxn();
       txn->Init(this, range, &mRangeUpdater);
       aggTxn->AppendChild(txn);
     } else if (aAction != eNone) {
@@ -4406,12 +4406,12 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
     // there is a priorNode, so delete its last child (if chardata, delete the
     // last char). if it has no children, delete it
     if (priorNode->IsNodeOfType(nsINode::eDATA_NODE)) {
-      nsRefPtr priorNodeAsCharData =
+      RefPtr priorNodeAsCharData =
         static_cast(priorNode.get());
       uint32_t length = priorNode->Length();
       // Bail out for empty chardata XXX: Do we want to do something else?
       NS_ENSURE_STATE(length);
-      nsRefPtr txn =
+      RefPtr txn =
         CreateTxnForDeleteCharacter(*priorNodeAsCharData, length, ePrevious);
       NS_ENSURE_STATE(txn);
 
@@ -4420,7 +4420,7 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
       aTxn->AppendChild(txn);
     } else {
       // priorNode is not chardata, so tell its parent to delete it
-      nsRefPtr txn;
+      RefPtr txn;
       res = CreateTxnForDeleteNode(priorNode, getter_AddRefs(txn));
       NS_ENSURE_SUCCESS(res, res);
 
@@ -4441,12 +4441,12 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
     // there is a nextNode, so delete its first child (if chardata, delete the
     // first char). if it has no children, delete it
     if (nextNode->IsNodeOfType(nsINode::eDATA_NODE)) {
-      nsRefPtr nextNodeAsCharData =
+      RefPtr nextNodeAsCharData =
         static_cast(nextNode.get());
       uint32_t length = nextNode->Length();
       // Bail out for empty chardata XXX: Do we want to do something else?
       NS_ENSURE_STATE(length);
-      nsRefPtr txn =
+      RefPtr txn =
         CreateTxnForDeleteCharacter(*nextNodeAsCharData, 0, eNext);
       NS_ENSURE_STATE(txn);
 
@@ -4455,7 +4455,7 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
       aTxn->AppendChild(txn);
     } else {
       // nextNode is not chardata, so tell its parent to delete it
-      nsRefPtr txn;
+      RefPtr txn;
       res = CreateTxnForDeleteNode(nextNode, getter_AddRefs(txn));
       NS_ENSURE_SUCCESS(res, res);
       aTxn->AppendChild(txn);
@@ -4467,10 +4467,10 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
   }
 
   if (node->IsNodeOfType(nsINode::eDATA_NODE)) {
-    nsRefPtr nodeAsCharData =
+    RefPtr nodeAsCharData =
       static_cast(node.get());
     // we have chardata, so delete a char at the proper offset
-    nsRefPtr txn = CreateTxnForDeleteCharacter(*nodeAsCharData,
+    RefPtr txn = CreateTxnForDeleteCharacter(*nodeAsCharData,
                                                               offset, aAction);
     NS_ENSURE_STATE(txn);
 
@@ -4501,14 +4501,14 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
     NS_ENSURE_STATE(selectedNode);
 
     if (selectedNode->IsNodeOfType(nsINode::eDATA_NODE)) {
-      nsRefPtr selectedNodeAsCharData =
+      RefPtr selectedNodeAsCharData =
         static_cast(selectedNode.get());
       // we are deleting from a chardata node, so do a character deletion
       uint32_t position = 0;
       if (aAction == ePrevious) {
         position = selectedNode->Length();
       }
-      nsRefPtr delTextTxn =
+      RefPtr delTextTxn =
         CreateTxnForDeleteCharacter(*selectedNodeAsCharData, position,
                                     aAction);
       NS_ENSURE_TRUE(delTextTxn, NS_ERROR_NULL_POINTER);
@@ -4517,7 +4517,7 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange*          aRange,
       *aOffset = delTextTxn->GetOffset();
       *aLength = delTextTxn->GetNumCharsToDelete();
     } else {
-      nsRefPtr delElementTxn;
+      RefPtr delElementTxn;
       res = CreateTxnForDeleteNode(selectedNode, getter_AddRefs(delElementTxn));
       NS_ENSURE_SUCCESS(res, res);
       NS_ENSURE_TRUE(delElementTxn, NS_ERROR_NULL_POINTER);
@@ -4544,7 +4544,7 @@ nsresult
 nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
   nsCOMPtr parentNode;
@@ -4554,7 +4554,7 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
 
   int32_t offset = GetChildOffset(aNode, parentNode);
 
-  nsRefPtr range;
+  RefPtr range;
   res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
@@ -4564,7 +4564,7 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
 
 nsresult nsEditor::ClearSelection()
 {
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
   return selection->RemoveAllRanges();
 }
@@ -4706,7 +4706,7 @@ nsEditor::InitializeSelection(nsIDOMEventTarget* aFocusEventTarget)
     targetNode->NodeType() == nsIDOMNode::DOCUMENT_NODE &&
     targetNode->HasFlag(NODE_IS_EDITABLE);
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   nsCOMPtr presShell = GetPresShell();
@@ -4717,7 +4717,7 @@ nsEditor::InitializeSelection(nsIDOMEventTarget* aFocusEventTarget)
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Init the caret
-  nsRefPtr caret = presShell->GetCaret();
+  RefPtr caret = presShell->GetCaret();
   NS_ENSURE_TRUE(caret, NS_ERROR_UNEXPECTED);
   caret->SetIgnoreUserModify(false);
   caret->SetSelection(selection);
@@ -4780,7 +4780,7 @@ nsEditor::FinalizeSelection()
   nsresult rv = GetSelectionController(getter_AddRefs(selCon));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   selection->SetAncestorLimiter(nullptr);
@@ -5166,12 +5166,12 @@ nsEditor::GetIMESelectionStartOffsetIn(nsINode* aTextNode)
     nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT
   };
   for (auto selectionType : kIMESelectionTypes) {
-    nsRefPtr selection = GetSelection(selectionType);
+    RefPtr selection = GetSelection(selectionType);
     if (!selection) {
       continue;
     }
     for (uint32_t i = 0; i < selection->RangeCount(); i++) {
-      nsRefPtr range = selection->GetRangeAt(i);
+      RefPtr range = selection->GetRangeAt(i);
       if (NS_WARN_IF(!range)) {
         continue;
       }
@@ -5203,7 +5203,7 @@ nsEditor::HideCaret(bool aHide)
 
   nsCOMPtr presShell = GetPresShell();
   NS_ENSURE_TRUE_VOID(presShell);
-  nsRefPtr caret = presShell->GetCaret();
+  RefPtr caret = presShell->GetCaret();
   NS_ENSURE_TRUE_VOID(caret);
 
   mHidingCaret = aHide;
diff --git a/editor/libeditor/nsEditor.h b/editor/libeditor/nsEditor.h
index 4873838fca..06eed2775e 100644
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -838,9 +838,9 @@ protected:
 
   nsCOMPtr mInlineSpellChecker;
 
-  nsRefPtr mTxnMgr;
+  RefPtr mTxnMgr;
   nsCOMPtr mRootElement; // cached root node
-  nsRefPtr    mIMETextNode; // current IME text node
+  RefPtr    mIMETextNode; // current IME text node
   nsCOMPtr mEventTarget; // The form field as an event receiver
   nsCOMPtr mEventListener;
   nsWeakPtr        mSelConWeak;          // weak reference to the nsISelectionController
@@ -851,7 +851,7 @@ protected:
   nsString         *mPhonetic;
   // IME composition this is not null between compositionstart and
   // compositionend.
-  nsRefPtr mComposition;
+  RefPtr mComposition;
 
   // various listeners
   // Listens to all low level actions on the doc
diff --git a/editor/libeditor/nsEditorEventListener.cpp b/editor/libeditor/nsEditorEventListener.cpp
index 433cd1b237..53dba92be1 100644
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -719,7 +719,7 @@ nsEditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
     return NS_ERROR_NULL_POINTER;
   }
 
-  nsRefPtr selection = mEditor->GetSelection();
+  RefPtr selection = mEditor->GetSelection();
   if (selection) {
     selection->Collapse(parent, offset);
   }
@@ -953,7 +953,7 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
   nsCOMPtr dataTransfer = do_QueryInterface(domDataTransfer);
   NS_ENSURE_TRUE(dataTransfer, false);
 
-  nsRefPtr types = dataTransfer->Types();
+  RefPtr types = dataTransfer->Types();
 
   // Plaintext editors only support dropping text. Otherwise, HTML and files
   // can be dropped as well.
@@ -997,7 +997,7 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
     return true;
   }
 
-  nsRefPtr selection = mEditor->GetSelection();
+  RefPtr selection = mEditor->GetSelection();
   if (!selection) {
     return false;
   }
@@ -1022,7 +1022,7 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
   NS_ENSURE_SUCCESS(rv, false);
 
   for (int32_t i = 0; i < rangeCount; i++) {
-    nsRefPtr range = selection->GetRangeAt(i);
+    RefPtr range = selection->GetRangeAt(i);
     if (!range) {
       // Don't bail yet, iterate through them all
       continue;
diff --git a/editor/libeditor/nsEditorEventListener.h b/editor/libeditor/nsEditorEventListener.h
index 0820cd5b72..913bf010bb 100644
--- a/editor/libeditor/nsEditorEventListener.h
+++ b/editor/libeditor/nsEditorEventListener.h
@@ -85,7 +85,7 @@ protected:
   nsresult HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent);
 
   nsEditor* mEditor; // weak
-  nsRefPtr mCaret;
+  RefPtr mCaret;
   bool mCommitText;
   bool mInTransaction;
   bool mMouseDownOrUpConsumedByIME;
diff --git a/editor/libeditor/nsEditorUtils.h b/editor/libeditor/nsEditorUtils.h
index ab2552f9ea..99c6642cec 100644
--- a/editor/libeditor/nsEditorUtils.h
+++ b/editor/libeditor/nsEditorUtils.h
@@ -78,7 +78,7 @@ class MOZ_RAII nsAutoSelectionReset
 {
   private:
     /** ref-counted reference to the selection that we are supposed to restore */
-    nsRefPtr mSel;
+    RefPtr mSel;
     nsEditor *mEd;  // non-owning ref to nsEditor
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
diff --git a/editor/libeditor/nsHTMLAbsPosition.cpp b/editor/libeditor/nsHTMLAbsPosition.cpp
index 9c70648a50..248772dcf5 100644
--- a/editor/libeditor/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/nsHTMLAbsPosition.cpp
@@ -65,7 +65,7 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
 
   // the line below does not match the code; should it be removed?
   // Find out if the selection is collapsed:
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   nsTextRulesInfo ruleInfo(aEnabled ? EditAction::setAbsolutePosition :
@@ -174,7 +174,7 @@ nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
 
   // brade: can we get rid of this comment?
   // Find out if the selection is collapsed:
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   nsTextRulesInfo ruleInfo(aChange < 0 ? EditAction::decreaseZIndex :
                                          EditAction::increaseZIndex);
@@ -425,7 +425,7 @@ nsHTMLEditor::EndMoving()
 
   mGrabberClicked = false;
   mIsMoving = false;
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   if (!selection) {
     return NS_ERROR_NOT_INITIALIZED;
   }
@@ -538,7 +538,7 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
     nsCOMPtr element = do_QueryInterface(aElement);
     if (element && element->IsHTMLElement(nsGkAtoms::div) &&
         !HasStyleOrIdOrClass(element)) {
-      nsRefPtr htmlRules = static_cast(mRules.get());
+      RefPtr htmlRules = static_cast(mRules.get());
       NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
       nsresult res = htmlRules->MakeSureElemStartsOrEndsOnCR(aElement);
       NS_ENSURE_SUCCESS(res, res);
@@ -631,13 +631,13 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
                                          bgColorStr);
     NS_ENSURE_SUCCESS(res, res);
     if (bgColorStr.EqualsLiteral("transparent")) {
-      nsRefPtr cssDecl =
+      RefPtr cssDecl =
         mHTMLCSSUtils->GetComputedStyle(element);
       NS_ENSURE_STATE(cssDecl);
 
       // from these declarations, get the one we want and that one only
       ErrorResult error;
-      nsRefPtr cssVal = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), error);
+      RefPtr cssVal = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), error);
       NS_ENSURE_TRUE(!error.Failed(), error.StealNSResult());
 
       nsROCSSPrimitiveValue* val = cssVal->AsPrimitiveValue();
diff --git a/editor/libeditor/nsHTMLAnonymousUtils.cpp b/editor/libeditor/nsHTMLAnonymousUtils.cpp
index c0d7841b81..96ac8cb2be 100644
--- a/editor/libeditor/nsHTMLAnonymousUtils.cpp
+++ b/editor/libeditor/nsHTMLAnonymousUtils.cpp
@@ -426,7 +426,7 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
     mResizedObjectIsAbsolutelyPositioned = true;
 
     // Get the all the computed css styles attached to the element node
-    nsRefPtr cssDecl =
+    RefPtr cssDecl =
       mHTMLCSSUtils->GetComputedStyle(element);
     NS_ENSURE_STATE(cssDecl);
 
diff --git a/editor/libeditor/nsHTMLCSSUtils.cpp b/editor/libeditor/nsHTMLCSSUtils.cpp
index b20b91835d..63f631f507 100644
--- a/editor/libeditor/nsHTMLCSSUtils.cpp
+++ b/editor/libeditor/nsHTMLCSSUtils.cpp
@@ -435,7 +435,7 @@ nsresult
 nsHTMLCSSUtils::SetCSSProperty(Element& aElement, nsIAtom& aProperty,
                                const nsAString& aValue, bool aSuppressTxn)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     CreateCSSPropertyTxn(aElement, aProperty, aValue, ChangeStyleTxn::eSet);
   if (aSuppressTxn) {
     return txn->DoTransaction();
@@ -460,7 +460,7 @@ nsresult
 nsHTMLCSSUtils::RemoveCSSProperty(Element& aElement, nsIAtom& aProperty,
                                   const nsAString& aValue, bool aSuppressTxn)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     CreateCSSPropertyTxn(aElement, aProperty, aValue, ChangeStyleTxn::eRemove);
   if (aSuppressTxn) {
     return txn->DoTransaction();
@@ -473,7 +473,7 @@ nsHTMLCSSUtils::CreateCSSPropertyTxn(Element& aElement, nsIAtom& aAttribute,
                                      const nsAString& aValue,
                                      ChangeStyleTxn::EChangeType aChangeType)
 {
-  nsRefPtr txn =
+  RefPtr txn =
     new ChangeStyleTxn(aElement, aAttribute, aValue, aChangeType);
   return txn.forget();
 }
@@ -505,7 +505,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
 
   if (aStyleType == eComputed) {
     // Get the all the computed css styles attached to the element node
-    nsRefPtr cssDecl = GetComputedStyle(element);
+    RefPtr cssDecl = GetComputedStyle(element);
     NS_ENSURE_STATE(cssDecl);
 
     // from these declarations, get the one we want and that one only
@@ -516,7 +516,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
   }
 
   MOZ_ASSERT(aStyleType == eSpecified);
-  nsRefPtr rule = element->GetInlineStyleRule();
+  RefPtr rule = element->GetInlineStyleRule();
   if (!rule) {
     return NS_OK;
   }
@@ -540,7 +540,7 @@ nsHTMLCSSUtils::GetComputedStyle(dom::Element* aElement)
   nsIPresShell* presShell = doc->GetShell();
   NS_ENSURE_TRUE(presShell, nullptr);
 
-  nsRefPtr style =
+  RefPtr style =
     NS_NewComputedDOMStyle(aElement, EmptyString(), presShell);
 
   return style.forget();
diff --git a/editor/libeditor/nsHTMLDataTransfer.cpp b/editor/libeditor/nsHTMLDataTransfer.cpp
index 2982122ff8..697adcd97f 100644
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -113,7 +113,7 @@ nsHTMLEditor::LoadHTML(const nsAString & aInputString)
   nsAutoRules beginRulesSniffing(this, EditAction::loadHTML, nsIEditor::eNext);
 
   // Get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   nsTextRulesInfo ruleInfo(EditAction::loadHTML);
@@ -135,7 +135,7 @@ nsHTMLEditor::LoadHTML(const nsAString & aInputString)
     }
 
     // Get the first range in the selection, for context:
-    nsRefPtr range = selection->GetRangeAt(0);
+    RefPtr range = selection->GetRangeAt(0);
     NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
 
     // create fragment for pasted html
@@ -214,7 +214,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
   nsAutoRules beginRulesSniffing(this, EditAction::htmlPaste, nsIEditor::eNext);
 
   // Get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   // create a dom document fragment that represents the structure to paste
@@ -1216,7 +1216,7 @@ nsresult nsHTMLEditor::InsertFromDataTransfer(DataTransfer *aDataTransfer,
                                               bool aDoDeleteSelection)
 {
   ErrorResult rv;
-  nsRefPtr types = aDataTransfer->MozTypesAt(aIndex, rv);
+  RefPtr types = aDataTransfer->MozTypesAt(aIndex, rv);
   if (rv.Failed()) {
     return rv.StealNSResult();
   }
@@ -1555,7 +1555,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
   nsAutoRules beginRulesSniffing(this, EditAction::insertQuotation, nsIEditor::eNext);
 
   // get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // give rules a chance to handle or cancel
@@ -1746,7 +1746,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
     return nsPlaintextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
 
   // get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   nsAutoEditBatch beginBatching(this);
@@ -1836,7 +1836,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
   }
 
   // get selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   nsAutoEditBatch beginBatching(this);
@@ -2007,7 +2007,7 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
   // if we have context info, create a fragment for that
   nsresult rv = NS_OK;
   nsCOMPtr contextLeaf;
-  nsRefPtr contextAsNode;
+  RefPtr contextAsNode;
   if (!aContextStr.IsEmpty()) {
     rv = ParseFragment(aContextStr, nullptr, doc, getter_AddRefs(contextAsNode),
                        aTrustedInput);
@@ -2038,7 +2038,7 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
   } else {
     contextAtom = nsGkAtoms::body;
   }
-  nsRefPtr fragment;
+  RefPtr fragment;
   rv = ParseFragment(aInputString,
                      contextAtom,
                      doc,
@@ -2108,7 +2108,7 @@ nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
 {
   nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
 
-  nsRefPtr fragment =
+  RefPtr fragment =
     new DocumentFragment(aTargetDocument->NodeInfoManager());
   nsresult rv = nsContentUtils::ParseFragmentHTML(aFragStr,
                                                   fragment,
@@ -2144,7 +2144,7 @@ nsHTMLEditor::CreateListOfNodesToPaste(DocumentFragment& aFragment,
     aEndOffset = aFragment.Length();
   }
 
-  nsRefPtr docFragRange;
+  RefPtr docFragRange;
   nsresult rv = nsRange::CreateRange(aStartNode, aStartOffset,
                                      aEndNode, aEndOffset,
                                      getter_AddRefs(docFragRange));
diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp
index 5cf340f1db..f7a2539d7f 100644
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -314,7 +314,7 @@ nsHTMLEditRules::BeforeEdit(EditAction action,
 
     // get selection
     NS_ENSURE_STATE(mHTMLEditor);
-    nsRefPtr selection = mHTMLEditor->GetSelection();
+    RefPtr selection = mHTMLEditor->GetSelection();
 
     // get the selection location
     NS_ENSURE_STATE(selection->RangeCount());
@@ -421,7 +421,7 @@ nsHTMLEditRules::AfterEditInner(EditAction action,
   if (action == EditAction::ignore) return NS_OK;
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   NS_ENSURE_STATE(selection);
 
   nsCOMPtr rangeStartParent, rangeEndParent;
@@ -584,7 +584,7 @@ nsHTMLEditRules::WillDoAction(Selection* aSelection,
   }
   NS_ENSURE_TRUE(aSelection->RangeCount(), NS_OK);
 
-  nsRefPtr range = aSelection->GetRangeAt(0);
+  RefPtr range = aSelection->GetRangeAt(0);
   nsCOMPtr selStartNode = range->GetStartParent();
 
   NS_ENSURE_STATE(mHTMLEditor);
@@ -793,7 +793,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
 
   // get selection
   NS_ENSURE_STATE(mHTMLEditor);
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   NS_ENSURE_STATE(selection);
 
   // get selection location
@@ -830,7 +830,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
   }
   else
   {
-    nsTArray> arrayOfRanges;
+    nsTArray> arrayOfRanges;
     GetPromotedRanges(*selection, arrayOfRanges, EditAction::align);
 
     // use these ranges to construct a list of nodes to act on.
@@ -1006,7 +1006,7 @@ nsHTMLEditRules::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
     NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
     int32_t selOffset;
     NS_ENSURE_STATE(mHTMLEditor);
-    nsRefPtr selection = mHTMLEditor->GetSelection();
+    RefPtr selection = mHTMLEditor->GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
     // test start parent hierarchy
@@ -1081,7 +1081,7 @@ nsHTMLEditRules::GetParagraphState(bool *aMixed, nsAString &outFormat)
     nsCOMPtr selNode;
     int32_t selOffset;
     NS_ENSURE_STATE(mHTMLEditor);
-    nsRefPtr selection = mHTMLEditor->GetSelection();
+    RefPtr selection = mHTMLEditor->GetSelection();
     NS_ENSURE_STATE(selection);
     NS_ENSURE_STATE(mHTMLEditor);
     res = mHTMLEditor->GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
@@ -2000,7 +2000,7 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
           }
         }
       } else {
-        nsRefPtr range = aSelection->GetRangeAt(0);
+        RefPtr range = aSelection->GetRangeAt(0);
         NS_ENSURE_STATE(range);
 
         NS_ASSERTION(range->GetStartParent() == visNode,
@@ -3338,7 +3338,7 @@ nsHTMLEditRules::WillRemoveList(Selection* aSelection,
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
 
-  nsTArray> arrayOfRanges;
+  nsTArray> arrayOfRanges;
   GetPromotedRanges(*aSelection, arrayOfRanges, EditAction::makeList);
 
   // use these ranges to contruct a list of nodes to act on.
@@ -3818,7 +3818,7 @@ nsHTMLEditRules::WillHTMLIndent(Selection* aSelection,
   // block parent, and then further expands to include any ancestors
   // whose children are all in the range
 
-  nsTArray> arrayOfRanges;
+  nsTArray> arrayOfRanges;
   GetPromotedRanges(*aSelection, arrayOfRanges, EditAction::indent);
 
   // use these ranges to contruct a list of nodes to act on.
@@ -5155,7 +5155,7 @@ nsHTMLEditRules::ExpandSelectionForDeletion(Selection* aSelection)
   if (rangeCount != 1) return NS_OK;
 
   // find current sel start and end
-  nsRefPtr range = aSelection->GetRangeAt(0);
+  RefPtr range = aSelection->GetRangeAt(0);
   NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
   nsCOMPtr selStartNode, selEndNode, selCommon;
   int32_t selStartOffset, selEndOffset;
@@ -5279,7 +5279,7 @@ nsHTMLEditRules::ExpandSelectionForDeletion(Selection* aSelection)
     // create a range that represents expanded selection
     nsCOMPtr node = do_QueryInterface(selStartNode);
     NS_ENSURE_STATE(node);
-    nsRefPtr range = new nsRange(node);
+    RefPtr range = new nsRange(node);
     res = range->SetStart(selStartNode, selStartOffset);
     NS_ENSURE_SUCCESS(res, res);
     res = range->SetEnd(selEndNode, selEndOffset);
@@ -5334,7 +5334,7 @@ nsHTMLEditRules::NormalizeSelection(Selection* inSelection)
   // we don't need to mess with cell selections, and we assume multirange selections are those.
   if (rangeCount != 1) return NS_OK;
 
-  nsRefPtr range = inSelection->GetRangeAt(0);
+  RefPtr range = inSelection->GetRangeAt(0);
   NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
   nsCOMPtr startNode, endNode;
   int32_t startOffset, endOffset;
@@ -5659,17 +5659,17 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
 //
 void
 nsHTMLEditRules::GetPromotedRanges(Selection& aSelection,
-                                   nsTArray>& outArrayOfRanges,
+                                   nsTArray>& outArrayOfRanges,
                                    EditAction inOperationType)
 {
   uint32_t rangeCount = aSelection.RangeCount();
 
   for (uint32_t i = 0; i < rangeCount; i++) {
-    nsRefPtr selectionRange = aSelection.GetRangeAt(i);
+    RefPtr selectionRange = aSelection.GetRangeAt(i);
     MOZ_ASSERT(selectionRange);
 
     // Clone range so we don't muck with actual selection ranges
-    nsRefPtr opRange = selectionRange->CloneRange();
+    RefPtr opRange = selectionRange->CloneRange();
 
     // Make a new adjusted range to represent the appropriate block content.
     // The basic idea is to push out the range endpoints to truly enclose the
@@ -5732,7 +5732,7 @@ nsHTMLEditRules::PromoteRange(nsRange& aRange, EditAction aOperationType)
   nsCOMPtr opStartNode;
   nsCOMPtr opEndNode;
   int32_t opStartOffset, opEndOffset;
-  nsRefPtr opRange;
+  RefPtr opRange;
 
   GetPromotedPoint(kStart, GetAsDOMNode(startNode), startOffset,
                    aOperationType, address_of(opStartNode), &opStartOffset);
@@ -5774,7 +5774,7 @@ private:
 //                       new array of nodes to be acted on.
 //
 nsresult
-nsHTMLEditRules::GetNodesForOperation(nsTArray>& aArrayOfRanges,
+nsHTMLEditRules::GetNodesForOperation(nsTArray>& aArrayOfRanges,
                                       nsTArray>& aOutArrayOfNodes,
                                       EditAction aOperationType,
                                       TouchContent aTouchContent)
@@ -5915,7 +5915,7 @@ nsHTMLEditRules::GetListActionNodes(nsTArray>& aOutArrayO
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr kungFuDeathGrip(mHTMLEditor);
 
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
   // Added this in so that ui code can ask to change an entire list, even if
@@ -5923,7 +5923,7 @@ nsHTMLEditRules::GetListActionNodes(nsTArray>& aOutArrayO
   if (aEntireList == EntireList::yes) {
     uint32_t rangeCount = selection->RangeCount();
     for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
-      nsRefPtr range = selection->GetRangeAt(rangeIdx);
+      RefPtr range = selection->GetRangeAt(rangeIdx);
       for (nsCOMPtr parent = range->GetCommonAncestor();
            parent; parent = parent->GetParentNode()) {
         if (nsHTMLEditUtils::IsList(parent)) {
@@ -6056,7 +6056,7 @@ nsHTMLEditRules::GetParagraphFormatNodes(nsTArray>& outAr
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr kungFuDeathGrip(mHTMLEditor);
 
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   NS_ENSURE_STATE(selection);
 
   // Contruct a list of nodes to act on.
@@ -6229,7 +6229,7 @@ nsHTMLEditRules::GetNodesFromPoint(::DOMPoint aPoint,
                                    TouchContent aTouchContent)
 {
   NS_ENSURE_STATE(aPoint.node);
-  nsRefPtr range = new nsRange(aPoint.node);
+  RefPtr range = new nsRange(aPoint.node);
   nsresult res = range->SetStart(aPoint.node, aPoint.offset);
   MOZ_ASSERT(NS_SUCCEEDED(res));
 
@@ -6237,7 +6237,7 @@ nsHTMLEditRules::GetNodesFromPoint(::DOMPoint aPoint,
   PromoteRange(*range, aOperation);
 
   // Make array of ranges
-  nsTArray> arrayOfRanges;
+  nsTArray> arrayOfRanges;
 
   // Stuff new opRange into array
   arrayOfRanges.AppendElement(range);
@@ -6262,7 +6262,7 @@ nsHTMLEditRules::GetNodesFromSelection(Selection& aSelection,
                                        TouchContent aTouchContent)
 {
   // Promote selection ranges
-  nsTArray> arrayOfRanges;
+  nsTArray> arrayOfRanges;
   GetPromotedRanges(aSelection, arrayOfRanges, aOperation);
 
   // Use these ranges to contruct a list of nodes to act on.
@@ -7264,7 +7264,7 @@ nsHTMLEditRules::ReapplyCachedStyles()
 
   // get selection point; if it doesn't exist, we have nothing to do
   NS_ENSURE_STATE(mHTMLEditor);
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   MOZ_ASSERT(selection);
   if (!selection->RangeCount()) {
     // Nothing to do
@@ -7384,7 +7384,7 @@ nsHTMLEditRules::PinSelectionToNewBlock(Selection* aSelection)
   // use ranges and sRangeHelper to compare sel point to new block
   nsCOMPtr node = do_QueryInterface(selNode);
   NS_ENSURE_STATE(node);
-  nsRefPtr range = new nsRange(node);
+  RefPtr range = new nsRange(node);
   res = range->SetStart(selNode, selOffset);
   NS_ENSURE_SUCCESS(res, res);
   res = range->SetEnd(selNode, selOffset);
@@ -7898,12 +7898,12 @@ nsHTMLEditRules::SelectionEndpointInNode(nsINode* aNode, bool* aResult)
   *aResult = false;
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   NS_ENSURE_STATE(selection);
 
   uint32_t rangeCount = selection->RangeCount();
   for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
-    nsRefPtr range = selection->GetRangeAt(rangeIdx);
+    RefPtr range = selection->GetRangeAt(rangeIdx);
     nsCOMPtr startParent, endParent;
     range->GetStartContainer(getter_AddRefs(startParent));
     if (startParent)
@@ -8100,7 +8100,7 @@ nsHTMLEditRules::ConfirmSelectionInBody()
 
   // get the selection
   NS_ENSURE_STATE(mHTMLEditor);
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   NS_ENSURE_STATE(selection);
 
   // get the selection start location
@@ -8416,7 +8416,7 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection* aSelection)
   if (!mListenerEnabled) {
     return NS_OK;
   }
-  nsRefPtr selection = static_cast(aSelection);
+  RefPtr selection = static_cast(aSelection);
   // get the (collapsed) selection location
   nsCOMPtr selNode;
   int32_t selOffset;
@@ -8781,7 +8781,7 @@ nsHTMLEditRules::WillAbsolutePosition(Selection* aSelection,
   // block parent, and then further expands to include any ancestors
   // whose children are all in the range
 
-  nsTArray> arrayOfRanges;
+  nsTArray> arrayOfRanges;
   GetPromotedRanges(*aSelection, arrayOfRanges,
                     EditAction::setAbsolutePosition);
 
@@ -9049,7 +9049,7 @@ nsHTMLEditRules::DocumentModifiedWorker()
   nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
 
   nsCOMPtr kungFuDeathGrip(mHTMLEditor);
-  nsRefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr selection = mHTMLEditor->GetSelection();
   if (!selection) {
     return;
   }
diff --git a/editor/libeditor/nsHTMLEditRules.h b/editor/libeditor/nsHTMLEditRules.h
index 33eee5b5c8..0bdcc0f8a1 100644
--- a/editor/libeditor/nsHTMLEditRules.h
+++ b/editor/libeditor/nsHTMLEditRules.h
@@ -265,11 +265,11 @@ protected:
                         int32_t aOffset, EditAction actionID,
                         nsCOMPtr* outNode, int32_t* outOffset);
   void GetPromotedRanges(mozilla::dom::Selection& aSelection,
-                         nsTArray>& outArrayOfRanges,
+                         nsTArray>& outArrayOfRanges,
                          EditAction inOperationType);
   void PromoteRange(nsRange& aRange, EditAction inOperationType);
   enum class TouchContent { no, yes };
-  nsresult GetNodesForOperation(nsTArray>& aArrayOfRanges,
+  nsresult GetNodesForOperation(nsTArray>& aArrayOfRanges,
                                 nsTArray>& aOutArrayOfNodes,
                                 EditAction aOperationType,
                                 TouchContent aTouchContent = TouchContent::yes);
@@ -347,16 +347,16 @@ protected:
 // data members
 protected:
   nsHTMLEditor           *mHTMLEditor;
-  nsRefPtr       mDocChangeRange;
+  RefPtr       mDocChangeRange;
   bool                    mListenerEnabled;
   bool                    mReturnInEmptyLIKillsList;
   bool                    mDidDeleteSelection;
   bool                    mDidRangedDelete;
   bool                    mRestoreContentEditableCount;
-  nsRefPtr       mUtilRange;
+  RefPtr       mUtilRange;
   uint32_t                mJoinOffset;  // need to remember an int across willJoin/didJoin...
   nsCOMPtr    mNewBlock;
-  nsRefPtr  mRangeItem;
+  RefPtr  mRangeItem;
   StyleCache              mCachedStyles[SIZE_STYLE_TABLE];
 };
 
diff --git a/editor/libeditor/nsHTMLEditor.cpp b/editor/libeditor/nsHTMLEditor.cpp
index 3bcf39afa3..d4cdd62394 100644
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -121,7 +121,7 @@ nsHTMLEditor::~nsHTMLEditor()
 
   //the autopointers will clear themselves up.
   //but we need to also remove the listeners or we have a leak
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   // if we don't get the selection, just skip this
   if (selection) {
     nsCOMPtrlistener;
@@ -285,7 +285,7 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
       AddOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/EditorOverride.css"));
     }
 
-    nsRefPtr selection = GetSelection();
+    RefPtr selection = GetSelection();
     if (selection)
     {
       nsCOMPtrlistener;
@@ -511,7 +511,7 @@ nsHTMLEditor::BeginningOfDocument()
   }
 
   // Get the selection
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   // Get the root element.
@@ -626,7 +626,7 @@ nsHTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
         return NS_OK;
       }
 
-      nsRefPtr selection = GetSelection();
+      RefPtr selection = GetSelection();
       NS_ENSURE_TRUE(selection && selection->RangeCount(), NS_ERROR_FAILURE);
 
       nsCOMPtr node = selection->GetRangeAt(0)->GetStartParent();
@@ -804,7 +804,7 @@ nsHTMLEditor::IsBlockNode(nsINode *aNode)
 NS_IMETHODIMP
 nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
 {
-  nsRefPtr txn = new SetDocTitleTxn();
+  RefPtr txn = new SetDocTitleTxn();
   NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
 
   nsresult result = txn->Init(this, &aTitle);
@@ -1000,7 +1000,7 @@ nsHTMLEditor::UpdateBaseURL()
   NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
 
   // Look for an HTML  tag
-  nsRefPtr nodeList =
+  RefPtr nodeList =
     doc->GetElementsByTagName(NS_LITERAL_STRING("base"));
 
   // If no base tag, then set baseURL to the document's URL.  This is very
@@ -1082,7 +1082,7 @@ nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
     *outHandled = true;
     // Put selection in right place.  Use table code to get selection and index
     // to new row...
-    nsRefPtr selection;
+    RefPtr selection;
     nsCOMPtr tblElement, cell;
     int32_t row;
     res = GetCellContext(getter_AddRefs(selection),
@@ -1130,7 +1130,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(
 {
   MOZ_ASSERT(aNode);
 
-  nsRefPtr selection = aSelection;
+  RefPtr selection = aSelection;
   if (!selection) {
     selection = GetSelection();
   }
@@ -1165,7 +1165,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
 {
   // don't do any post processing, rules get confused
   nsAutoRules beginRulesSniffing(this, EditAction::ignore, nsIEditor::eNone);
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   ForceCompositionEnd();
@@ -1175,7 +1175,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
   nsCOMPtr doc = do_QueryReferent(mDocWeak);
   NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
 
-  nsRefPtr nodeList =
+  RefPtr nodeList =
     doc->GetElementsByTagName(NS_LITERAL_STRING("head"));
   NS_ENSURE_TRUE(nodeList, NS_ERROR_NULL_POINTER);
 
@@ -1198,11 +1198,11 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
   nsAutoEditBatch beginBatching(this);
 
   // Get the first range in the selection, for context:
-  nsRefPtr range = selection->GetRangeAt(0);
+  RefPtr range = selection->GetRangeAt(0);
   NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
 
   ErrorResult err;
-  nsRefPtr docfrag =
+  RefPtr docfrag =
     range->CreateContextualFragment(inputString, err);
 
   // XXXX BUG 50965: This is not returning the text between ...
@@ -1240,7 +1240,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
 {
   ForceCompositionEnd();
 
-  nsRefPtr selection = GetSelection();
+  RefPtr selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr bodyElement = GetRoot();
@@ -1368,11 +1368,11 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
   bodyTag.AssignLiteral("
range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); NS_ENSURE_TRUE(range, NS_ERROR_FAILURE); ErrorResult rv; - nsRefPtr docfrag = + RefPtr docfrag = range->CreateContextualFragment(bodyTag, rv); NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult()); NS_ENSURE_TRUE(docfrag, NS_ERROR_NULL_POINTER); @@ -1476,7 +1476,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele nsAutoEditBatch beginBatching(this); nsAutoRules beginRulesSniffing(this, EditAction::insertElement, nsIEditor::eNext); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { return NS_ERROR_FAILURE; } @@ -1632,7 +1632,7 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement) // Must be sure that element is contained in the document body if (IsDescendantOfEditorRoot(aElement)) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsCOMPtrparent; res = aElement->GetParentNode(getter_AddRefs(parent)); @@ -1658,7 +1658,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement) // Be sure the element is contained in the document body if (aElement && IsDescendantOfEditorRoot(aElement)) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsCOMPtrparent; res = aElement->GetParentNode(getter_AddRefs(parent)); @@ -1687,7 +1687,7 @@ nsHTMLEditor::GetParagraphState(bool *aMixed, nsAString &outFormat) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER); - nsRefPtr htmlRules = static_cast(mRules.get()); + RefPtr htmlRules = static_cast(mRules.get()); return htmlRules->GetParagraphState(aMixed, outFormat); } @@ -1732,7 +1732,7 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo aOutColor.AssignLiteral("transparent"); // get selection - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection && selection->GetRangeAt(0)); // get selection location @@ -1861,7 +1861,7 @@ nsHTMLEditor::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } NS_ENSURE_TRUE(aMixed && aOL && aUL && aDL, NS_ERROR_NULL_POINTER); - nsRefPtr htmlRules = static_cast(mRules.get()); + RefPtr htmlRules = static_cast(mRules.get()); return htmlRules->GetListState(aMixed, aOL, aUL, aDL); } @@ -1872,7 +1872,7 @@ nsHTMLEditor::GetListItemState(bool *aMixed, bool *aLI, bool *aDT, bool *aDD) if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } NS_ENSURE_TRUE(aMixed && aLI && aDT && aDD, NS_ERROR_NULL_POINTER); - nsRefPtr htmlRules = static_cast(mRules.get()); + RefPtr htmlRules = static_cast(mRules.get()); return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD); } @@ -1882,7 +1882,7 @@ nsHTMLEditor::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } NS_ENSURE_TRUE(aMixed && aAlign, NS_ERROR_NULL_POINTER); - nsRefPtr htmlRules = static_cast(mRules.get()); + RefPtr htmlRules = static_cast(mRules.get()); return htmlRules->GetAlignment(aMixed, aAlign); } @@ -1894,7 +1894,7 @@ nsHTMLEditor::GetIndentState(bool *aCanIndent, bool *aCanOutdent) if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } NS_ENSURE_TRUE(aCanIndent && aCanOutdent, NS_ERROR_NULL_POINTER); - nsRefPtr htmlRules = static_cast(mRules.get()); + RefPtr htmlRules = static_cast(mRules.get()); return htmlRules->GetIndentState(aCanIndent, aCanOutdent); } @@ -1914,7 +1914,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons nsAutoRules beginRulesSniffing(this, EditAction::makeList, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(EditAction::makeList); @@ -1986,7 +1986,7 @@ nsHTMLEditor::RemoveList(const nsAString& aListType) nsAutoRules beginRulesSniffing(this, EditAction::removeList, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(EditAction::removeList); @@ -2017,7 +2017,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType) nsAutoRules beginRulesSniffing(this, EditAction::makeDefListItem, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(EditAction::makeDefListItem); ruleInfo.blockType = &aItemType; @@ -2048,7 +2048,7 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType) nsAutoRules beginRulesSniffing(this, EditAction::makeBasicBlock, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(EditAction::makeBasicBlock); ruleInfo.blockType = &aBlockType; @@ -2120,7 +2120,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent) nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(opID); @@ -2194,7 +2194,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType) bool cancel, handled; // Find out if the selection is collapsed: - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(EditAction::align); ruleInfo.alignType = &aAlignType; @@ -2215,7 +2215,7 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName, nsCOMPtr node = aNode; if (!node) { // If no node supplied, get it from anchor node of current selection - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, nullptr); nsCOMPtr anchorNode = selection->GetAnchorNode(); @@ -2316,7 +2316,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet *aReturn = nullptr; // First look for a single element in selection - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); bool bNodeFound = false; @@ -2331,7 +2331,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet bool isNamedAnchorTag = IsNamedAnchorTag(TagName); nsCOMPtr selectedElement; - nsRefPtr range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); NS_ENSURE_STATE(range); nsCOMPtr startParent; @@ -2433,7 +2433,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet if (!isCollapsed) // Don't bother to examine selection if it is collapsed { - nsRefPtr currange = selection->GetRangeAt(0); + RefPtr currange = selection->GetRangeAt(0); if (currange) { nsCOMPtr iter = do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res); @@ -2587,7 +2587,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) NS_ENSURE_TRUE(aAnchorElement, NS_ERROR_NULL_POINTER); // We must have a real selection - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); if (selection->Collapsed()) { @@ -2799,12 +2799,12 @@ nsHTMLEditor::ReplaceStyleSheet(const nsAString& aURL) NS_IMETHODIMP nsHTMLEditor::RemoveStyleSheet(const nsAString &aURL) { - nsRefPtr sheet; + RefPtr sheet; nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED); - nsRefPtr txn; + RefPtr txn; rv = CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(txn)); if (!txn) rv = NS_ERROR_NULL_POINTER; if (NS_SUCCEEDED(rv)) @@ -2839,7 +2839,7 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL) // We MUST ONLY load synchronous local files (no @import) // XXXbz Except this will actually try to load remote files // synchronously, of course.. - nsRefPtr sheet; + RefPtr sheet; // Editor override style sheets may want to style Gecko anonymous boxes rv = ps->GetDocument()->CSSLoader()-> LoadSheetSync(uaURI, true, true, getter_AddRefs(sheet)); @@ -2883,7 +2883,7 @@ nsHTMLEditor::ReplaceOverrideStyleSheet(const nsAString& aURL) NS_IMETHODIMP nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL) { - nsRefPtr sheet; + RefPtr sheet; GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); // Make sure we remove the stylesheet from our internal list in all @@ -2906,7 +2906,7 @@ nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL) NS_IMETHODIMP nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable) { - nsRefPtr sheet; + RefPtr sheet; nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(sheet, NS_OK); // Don't fail if sheet not found @@ -2921,7 +2921,7 @@ nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable) bool nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL) { - nsRefPtr sheet; + RefPtr sheet; nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, false); @@ -3067,7 +3067,7 @@ nsHTMLEditor::DeleteSelectionImpl(EDirection aAction, return NS_OK; } - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); // Just checking that the selection itself is collapsed doesn't seem to work // right in the multi-range case NS_ENSURE_STATE(selection); @@ -3219,7 +3219,7 @@ nsHTMLEditor::DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer, // Update spellcheck for only the newly-inserted node (bug 743819) if (mInlineSpellChecker) { - nsRefPtr range = new nsRange(aChild); + RefPtr range = new nsRange(aChild); int32_t endIndex = aIndexInContainer + 1; if (aInsertedOrAppended == eAppended) { // Count all the appended nodes @@ -3283,7 +3283,7 @@ nsHTMLEditor::GetIsSelectionEditable(bool* aIsSelectionEditable) { MOZ_ASSERT(aIsSelectionEditable); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // Per the editing spec as of June 2012: we have to have a selection whose @@ -3331,7 +3331,7 @@ SetSelectionAroundHeadChildren(Selection* aSelection, NS_IMETHODIMP nsHTMLEditor::GetHeadContentsAsHTML(nsAString& aOutputString) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // Save current selection @@ -3402,7 +3402,7 @@ nsHTMLEditor::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, if (!mLastStyleSheetURL.IsEmpty()) RemoveStyleSheet(mLastStyleSheetURL); - nsRefPtr txn; + RefPtr txn; rv = CreateTxnForAddStyleSheet(aSheet, getter_AddRefs(txn)); if (!txn) rv = NS_ERROR_NULL_POINTER; if (NS_SUCCEEDED(rv)) @@ -3533,7 +3533,7 @@ nsHTMLEditor::SelectAll() { ForceCompositionEnd(); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); nsCOMPtr anchorNode; @@ -3671,7 +3671,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement) } // Set selection at beginning of the found node - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, false); return NS_SUCCEEDED(selection->CollapseNative(node, 0)); @@ -4543,7 +4543,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor) // Protect the edit rules object from dying nsCOMPtr kungFuDeathGrip(mRules); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); bool isCollapsed = selection->Collapsed(); @@ -4562,7 +4562,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor) // Loop through the ranges in the selection NS_NAMED_LITERAL_STRING(bgcolor, "bgcolor"); for (uint32_t i = 0; i < selection->RangeCount(); i++) { - nsRefPtr range = selection->GetRangeAt(i); + RefPtr range = selection->GetRangeAt(i); NS_ENSURE_TRUE(range, NS_ERROR_FAILURE); nsCOMPtr cachedBlockParent; @@ -4827,7 +4827,7 @@ nsHTMLEditor::EndUpdateViewBatch() // to listen too (in particular when an ancestor of the selection is // changed but the selection itself is not changed). if (mUpdateCount == 0) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED); res = CheckSelectionStateForAnonymousButtons(selection); } @@ -4837,7 +4837,7 @@ nsHTMLEditor::EndUpdateViewBatch() NS_IMETHODIMP nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); // if we don't get the selection, just skip this if (!selection) { return NS_ERROR_FAILURE; @@ -4857,7 +4857,7 @@ nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn) if (rangeCount == 1) { - nsRefPtr range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER); nsCOMPtr startContainer, endContainer; @@ -4885,7 +4885,7 @@ nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn) } else { int32_t i; - nsRefPtr range; + RefPtr range; for (i = 0; i < rangeCount; i++) { range = selection->GetRangeAt(i); @@ -5049,7 +5049,7 @@ nsHTMLEditor::GetActiveEditingHost() } // We're HTML editor for contenteditable - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, nullptr); nsCOMPtr focusNode; nsresult rv = selection->GetFocusNode(getter_AddRefs(focusNode)); diff --git a/editor/libeditor/nsHTMLEditor.h b/editor/libeditor/nsHTMLEditor.h index e9e44969ba..268ef70fc5 100644 --- a/editor/libeditor/nsHTMLEditor.h +++ b/editor/libeditor/nsHTMLEditor.h @@ -759,7 +759,7 @@ protected: nsTArray> mContentFilters; - nsRefPtr mTypeInState; + RefPtr mTypeInState; bool mCRInParagraphCreatesParagraph; @@ -774,7 +774,7 @@ protected: // Maintain a list of associated style sheets and their urls. nsTArray mStyleSheetURLs; - nsTArray> mStyleSheets; + nsTArray> mStyleSheets; // an array for holding default style settings nsTArray mDefaultStyles; diff --git a/editor/libeditor/nsHTMLEditorEventListener.cpp b/editor/libeditor/nsHTMLEditorEventListener.cpp index 7e2aed530a..13bad39c06 100644 --- a/editor/libeditor/nsHTMLEditorEventListener.cpp +++ b/editor/libeditor/nsHTMLEditorEventListener.cpp @@ -105,7 +105,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent) nsCOMPtr element = do_QueryInterface(target); if (isContextClick || (buttonNumber == 0 && clickCount == 2)) { - nsRefPtr selection = mEditor->GetSelection(); + RefPtr selection = mEditor->GetSelection(); NS_ENSURE_TRUE(selection, NS_OK); // Get location of mouse within target node @@ -126,7 +126,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent) NS_ENSURE_SUCCESS(rv, rv); for (int32_t i = 0; i < rangeCount; i++) { - nsRefPtr range = selection->GetRangeAt(i); + RefPtr range = selection->GetRangeAt(i); if (!range) { // Don't bail yet, iterate through them all continue; diff --git a/editor/libeditor/nsHTMLEditorStyle.cpp b/editor/libeditor/nsHTMLEditorStyle.cpp index 4b63b292a0..101174b1e7 100644 --- a/editor/libeditor/nsHTMLEditorStyle.cpp +++ b/editor/libeditor/nsHTMLEditorStyle.cpp @@ -117,7 +117,7 @@ nsHTMLEditor::SetInlineProperty(nsIAtom* aProperty, nsCOMPtr kungFuDeathGrip(mRules); ForceCompositionEnd(); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); if (selection->Collapsed()) { @@ -141,7 +141,7 @@ nsHTMLEditor::SetInlineProperty(nsIAtom* aProperty, // Loop through the ranges in the selection uint32_t rangeCount = selection->RangeCount(); for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; rangeIdx++) { - nsRefPtr range = selection->GetRangeAt(rangeIdx); + RefPtr range = selection->GetRangeAt(rangeIdx); // Adjust range to include any ancestors whose children are entirely // selected @@ -335,7 +335,7 @@ nsHTMLEditor::SetInlinePropertyOnTextNode(Text& aText, // Do we need to split the text node? ErrorResult rv; - nsRefPtr text = &aText; + RefPtr text = &aText; if (uint32_t(aEndOffset) != aText.Length()) { // We need to split off back of text node text = SplitNode(aText, aEndOffset, rv)->GetAsText(); @@ -1045,11 +1045,11 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty, *aFirst = false; bool first = true; - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); bool isCollapsed = selection->Collapsed(); - nsRefPtr range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); // XXX: Should be a while loop, to get each separate range // XXX: ERROR_HANDLING can currentItem be null? if (range) { @@ -1262,7 +1262,7 @@ nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty, NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED); ForceCompositionEnd(); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); if (selection->Collapsed()) { @@ -1298,7 +1298,7 @@ nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty, // Loop through the ranges in the selection uint32_t rangeCount = selection->RangeCount(); for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) { - nsRefPtr range = selection->GetRangeAt(rangeIdx); + RefPtr range = selection->GetRangeAt(rangeIdx); if (aProperty == nsGkAtoms::name) { // Promote range if it starts or end in a named anchor and we want to // remove named anchors @@ -1405,7 +1405,7 @@ nsHTMLEditor::RelativeFontChange(FontSize aDir) ForceCompositionEnd(); // Get the selection - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); // If selection is collapsed, set typing state if (selection->Collapsed()) { @@ -1441,7 +1441,7 @@ nsHTMLEditor::RelativeFontChange(FontSize aDir) // Loop through the ranges in the selection uint32_t rangeCount = selection->RangeCount(); for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) { - nsRefPtr range = selection->GetRangeAt(rangeIdx); + RefPtr range = selection->GetRangeAt(rangeIdx); // Adjust range to include any ancestors with entirely selected children nsresult res = PromoteInlineRange(range); diff --git a/editor/libeditor/nsHTMLURIRefObject.cpp b/editor/libeditor/nsHTMLURIRefObject.cpp index 809d8f15ff..6aeb28c835 100644 --- a/editor/libeditor/nsHTMLURIRefObject.cpp +++ b/editor/libeditor/nsHTMLURIRefObject.cpp @@ -248,7 +248,7 @@ nsHTMLURIRefObject::SetNode(nsIDOMNode *aNode) nsresult NS_NewHTMLURIRefObject(nsIURIRefObject** aResult, nsIDOMNode* aNode) { - nsRefPtr refObject = new nsHTMLURIRefObject(); + RefPtr refObject = new nsHTMLURIRefObject(); nsresult rv = refObject->SetNode(aNode); if (NS_FAILED(rv)) { *aResult = 0; diff --git a/editor/libeditor/nsPlaintextDataTransfer.cpp b/editor/libeditor/nsPlaintextDataTransfer.cpp index 2a8f8e5e74..14c5cdc193 100644 --- a/editor/libeditor/nsPlaintextDataTransfer.cpp +++ b/editor/libeditor/nsPlaintextDataTransfer.cpp @@ -77,7 +77,7 @@ nsresult nsPlaintextEditor::InsertTextAt(const nsAString &aStringToInsert, if (aDestinationNode) { nsresult res; - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); nsCOMPtr targetNode = aDestinationNode; @@ -219,7 +219,7 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) rv = uiEvent->GetRangeOffset(&newSelectionOffset); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); bool isCollapsed = selection->Collapsed(); @@ -256,7 +256,7 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) for (int32_t j = 0; j < rangeCount; j++) { - nsRefPtr range = selection->GetRangeAt(j); + RefPtr range = selection->GetRangeAt(j); if (!range) { // don't bail yet, iterate through them all continue; diff --git a/editor/libeditor/nsPlaintextEditor.cpp b/editor/libeditor/nsPlaintextEditor.cpp index 67df3e24a4..48377143c7 100644 --- a/editor/libeditor/nsPlaintextEditor.cpp +++ b/editor/libeditor/nsPlaintextEditor.cpp @@ -507,7 +507,7 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr* aInOutParent, int32_t offset; nsCOMPtr parent = GetNodeLocation(*outBRNode, &offset); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); if (aSelect == eNext) { @@ -542,7 +542,7 @@ nsPlaintextEditor::InsertBR(nsCOMPtr* outBRNode) // calling it text insertion to trigger moz br treatment by rules nsAutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); nsresult res; @@ -660,7 +660,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction, nsAutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // If there is an existing selection when an extended delete is requested, @@ -717,7 +717,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert) nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsAutoString resultString; // XXX can we trust instring to outlive ruleInfo, @@ -754,7 +754,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak() nsAutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(EditAction::insertBreak); @@ -853,7 +853,7 @@ nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) nsCOMPtr ps = GetPresShell(); NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); // NOTE: TextComposition should receive selection change notification before @@ -871,7 +871,7 @@ nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) NotifyEditorObservers(eNotifyEditorObserversOfBefore); - nsRefPtr caretP = ps->GetCaret(); + RefPtr caretP = ps->GetCaret(); nsresult rv; { @@ -1110,7 +1110,7 @@ nsPlaintextEditor::Undo(uint32_t aCount) nsAutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(EditAction::undo); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); bool cancel, handled; nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -1139,7 +1139,7 @@ nsPlaintextEditor::Redo(uint32_t aCount) nsAutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(EditAction::redo); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); bool cancel, handled; nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -1156,7 +1156,7 @@ nsPlaintextEditor::Redo(uint32_t aCount) bool nsPlaintextEditor::CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { return false; } @@ -1180,7 +1180,7 @@ nsPlaintextEditor::FireClipboardEvent(EventMessage aEventMessage, nsCOMPtr presShell = GetPresShell(); NS_ENSURE_TRUE(presShell, false); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { return false; } @@ -1273,7 +1273,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType, // in which case we use our existing selection ... if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); rv = docEncoder->SetSelection(selection); NS_ENSURE_SUCCESS(rv, rv); @@ -1430,7 +1430,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText, quotedStuff.Append(char16_t('\n')); // get selection - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsAutoEditBatch beginBatching(this); @@ -1477,7 +1477,7 @@ nsPlaintextEditor::SharedOutputString(uint32_t aFlags, bool* aIsCollapsed, nsAString& aResult) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED); *aIsCollapsed = selection->Collapsed(); diff --git a/editor/libeditor/nsSelectionState.cpp b/editor/libeditor/nsSelectionState.cpp index 8a9feaac1a..1f3c5047f0 100644 --- a/editor/libeditor/nsSelectionState.cpp +++ b/editor/libeditor/nsSelectionState.cpp @@ -89,7 +89,7 @@ nsSelectionState::RestoreSelection(Selection* aSel) // set the selection ranges anew for (i=0; i range = mArray[i]->GetRange(); + RefPtr range = mArray[i]->GetRange(); NS_ENSURE_TRUE(range, NS_ERROR_UNEXPECTED); res = aSel->AddRange(range); @@ -103,7 +103,7 @@ bool nsSelectionState::IsCollapsed() { if (1 != mArray.Length()) return false; - nsRefPtr range = mArray[0]->GetRange(); + RefPtr range = mArray[0]->GetRange(); NS_ENSURE_TRUE(range, false); bool bIsCollapsed = false; range->GetCollapsed(&bIsCollapsed); @@ -120,8 +120,8 @@ nsSelectionState::IsEqual(nsSelectionState *aSelState) for (i=0; i myRange = mArray[i]->GetRange(); - nsRefPtr itsRange = aSelState->mArray[i]->GetRange(); + RefPtr myRange = mArray[i]->GetRange(); + RefPtr itsRange = aSelState->mArray[i]->GetRange(); NS_ENSURE_TRUE(myRange && itsRange, false); int16_t compResult; @@ -665,7 +665,7 @@ nsRangeStore::StoreRange(nsRange* aRange) already_AddRefed nsRangeStore::GetRange() { - nsRefPtr range = new nsRange(startNode); + RefPtr range = new nsRange(startNode); nsresult res = range->Set(startNode, startOffset, endNode, endOffset); NS_ENSURE_SUCCESS(res, nullptr); return range.forget(); diff --git a/editor/libeditor/nsSelectionState.h b/editor/libeditor/nsSelectionState.h index d3c6abbfdb..12b17e1407 100644 --- a/editor/libeditor/nsSelectionState.h +++ b/editor/libeditor/nsSelectionState.h @@ -66,7 +66,7 @@ class nsSelectionState void MakeEmpty(); bool IsEmpty(); protected: - nsTArray > mArray; + nsTArray > mArray; friend class nsRangeUpdater; }; @@ -121,7 +121,7 @@ class nsRangeUpdater void DidMoveNode(nsINode* aOldParent, int32_t aOldOffset, nsINode* aNewParent, int32_t aNewOffset); protected: - nsTArray > mArray; + nsTArray > mArray; bool mLock; }; @@ -139,7 +139,7 @@ class MOZ_STACK_CLASS nsAutoTrackDOMPoint nsCOMPtr* mNode; nsCOMPtr* mDOMNode; int32_t* mOffset; - nsRefPtr mRangeItem; + RefPtr mRangeItem; public: nsAutoTrackDOMPoint(nsRangeUpdater &aRangeUpdater, nsCOMPtr* aNode, int32_t* aOffset) diff --git a/editor/libeditor/nsStyleSheetTxns.h b/editor/libeditor/nsStyleSheetTxns.h index d6c827334e..fe63b3ca75 100644 --- a/editor/libeditor/nsStyleSheetTxns.h +++ b/editor/libeditor/nsStyleSheetTxns.h @@ -36,7 +36,7 @@ public: protected: nsIEditor* mEditor; // the editor that created this transaction - nsRefPtr mSheet; // the style sheet to add + RefPtr mSheet; // the style sheet to add }; @@ -61,7 +61,7 @@ public: protected: nsIEditor* mEditor; // the editor that created this transaction - nsRefPtr mSheet; // the style sheet to remove + RefPtr mSheet; // the style sheet to remove }; diff --git a/editor/libeditor/nsTableEditor.cpp b/editor/libeditor/nsTableEditor.cpp index 40549d64a9..cea82f8f74 100644 --- a/editor/libeditor/nsTableEditor.cpp +++ b/editor/libeditor/nsTableEditor.cpp @@ -374,7 +374,7 @@ nsHTMLEditor::GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode) NS_IMETHODIMP nsHTMLEditor::InsertTableColumn(int32_t aNumber, bool aAfter) { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsCOMPtr curCell; int32_t startRowIndex, startColIndex; @@ -501,7 +501,7 @@ nsHTMLEditor::InsertTableColumn(int32_t aNumber, bool aAfter) NS_IMETHODIMP nsHTMLEditor::InsertTableRow(int32_t aNumber, bool aAfter) { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsCOMPtr curCell; @@ -699,7 +699,7 @@ nsHTMLEditor::DeleteTable2(nsIDOMElement* aTable, Selection* aSelection) NS_IMETHODIMP nsHTMLEditor::DeleteTable() { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsresult res = GetCellContext(getter_AddRefs(selection), getter_AddRefs(table), @@ -714,7 +714,7 @@ nsHTMLEditor::DeleteTable() NS_IMETHODIMP nsHTMLEditor::DeleteTableCell(int32_t aNumber) { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsCOMPtr cell; int32_t startRowIndex, startColIndex; @@ -908,7 +908,7 @@ nsHTMLEditor::DeleteTableCell(int32_t aNumber) NS_IMETHODIMP nsHTMLEditor::DeleteTableCellContents() { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsCOMPtr cell; int32_t startRowIndex, startColIndex; @@ -985,7 +985,7 @@ nsHTMLEditor::DeleteCellContents(nsIDOMElement *aCell) NS_IMETHODIMP nsHTMLEditor::DeleteTableColumn(int32_t aNumber) { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsCOMPtr cell; int32_t startRowIndex, startColIndex, rowCount, colCount; @@ -1128,7 +1128,7 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, int32_t aColIndex) if (rowCount == 1) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); return DeleteTable2(aTable, selection); } @@ -1161,7 +1161,7 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, int32_t aColIndex) NS_IMETHODIMP nsHTMLEditor::DeleteTableRow(int32_t aNumber) { - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; nsCOMPtr cell; int32_t startRowIndex, startColIndex; @@ -1399,7 +1399,7 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC { NS_ENSURE_TRUE(aStartCell && aEndCell, NS_ERROR_NULL_POINTER); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); NS_NAMED_LITERAL_STRING(tableStr, "table"); @@ -1505,7 +1505,7 @@ nsHTMLEditor::SelectAllTableCells() res = GetTableSize(table, &rowCount, &colCount); NS_ENSURE_SUCCESS(res, res); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); // Suppress nsISelectionListener notification @@ -1558,7 +1558,7 @@ nsHTMLEditor::SelectTableRow() nsCOMPtr startCell = cell; // Get table and location of cell: - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; int32_t startRowIndex, startColIndex; @@ -1625,7 +1625,7 @@ nsHTMLEditor::SelectTableColumn() nsCOMPtr startCell = cell; // Get location of cell: - nsRefPtr selection; + RefPtr selection; nsCOMPtr table; int32_t startRowIndex, startColIndex; @@ -1924,7 +1924,7 @@ nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElemen // Save current selection to restore when done // This is needed so ReplaceContainer can monitor selection // when replacing nodes - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); nsAutoSelectionReset selectionResetter(selection, this); @@ -2188,14 +2188,14 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents) } } // Cleanup selection: remove ranges where cells were deleted - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); int32_t rangeCount; res = selection->GetRangeCount(&rangeCount); NS_ENSURE_SUCCESS(res, res); - nsRefPtr range; + RefPtr range; int32_t i; for (i = 0; i < rangeCount; i++) { @@ -2457,7 +2457,7 @@ nsHTMLEditor::FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& a NS_IMETHODIMP nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); nsCOMPtr table; @@ -2765,7 +2765,7 @@ nsHTMLEditor::GetCellContext(Selection** aSelection, if (aRowIndex) *aRowIndex = 0; if (aColIndex) *aColIndex = 0; - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); if (aSelection) @@ -2913,10 +2913,10 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell) *aCell = nullptr; if (aRange) *aRange = nullptr; - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); - nsRefPtr range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); NS_ENSURE_TRUE(range, NS_ERROR_FAILURE); mSelectedCellIndex = 0; @@ -2951,7 +2951,7 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell) *aCell = nullptr; if (aRange) *aRange = nullptr; - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); int32_t rangeCount = selection->RangeCount(); @@ -2961,7 +2961,7 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell) return NS_EDITOR_ELEMENT_NOT_FOUND; // Scan through ranges to find next valid selected cell - nsRefPtr range; + RefPtr range; nsresult res; for (; mSelectedCellIndex < rangeCount; mSelectedCellIndex++) { @@ -3033,7 +3033,7 @@ nsHTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, in { NS_ENSURE_TRUE(aTable, NS_ERROR_NOT_INITIALIZED); - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); nsresult res; if (!selection) @@ -3128,7 +3128,7 @@ nsHTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName, aTagName.Truncate(); *aSelectedCount = 0; - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); // Try to get the first selected cell diff --git a/editor/libeditor/nsTextEditRules.cpp b/editor/libeditor/nsTextEditRules.cpp index 9bea8415b3..edd1376bb3 100644 --- a/editor/libeditor/nsTextEditRules.cpp +++ b/editor/libeditor/nsTextEditRules.cpp @@ -116,7 +116,7 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor) InitFields(); mEditor = aEditor; // we hold a non-refcounted reference back to our editor - nsRefPtr selection = mEditor->GetSelection(); + RefPtr selection = mEditor->GetSelection(); NS_WARN_IF_FALSE(selection, "editor cannot get selection"); // Put in a magic br if needed. This method handles null selection, @@ -183,7 +183,7 @@ nsTextEditRules::BeforeEdit(EditAction action, // get the selection and cache the position before editing NS_ENSURE_STATE(mEditor); - nsRefPtr selection = mEditor->GetSelection(); + RefPtr selection = mEditor->GetSelection(); NS_ENSURE_STATE(selection); selection->GetAnchorNode(getter_AddRefs(mCachedSelectionNode)); @@ -206,7 +206,7 @@ nsTextEditRules::AfterEdit(EditAction action, if (!--mActionNesting) { NS_ENSURE_STATE(mEditor); - nsRefPtr selection = mEditor->GetSelection(); + RefPtr selection = mEditor->GetSelection(); NS_ENSURE_STATE(selection); NS_ENSURE_STATE(mEditor); @@ -480,7 +480,7 @@ GetTextNode(Selection* selection, nsEditor* editor) { NS_ENSURE_TRUE(node, nullptr); // This should be the root node, walk the tree looking for text nodes NodeFilterHolder filter; - nsRefPtr iter = new NodeIterator(node, nsIDOMNodeFilter::SHOW_TEXT, filter); + RefPtr iter = new NodeIterator(node, nsIDOMNodeFilter::SHOW_TEXT, filter); while (!editor->IsTextNode(selNode)) { if (NS_FAILED(res = iter->NextNode(getter_AddRefs(selNode))) || !selNode) { return nullptr; @@ -1076,7 +1076,7 @@ nsTextEditRules::RemoveRedundantTrailingBR() return NS_OK; NS_ENSURE_STATE(mEditor); - nsRefPtr body = mEditor->GetRoot(); + RefPtr body = mEditor->GetRoot(); if (!body) return NS_ERROR_NULL_POINTER; @@ -1086,7 +1086,7 @@ nsTextEditRules::RemoveRedundantTrailingBR() return NS_OK; } - nsRefPtr child = body->GetFirstChild(); + RefPtr child = body->GetFirstChild(); if (!child || !child->IsElement()) { return NS_OK; } @@ -1333,7 +1333,7 @@ nsresult nsTextEditRules::HideLastPWInput() { FillBufWithPWChars(&hiddenText, mLastLength); NS_ENSURE_STATE(mEditor); - nsRefPtr selection = mEditor->GetSelection(); + RefPtr selection = mEditor->GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); int32_t start, end; nsContentUtils::GetSelectionInTextControl(selection, mEditor->GetRoot(), diff --git a/editor/libeditor/nsTextEditRulesBidi.cpp b/editor/libeditor/nsTextEditRulesBidi.cpp index 99a0fa371a..a03f3a240e 100644 --- a/editor/libeditor/nsTextEditRulesBidi.cpp +++ b/editor/libeditor/nsTextEditRulesBidi.cpp @@ -47,7 +47,7 @@ nsTextEditRules::CheckBidiLevelForDeletion(Selection* aSelection, nsBidiLevel levelBefore; nsBidiLevel levelAfter; - nsRefPtr frameSelection = + RefPtr frameSelection = static_cast(aSelection)->GetFrameSelection(); NS_ENSURE_TRUE(frameSelection, NS_ERROR_NULL_POINTER); @@ -91,7 +91,7 @@ nsTextEditRules::UndefineCaretBidiLevel(Selection* aSelection) * So we set the caret Bidi level to UNDEFINED here, and the caret code will * set it correctly later */ - nsRefPtr frameSelection = aSelection->GetFrameSelection(); + RefPtr frameSelection = aSelection->GetFrameSelection(); if (frameSelection) { frameSelection->UndefineCaretBidiLevel(); } diff --git a/editor/libeditor/nsWSRunObject.cpp b/editor/libeditor/nsWSRunObject.cpp index 65f204cda4..8c4ce5e634 100644 --- a/editor/libeditor/nsWSRunObject.cpp +++ b/editor/libeditor/nsWSRunObject.cpp @@ -406,7 +406,7 @@ nsWSRunObject::DeleteWSBackward() // Caller's job to ensure that previous char is really ws. If it is normal // ws, we need to delete the whole run. if (nsCRT::IsAsciiSpace(point.mChar)) { - nsRefPtr startNodeText, endNodeText; + RefPtr startNodeText, endNodeText; int32_t startOffset, endOffset; GetAsciiWSBounds(eBoth, point.mTextNode, point.mOffset + 1, getter_AddRefs(startNodeText), &startOffset, @@ -457,7 +457,7 @@ nsWSRunObject::DeleteWSForward() // Caller's job to ensure that next char is really ws. If it is normal ws, // we need to delete the whole run. if (nsCRT::IsAsciiSpace(point.mChar)) { - nsRefPtr startNodeText, endNodeText; + RefPtr startNodeText, endNodeText; int32_t startOffset, endOffset; GetAsciiWSBounds(eBoth, point.mTextNode, point.mOffset + 1, getter_AddRefs(startNodeText), &startOffset, @@ -627,7 +627,7 @@ nsWSRunObject::GetWSNodes() nsCOMPtr wsBoundingParent = GetWSBoundingParent(); // first look backwards to find preceding ws nodes - if (nsRefPtr textNode = mNode->GetAsText()) { + if (RefPtr textNode = mNode->GetAsText()) { const nsTextFragment* textFrag = textNode->GetText(); mNodeArray.InsertElementAt(0, textNode); @@ -671,7 +671,7 @@ nsWSRunObject::GetWSNodes() mStartOffset = start.offset; mStartReason = WSType::otherBlock; mStartReasonNode = priorNode; - } else if (nsRefPtr textNode = priorNode->GetAsText()) { + } else if (RefPtr textNode = priorNode->GetAsText()) { mNodeArray.InsertElementAt(0, textNode); const nsTextFragment *textFrag; if (!textNode || !(textFrag = textNode->GetText())) { @@ -733,7 +733,7 @@ nsWSRunObject::GetWSNodes() } // then look ahead to find following ws nodes - if (nsRefPtr textNode = mNode->GetAsText()) { + if (RefPtr textNode = mNode->GetAsText()) { // don't need to put it on list. it already is from code above const nsTextFragment *textFrag = textNode->GetText(); @@ -778,7 +778,7 @@ nsWSRunObject::GetWSNodes() mEndOffset = end.offset; mEndReason = WSType::otherBlock; mEndReasonNode = nextNode; - } else if (nsRefPtr textNode = nextNode->GetAsText()) { + } else if (RefPtr textNode = nextNode->GetAsText()) { mNodeArray.AppendElement(textNode); const nsTextFragment *textFrag; if (!textNode || !(textFrag = textNode->GetText())) { @@ -1224,7 +1224,7 @@ nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject) WSPoint point = GetCharBefore(mNode, mOffset); if (point.mTextNode && nsCRT::IsAsciiSpace(point.mChar)) { - nsRefPtr wsStartNode, wsEndNode; + RefPtr wsStartNode, wsEndNode; int32_t wsStartOffset, wsEndOffset; GetAsciiWSBounds(eBoth, mNode, mOffset, getter_AddRefs(wsStartNode), &wsStartOffset, @@ -1269,7 +1269,7 @@ nsWSRunObject::PrepareToSplitAcrossBlocksPriv() WSPoint point = GetCharBefore(mNode, mOffset); if (point.mTextNode && nsCRT::IsAsciiSpace(point.mChar)) { - nsRefPtr wsStartNode, wsEndNode; + RefPtr wsStartNode, wsEndNode; int32_t wsStartOffset, wsEndOffset; GetAsciiWSBounds(eBoth, mNode, mOffset, getter_AddRefs(wsStartNode), &wsStartOffset, @@ -1326,10 +1326,10 @@ nsWSRunObject::DeleteChars(nsINode* aStartNode, int32_t aStartOffset, } nsresult res; - nsRefPtr range; + RefPtr range; int32_t count = mNodeArray.Length(); for (; idx < count; idx++) { - nsRefPtr node = mNodeArray[idx]; + RefPtr node = mNodeArray[idx]; if (!node) { // We ran out of ws nodes; must have been deleting to end return NS_OK; @@ -1489,7 +1489,7 @@ nsWSRunObject::ConvertToNBSP(WSPoint aPoint, AreaRestriction aAR) NS_ENSURE_SUCCESS(res, res); // Next, find range of ws it will replace - nsRefPtr startNode, endNode; + RefPtr startNode, endNode; int32_t startOffset = 0, endOffset = 0; GetAsciiWSBounds(eAfter, aPoint.mTextNode, aPoint.mOffset + 1, @@ -1513,7 +1513,7 @@ nsWSRunObject::GetAsciiWSBounds(int16_t aDir, nsINode* aNode, int32_t aOffset, MOZ_ASSERT(aNode && outStartNode && outStartOffset && outEndNode && outEndOffset); - nsRefPtr startNode, endNode; + RefPtr startNode, endNode; int32_t startOffset = 0, endOffset = 0; if (aDir & eAfter) { @@ -1638,7 +1638,7 @@ nsWSRunObject::GetWSPointAfter(nsINode* aNode, int32_t aOffset) uint32_t firstNum = 0, curNum = numNodes/2, lastNum = numNodes; int16_t cmp = 0; - nsRefPtr curNode; + RefPtr curNode; // Begin binary search. We do this because we need to minimize calls to // ComparePoints(), which is expensive. @@ -1660,12 +1660,12 @@ nsWSRunObject::GetWSPointAfter(nsINode* aNode, int32_t aOffset) if (curNum == mNodeArray.Length()) { // hey asked for past our range (it's after the last node). GetCharAfter // will do the work for us when we pass it the last index of the last node. - nsRefPtr textNode(mNodeArray[curNum - 1]); + RefPtr textNode(mNodeArray[curNum - 1]); WSPoint point(textNode, textNode->TextLength(), 0); return GetCharAfter(point); } else { // The char after the point is the first character of our range. - nsRefPtr textNode(mNodeArray[curNum]); + RefPtr textNode(mNodeArray[curNum]); WSPoint point(textNode, 0, 0); return GetCharAfter(point); } @@ -1687,7 +1687,7 @@ nsWSRunObject::GetWSPointBefore(nsINode* aNode, int32_t aOffset) uint32_t firstNum = 0, curNum = numNodes/2, lastNum = numNodes; int16_t cmp = 0; - nsRefPtr curNode; + RefPtr curNode; // Begin binary search. We do this because we need to minimize calls to // ComparePoints(), which is expensive. @@ -1709,14 +1709,14 @@ nsWSRunObject::GetWSPointBefore(nsINode* aNode, int32_t aOffset) if (curNum == mNodeArray.Length()) { // Get the point before the end of the last node, we can pass the length of // the node into GetCharBefore, and it will return the last character. - nsRefPtr textNode(mNodeArray[curNum - 1]); + RefPtr textNode(mNodeArray[curNum - 1]); WSPoint point(textNode, textNode->TextLength(), 0); return GetCharBefore(point); } else { // We can just ask the current node for the point immediately before it, // it will handle moving to the previous node (if any) and returning the // appropriate character - nsRefPtr textNode(mNodeArray[curNum]); + RefPtr textNode(mNodeArray[curNum]); WSPoint point(textNode, 0, 0); return GetCharBefore(point); } @@ -1816,7 +1816,7 @@ nsWSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun) // editor softwraps at this point, the spaces won't be split across lines, // which looks ugly and is bad for the moose. - nsRefPtr startNode, endNode; + RefPtr startNode, endNode; int32_t startOffset, endOffset; GetAsciiWSBounds(eBoth, prevPoint.mTextNode, prevPoint.mOffset + 1, getter_AddRefs(startNode), &startOffset, diff --git a/editor/libeditor/nsWSRunObject.h b/editor/libeditor/nsWSRunObject.h index 30da0bfabc..f4bd19965f 100644 --- a/editor/libeditor/nsWSRunObject.h +++ b/editor/libeditor/nsWSRunObject.h @@ -282,7 +282,7 @@ class MOZ_STACK_CLASS nsWSRunObject // stored in the struct. struct MOZ_STACK_CLASS WSPoint { - nsRefPtr mTextNode; + RefPtr mTextNode; uint32_t mOffset; char16_t mChar; @@ -361,14 +361,14 @@ class MOZ_STACK_CLASS nsWSRunObject WSType mEndReason; // reason why ws ends (eText, eOtherBlock, etc) nsCOMPtr mEndReasonNode; // the node that implicated by end reason - nsRefPtr mFirstNBSPNode; // location of first nbsp in ws run, if any + RefPtr mFirstNBSPNode; // location of first nbsp in ws run, if any int32_t mFirstNBSPOffset; // ... - nsRefPtr mLastNBSPNode; // location of last nbsp in ws run, if any + RefPtr mLastNBSPNode; // location of last nbsp in ws run, if any int32_t mLastNBSPOffset; // ... // the list of nodes containing ws in this run - nsTArray> mNodeArray; + nsTArray> mNodeArray; WSFragment *mStartRun; // the first WSFragment in the run WSFragment *mEndRun; // the last WSFragment in the run, may be same as first diff --git a/editor/txmgr/nsTransactionItem.cpp b/editor/txmgr/nsTransactionItem.cpp index 8f57343b18..5ca1b56d2c 100644 --- a/editor/txmgr/nsTransactionItem.cpp +++ b/editor/txmgr/nsTransactionItem.cpp @@ -146,7 +146,7 @@ nsTransactionItem::GetChild(int32_t aIndex, nsTransactionItem **aChild) if (numItems > 0 && aIndex < numItems) { NS_ENSURE_TRUE(mUndoStack, NS_ERROR_FAILURE); - nsRefPtr child = mUndoStack->GetItem(aIndex); + RefPtr child = mUndoStack->GetItem(aIndex); child.forget(aChild); return *aChild ? NS_OK : NS_ERROR_FAILURE; } @@ -161,7 +161,7 @@ nsTransactionItem::GetChild(int32_t aIndex, nsTransactionItem **aChild) NS_ENSURE_TRUE(mRedoStack && numItems != 0 && aIndex < numItems, NS_ERROR_FAILURE); - nsRefPtr child = mRedoStack->GetItem(aIndex); + RefPtr child = mRedoStack->GetItem(aIndex); child.forget(aChild); return *aChild ? NS_OK : NS_ERROR_FAILURE; } @@ -200,7 +200,7 @@ nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr) nsresult nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr) { - nsRefPtr item; + RefPtr item; nsresult result = NS_OK; int32_t sz = 0; @@ -276,7 +276,7 @@ nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr) nsresult nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr) { - nsRefPtr item; + RefPtr item; nsresult result = NS_OK; if (!mRedoStack) diff --git a/editor/txmgr/nsTransactionList.cpp b/editor/txmgr/nsTransactionList.cpp index 16c4d37473..d4567c98e3 100644 --- a/editor/txmgr/nsTransactionList.cpp +++ b/editor/txmgr/nsTransactionList.cpp @@ -69,7 +69,7 @@ NS_IMETHODIMP nsTransactionList::ItemIsBatch(int32_t aIndex, bool *aIsBatch) NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - nsRefPtr item; + RefPtr item; nsresult result = NS_OK; @@ -97,7 +97,7 @@ NS_IMETHODIMP nsTransactionList::GetData(int32_t aIndex, NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - nsRefPtr item; + RefPtr item; if (mTxnStack) { item = mTxnStack->GetItem(aIndex); @@ -131,7 +131,7 @@ NS_IMETHODIMP nsTransactionList::GetItem(int32_t aIndex, nsITransaction **aItem) NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - nsRefPtr item; + RefPtr item; nsresult result = NS_OK; @@ -159,7 +159,7 @@ NS_IMETHODIMP nsTransactionList::GetNumChildrenForItem(int32_t aIndex, int32_t * NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - nsRefPtr item; + RefPtr item; nsresult result = NS_OK; @@ -185,7 +185,7 @@ NS_IMETHODIMP nsTransactionList::GetChildListForItem(int32_t aIndex, nsITransact NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - nsRefPtr item; + RefPtr item; nsresult result = NS_OK; diff --git a/editor/txmgr/nsTransactionList.h b/editor/txmgr/nsTransactionList.h index 32733fe09c..958ae7638d 100644 --- a/editor/txmgr/nsTransactionList.h +++ b/editor/txmgr/nsTransactionList.h @@ -25,7 +25,7 @@ private: nsWeakPtr mTxnMgr; nsTransactionStack *mTxnStack; - nsRefPtr mTxnItem; + RefPtr mTxnItem; protected: virtual ~nsTransactionList(); diff --git a/editor/txmgr/nsTransactionManager.cpp b/editor/txmgr/nsTransactionManager.cpp index 7b26c257c8..a879db0b35 100644 --- a/editor/txmgr/nsTransactionManager.cpp +++ b/editor/txmgr/nsTransactionManager.cpp @@ -102,7 +102,7 @@ nsTransactionManager::UndoTransaction() // executing a transaction's DoTransaction() method! If this happens, // the UndoTransaction() request is ignored, and we return NS_ERROR_FAILURE. - nsRefPtr tx = mDoStack.Peek(); + RefPtr tx = mDoStack.Peek(); if (tx) { return NS_ERROR_FAILURE; @@ -155,7 +155,7 @@ nsTransactionManager::RedoTransaction() // executing a transaction's DoTransaction() method! If this happens, // the RedoTransaction() request is ignored, and we return NS_ERROR_FAILURE. - nsRefPtr tx = mDoStack.Peek(); + RefPtr tx = mDoStack.Peek(); if (tx) { return NS_ERROR_FAILURE; @@ -264,7 +264,7 @@ nsTransactionManager::EndBatch(bool aAllowEmpty) // future when we allow users to execute a transaction when beginning // a batch!!!! - nsRefPtr tx = mDoStack.Peek(); + RefPtr tx = mDoStack.Peek(); if (tx) { ti = tx->GetTransaction(); @@ -331,7 +331,7 @@ nsTransactionManager::SetMaxTransactionCount(int32_t aMaxCount) // SetMaxTransactionCount() request is ignored, and we return // NS_ERROR_FAILURE. - nsRefPtr tx = mDoStack.Peek(); + RefPtr tx = mDoStack.Peek(); if (tx) { return NS_ERROR_FAILURE; @@ -402,7 +402,7 @@ nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction) already_AddRefed nsTransactionManager::PeekUndoStack() { - nsRefPtr tx = mUndoStack.Peek(); + RefPtr tx = mUndoStack.Peek(); if (!tx) { return nullptr; @@ -422,7 +422,7 @@ nsTransactionManager::PeekRedoStack(nsITransaction** aTransaction) already_AddRefed nsTransactionManager::PeekRedoStack() { - nsRefPtr tx = mRedoStack.Peek(); + RefPtr tx = mRedoStack.Peek(); if (!tx) { return nullptr; @@ -463,8 +463,8 @@ nsTransactionManager::BatchTopUndo() return NS_OK; } - nsRefPtr lastUndo; - nsRefPtr previousUndo; + RefPtr lastUndo; + RefPtr previousUndo; lastUndo = mUndoStack.Pop(); MOZ_ASSERT(lastUndo, "There should be at least two transactions."); @@ -487,7 +487,7 @@ nsTransactionManager::BatchTopUndo() nsresult nsTransactionManager::RemoveTopUndo() { - nsRefPtr lastUndo; + RefPtr lastUndo; lastUndo = mUndoStack.Peek(); if (!lastUndo) { @@ -768,7 +768,7 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction, // XXX: POSSIBLE OPTIMIZATION // We could use a factory that pre-allocates/recycles transaction items. - nsRefPtr tx = new nsTransactionItem(aTransaction); + RefPtr tx = new nsTransactionItem(aTransaction); if (aData) { nsCOMArray& data = tx->GetData(); @@ -796,7 +796,7 @@ nsTransactionManager::EndTransaction(bool aAllowEmpty) { nsresult result = NS_OK; - nsRefPtr tx = mDoStack.Pop(); + RefPtr tx = mDoStack.Pop(); if (!tx) return NS_ERROR_FAILURE; @@ -834,7 +834,7 @@ nsTransactionManager::EndTransaction(bool aAllowEmpty) // the current transaction is a "sub" transaction, and should // be added to the transaction at the top of the do stack. - nsRefPtr top = mDoStack.Peek(); + RefPtr top = mDoStack.Peek(); if (top) { result = top->AddChild(tx); @@ -893,7 +893,7 @@ nsTransactionManager::EndTransaction(bool aAllowEmpty) int32_t sz = mUndoStack.GetSize(); if (mMaxTransactionCount > 0 && sz >= mMaxTransactionCount) { - nsRefPtr overflow = mUndoStack.PopBottom(); + RefPtr overflow = mUndoStack.PopBottom(); } // Push the transaction on the undo stack: diff --git a/editor/txmgr/nsTransactionStack.cpp b/editor/txmgr/nsTransactionStack.cpp index 4762b79a91..f9425f390f 100644 --- a/editor/txmgr/nsTransactionStack.cpp +++ b/editor/txmgr/nsTransactionStack.cpp @@ -38,7 +38,7 @@ nsTransactionStack::Pop() if (mDeque.empty()) { return nullptr; } - nsRefPtr ret = mDeque.back().forget(); + RefPtr ret = mDeque.back().forget(); mDeque.pop_back(); return ret.forget(); } @@ -49,7 +49,7 @@ nsTransactionStack::PopBottom() if (mDeque.empty()) { return nullptr; } - nsRefPtr ret = mDeque.front().forget(); + RefPtr ret = mDeque.front().forget(); mDeque.pop_front(); return ret.forget(); } @@ -60,7 +60,7 @@ nsTransactionStack::Peek() if (mDeque.empty()) { return nullptr; } - nsRefPtr ret = mDeque.back(); + RefPtr ret = mDeque.back(); return ret.forget(); } @@ -70,7 +70,7 @@ nsTransactionStack::GetItem(int32_t aIndex) if (aIndex < 0 || aIndex >= static_cast(mDeque.size())) { return nullptr; } - nsRefPtr ret = mDeque[aIndex]; + RefPtr ret = mDeque[aIndex]; return ret.forget(); } @@ -78,7 +78,7 @@ void nsTransactionStack::Clear() { while (!mDeque.empty()) { - nsRefPtr tx = mType == FOR_UNDO ? Pop() : PopBottom(); + RefPtr tx = mType == FOR_UNDO ? Pop() : PopBottom(); }; } diff --git a/editor/txmgr/nsTransactionStack.h b/editor/txmgr/nsTransactionStack.h index 3c75c450c6..2c56280954 100644 --- a/editor/txmgr/nsTransactionStack.h +++ b/editor/txmgr/nsTransactionStack.h @@ -32,7 +32,7 @@ public: void DoTraverse(nsCycleCollectionTraversalCallback &cb); private: - std::deque > mDeque; + std::deque > mDeque; const Type mType; }; diff --git a/editor/txtsvc/nsFilteredContentIterator.h b/editor/txtsvc/nsFilteredContentIterator.h index 8b16ade2ad..175f70e3f7 100644 --- a/editor/txtsvc/nsFilteredContentIterator.h +++ b/editor/txtsvc/nsFilteredContentIterator.h @@ -66,7 +66,7 @@ protected: nsCOMPtr mMapAtom; nsCOMPtr mFilter; - nsRefPtr mRange; + RefPtr mRange; bool mDidSkip; bool mIsOutOfRange; eDirectionType mDirection; diff --git a/editor/txtsvc/nsTextServicesDocument.cpp b/editor/txtsvc/nsTextServicesDocument.cpp index 993335d946..587b4ad9f9 100644 --- a/editor/txtsvc/nsTextServicesDocument.cpp +++ b/editor/txtsvc/nsTextServicesDocument.cpp @@ -264,7 +264,7 @@ NS_IMETHODIMP nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange) { NS_ENSURE_ARG_POINTER(aRange); - nsRefPtr range = static_cast(aRange); + RefPtr range = static_cast(aRange); // Get the end points of the range. @@ -524,12 +524,12 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, return result; } - nsRefPtr selection = static_cast(domSelection.get()); + RefPtr selection = static_cast(domSelection.get()); bool isCollapsed = selection->IsCollapsed(); nsCOMPtr iter; - nsRefPtr range; + RefPtr range; nsCOMPtr parent; int32_t i, rangeCount, offset; @@ -1964,7 +1964,7 @@ nsTextServicesDocument::CreateContentIterator(nsRange* aRange, // Create a nsFilteredContentIterator // This class wraps the ContentIterator in order to give itself a chance // to filter out certain content nodes - nsRefPtr filter = new nsFilteredContentIterator(mTxtSvcFilter); + RefPtr filter = new nsFilteredContentIterator(mTxtSvcFilter); nsresult result = filter->Init(aRange); if (NS_FAILED(result)) { @@ -2033,7 +2033,7 @@ nsTextServicesDocument::CreateDocumentContentRange(nsRange** aRange) nsCOMPtr nativeNode = do_QueryInterface(node); NS_ENSURE_STATE(nativeNode); - nsRefPtr range = new nsRange(nativeNode); + RefPtr range = new nsRange(nativeNode); rv = range->SelectNodeContents(node); NS_ENSURE_SUCCESS(rv, rv); @@ -2095,7 +2095,7 @@ nsTextServicesDocument::CreateDocumentContentIterator(nsIContentIterator **aIter NS_ENSURE_TRUE(aIterator, NS_ERROR_NULL_POINTER); - nsRefPtr range; + RefPtr range; result = CreateDocumentContentRange(getter_AddRefs(range)); @@ -2527,7 +2527,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS NS_ENSURE_SUCCESS(result, result); NS_ENSURE_TRUE(domSelection, NS_ERROR_FAILURE); - nsRefPtr selection = static_cast(domSelection.get()); + RefPtr selection = static_cast(domSelection.get()); // The calling function should have done the GetIsCollapsed() // check already. Just assume it's collapsed! @@ -2552,7 +2552,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS int32_t eStartOffset = eStart->mNodeOffset; int32_t eEndOffset = eEnd->mNodeOffset + eEnd->mLength; - nsRefPtr range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); NS_ENSURE_STATE(range); nsCOMPtr domParent; @@ -2736,7 +2736,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc { nsresult result; - nsRefPtr range; + RefPtr range; OffsetEntry *entry; nsCOMPtr domSelection; @@ -2745,7 +2745,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc NS_ENSURE_SUCCESS(result, result); NS_ENSURE_TRUE(domSelection, NS_ERROR_FAILURE); - nsRefPtr selection = static_cast(domSelection.get()); + RefPtr selection = static_cast(domSelection.get()); // It is assumed that the calling function has made sure that the // selection is not collapsed, and that the input params to this diff --git a/editor/txtsvc/nsTextServicesDocument.h b/editor/txtsvc/nsTextServicesDocument.h index 620695f191..d4e0345465 100644 --- a/editor/txtsvc/nsTextServicesDocument.h +++ b/editor/txtsvc/nsTextServicesDocument.h @@ -83,7 +83,7 @@ private: int32_t mSelEndIndex; int32_t mSelEndOffset; - nsRefPtr mExtent; + RefPtr mExtent; nsCOMPtr mTxtSvcFilter; diff --git a/embedding/browser/nsContextMenuInfo.cpp b/embedding/browser/nsContextMenuInfo.cpp index a4fa58c80f..f7d0ac578d 100644 --- a/embedding/browser/nsContextMenuInfo.cpp +++ b/embedding/browser/nsContextMenuInfo.cpp @@ -156,7 +156,7 @@ nsContextMenuInfo::GetBackgroundImageContainer(imgIContainer** aImageContainer) NS_ENSURE_ARG_POINTER(aImageContainer); NS_ENSURE_STATE(mDOMNode); - nsRefPtr request; + RefPtr request; GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request)); if (request) { return request->GetImage(aImageContainer); @@ -171,7 +171,7 @@ nsContextMenuInfo::GetBackgroundImageSrc(nsIURI** aURI) NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_STATE(mDOMNode); - nsRefPtr request; + RefPtr request; GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request)); if (request) { return request->GetURI(aURI); @@ -198,7 +198,7 @@ nsContextMenuInfo::HasBackgroundImage(nsIDOMNode* aDOMNode) { NS_ENSURE_TRUE(aDOMNode, false); - nsRefPtr request; + RefPtr request; GetBackgroundImageRequest(aDOMNode, getter_AddRefs(request)); return (request != nullptr); @@ -287,7 +287,7 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode, NS_NewURI(getter_AddRefs(bgUri), bgStringValue); NS_ENSURE_TRUE(bgUri, NS_ERROR_FAILURE); - nsRefPtr il = imgLoader::GetInstance(); + RefPtr il = imgLoader::GetInstance(); NS_ENSURE_TRUE(il, NS_ERROR_FAILURE); return il->LoadImage(bgUri, nullptr, nullptr, diff --git a/embedding/browser/nsDocShellTreeOwner.cpp b/embedding/browser/nsDocShellTreeOwner.cpp index 3118526425..0d3a0381e4 100644 --- a/embedding/browser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/nsDocShellTreeOwner.cpp @@ -447,7 +447,7 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, Set the preferred size on the aShellItem. */ - nsRefPtr presContext; + RefPtr presContext; mWebBrowser->mDocShell->GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); diff --git a/embedding/browser/nsDocShellTreeOwner.h b/embedding/browser/nsDocShellTreeOwner.h index fe7235ab34..7186500d15 100644 --- a/embedding/browser/nsDocShellTreeOwner.h +++ b/embedding/browser/nsDocShellTreeOwner.h @@ -125,8 +125,8 @@ protected: // the objects that listen for chrome events like context menus and tooltips. // They are separate objects to avoid circular references between |this| // and the DOM. - nsRefPtr mChromeTooltipListener; - nsRefPtr mChromeContextMenuListener; + RefPtr mChromeTooltipListener; + RefPtr mChromeContextMenuListener; nsCOMPtr mPrompter; nsCOMPtr mAuthPrompter; diff --git a/embedding/browser/nsWebBrowser.cpp b/embedding/browser/nsWebBrowser.cpp index 81bc9af5a4..f89e922812 100644 --- a/embedding/browser/nsWebBrowser.cpp +++ b/embedding/browser/nsWebBrowser.cpp @@ -1729,7 +1729,7 @@ nsWebBrowser::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) NS_ASSERTION(layerManager, "Must be in paint event"); layerManager->BeginTransaction(); - nsRefPtr root = layerManager->CreatePaintedLayer(); + RefPtr root = layerManager->CreatePaintedLayer(); if (root) { nsIntRect dirtyRect = aRegion.GetBounds(); root->SetVisibleRegion(dirtyRect); diff --git a/embedding/browser/nsWebBrowser.h b/embedding/browser/nsWebBrowser.h index 26267d4ca9..4eb60881a4 100644 --- a/embedding/browser/nsWebBrowser.h +++ b/embedding/browser/nsWebBrowser.h @@ -125,7 +125,7 @@ protected: virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) override; protected: - nsRefPtr mDocShellTreeOwner; + RefPtr mDocShellTreeOwner; nsCOMPtr mDocShell; nsCOMPtr mDocShellAsReq; nsCOMPtr mDocShellAsWin; @@ -156,7 +156,7 @@ protected: uint32_t mPersistFlags; // stream - nsRefPtr mStream; + RefPtr mStream; // Weak Reference interfaces... nsIWidget* mParentWidget; diff --git a/embedding/components/commandhandler/nsCommandGroup.cpp b/embedding/components/commandhandler/nsCommandGroup.cpp index 5a92c8b68a..8e69fe372e 100644 --- a/embedding/components/commandhandler/nsCommandGroup.cpp +++ b/embedding/components/commandhandler/nsCommandGroup.cpp @@ -285,7 +285,7 @@ nsControllerCommandGroup::IsCommandInGroup(const char* aCommand, NS_IMETHODIMP nsControllerCommandGroup::GetGroupsEnumerator(nsISimpleEnumerator** aResult) { - nsRefPtr groupsEnum = new nsGroupsEnumerator(mGroupsHash); + RefPtr groupsEnum = new nsGroupsEnumerator(mGroupsHash); groupsEnum.forget(aResult); return NS_OK; @@ -298,7 +298,7 @@ nsControllerCommandGroup::GetEnumeratorForGroup(const char* aGroup, nsDependentCString groupKey(aGroup); nsTArray* commandList = mGroupsHash.Get(groupKey); // may be null - nsRefPtr theGroupEnum = + RefPtr theGroupEnum = new nsNamedGroupEnumerator(commandList); theGroupEnum.forget(aResult); diff --git a/embedding/components/find/nsFind.cpp b/embedding/components/find/nsFind.cpp index 1ca9743d37..5a8ec1b2e3 100644 --- a/embedding/components/find/nsFind.cpp +++ b/embedding/components/find/nsFind.cpp @@ -123,7 +123,7 @@ protected: private: static already_AddRefed CreateRange(nsINode* aNode) { - nsRefPtr range = new nsRange(aNode); + RefPtr range = new nsRange(aNode); range->SetMaySpanAnonymousSubtrees(true); return range.forget(); } diff --git a/embedding/components/find/nsFind.h b/embedding/components/find/nsFind.h index 7b0667152c..0e3cb7dde9 100644 --- a/embedding/components/find/nsFind.h +++ b/embedding/components/find/nsFind.h @@ -68,7 +68,7 @@ protected: // The iterator we use to move through the document: nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset, nsIDOMNode* aEndNode, int32_t aEndOffset); - nsRefPtr mIterator; + RefPtr mIterator; }; #endif // nsFind_h__ diff --git a/embedding/components/printingui/ipc/nsPrintingProxy.cpp b/embedding/components/printingui/ipc/nsPrintingProxy.cpp index 730850e424..f790e70e11 100644 --- a/embedding/components/printingui/ipc/nsPrintingProxy.cpp +++ b/embedding/components/printingui/ipc/nsPrintingProxy.cpp @@ -50,7 +50,7 @@ nsPrintingProxy::GetInstance() ClearOnShutdown(&sPrintingProxyInstance); } - nsRefPtr inst = sPrintingProxyInstance.get(); + RefPtr inst = sPrintingProxyInstance.get(); return inst.forget(); } @@ -100,7 +100,7 @@ nsPrintingProxy::ShowPrintDialog(nsIDOMWindow *parent, // nested event loop while we wait for the results of the dialog // to be returned to us. - nsRefPtr dialog = new PrintSettingsDialogChild(); + RefPtr dialog = new PrintSettingsDialogChild(); SendPPrintSettingsDialogConstructor(dialog); mozilla::unused << SendShowPrintDialog(dialog, pBrowser, inSettings); @@ -144,7 +144,7 @@ nsPrintingProxy::ShowProgress(nsIDOMWindow* parent, nsCOMPtr tabchild = do_GetInterface(owner); TabChild* pBrowser = static_cast(tabchild.get()); - nsRefPtr dialogChild = + RefPtr dialogChild = new PrintProgressDialogChild(openDialogObserver); SendPPrintProgressDialogConstructor(dialogChild); diff --git a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp index 19339d608d..02dccbd728 100644 --- a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp @@ -3194,7 +3194,7 @@ nsWebBrowserPersist::CloneNodeWithFixedUpAttributes( NS_NAMED_LITERAL_STRING(valueAttr, "value"); // Update element node attributes with user-entered form state nsCOMPtr content = do_QueryInterface(*aNodeOut); - nsRefPtr outElt = + RefPtr outElt = HTMLInputElement::FromContentOrNull(content); nsCOMPtr formControl = do_QueryInterface(*aNodeOut); switch (formControl->GetType()) { @@ -3665,7 +3665,7 @@ nsWebBrowserPersist::SaveDocumentWithFixup( { NS_ENSURE_ARG_POINTER(aFile); - nsRefPtr nodeFixup = new nsEncoderNodeFixup(); + RefPtr nodeFixup = new nsEncoderNodeFixup(); nodeFixup->mWebBrowserPersist = this; nsresult rv = NS_OK; diff --git a/embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp b/embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp index fbb6896e22..e5ef170483 100644 --- a/embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp +++ b/embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp @@ -56,7 +56,7 @@ nsAutoWindowStateHelper::DispatchEventToChrome(const char* aEventName) } ErrorResult rv; - nsRefPtr event = doc->CreateEvent(NS_LITERAL_STRING("Events"), rv); + RefPtr event = doc->CreateEvent(NS_LITERAL_STRING("Events"), rv); if (rv.Failed()) { return false; } diff --git a/extensions/auth/nsAuthFactory.cpp b/extensions/auth/nsAuthFactory.cpp index 0712d896cf..a6434251f4 100644 --- a/extensions/auth/nsAuthFactory.cpp +++ b/extensions/auth/nsAuthFactory.cpp @@ -113,7 +113,7 @@ nsSambaNTLMAuthConstructor(nsISupports *outer, REFNSIID iid, void **result) if (outer) return NS_ERROR_NO_AGGREGATION; - nsRefPtr auth = new nsAuthSambaNTLM(); + RefPtr auth = new nsAuthSambaNTLM(); if (!auth) return NS_ERROR_OUT_OF_MEMORY; diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 0641fec1d8..fe7ac538c0 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -282,7 +282,7 @@ public: bool aRebuildOnSuccess); protected: - nsRefPtr mManager; + RefPtr mManager; bool mRebuildOnSuccess; }; @@ -299,7 +299,7 @@ NS_IMETHODIMP CloseDatabaseListener::Complete(nsresult, nsISupports*) { // Help breaking cycles - nsRefPtr manager = mManager.forget(); + RefPtr manager = mManager.forget(); if (mRebuildOnSuccess && !manager->mIsShuttingDown) { return manager->InitDB(true); } @@ -331,7 +331,7 @@ public: explicit DeleteFromMozHostListener(nsPermissionManager* aManager); protected: - nsRefPtr mManager; + RefPtr mManager; }; NS_IMPL_ISUPPORTS(DeleteFromMozHostListener, mozIStorageStatementCallback) @@ -356,7 +356,7 @@ NS_IMETHODIMP DeleteFromMozHostListener::HandleError(mozIStorageError *) NS_IMETHODIMP DeleteFromMozHostListener::HandleCompletion(uint16_t aReason) { // Help breaking cycles - nsRefPtr manager = mManager.forget(); + RefPtr manager = mManager.forget(); if (aReason == REASON_ERROR) { manager->CloseDB(true); @@ -790,7 +790,7 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal, // When an entry already exists, PutEntry will return that, instead // of adding a new one - nsRefPtr key = new PermissionKey(aPrincipal); + RefPtr key = new PermissionKey(aPrincipal); PermissionHashKey* entry = mPermissionTable.PutEntry(key); if (!entry) return NS_ERROR_FAILURE; if (!entry->GetKey()) { @@ -1391,7 +1391,7 @@ nsPermissionManager::GetPermissionHashKey(const nsACString& aHost, { PermissionHashKey* entry = nullptr; - nsRefPtr key = new PermissionKey(aHost, aAppId, aIsInBrowserElement); + RefPtr key = new PermissionKey(aHost, aAppId, aIsInBrowserElement); entry = mPermissionTable.GetEntry(key); if (entry) { diff --git a/extensions/gio/nsGIOProtocolHandler.cpp b/extensions/gio/nsGIOProtocolHandler.cpp index 43aac0c77e..71db2d5da3 100644 --- a/extensions/gio/nsGIOProtocolHandler.cpp +++ b/extensions/gio/nsGIOProtocolHandler.cpp @@ -1061,7 +1061,7 @@ nsGIOProtocolHandler::NewChannel2(nsIURI* aURI, if (NS_FAILED(rv)) return rv; - nsRefPtr stream = new nsGIOInputStream(spec); + RefPtr stream = new nsGIOInputStream(spec); if (!stream) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index a9fcb30410..159779cf22 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -352,7 +352,7 @@ mozInlineSpellStatus::FinishNavigationEvent(mozInlineSpellWordUtil& aWordUtil) // find the word on the old caret position, this is the one that we MAY need // to check - nsRefPtr oldWord; + RefPtr oldWord; rv = aWordUtil.GetRangeForWord(oldAnchorNode, oldAnchorOffset, getter_AddRefs(oldWord)); NS_ENSURE_SUCCESS(rv, rv); @@ -512,7 +512,7 @@ public: } private: - nsRefPtr mSpellChecker; + RefPtr mSpellChecker; }; NS_IMPL_ISUPPORTS(InitEditorSpellCheckCallback, nsIEditorSpellCheckCallback) @@ -1207,7 +1207,7 @@ mozInlineSpellChecker::SpellCheckBetweenNodes(nsIDOMNode *aStartNode, nsIDOMNode *aEndNode, int32_t aEndOffset) { - nsRefPtr range; + RefPtr range; nsresult rv = MakeSpellCheckRange(aStartNode, aStartOffset, aEndNode, aEndOffset, getter_AddRefs(range)); @@ -1311,7 +1311,7 @@ mozInlineSpellChecker::ScheduleSpellCheck(const mozInlineSpellStatus& aStatus) return NS_OK; } - nsRefPtr resume = + RefPtr resume = new mozInlineSpellResume(aStatus, mDisabledAsyncToken); NS_ENSURE_TRUE(resume, NS_ERROR_OUT_OF_MEMORY); @@ -1351,7 +1351,7 @@ mozInlineSpellChecker::DoSpellCheckSelection(mozInlineSpellWordUtil& aWordUtil, // Since we could be modifying the ranges for the spellCheckSelection while // looping on the spell check selection, keep a separate array of range // elements inside the selection - nsTArray> ranges; + nsTArray> ranges; int32_t count = aSpellCheckSelection->RangeCount(); @@ -1481,7 +1481,7 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil, PRTime beginTime = PR_Now(); nsAutoString wordText; - nsRefPtr wordRange; + RefPtr wordRange; bool dontCheckWord; while (NS_SUCCEEDED(aWordUtil.GetNextWord(wordText, getter_AddRefs(wordRange), @@ -1514,7 +1514,7 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil, // likewise, if this word is inside new text, we won't bother testing if (!aStatus->mCreatedRange || !aStatus->mCreatedRange->IsPointInRange(*beginNode, beginOffset, erv)) { - nsTArray> ranges; + nsTArray> ranges; aSpellCheckSelection->GetRangesForInterval(*beginNode, beginOffset, *endNode, endOffset, true, ranges, erv); @@ -1599,7 +1599,7 @@ public: } private: - nsRefPtr mSpellChecker; + RefPtr mSpellChecker; int32_t mDelta; }; @@ -1972,7 +1972,7 @@ public: private: ~UpdateCurrentDictionaryCallback() {} - nsRefPtr mSpellChecker; + RefPtr mSpellChecker; uint32_t mDisabledAsyncToken; }; NS_IMPL_ISUPPORTS(UpdateCurrentDictionaryCallback, nsIEditorSpellCheckCallback) @@ -1992,7 +1992,7 @@ NS_IMETHODIMP mozInlineSpellChecker::UpdateCurrentDictionary() mPreviousDictionary.Truncate(); } - nsRefPtr cb = + RefPtr cb = new UpdateCurrentDictionaryCallback(this, mDisabledAsyncToken); NS_ENSURE_STATE(cb); nsresult rv = spellCheck->UpdateCurrentDictionary(cb); diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.h b/extensions/spellcheck/src/mozInlineSpellChecker.h index dfbc932e7d..bcb4b9b628 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.h +++ b/extensions/spellcheck/src/mozInlineSpellChecker.h @@ -55,7 +55,7 @@ public: return mOp == eOpChange && !mRange; } - nsRefPtr mSpellChecker; + RefPtr mSpellChecker; // The total number of words checked in this sequence, using this tally tells // us when to stop. This count is preserved as we continue checking in new @@ -72,14 +72,14 @@ public: // Used for events where we have already computed the range to use. It can // also be nullptr in these cases where we need to check the entire range. - nsRefPtr mRange; + RefPtr mRange; // If we happen to know something was inserted, this is that range. // Can be nullptr (this only allows an optimization, so not setting doesn't hurt) - nsRefPtr mCreatedRange; + RefPtr mCreatedRange; // Contains the range computed for the current word. Can be nullptr. - nsRefPtr mNoCheckRange; + RefPtr mNoCheckRange; // Indicates the position of the cursor for the event (so we can compute // mNoCheckRange). It can be nullptr if we don't care about the cursor position @@ -170,7 +170,7 @@ private: // When mPendingSpellCheck is non-null, this is the callback passed when // it was initialized. - nsRefPtr mPendingInitEditorSpellCheckCallback; + RefPtr mPendingInitEditorSpellCheckCallback; // Set when we have spellchecked after the last edit operation. See the // commment at the top of the .cpp file for more info. diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp index 6489e53b55..2d111d6c7c 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp @@ -322,7 +322,7 @@ mozInlineSpellWordUtil::MakeRange(NodeOffset aBegin, NodeOffset aEnd, if (!mDOMDocument) return NS_ERROR_NOT_INITIALIZED; - nsRefPtr range = new nsRange(aBegin.mNode); + RefPtr range = new nsRange(aBegin.mNode); nsresult rv = range->Set(aBegin.mNode, aBegin.mOffset, aEnd.mNode, aEnd.mOffset); NS_ENSURE_SUCCESS(rv, rv); diff --git a/extensions/spellcheck/src/mozPersonalDictionary.cpp b/extensions/spellcheck/src/mozPersonalDictionary.cpp index 44f2fc405a..799f879d75 100644 --- a/extensions/spellcheck/src/mozPersonalDictionary.cpp +++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp @@ -80,7 +80,7 @@ public: } private: - nsRefPtr mDict; + RefPtr mDict; }; class mozPersonalDictionarySave final : public nsRunnable @@ -161,7 +161,7 @@ public: private: nsTArray mDictWords; nsCOMPtr mFile; - nsRefPtr mDict; + RefPtr mDict; }; mozPersonalDictionary::mozPersonalDictionary() diff --git a/extensions/spellcheck/src/mozSpellChecker.cpp b/extensions/spellcheck/src/mozSpellChecker.cpp index c695efb863..7ef1606921 100644 --- a/extensions/spellcheck/src/mozSpellChecker.cpp +++ b/extensions/spellcheck/src/mozSpellChecker.cpp @@ -390,7 +390,7 @@ mozSpellChecker::SetCurrentDictionary(const nsAString &aDictionary) } // Calls to mozISpellCheckingEngine::SetDictionary might destroy us - nsRefPtr kungFuDeathGrip = this; + RefPtr kungFuDeathGrip = this; mSpellCheckingEngine = nullptr; diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index ec1cfe2784..4ff0e59808 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -71,7 +71,7 @@ public: 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; - HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture)); + HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(tmpTexture)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(size))) << "[D2D] 1 CreateTexture2D failure " << size << " Code: " << hexa(hr) << " format " << (int)format; return; @@ -82,10 +82,10 @@ public: RefPtr surf; - tmpTexture->QueryInterface((IDXGISurface**)byRef(surf)); + tmpTexture->QueryInterface((IDXGISurface**)getter_AddRefs(surf)); hr = mDT->mRT->CreateSharedBitmap(IID_IDXGISurface, surf, - &props, byRef(mOldSurfBitmap)); + &props, getter_AddRefs(mOldSurfBitmap)); if (FAILED(hr)) { gfxCriticalError() << "[D2D] CreateSharedBitmap failure " << size << " Code: " << hexa(hr); @@ -103,7 +103,7 @@ public: Float(clipBounds.y), Float(clipBounds.XMost()), Float(clipBounds.YMost())), - byRef(rectGeom)); + getter_AddRefs(rectGeom)); mClippedArea = IntersectGeometry(mClippedArea, rectGeom); } @@ -127,18 +127,18 @@ public: RefPtr rectGeom; factory()->CreateRectangleGeometry( D2D1::RectF(0, 0, float(mDT->mSize.width), float(mDT->mSize.height)), - byRef(rectGeom)); + getter_AddRefs(rectGeom)); RefPtr invClippedArea; - factory()->CreatePathGeometry(byRef(invClippedArea)); + factory()->CreatePathGeometry(getter_AddRefs(invClippedArea)); RefPtr sink; - invClippedArea->Open(byRef(sink)); + invClippedArea->Open(getter_AddRefs(sink)); rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, nullptr, sink); sink->Close(); RefPtr brush; - HRESULT hr = rt->CreateBitmapBrush(mOldSurfBitmap, D2D1::BitmapBrushProperties(), D2D1::BrushProperties(), byRef(brush)); + HRESULT hr = rt->CreateBitmapBrush(mOldSurfBitmap, D2D1::BitmapBrushProperties(), D2D1::BrushProperties(), getter_AddRefs(brush)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(false)) << "[D2D] CreateBitmapBrush failure " << hexa(hr); return; @@ -319,7 +319,7 @@ DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface, D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(srcSurf->GetFormat())); - hr = mRT->CreateBitmap(D2D1::SizeU(UINT32(sourceRect.width), UINT32(sourceRect.height)), data, stride, props, byRef(bitmap)); + hr = mRT->CreateBitmap(D2D1::SizeU(UINT32(sourceRect.width), UINT32(sourceRect.height)), data, stride, props, getter_AddRefs(bitmap)); } if (FAILED(hr)) { IntSize size(sourceRect.width, sourceRect.height); @@ -384,7 +384,7 @@ DrawTargetD2D::DrawFilter(FilterNode *aNode, RefPtr dc; HRESULT hr; - hr = mRT->QueryInterface((ID2D1DeviceContext**)byRef(dc)); + hr = mRT->QueryInterface((ID2D1DeviceContext**)getter_AddRefs(dc)); if (SUCCEEDED(hr) && aNode->GetBackendType() == FILTER_BACKEND_DIRECT2D1_1) { ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, ColorPattern(Color())); @@ -392,7 +392,7 @@ DrawTargetD2D::DrawFilter(FilterNode *aNode, PrepareForDrawing(rt); rt->SetAntialiasMode(D2DAAMode(aOptions.mAntialiasMode)); - hr = rt->QueryInterface((ID2D1DeviceContext**)byRef(dc)); + hr = rt->QueryInterface((ID2D1DeviceContext**)getter_AddRefs(dc)); if (SUCCEEDED(hr)) { FilterNodeD2D1* node = static_cast(aNode); @@ -477,7 +477,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, if (!mTempRTView) { // This view is only needed in this path. - HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, nullptr, byRef(mTempRTView)); + HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, nullptr, getter_AddRefs(mTempRTView)); if (FAILED(hr)) { gfxWarning() << "Failure to create RenderTargetView. Code: " << hexa(hr); @@ -496,7 +496,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, if (mPushedClips.size()) { EnsureClipMaskTexture(&clipBounds); - mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, byRef(maskSRView)); + mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, getter_AddRefs(maskSRView)); } IntSize srcSurfSize; @@ -538,7 +538,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, desc.MiscFlags = D3D10_RESOURCE_MISC_GENERATE_MIPS; RefPtr mipTexture; - hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mipTexture)); + hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mipTexture)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSurface->GetSize()))) << "[D2D] 2 CreateTexture2D failure " << aSurface->GetSize() << " Code: " << hexa(hr); @@ -565,7 +565,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, dsSize.height, 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; RefPtr tmpDSTexture; - hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpDSTexture)); + hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(tmpDSTexture)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(dsSize))) << "[D2D] 3 CreateTexture2D failure " << dsSize << " Code: " << hexa(hr); @@ -579,13 +579,13 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, box.bottom = aSurface->GetSize().height; mDevice->CopySubresourceRegion(mipTexture, 0, 0, 0, 0, static_cast(aSurface)->mTexture, 0, &box); - mDevice->CreateShaderResourceView(mipTexture, nullptr, byRef(srView)); + mDevice->CreateShaderResourceView(mipTexture, nullptr, getter_AddRefs(srView)); mDevice->GenerateMips(srView); RefPtr dsRTView; RefPtr dsSRView; - mDevice->CreateRenderTargetView(tmpDSTexture, nullptr, byRef(dsRTView)); - mDevice->CreateShaderResourceView(tmpDSTexture, nullptr, byRef(dsSRView)); + mDevice->CreateRenderTargetView(tmpDSTexture, nullptr, getter_AddRefs(dsRTView)); + mDevice->CreateShaderResourceView(tmpDSTexture, nullptr, getter_AddRefs(dsSRView)); // We're not guaranteed the texture we created will be empty, we've // seen old content at least on NVidia drivers. @@ -676,9 +676,9 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; - mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture)); - mDevice->CreateRenderTargetView(tmpTexture, nullptr, byRef(tmpRTView)); - mDevice->CreateShaderResourceView(tmpTexture, nullptr, byRef(tmpSRView)); + mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(tmpTexture)); + mDevice->CreateRenderTargetView(tmpTexture, nullptr, getter_AddRefs(tmpRTView)); + mDevice->CreateShaderResourceView(tmpTexture, nullptr, getter_AddRefs(tmpSRView)); tmpSurfSize = srcSurfSize; } @@ -850,7 +850,7 @@ DrawTargetD2D::CopySurface(SourceSurface *aSurface, if (aSurface->GetFormat() == SurfaceFormat::A8) { RefPtr brush; mRT->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), - D2D1::BrushProperties(), byRef(brush)); + D2D1::BrushProperties(), getter_AddRefs(brush)); mRT->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED); mRT->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS); } else { @@ -1275,7 +1275,7 @@ already_AddRefed DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const { RefPtr path; - HRESULT hr = factory()->CreatePathGeometry(byRef(path)); + HRESULT hr = factory()->CreatePathGeometry(getter_AddRefs(path)); if (FAILED(hr)) { gfxWarning() << "Failed to create Direct2D Path Geometry. Code: " << hexa(hr); @@ -1283,7 +1283,7 @@ DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const } RefPtr sink; - hr = path->Open(byRef(sink)); + hr = path->Open(getter_AddRefs(sink)); if (FAILED(hr)) { gfxWarning() << "Failed to access Direct2D Path Geometry. Code: " << hexa(hr); return nullptr; @@ -1311,7 +1311,7 @@ DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, E HRESULT hr = mRT->CreateGradientStopCollection(stops, aNumStops, D2D1_GAMMA_2_2, D2DExtend(aExtendMode), - byRef(stopCollection)); + getter_AddRefs(stopCollection)); delete [] stops; if (FAILED(hr)) { @@ -1326,7 +1326,7 @@ already_AddRefed DrawTargetD2D::CreateFilter(FilterType aType) { RefPtr dc; - HRESULT hr = mRT->QueryInterface((ID2D1DeviceContext**)byRef(dc)); + HRESULT hr = mRT->QueryInterface((ID2D1DeviceContext**)getter_AddRefs(dc)); if (SUCCEEDED(hr)) { return FilterNodeD2D1::Create(dc, aType); @@ -1367,7 +1367,7 @@ DrawTargetD2D::Init(const IntSize &aSize, SurfaceFormat aFormat) 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; - hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture)); + hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "Failed to init Direct2D DrawTarget. Size: " << mSize << " Code: " << hexa(hr); @@ -1396,9 +1396,9 @@ DrawTargetD2D::Init(ID3D10Texture2D *aTexture, SurfaceFormat aFormat) } RefPtr device; - mTexture->GetDevice(byRef(device)); + mTexture->GetDevice(getter_AddRefs(device)); - hr = device->QueryInterface((ID3D10Device1**)byRef(mDevice)); + hr = device->QueryInterface((ID3D10Device1**)getter_AddRefs(mDevice)); if (FAILED(hr)) { gfxCriticalError() << "Failed to get D3D10 device from texture." << " format " << (int)aFormat; @@ -1437,7 +1437,7 @@ DrawTargetD2D::InitD3D10Data() createD3DEffect = (decltype(D3D10CreateEffectFromMemory)*) GetProcAddress(d3dModule, "D3D10CreateEffectFromMemory"); - hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, nullptr, byRef(mPrivateData->mEffect)); + hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, nullptr, getter_AddRefs(mPrivateData->mEffect)); if (FAILED(hr)) { gfxWarning() << "Failed to initialize Direct2D required effects. Code: " << hexa(hr); @@ -1459,7 +1459,7 @@ DrawTargetD2D::InitD3D10Data() sizeof(layout) / sizeof(D3D10_INPUT_ELEMENT_DESC), passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, - byRef(mPrivateData->mInputLayout)); + getter_AddRefs(mPrivateData->mInputLayout)); if (FAILED(hr)) { gfxWarning() << "Failed to initialize Direct2D required InputLayout. Code: " << hexa(hr); @@ -1471,7 +1471,7 @@ DrawTargetD2D::InitD3D10Data() data.pSysMem = vertices; CD3D10_BUFFER_DESC bufferDesc(sizeof(vertices), D3D10_BIND_VERTEX_BUFFER); - hr = mDevice->CreateBuffer(&bufferDesc, &data, byRef(mPrivateData->mVB)); + hr = mDevice->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mPrivateData->mVB)); if (FAILED(hr)) { gfxWarning() << "Failed to initialize Direct2D required VertexBuffer. Code: " << hexa(hr); @@ -1497,12 +1497,12 @@ DrawTargetD2D::GetCachedLayer() if (mCurrentCachedLayer < 5) { if (!mCachedLayers[mCurrentCachedLayer]) { - mRT->CreateLayer(byRef(mCachedLayers[mCurrentCachedLayer])); + mRT->CreateLayer(getter_AddRefs(mCachedLayers[mCurrentCachedLayer])); mVRAMUsageDT += GetByteSize(); } layer = mCachedLayers[mCurrentCachedLayer]; } else { - mRT->CreateLayer(byRef(layer)); + mRT->CreateLayer(getter_AddRefs(layer)); } mCurrentCachedLayer++; @@ -1652,7 +1652,7 @@ DrawTargetD2D::GetBlendStateForOperator(CompositionOp aOperator) desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; } - mDevice->CreateBlendState(&desc, byRef(mPrivateData->mBlendStates[operatorIndex])); + mDevice->CreateBlendState(&desc, getter_AddRefs(mPrivateData->mBlendStates[operatorIndex])); return mPrivateData->mBlendStates[operatorIndex]; } @@ -1771,7 +1771,7 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP CD3D10_TEXTURE2D_DESC desc(DXGIFormat(format), size.width, size.height, 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; - HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture)); + HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(tmpTexture)); if (FAILED(hr)) { gfxWarning() << "Failed to create temporary texture to hold surface data."; return; @@ -1785,7 +1785,7 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP DrawTargetD2D::Flush(); - hr = mDevice->CreateShaderResourceView(tmpTexture, nullptr, byRef(mBckSRView)); + hr = mDevice->CreateShaderResourceView(tmpTexture, nullptr, getter_AddRefs(mBckSRView)); if (FAILED(hr)) { gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hexa(hr); @@ -1928,10 +1928,10 @@ DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds) } RefPtr newGeom; - factory()->CreatePathGeometry(byRef(newGeom)); + factory()->CreatePathGeometry(getter_AddRefs(newGeom)); RefPtr currentSink; - newGeom->Open(byRef(currentSink)); + newGeom->Open(getter_AddRefs(currentSink)); if (iter->mPath) { pathGeom->CombineWithGeometry(iter->mPath->GetGeometry(), D2D1_COMBINE_MODE_INTERSECT, @@ -1968,7 +1968,7 @@ DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aForm RefPtr surface; RefPtr rt; - hr = aTexture->QueryInterface((IDXGISurface**)byRef(surface)); + hr = aTexture->QueryInterface((IDXGISurface**)getter_AddRefs(surface)); if (FAILED(hr)) { gfxCriticalError() << "Failed to QI texture to surface. Code: " << hexa(hr); @@ -1986,7 +1986,7 @@ DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aForm D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(desc.Format, alphaMode)); - hr = factory()->CreateDxgiSurfaceRenderTarget(surface, props, byRef(rt)); + hr = factory()->CreateDxgiSurfaceRenderTarget(surface, props, getter_AddRefs(rt)); if (FAILED(hr)) { gfxCriticalError() << "Failed to create D2D render target for texture. Code: " @@ -2012,7 +2012,7 @@ DrawTargetD2D::EnsureViews() 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; - hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTempTexture)); + hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTempTexture)); if (FAILED(hr)) { gfxWarning() << *this << "Failed to create temporary texture for rendertarget. Size: " @@ -2020,14 +2020,14 @@ DrawTargetD2D::EnsureViews() return; } - hr = mDevice->CreateShaderResourceView(mTempTexture, nullptr, byRef(mSRView)); + hr = mDevice->CreateShaderResourceView(mTempTexture, nullptr, getter_AddRefs(mSRView)); if (FAILED(hr)) { gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hexa(hr); return; } - hr = mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(mRTView)); + hr = mDevice->CreateRenderTargetView(mTexture, nullptr, getter_AddRefs(mRTView)); if (FAILED(hr)) { gfxWarning() << *this << "Failed to create rendertarget view for temp texture. Code: " << hexa(hr); @@ -2085,7 +2085,7 @@ DrawTargetD2D::EnsureClipMaskTexture(IntRect *aBounds) 1, 1); desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; - HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mCurrentClipMaskTexture)); + HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mCurrentClipMaskTexture)); if (FAILED(hr)) { gfxWarning() << "Failed to create texture for ClipMask!"; @@ -2100,7 +2100,7 @@ DrawTargetD2D::EnsureClipMaskTexture(IntRect *aBounds) } RefPtr brush; - rt->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), byRef(brush)); + rt->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), getter_AddRefs(brush)); rt->BeginDraw(); rt->Clear(D2D1::ColorF(0, 0)); @@ -2122,7 +2122,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont, if (aParams) { params = aParams; } else { - mRT->GetTextRenderingParams(byRef(params)); + mRT->GetTextRenderingParams(getter_AddRefs(params)); } DWRITE_RENDERING_MODE renderMode = DWRITE_RENDERING_MODE_DEFAULT; @@ -2172,7 +2172,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont, RefPtr analysis; hr = GetDWriteFactory()->CreateGlyphRunAnalysis(&autoRun, 1.0f, &mat, - renderMode, measureMode, 0, 0, byRef(analysis)); + renderMode, measureMode, 0, 0, getter_AddRefs(analysis)); if (FAILED(hr)) { return false; @@ -2203,7 +2203,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont, } RefPtr srView; - hr = mDevice->CreateShaderResourceView(tex, nullptr, byRef(srView)); + hr = mDevice->CreateShaderResourceView(tex, nullptr, getter_AddRefs(srView)); if (FAILED(hr)) { return false; @@ -2246,7 +2246,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont, Float(rectBounds.y), Float(rectBounds.width + rectBounds.x), Float(rectBounds.height + rectBounds.y)), - byRef(rectGeom)); + getter_AddRefs(rectGeom)); D2D1_GEOMETRY_RELATION relation; if (FAILED(geom->CompareWithGeometry(rectGeom, D2D1::IdentityMatrix(), &relation)) || @@ -2260,7 +2260,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont, EnsureClipMaskTexture(clipBounds); RefPtr srViewMask; - hr = mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, byRef(srViewMask)); + hr = mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, getter_AddRefs(srViewMask)); if (FAILED(hr)) { return false; @@ -2279,7 +2279,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont, RefPtr rtView; ID3D10RenderTargetView *rtViews; - mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(rtView)); + mDevice->CreateRenderTargetView(mTexture, nullptr, getter_AddRefs(rtView)); rtViews = rtView; mDevice->OMSetRenderTargets(1, &rtViews, nullptr); @@ -2293,7 +2293,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) { if (!IsPatternSupportedByD2D(aPattern)) { RefPtr colBrush; - mRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush)); + mRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), getter_AddRefs(colBrush)); return colBrush.forget(); } @@ -2303,7 +2303,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) mRT->CreateSolidColorBrush(D2D1::ColorF(color.r, color.g, color.b, color.a), D2D1::BrushProperties(aAlpha), - byRef(colBrush)); + getter_AddRefs(colBrush)); return colBrush.forget(); } if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) { @@ -2325,7 +2325,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) stops->mStopCollection->GetGradientStops(&d2dStops.front(), stopCount); mRT->CreateSolidColorBrush(d2dStops.back().color, D2D1::BrushProperties(aAlpha), - byRef(colBrush)); + getter_AddRefs(colBrush)); return colBrush.forget(); } @@ -2333,7 +2333,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) D2DPoint(pat->mEnd)), D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)), stops->mStopCollection, - byRef(gradBrush)); + getter_AddRefs(gradBrush)); return gradBrush.forget(); } if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) { @@ -2355,7 +2355,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) pat->mRadius2, pat->mRadius2), D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)), stops->mStopCollection, - byRef(gradBrush)); + getter_AddRefs(gradBrush)); return gradBrush.forget(); } @@ -2430,7 +2430,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) bitmap = CreatePartialBitmapForSurface(dataSurf, mTransform, mSize, pat->mExtendMode, mat, mRT, &sourceRect); if (!bitmap) { RefPtr colBrush; - mRT->CreateSolidColorBrush(D2D1::ColorF(0, 0), byRef(colBrush)); + mRT->CreateSolidColorBrush(D2D1::ColorF(0, 0), getter_AddRefs(colBrush)); return colBrush.forget(); } } @@ -2442,7 +2442,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) D2DExtend(pat->mExtendMode), D2DFilter(pat->mFilter)), D2D1::BrushProperties(aAlpha, D2DMatrix(mat)), - byRef(bmBrush)); + getter_AddRefs(bmBrush)); if (FAILED(hr)) { gfxCriticalError() << "[D2D] 1CreateBitmapBrush failure: " << hexa(hr); return nullptr; @@ -2521,7 +2521,7 @@ DrawTargetD2D::CreateGradientTexture(const GradientStopsD2D *aStops) data.SysMemPitch = 4096 * 4; RefPtr tex; - mDevice->CreateTexture2D(&desc, &data, byRef(tex)); + mDevice->CreateTexture2D(&desc, &data, getter_AddRefs(tex)); return tex.forget(); } @@ -2579,7 +2579,7 @@ DrawTargetD2D::CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, cons data.pSysMem = alignedTextureData; RefPtr tex; - hr = mDevice->CreateTexture2D(&desc, &data, byRef(tex)); + hr = mDevice->CreateTexture2D(&desc, &data, getter_AddRefs(tex)); delete [] alignedTextureData; delete [] texture; @@ -2608,7 +2608,7 @@ DrawTargetD2D::SetupEffectForRadialGradient(const RadialGradientPattern *aPatter RefPtr tex = CreateGradientTexture(stops); RefPtr srView; - mDevice->CreateShaderResourceView(tex, nullptr, byRef(srView)); + mDevice->CreateShaderResourceView(tex, nullptr, getter_AddRefs(srView)); mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView); @@ -2723,7 +2723,7 @@ DrawTargetD2D::factory() } RefPtr factoryD2D1; - hr = mFactory->QueryInterface((ID2D1Factory1**)byRef(factoryD2D1)); + hr = mFactory->QueryInterface((ID2D1Factory1**)getter_AddRefs(factoryD2D1)); if (SUCCEEDED(hr)) { ExtendInputEffectD2D1::Register(factoryD2D1); } @@ -2736,7 +2736,7 @@ DrawTargetD2D::CleanupD2D() { if (mFactory) { RefPtr factoryD2D1; - HRESULT hr = mFactory->QueryInterface((ID2D1Factory1**)byRef(factoryD2D1)); + HRESULT hr = mFactory->QueryInterface((ID2D1Factory1**)getter_AddRefs(factoryD2D1)); if (SUCCEEDED(hr)) { ExtendInputEffectD2D1::Unregister(factoryD2D1); } @@ -2802,7 +2802,7 @@ DrawTargetD2D::PushD2DLayer(ID2D1RenderTarget *aRT, ID2D1Geometry *aGeometry, ID } RefPtr dc; - HRESULT hr = aRT->QueryInterface(IID_ID2D1DeviceContext, (void**)((ID2D1DeviceContext**)byRef(dc))); + HRESULT hr = aRT->QueryInterface(IID_ID2D1DeviceContext, (void**)((ID2D1DeviceContext**)getter_AddRefs(dc))); if (FAILED(hr)) { aRT->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), aGeometry, diff --git a/gfx/2d/DrawTargetD2D1.cpp b/gfx/2d/DrawTargetD2D1.cpp index 4b327dda8e..41d0eb3bed 100644 --- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -139,7 +139,7 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface, if (aSurface->GetType() == SurfaceType::D2D1_1_IMAGE) { // If this is called with a DataSourceSurface it might do a partial upload // that our DrawBitmap call doesn't support. - image->QueryInterface((ID2D1Bitmap**)byRef(bitmap)); + image->QueryInterface((ID2D1Bitmap**)getter_AddRefs(bitmap)); } if (bitmap && aSurfOptions.mSamplingBounds == SamplingBounds::UNBOUNDED) { @@ -153,7 +153,7 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface, D2D1_EXTEND_MODE_CLAMP, D2DInterpolationMode(aSurfOptions.mFilter)), D2D1::BrushProperties(aOptions.mAlpha, D2DMatrix(transform)), - byRef(brush)); + getter_AddRefs(brush)); mDC->FillRectangle(D2DRect(aDest), brush); } @@ -210,7 +210,7 @@ DrawTargetD2D1::DrawSurfaceWithShadow(SourceSurface *aSurface, // Step 1, create the shadow effect. RefPtr shadowEffect; - HRESULT hr = mDC->CreateEffect(CLSID_D2D1Shadow, byRef(shadowEffect)); + HRESULT hr = mDC->CreateEffect(CLSID_D2D1Shadow, getter_AddRefs(shadowEffect)); if (FAILED(hr) || !shadowEffect) { gfxWarning() << "Failed to create shadow effect. Code: " << hexa(hr); return; @@ -261,7 +261,7 @@ DrawTargetD2D1::ClearRect(const Rect &aRect) RefPtr geom = GetClippedGeometry(&addClipRect); RefPtr brush; - mDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), byRef(brush)); + mDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), getter_AddRefs(brush)); mDC->PushAxisAlignedClip(D2D1::RectF(addClipRect.x, addClipRect.y, addClipRect.XMost(), addClipRect.YMost()), D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); mDC->FillGeometry(geom, brush); mDC->PopAxisAlignedClip(); @@ -339,12 +339,12 @@ DrawTargetD2D1::CopySurface(SourceSurface *aSurface, } RefPtr bitmap; - image->QueryInterface((ID2D1Bitmap**)byRef(bitmap)); + image->QueryInterface((ID2D1Bitmap**)getter_AddRefs(bitmap)); if (bitmap && mFormat == SurfaceFormat::A8) { RefPtr brush; mDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), - D2D1::BrushProperties(), byRef(brush)); + D2D1::BrushProperties(), getter_AddRefs(brush)); mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED); mDC->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_COPY); mDC->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS); @@ -574,9 +574,9 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *aFont, DWRITE_MEASURING_MODE_NATURAL, &userRect); RefPtr path; - D2DFactory()->CreatePathGeometry(byRef(path)); + D2DFactory()->CreatePathGeometry(getter_AddRefs(path)); RefPtr sink; - path->Open(byRef(sink)); + path->Open(getter_AddRefs(sink)); sink->BeginFigure(D2D1::Point2F(userRect.left, userRect.top), D2D1_FIGURE_BEGIN_FILLED); sink->AddLine(D2D1::Point2F(userRect.right, userRect.top)); sink->AddLine(D2D1::Point2F(userRect.right, userRect.bottom)); @@ -729,7 +729,7 @@ DrawTargetD2D1::CreateSourceSurfaceFromData(unsigned char *aData, HRESULT hr = mDC->CreateBitmap(D2DIntSize(aSize), aData, aStride, D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(aFormat)), - byRef(bitmap)); + getter_AddRefs(bitmap)); if (FAILED(hr) || !bitmap) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "[D2D1.1] 1CreateBitmap failure " << aSize << " Code: " << hexa(hr) << " format " << (int)aFormat; @@ -755,7 +755,7 @@ already_AddRefed DrawTargetD2D1::CreatePathBuilder(FillRule aFillRule) const { RefPtr path; - HRESULT hr = factory()->CreatePathGeometry(byRef(path)); + HRESULT hr = factory()->CreatePathGeometry(getter_AddRefs(path)); if (FAILED(hr)) { gfxWarning() << *this << ": Failed to create Direct2D Path Geometry. Code: " << hexa(hr); @@ -763,7 +763,7 @@ DrawTargetD2D1::CreatePathBuilder(FillRule aFillRule) const } RefPtr sink; - hr = path->Open(byRef(sink)); + hr = path->Open(getter_AddRefs(sink)); if (FAILED(hr)) { gfxWarning() << *this << ": Failed to access Direct2D Path Geometry. Code: " << hexa(hr); return nullptr; @@ -796,7 +796,7 @@ DrawTargetD2D1::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, HRESULT hr = mDC->CreateGradientStopCollection(stops, aNumStops, D2D1_GAMMA_2_2, D2DExtend(aExtendMode), - byRef(stopCollection)); + getter_AddRefs(stopCollection)); delete [] stops; if (FAILED(hr)) { @@ -823,7 +823,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) return false; } - hr = device->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC)); + hr = device->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, getter_AddRefs(mDC)); if (FAILED(hr)) { gfxCriticalError() <<"[D2D1.1] 1Failed to create a DeviceContext, code: " << hexa(hr) << " format " << (int)aFormat; @@ -832,7 +832,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) RefPtr dxgiSurface; aTexture->QueryInterface(__uuidof(IDXGISurface), - (void**)((IDXGISurface**)byRef(dxgiSurface))); + (void**)((IDXGISurface**)getter_AddRefs(dxgiSurface))); if (!dxgiSurface) { gfxCriticalError() <<"[D2D1.1] Failed to obtain a DXGI surface."; return false; @@ -844,7 +844,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) props.pixelFormat = D2DPixelFormat(aFormat); props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET; - hr = mDC->CreateBitmapFromDxgiSurface(dxgiSurface, props, (ID2D1Bitmap1**)byRef(mBitmap)); + hr = mDC->CreateBitmapFromDxgiSurface(dxgiSurface, props, (ID2D1Bitmap1**)getter_AddRefs(mBitmap)); if (FAILED(hr)) { gfxCriticalError() << "[D2D1.1] CreateBitmapFromDxgiSurface failure Code: " << hexa(hr) << " format " << (int)aFormat; @@ -860,7 +860,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) props.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; props.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; - hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap)); + hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)getter_AddRefs(mTempBitmap)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(mSize))) << "[D2D1.1] 2CreateBitmap failure " << mSize << " Code: " << hexa(hr); @@ -871,7 +871,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) // issueing multiple drawing commands simultaneously to a single drawtarget // from multiple threads is unexpected since there's no way to guarantee // ordering in that situation anyway. - hr = mDC->CreateSolidColorBrush(D2D1::ColorF(0, 0), byRef(mSolidColorBrush)); + hr = mDC->CreateSolidColorBrush(D2D1::ColorF(0, 0), getter_AddRefs(mSolidColorBrush)); if (FAILED(hr)) { gfxCriticalError() << "[D2D1.1] Failure creating solid color brush."; @@ -895,7 +895,7 @@ DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat) return false; } - hr = device->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC)); + hr = device->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, getter_AddRefs(mDC)); if (FAILED(hr)) { gfxCriticalError() <<"[D2D1.1] 2Failed to create a DeviceContext, code: " << hexa(hr) << " format " << (int)aFormat; @@ -915,7 +915,7 @@ DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat) props.pixelFormat = D2DPixelFormat(aFormat); props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET; - hr = mDC->CreateBitmap(D2DIntSize(aSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mBitmap)); + hr = mDC->CreateBitmap(D2DIntSize(aSize), nullptr, 0, props, (ID2D1Bitmap1**)getter_AddRefs(mBitmap)); if (FAILED(hr)) { gfxCriticalError() << "[D2D1.1] 3CreateBitmap failure " << aSize << " Code: " << hexa(hr) << " format " << (int)aFormat; @@ -925,7 +925,7 @@ DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat) props.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; props.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; - hr = mDC->CreateBitmap(D2DIntSize(aSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap)); + hr = mDC->CreateBitmap(D2DIntSize(aSize), nullptr, 0, props, (ID2D1Bitmap1**)getter_AddRefs(mTempBitmap)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "[D2D1.1] failed to create new TempBitmap " << aSize << " Code: " << hexa(hr); @@ -934,7 +934,7 @@ DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat) mDC->SetTarget(mBitmap); - hr = mDC->CreateSolidColorBrush(D2D1::ColorF(0, 0), byRef(mSolidColorBrush)); + hr = mDC->CreateSolidColorBrush(D2D1::ColorF(0, 0), getter_AddRefs(mSolidColorBrush)); if (FAILED(hr)) { gfxCriticalError() << "[D2D1.1] Failure creating solid color brush."; @@ -1059,7 +1059,7 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) PopAllClips(); RefPtr image; - mDC->GetTarget(byRef(image)); + mDC->GetTarget(getter_AddRefs(image)); mDC->SetTarget(mBitmap); @@ -1075,7 +1075,7 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) if (clipIsComplex) { if (!IsOperatorBoundByMask(aOp)) { - HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), byRef(tmpBitmap)); + HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(mSize))) << "[D2D1.1] 6CreateBitmap failure " << mSize << " Code: " << hexa(hr) << " format " << (int)mFormat; // For now, crash in this scenario; this should happen because tmpBitmap is @@ -1094,7 +1094,7 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) if (tmpBitmap) { RefPtr brush; RefPtr inverseGeom = GetInverseClippedGeometry(); - mDC->CreateBitmapBrush(tmpBitmap, byRef(brush)); + mDC->CreateBitmapBrush(tmpBitmap, getter_AddRefs(brush)); mDC->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_COPY); mDC->FillGeometry(inverseGeom, brush); @@ -1104,7 +1104,7 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) } if (!mBlendEffect) { - HRESULT hr = mDC->CreateEffect(CLSID_D2D1Blend, byRef(mBlendEffect)); + HRESULT hr = mDC->CreateEffect(CLSID_D2D1Blend, getter_AddRefs(mBlendEffect)); if (FAILED(hr) || !mBlendEffect) { gfxWarning() << "Failed to create blend effect!"; @@ -1113,7 +1113,7 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) } RefPtr tmpBitmap; - HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), byRef(tmpBitmap)); + HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(mSize))) << "[D2D1.1] 5CreateBitmap failure " << mSize << " Code: " << hexa(hr) << " format " << (int)mFormat; return; @@ -1147,7 +1147,7 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) RefPtr radialGradientEffect; - HRESULT hr = mDC->CreateEffect(CLSID_RadialGradientEffect, byRef(radialGradientEffect)); + HRESULT hr = mDC->CreateEffect(CLSID_RadialGradientEffect, getter_AddRefs(radialGradientEffect)); if (FAILED(hr) || !radialGradientEffect) { gfxWarning() << "Failed to create radial gradient effect. Code: " << hexa(hr); return; @@ -1269,10 +1269,10 @@ DrawTargetD2D1::GetClippedGeometry(IntRect *aClipBounds) } RefPtr newGeom; - factory()->CreatePathGeometry(byRef(newGeom)); + factory()->CreatePathGeometry(getter_AddRefs(newGeom)); RefPtr currentSink; - newGeom->Open(byRef(currentSink)); + newGeom->Open(getter_AddRefs(currentSink)); if (iter->mPath) { pathGeom->CombineWithGeometry(iter->mPath->GetGeometry(), D2D1_COMBINE_MODE_INTERSECT, @@ -1309,10 +1309,10 @@ DrawTargetD2D1::GetInverseClippedGeometry() RefPtr rectGeom; RefPtr inverseGeom; - factory()->CreateRectangleGeometry(D2D1::RectF(0, 0, mSize.width, mSize.height), byRef(rectGeom)); - factory()->CreatePathGeometry(byRef(inverseGeom)); + factory()->CreateRectangleGeometry(D2D1::RectF(0, 0, mSize.width, mSize.height), getter_AddRefs(rectGeom)); + factory()->CreatePathGeometry(getter_AddRefs(inverseGeom)); RefPtr sink; - inverseGeom->Open(byRef(sink)); + inverseGeom->Open(getter_AddRefs(sink)); rectGeom->CombineWithGeometry(geom, D2D1_COMBINE_MODE_EXCLUDE, D2D1::IdentityMatrix(), sink); sink->Close(); @@ -1416,7 +1416,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) D2DPoint(pat->mEnd)), D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)), stops->mStopCollection, - byRef(gradBrush)); + getter_AddRefs(gradBrush)); if (!gradBrush) { gfxWarning() << "Couldn't create gradient brush."; @@ -1444,7 +1444,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) pat->mRadius2, pat->mRadius2), D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)), stops->mStopCollection, - byRef(gradBrush)); + getter_AddRefs(gradBrush)); if (!gradBrush) { gfxWarning() << "Couldn't create gradient brush."; @@ -1476,7 +1476,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) bool useSamplingRect = false; if (pat->mSamplingRect.IsEmpty()) { RefPtr bitmap; - image->QueryInterface((ID2D1Bitmap**)byRef(bitmap)); + image->QueryInterface((ID2D1Bitmap**)getter_AddRefs(bitmap)); if (bitmap) { RefPtr bitmapBrush; mDC->CreateBitmapBrush(bitmap, @@ -1484,7 +1484,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) D2DExtend(pat->mExtendMode), D2DFilter(pat->mFilter)), D2D1::BrushProperties(aAlpha, D2DMatrix(mat)), - byRef(bitmapBrush)); + getter_AddRefs(bitmapBrush)); if (!bitmapBrush) { gfxWarning() << "Couldn't create bitmap brush!"; return CreateTransparentBlackBrush(); @@ -1511,7 +1511,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) D2DExtend(pat->mExtendMode), D2DInterpolationMode(pat->mFilter)), D2D1::BrushProperties(aAlpha, D2DMatrix(mat)), - byRef(imageBrush)); + getter_AddRefs(imageBrush)); if (!imageBrush) { gfxWarning() << "Couldn't create image brush!"; @@ -1574,7 +1574,7 @@ DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const HRESULT hr = mDC->CreateBitmap(D2DIntSize(data->GetSize()), map.GetData(), map.GetStride(), D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(data->GetFormat())), - byRef(bitmap)); + getter_AddRefs(bitmap)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(data->GetSize()))) << "[D2D1.1] 4CreateBitmap failure " << data->GetSize() << " Code: " << hexa(hr) << " format " << (int)data->GetFormat(); diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 57610f64c4..ec842001fd 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -728,7 +728,7 @@ Factory::SetDirect3D11Device(ID3D11Device *aDevice) RefPtr factory = D2DFactory1(); RefPtr device; - aDevice->QueryInterface((IDXGIDevice**)byRef(device)); + aDevice->QueryInterface((IDXGIDevice**)getter_AddRefs(device)); HRESULT hr = factory->CreateDevice(device, &mD2D1Device); if (FAILED(hr)) { gfxCriticalError() << "[D2D1] Failed to create gfx factory's D2D1 device, code: " << hexa(hr); diff --git a/gfx/2d/FilterNodeD2D1.cpp b/gfx/2d/FilterNodeD2D1.cpp index 364460a06f..c0709f97eb 100644 --- a/gfx/2d/FilterNodeD2D1.cpp +++ b/gfx/2d/FilterNodeD2D1.cpp @@ -547,7 +547,7 @@ FilterNodeD2D1::Create(ID2D1DeviceContext *aDC, FilterType aType) RefPtr effect; HRESULT hr; - hr = aDC->CreateEffect(GetCLDIDForFilterType(aType), byRef(effect)); + hr = aDC->CreateEffect(GetCLDIDForFilterType(aType), getter_AddRefs(effect)); if (FAILED(hr) || !effect) { gfxCriticalErrorOnce() << "Failed to create effect for FilterType: " << hexa(hr); @@ -857,7 +857,7 @@ FilterNodeConvolveD2D1::FilterNodeConvolveD2D1(ID2D1DeviceContext *aDC) HRESULT hr; - hr = aDC->CreateEffect(CLSID_D2D1ConvolveMatrix, byRef(mEffect)); + hr = aDC->CreateEffect(CLSID_D2D1ConvolveMatrix, getter_AddRefs(mEffect)); if (FAILED(hr) || !mEffect) { gfxWarning() << "Failed to create ConvolveMatrix filter!"; @@ -866,14 +866,14 @@ FilterNodeConvolveD2D1::FilterNodeConvolveD2D1(ID2D1DeviceContext *aDC) mEffect->SetValue(D2D1_CONVOLVEMATRIX_PROP_BORDER_MODE, D2D1_BORDER_MODE_SOFT); - hr = aDC->CreateEffect(CLSID_ExtendInputEffect, byRef(mExtendInputEffect)); + hr = aDC->CreateEffect(CLSID_ExtendInputEffect, getter_AddRefs(mExtendInputEffect)); if (FAILED(hr) || !mExtendInputEffect) { gfxWarning() << "Failed to create ConvolveMatrix filter!"; return; } - hr = aDC->CreateEffect(CLSID_D2D1Border, byRef(mBorderEffect)); + hr = aDC->CreateEffect(CLSID_D2D1Border, getter_AddRefs(mBorderEffect)); if (FAILED(hr) || !mBorderEffect) { gfxWarning() << "Failed to create ConvolveMatrix filter!"; @@ -1016,7 +1016,7 @@ FilterNodeExtendInputAdapterD2D1::FilterNodeExtendInputAdapterD2D1(ID2D1DeviceCo HRESULT hr; - hr = aDC->CreateEffect(CLSID_ExtendInputEffect, byRef(mExtendInputEffect)); + hr = aDC->CreateEffect(CLSID_ExtendInputEffect, getter_AddRefs(mExtendInputEffect)); if (FAILED(hr) || !mExtendInputEffect) { gfxWarning() << "Failed to create extend input effect for filter: " << hexa(hr); @@ -1060,14 +1060,14 @@ FilterNodePremultiplyAdapterD2D1::FilterNodePremultiplyAdapterD2D1(ID2D1DeviceCo // filters is part of the FilterNode API. HRESULT hr; - hr = aDC->CreateEffect(CLSID_D2D1Premultiply, byRef(mPrePremultiplyEffect)); + hr = aDC->CreateEffect(CLSID_D2D1Premultiply, getter_AddRefs(mPrePremultiplyEffect)); if (FAILED(hr) || !mPrePremultiplyEffect) { gfxWarning() << "Failed to create ComponentTransfer filter!"; return; } - hr = aDC->CreateEffect(CLSID_D2D1UnPremultiply, byRef(mPostUnpremultiplyEffect)); + hr = aDC->CreateEffect(CLSID_D2D1UnPremultiply, getter_AddRefs(mPostUnpremultiplyEffect)); if (FAILED(hr) || !mPostUnpremultiplyEffect) { gfxWarning() << "Failed to create ComponentTransfer filter!"; diff --git a/gfx/2d/HelpersD2D.h b/gfx/2d/HelpersD2D.h index 45de61aa82..330a12131b 100644 --- a/gfx/2d/HelpersD2D.h +++ b/gfx/2d/HelpersD2D.h @@ -426,7 +426,7 @@ static inline already_AddRefed ConvertRectToGeometry(const D2D1_RECT_F& aRect) { RefPtr rectGeom; - D2DFactory()->CreateRectangleGeometry(&aRect, byRef(rectGeom)); + D2DFactory()->CreateRectangleGeometry(&aRect, getter_AddRefs(rectGeom)); return rectGeom.forget(); } @@ -434,9 +434,9 @@ static inline already_AddRefed GetTransformedGeometry(ID2D1Geometry *aGeometry, const D2D1_MATRIX_3X2_F &aTransform) { RefPtr tmpGeometry; - D2DFactory()->CreatePathGeometry(byRef(tmpGeometry)); + D2DFactory()->CreatePathGeometry(getter_AddRefs(tmpGeometry)); RefPtr currentSink; - tmpGeometry->Open(byRef(currentSink)); + tmpGeometry->Open(getter_AddRefs(currentSink)); aGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, aTransform, currentSink); currentSink->Close(); @@ -447,9 +447,9 @@ static inline already_AddRefed IntersectGeometry(ID2D1Geometry *aGeometryA, ID2D1Geometry *aGeometryB) { RefPtr pathGeom; - D2DFactory()->CreatePathGeometry(byRef(pathGeom)); + D2DFactory()->CreatePathGeometry(getter_AddRefs(pathGeom)); RefPtr sink; - pathGeom->Open(byRef(sink)); + pathGeom->Open(getter_AddRefs(sink)); aGeometryA->CombineWithGeometry(aGeometryB, D2D1_COMBINE_MODE_INTERSECT, nullptr, sink); sink->Close(); @@ -517,13 +517,13 @@ CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions) &dash[0], // data() is not C++98, although it's in recent gcc // and VC10's STL dash.size(), - byRef(style)); + getter_AddRefs(style)); } else { hr = D2DFactory()->CreateStrokeStyle( D2D1::StrokeStyleProperties(capStyle, capStyle, capStyle, joinStyle, aStrokeOptions.mMiterLimit), - nullptr, 0, byRef(style)); + nullptr, 0, getter_AddRefs(style)); } if (FAILED(hr)) { @@ -616,7 +616,7 @@ CreatePartialBitmapForSurface(DataSourceSurface *aSurface, const Matrix &aDestin mapping.GetData() + int(uploadRect.x) * 4 + int(uploadRect.y) * mapping.GetStride(), mapping.GetStride(), D2D1::BitmapProperties(D2DPixelFormat(aSurface->GetFormat())), - byRef(bitmap)); + getter_AddRefs(bitmap)); } aSourceTransform.PreTranslate(uploadRect.x, uploadRect.y); @@ -673,7 +673,7 @@ CreatePartialBitmapForSurface(DataSourceSurface *aSurface, const Matrix &aDestin aRT->CreateBitmap(D2D1::SizeU(newSize.width, newSize.height), scaler.GetScaledData(), scaler.GetStride(), D2D1::BitmapProperties(D2DPixelFormat(aSurface->GetFormat())), - byRef(bitmap)); + getter_AddRefs(bitmap)); aSourceTransform.PreScale(Float(size.width) / newSize.width, Float(size.height) / newSize.height); diff --git a/gfx/2d/JobScheduler.h b/gfx/2d/JobScheduler.h index 9c72bc8faf..55dae4e6b7 100644 --- a/gfx/2d/JobScheduler.h +++ b/gfx/2d/JobScheduler.h @@ -8,6 +8,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/gfx/Types.h" +#include "mozilla/RefCounted.h" #ifdef WIN32 #include "mozilla/gfx/JobScheduler_win32.h" @@ -247,4 +248,4 @@ protected: } // namespace } // namespace -#endif \ No newline at end of file +#endif diff --git a/gfx/2d/JobScheduler_posix.h b/gfx/2d/JobScheduler_posix.h index 0b4dc88af0..cc1bef84ef 100644 --- a/gfx/2d/JobScheduler_posix.h +++ b/gfx/2d/JobScheduler_posix.h @@ -17,6 +17,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/DebugOnly.h" #include "mozilla/gfx/CriticalSection.h" +#include "mozilla/RefCounted.h" namespace mozilla { namespace gfx { diff --git a/gfx/2d/PathD2D.cpp b/gfx/2d/PathD2D.cpp index 2032862dc7..8f8fa8ab8c 100644 --- a/gfx/2d/PathD2D.cpp +++ b/gfx/2d/PathD2D.cpp @@ -357,7 +357,7 @@ already_AddRefed PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const { RefPtr path; - HRESULT hr = DrawTargetD2D::factory()->CreatePathGeometry(byRef(path)); + HRESULT hr = DrawTargetD2D::factory()->CreatePathGeometry(getter_AddRefs(path)); if (FAILED(hr)) { gfxWarning() << "Failed to create PathGeometry. Code: " << hexa(hr); @@ -365,7 +365,7 @@ PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) } RefPtr sink; - hr = path->Open(byRef(sink)); + hr = path->Open(getter_AddRefs(sink)); if (FAILED(hr)) { gfxWarning() << "Failed to open Geometry for writing. Code: " << hexa(hr); return nullptr; diff --git a/gfx/2d/QuartzSupport.h b/gfx/2d/QuartzSupport.h index 60a5b9c299..f56fcb77ca 100644 --- a/gfx/2d/QuartzSupport.h +++ b/gfx/2d/QuartzSupport.h @@ -84,7 +84,7 @@ private: _CGLContextObject *mOpenGLContext; CGImageRef mCGImage; void *mCGData; - mozilla::RefPtr mIOSurface; + RefPtr mIOSurface; uint32_t mFBO; uint32_t mIOTexture; int mUnsupportedWidth; diff --git a/gfx/2d/QuartzSupport.mm b/gfx/2d/QuartzSupport.mm index 74589d93d3..96827108ce 100644 --- a/gfx/2d/QuartzSupport.mm +++ b/gfx/2d/QuartzSupport.mm @@ -25,7 +25,7 @@ - (void)setContentsScale:(double)scale; @end -using mozilla::RefPtr; +using RefPtr; CGColorSpaceRef CreateSystemColorSpace() { CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID()); @@ -421,7 +421,7 @@ nsresult nsCARenderer::Render(int aWidth, int aHeight, // mIOSurface is set by AttachIOSurface(), not by SetupRenderer(). So // since it may have been set by a prior call to AttachIOSurface(), we // need to preserve it across the call to Destroy(). - mozilla::RefPtr ioSurface = mIOSurface; + RefPtr ioSurface = mIOSurface; Destroy(); mIOSurface = ioSurface; if (SetupRenderer(caLayer, aWidth, aHeight, aContentsScaleFactor, diff --git a/gfx/2d/RadialGradientEffectD2D1.cpp b/gfx/2d/RadialGradientEffectD2D1.cpp index 5301be3442..e6c15f7518 100644 --- a/gfx/2d/RadialGradientEffectD2D1.cpp +++ b/gfx/2d/RadialGradientEffectD2D1.cpp @@ -302,7 +302,7 @@ RadialGradientEffectD2D1::CreateEffect(IUnknown **aEffectImpl) HRESULT RadialGradientEffectD2D1::SetStopCollection(IUnknown *aStopCollection) { - if (SUCCEEDED(aStopCollection->QueryInterface((ID2D1GradientStopCollection**)byRef(mStopCollection)))) { + if (SUCCEEDED(aStopCollection->QueryInterface((ID2D1GradientStopCollection**)getter_AddRefs(mStopCollection)))) { return S_OK; } @@ -385,7 +385,7 @@ RadialGradientEffectD2D1::CreateGradientTexture() D2D1_EXTEND_MODE extendMode[] = { mStopCollection->GetExtendMode(), mStopCollection->GetExtendMode() }; props.extendModes = extendMode; - HRESULT hr = mEffectContext->CreateResourceTexture(nullptr, &props, &textureData.front(), &stride, 4096 * 4, byRef(tex)); + HRESULT hr = mEffectContext->CreateResourceTexture(nullptr, &props, &textureData.front(), &stride, 4096 * 4, getter_AddRefs(tex)); if (FAILED(hr)) { gfxWarning() << "Failed to create resource texture: " << hexa(hr); diff --git a/gfx/2d/ScaledFontDWrite.cpp b/gfx/2d/ScaledFontDWrite.cpp index 85873da933..885140be41 100644 --- a/gfx/2d/ScaledFontDWrite.cpp +++ b/gfx/2d/ScaledFontDWrite.cpp @@ -295,13 +295,13 @@ ScaledFontDWrite::ScaledFontDWrite(uint8_t *aData, uint32_t aSize, key.mSize = aSize; RefPtr fontFile; - if (FAILED(factory->CreateCustomFontFileReference(&key, sizeof(ffReferenceKey), DWriteFontFileLoader::Instance(), byRef(fontFile)))) { + if (FAILED(factory->CreateCustomFontFileReference(&key, sizeof(ffReferenceKey), DWriteFontFileLoader::Instance(), getter_AddRefs(fontFile)))) { gfxWarning() << "Failed to load font file from data!"; return; } IDWriteFontFile *ff = fontFile; - if (FAILED(factory->CreateFontFace(DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &ff, aIndex, DWRITE_FONT_SIMULATIONS_NONE, byRef(mFontFace)))) { + if (FAILED(factory->CreateFontFace(DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &ff, aIndex, DWRITE_FONT_SIMULATIONS_NONE, getter_AddRefs(mFontFace)))) { gfxWarning() << "Failed to create font face from font file data!"; } } @@ -371,7 +371,7 @@ ScaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton } RefPtr file; - mFontFace->GetFiles(&fileCount, byRef(file)); + mFontFace->GetFiles(&fileCount, getter_AddRefs(file)); const void *referenceKey; UINT32 refKeySize; @@ -382,10 +382,10 @@ ScaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton file->GetReferenceKey(&referenceKey, &refKeySize); RefPtr loader; - file->GetLoader(byRef(loader)); + file->GetLoader(getter_AddRefs(loader)); RefPtr stream; - loader->CreateStreamFromKey(referenceKey, refKeySize, byRef(stream)); + loader->CreateStreamFromKey(referenceKey, refKeySize, getter_AddRefs(stream)); UINT64 fileSize64; stream->GetFileSize(&fileSize64); diff --git a/gfx/2d/SourceSurfaceD2D.cpp b/gfx/2d/SourceSurfaceD2D.cpp index 438cdace2c..650b54473b 100644 --- a/gfx/2d/SourceSurfaceD2D.cpp +++ b/gfx/2d/SourceSurfaceD2D.cpp @@ -69,7 +69,7 @@ SourceSurfaceD2D::InitFromData(unsigned char *aData, } D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(aFormat)); - hr = aRT->CreateBitmap(D2DIntSize(aSize), props, byRef(mBitmap)); + hr = aRT->CreateBitmap(D2DIntSize(aSize), props, getter_AddRefs(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed to create D2D Bitmap for data. Code: " << hexa(hr); @@ -112,14 +112,14 @@ SourceSurfaceD2D::InitFromTexture(ID3D10Texture2D *aTexture, mFormat = aFormat; D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(aFormat)); - hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap)); + hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, getter_AddRefs(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed to create SharedBitmap. Code: " << hexa(hr); return false; } - aTexture->GetDevice(byRef(mDevice)); + aTexture->GetDevice(getter_AddRefs(mDevice)); DrawTargetD2D::mVRAMUsageSS += GetByteSize(); return true; @@ -148,14 +148,14 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface) desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; RefPtr sourceTexture; HRESULT hr = aSourceSurface->mDevice->CreateTexture2D(&desc, nullptr, - byRef(sourceTexture)); + getter_AddRefs(sourceTexture)); if (FAILED(hr)) { gfxWarning() << "Failed to create texture. Code: " << hexa(hr); return; } RefPtr dxgiSurface; - hr = sourceTexture->QueryInterface((IDXGISurface**)byRef(dxgiSurface)); + hr = sourceTexture->QueryInterface((IDXGISurface**)getter_AddRefs(dxgiSurface)); if (FAILED(hr)) { gfxWarning() << "Failed to create DXGI surface. Code: " << hexa(hr); return; @@ -168,7 +168,7 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface) RefPtr renderTarget; hr = DrawTargetD2D::factory()->CreateDxgiSurfaceRenderTarget(dxgiSurface, &rtProps, - byRef(renderTarget)); + getter_AddRefs(renderTarget)); if (FAILED(hr)) { gfxWarning() << "Failed to create render target. Code: " << hexa(hr); return; @@ -183,7 +183,7 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface) Float(mSize.height))); } else { RefPtr brush; - renderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), byRef(brush)); + renderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), getter_AddRefs(brush)); renderTarget->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED); renderTarget->FillOpacityMask(aSourceSurface->mBitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS); } @@ -196,7 +196,7 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface) desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ | D3D10_CPU_ACCESS_WRITE; desc.Usage = D3D10_USAGE_STAGING; desc.BindFlags = 0; - hr = aSourceSurface->mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture)); + hr = aSourceSurface->mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture)); if (FAILED(hr)) { gfxWarning() << "Failed to create staging texture. Code: " << hexa(hr); mTexture = nullptr; diff --git a/gfx/2d/SourceSurfaceD2D1.cpp b/gfx/2d/SourceSurfaceD2D1.cpp index 925c4ee51b..5dcbe968f6 100644 --- a/gfx/2d/SourceSurfaceD2D1.cpp +++ b/gfx/2d/SourceSurfaceD2D1.cpp @@ -18,7 +18,7 @@ SourceSurfaceD2D1::SourceSurfaceD2D1(ID2D1Image *aImage, ID2D1DeviceContext *aDC , mDrawTarget(aDT) , mDevice(Factory::GetD2D1Device()) { - aImage->QueryInterface((ID2D1Bitmap1**)byRef(mRealizedBitmap)); + aImage->QueryInterface((ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap)); mFormat = aFormat; mSize = aSize; @@ -52,7 +52,7 @@ SourceSurfaceD2D1::GetDataSurface() props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ; - hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(softwareBitmap)); + hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)getter_AddRefs(softwareBitmap)); if (FAILED(hr)) { gfxCriticalError() << "Failed to create software bitmap: " << mSize << " Code: " << hexa(hr); @@ -86,7 +86,7 @@ SourceSurfaceD2D1::EnsureRealizedBitmap() } RefPtr dc; - device->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_NONE, byRef(dc)); + device->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_NONE, getter_AddRefs(dc)); D2D1_BITMAP_PROPERTIES1 props; props.dpiX = 96; @@ -94,7 +94,7 @@ SourceSurfaceD2D1::EnsureRealizedBitmap() props.pixelFormat = D2DPixelFormat(mFormat); props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET; - dc->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mRealizedBitmap)); + dc->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap)); dc->SetTarget(mRealizedBitmap); @@ -119,7 +119,7 @@ SourceSurfaceD2D1::DrawTargetWillChange() props.pixelFormat = D2DPixelFormat(mFormat); props.colorContext = nullptr; props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET; - HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mRealizedBitmap)); + HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap)); if (FAILED(hr)) { gfxCriticalError() << "Failed to create bitmap to make DrawTarget copy. Size: " << mSize << " Code: " << hexa(hr); diff --git a/gfx/2d/SourceSurfaceD2DTarget.cpp b/gfx/2d/SourceSurfaceD2DTarget.cpp index b2145747cd..5ab6ca981a 100644 --- a/gfx/2d/SourceSurfaceD2DTarget.cpp +++ b/gfx/2d/SourceSurfaceD2DTarget.cpp @@ -64,7 +64,7 @@ SourceSurfaceD2DTarget::GetDataSurface() desc.BindFlags = 0; desc.MiscFlags = 0; - HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(dataSurf->mTexture)); + HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(dataSurf->mTexture)); if (FAILED(hr)) { gfxDebug() << "Failed to create staging texture for SourceSurface. Code: " << hexa(hr); @@ -91,7 +91,7 @@ SourceSurfaceD2DTarget::GetSRView() return mSRView; } - HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, byRef(mSRView)); + HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView)); if (FAILED(hr)) { gfxWarning() << "Failed to create ShaderResourceView. Code: " << hexa(hr); @@ -114,7 +114,7 @@ SourceSurfaceD2DTarget::DrawTargetWillChange() desc.MiscFlags = 0; // Get a copy of the surface data so the content at snapshot time was saved. - Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(mTexture)); + Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture)); Factory::GetDirect3D10Device()->CopyResource(mTexture, oldTexture); mBitmap = nullptr; @@ -140,7 +140,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT) IntSize size(desc.Width, desc.Height); RefPtr surf; - hr = mTexture->QueryInterface((IDXGISurface**)byRef(surf)); + hr = mTexture->QueryInterface((IDXGISurface**)getter_AddRefs(surf)); if (FAILED(hr)) { gfxWarning() << "Failed to query interface texture to DXGISurface. Code: " << hexa(hr); @@ -148,13 +148,13 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT) } D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(mFormat)); - hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap)); + hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, getter_AddRefs(mBitmap)); if (FAILED(hr)) { // This seems to happen for SurfaceFormat::A8 sometimes... hr = aRT->CreateBitmap(D2D1::SizeU(desc.Width, desc.Height), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), - byRef(mBitmap)); + getter_AddRefs(mBitmap)); if (FAILED(hr)) { gfxWarning() << "Failed in CreateBitmap. Code: " << hexa(hr); @@ -173,7 +173,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT) // a rendertarget and from there copying to a bitmap! Terrible! RefPtr surface; - hr = mTexture->QueryInterface((IDXGISurface**)byRef(surface)); + hr = mTexture->QueryInterface((IDXGISurface**)getter_AddRefs(surface)); if (FAILED(hr)) { gfxWarning() << "Failed to QI texture to surface."; @@ -182,7 +182,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT) D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2DPixelFormat(mFormat)); - hr = DrawTargetD2D::factory()->CreateDxgiSurfaceRenderTarget(surface, props, byRef(rt)); + hr = DrawTargetD2D::factory()->CreateDxgiSurfaceRenderTarget(surface, props, getter_AddRefs(rt)); if (FAILED(hr)) { gfxWarning() << "Failed to create D2D render target for texture."; diff --git a/gfx/2d/unittest/TestDrawTargetBase.h b/gfx/2d/unittest/TestDrawTargetBase.h index 1e51f30823..06a62413fd 100644 --- a/gfx/2d/unittest/TestDrawTargetBase.h +++ b/gfx/2d/unittest/TestDrawTargetBase.h @@ -33,6 +33,6 @@ protected: uint32_t RGBAPixelFromColor(const mozilla::gfx::Color &aColor); - mozilla::RefPtr mDT; - mozilla::RefPtr mDataSnapshot; + RefPtr mDT; + RefPtr mDataSnapshot; }; diff --git a/gfx/2d/unittest/TestDrawTargetD2D.h b/gfx/2d/unittest/TestDrawTargetD2D.h index e4647ba748..97bb88cf2e 100644 --- a/gfx/2d/unittest/TestDrawTargetD2D.h +++ b/gfx/2d/unittest/TestDrawTargetD2D.h @@ -15,5 +15,5 @@ public: TestDrawTargetD2D(); private: - mozilla::RefPtr mDevice; + RefPtr mDevice; }; diff --git a/gfx/gl/GLContextEGL.h b/gfx/gl/GLContextEGL.h index 759431807a..7265d0e277 100644 --- a/gfx/gl/GLContextEGL.h +++ b/gfx/gl/GLContextEGL.h @@ -122,7 +122,7 @@ public: const EGLContext mContext; protected: EGLSurface mSurfaceOverride; - nsRefPtr mThebesSurface; + RefPtr mThebesSurface; bool mBound; bool mIsPBuffer; diff --git a/gfx/gl/GLContextGLX.h b/gfx/gl/GLContextGLX.h index b5ea467607..fa09d82d67 100644 --- a/gfx/gl/GLContextGLX.h +++ b/gfx/gl/GLContextGLX.h @@ -80,7 +80,7 @@ private: GLXLibrary* mGLX; - nsRefPtr mPixmap; + RefPtr mPixmap; bool mOwnsContext; }; diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index 049829ad5d..0e82232479 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -247,7 +247,7 @@ GLContextProviderCGL::CreateForWindow(nsIWidget *aWidget) SurfaceCaps caps = SurfaceCaps::ForRGBA(); ContextProfile profile = ContextProfile::OpenGLCompatibility; - nsRefPtr glContext = new GLContextCGL(caps, context, false, + RefPtr glContext = new GLContextCGL(caps, context, false, profile); if (!glContext->Init()) { @@ -295,7 +295,7 @@ CreateOffscreenFBOContext(CreateContextFlags flags) } SurfaceCaps dummyCaps = SurfaceCaps::Any(); - nsRefPtr glContext = new GLContextCGL(dummyCaps, context, + RefPtr glContext = new GLContextCGL(dummyCaps, context, true, profile); return glContext.forget(); @@ -304,7 +304,7 @@ CreateOffscreenFBOContext(CreateContextFlags flags) already_AddRefed GLContextProviderCGL::CreateHeadless(CreateContextFlags flags) { - nsRefPtr gl; + RefPtr gl; gl = CreateOffscreenFBOContext(flags); if (!gl) return nullptr; @@ -332,7 +332,7 @@ GLContextProviderCGL::CreateOffscreen(const IntSize& size, return gl.forget(); } -static nsRefPtr gGlobalContext; +static RefPtr gGlobalContext; GLContext* GLContextProviderCGL::GetGlobalContext() diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 5983ed128c..795d2a0b1f 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -529,7 +529,7 @@ GLContextEGL::CreateGLContext(const SurfaceCaps& caps, return nullptr; } - nsRefPtr glContext = new GLContextEGL(caps, + RefPtr glContext = new GLContextEGL(caps, shareContext, isOffscreen, config, @@ -744,7 +744,7 @@ GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface) if (aContext && aSurface) { SurfaceCaps caps = SurfaceCaps::Any(); EGLConfig config = EGL_NO_CONFIG; - nsRefPtr glContext = + RefPtr glContext = new GLContextEGL(caps, nullptr, false, config, (EGLSurface)aSurface, (EGLContext)aContext); @@ -781,7 +781,7 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget) } SurfaceCaps caps = SurfaceCaps::Any(); - nsRefPtr glContext = + RefPtr glContext = GLContextEGL::CreateGLContext(caps, nullptr, false, config, surface); @@ -989,7 +989,7 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size) MOZ_ASSERT(surface); SurfaceCaps dummyCaps = SurfaceCaps::Any(); - nsRefPtr glContext = + RefPtr glContext = GLContextEGL::CreateGLContext(dummyCaps, nullptr, true, config, surface); diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 1fd047e228..5a9dd5b6d9 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -757,7 +757,7 @@ GLContextGLX::CreateGLContext( } GLXContext context; - nsRefPtr glContext; + RefPtr glContext; bool error; ScopedXErrorHandler xErrorHandler; @@ -1005,7 +1005,7 @@ GLContextProviderGLX::CreateWrappingExisting(void* aContext, void* aSurface) if (aContext && aSurface) { SurfaceCaps caps = SurfaceCaps::Any(); - nsRefPtr glContext = + RefPtr glContext = new GLContextGLX(caps, nullptr, // SharedContext false, // Offscreen @@ -1117,7 +1117,7 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget) GLContextGLX *shareContext = GetGlobalContextGLX(); SurfaceCaps caps = SurfaceCaps::Any(); - nsRefPtr glContext = GLContextGLX::CreateGLContext(caps, + RefPtr glContext = GLContextGLX::CreateGLContext(caps, shareContext, false, display, diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index 564804146f..0a7fd79a5c 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -446,7 +446,7 @@ GLContextProviderWGL::CreateForWindow(nsIWidget *aWidget) } SurfaceCaps caps = SurfaceCaps::ForRGBA(); - nsRefPtr glContext = new GLContextWGL(caps, + RefPtr glContext = new GLContextWGL(caps, shareContext, false, dc, @@ -541,7 +541,7 @@ CreatePBufferOffscreenContext(const IntSize& aSize, } SurfaceCaps dummyCaps = SurfaceCaps::Any(); - nsRefPtr glContext = new GLContextWGL(dummyCaps, + RefPtr glContext = new GLContextWGL(dummyCaps, aShareContext, true, pbuffer, @@ -594,7 +594,7 @@ CreateWindowOffscreenContext() } SurfaceCaps caps = SurfaceCaps::ForRGBA(); - nsRefPtr glContext = new GLContextWGL(caps, + RefPtr glContext = new GLContextWGL(caps, shareContext, true, dc, context, win); @@ -608,7 +608,7 @@ GLContextProviderWGL::CreateHeadless(CreateContextFlags) return nullptr; } - nsRefPtr glContext; + RefPtr glContext; // Always try to create a pbuffer context first, because we // want the context isolation. @@ -630,7 +630,7 @@ GLContextProviderWGL::CreateHeadless(CreateContextFlags) return nullptr; } - nsRefPtr retGL = glContext.get(); + RefPtr retGL = glContext.get(); return retGL.forget(); } @@ -649,7 +649,7 @@ GLContextProviderWGL::CreateOffscreen(const IntSize& size, return gl.forget(); } -static nsRefPtr gGlobalContext; +static RefPtr gGlobalContext; /*static*/ GLContext* GLContextProviderWGL::GetGlobalContext() diff --git a/gfx/gl/GLTextureImage.cpp b/gfx/gl/GLTextureImage.cpp index 906a2815eb..cd05f6f126 100644 --- a/gfx/gl/GLTextureImage.cpp +++ b/gfx/gl/GLTextureImage.cpp @@ -664,7 +664,7 @@ void TiledTextureImage::Resize(const gfx::IntSize& aSize) } // Create a new tile. - nsRefPtr teximg = + RefPtr teximg = TileGenFunc(mGL, size, mContentType, mFlags, mImageFormat); if (replace) mImages.ReplaceElementAt(i, teximg); @@ -723,7 +723,7 @@ CreateBasicTextureImage(GLContext* aGL, aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, aWrapMode); aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, aWrapMode); - nsRefPtr texImage = + RefPtr texImage = new BasicTextureImage(texture, aSize, aWrapMode, aContentType, aGL, aFlags, aImageFormat); return texImage.forget(); diff --git a/gfx/gl/GLTextureImage.h b/gfx/gl/GLTextureImage.h index ed42249e83..ba87f3f1a9 100644 --- a/gfx/gl/GLTextureImage.h +++ b/gfx/gl/GLTextureImage.h @@ -277,7 +277,7 @@ public: protected: GLuint mTexture; TextureState mTextureState; - nsRefPtr mGLContext; + RefPtr mGLContext; RefPtr mUpdateDrawTarget; nsIntRegion mUpdateRegion; @@ -324,7 +324,7 @@ protected: unsigned int mCurrentImage; BigImageIterationCallback mIterationCallback; void* mIterationCallbackData; - nsTArray< nsRefPtr > mImages; + nsTArray< RefPtr > mImages; bool mInUpdate; unsigned int mTileSize; unsigned int mRows, mColumns; diff --git a/gfx/gl/SharedSurfaceANGLE.cpp b/gfx/gl/SharedSurfaceANGLE.cpp index 3410540e77..51e83c71af 100644 --- a/gfx/gl/SharedSurfaceANGLE.cpp +++ b/gfx/gl/SharedSurfaceANGLE.cpp @@ -201,11 +201,11 @@ SharedSurface_ANGLEShareHandle::ConsumerAcquireImpl() RefPtr tex; HRESULT hr = gfxWindowsPlatform::GetPlatform()->GetD3D11Device()->OpenSharedResource(mShareHandle, __uuidof(ID3D11Texture2D), - (void**)(ID3D11Texture2D**)byRef(tex)); + (void**)(ID3D11Texture2D**)getter_AddRefs(tex)); if (SUCCEEDED(hr)) { mConsumerTexture = tex; RefPtr mutex; - hr = tex->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + hr = tex->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); if (SUCCEEDED(hr)) { mConsumerKeyedMutex = mutex; diff --git a/gfx/gl/SharedSurfaceEGL.h b/gfx/gl/SharedSurfaceEGL.h index 0184887e00..8b8c283cc8 100644 --- a/gfx/gl/SharedSurfaceEGL.h +++ b/gfx/gl/SharedSurfaceEGL.h @@ -46,7 +46,7 @@ public: protected: GLContext* mCurConsGL; GLuint mConsTex; - nsRefPtr mGarbageBin; + RefPtr mGarbageBin; EGLSync mSync; SharedSurface_EGLImage(GLContext* gl, diff --git a/gfx/gl/TextureImageCGL.mm b/gfx/gl/TextureImageCGL.mm index abb24d4f72..b83d823301 100644 --- a/gfx/gl/TextureImageCGL.mm +++ b/gfx/gl/TextureImageCGL.mm @@ -70,7 +70,7 @@ CreateTextureImageCGL(GLContext* gl, if (!gl->IsOffscreenSizeAllowed(aSize) && gfxPlatform::OffMainThreadCompositingEnabled()) { NS_ASSERTION(aWrapMode == LOCAL_GL_CLAMP_TO_EDGE, "Can't support wrapping with tiles!"); - nsRefPtr t = new gl::TiledTextureImage(gl, aSize, aContentType, + RefPtr t = new gl::TiledTextureImage(gl, aSize, aContentType, aFlags, aImageFormat); return t.forget(); } @@ -101,7 +101,7 @@ TileGenFuncCGL(GLContext *gl, gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE); gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE); - nsRefPtr teximage + RefPtr teximage (new TextureImageCGL(texture, aSize, LOCAL_GL_CLAMP_TO_EDGE, aContentType, gl, aFlags, aImageFormat)); return teximage.forget(); diff --git a/gfx/gl/TextureImageEGL.cpp b/gfx/gl/TextureImageEGL.cpp index b60110dea9..95a4fae8db 100644 --- a/gfx/gl/TextureImageEGL.cpp +++ b/gfx/gl/TextureImageEGL.cpp @@ -311,7 +311,7 @@ CreateTextureImageEGL(GLContext *gl, TextureImage::Flags aFlags, TextureImage::ImageFormat aImageFormat) { - nsRefPtr t = new gl::TiledTextureImage(gl, aSize, aContentType, aFlags, aImageFormat); + RefPtr t = new gl::TiledTextureImage(gl, aSize, aContentType, aFlags, aImageFormat); return t.forget(); } @@ -327,7 +327,7 @@ TileGenFuncEGL(GLContext *gl, GLuint texture; gl->fGenTextures(1, &texture); - nsRefPtr teximage = + RefPtr teximage = new TextureImageEGL(texture, aSize, LOCAL_GL_CLAMP_TO_EDGE, aContentType, gl, aFlags, TextureImage::Created, aImageFormat); diff --git a/gfx/layers/AtomicRefCountedWithFinalize.h b/gfx/layers/AtomicRefCountedWithFinalize.h index 8915c0d65c..b7e9ba5e73 100644 --- a/gfx/layers/AtomicRefCountedWithFinalize.h +++ b/gfx/layers/AtomicRefCountedWithFinalize.h @@ -62,17 +62,11 @@ protected: public: // Mark user classes that are considered flawless. - template - friend class RefPtr; - template friend class ::mozilla::StaticRefPtr; - template - friend class already_AddRefed; - template - friend class ::nsRefPtr; + friend class ::RefPtr; template friend struct ::RunnableMethodTraits; diff --git a/gfx/layers/CopyableCanvasLayer.h b/gfx/layers/CopyableCanvasLayer.h index bb1681a030..58fd650677 100644 --- a/gfx/layers/CopyableCanvasLayer.h +++ b/gfx/layers/CopyableCanvasLayer.h @@ -51,7 +51,7 @@ protected: void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr); RefPtr mSurface; - nsRefPtr mGLContext; + RefPtr mGLContext; GLuint mCanvasFrontbufferTexID; RefPtr mBufferProvider; diff --git a/gfx/layers/D3D11ShareHandleImage.cpp b/gfx/layers/D3D11ShareHandleImage.cpp index b483b7d932..550f7208f0 100644 --- a/gfx/layers/D3D11ShareHandleImage.cpp +++ b/gfx/layers/D3D11ShareHandleImage.cpp @@ -54,10 +54,10 @@ D3D11ShareHandleImage::GetAsSourceSurface() } RefPtr device; - texture->GetDevice(byRef(device)); + texture->GetDevice(getter_AddRefs(device)); RefPtr keyedMutex; - if (FAILED(texture->QueryInterface(static_cast(byRef(keyedMutex))))) { + if (FAILED(texture->QueryInterface(static_cast(getter_AddRefs(keyedMutex))))) { NS_WARNING("Failed to QueryInterface for IDXGIKeyedMutex, strange."); return nullptr; } @@ -80,7 +80,7 @@ D3D11ShareHandleImage::GetAsSourceSurface() RefPtr softTexture; HRESULT hr = device->CreateTexture2D(&softDesc, NULL, - static_cast(byRef(softTexture))); + static_cast(getter_AddRefs(softTexture))); if (FAILED(hr)) { NS_WARNING("Failed to create 2D staging texture."); @@ -89,7 +89,7 @@ D3D11ShareHandleImage::GetAsSourceSurface() } RefPtr context; - device->GetImmediateContext(byRef(context)); + device->GetImmediateContext(getter_AddRefs(context)); if (!context) { keyedMutex->ReleaseSync(0); return nullptr; diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp index da85d7953d..d8ab4e58a3 100644 --- a/gfx/layers/D3D9SurfaceImage.cpp +++ b/gfx/layers/D3D9SurfaceImage.cpp @@ -33,11 +33,11 @@ D3D9SurfaceImage::SetData(const Data& aData) RefPtr surface = aData.mSurface; RefPtr device; - hr = surface->GetDevice(byRef(device)); + hr = surface->GetDevice(getter_AddRefs(device)); NS_ENSURE_TRUE(SUCCEEDED(hr), E_FAIL); RefPtr d3d9; - hr = device->GetDirect3D(byRef(d3d9)); + hr = device->GetDirect3D(getter_AddRefs(d3d9)); NS_ENSURE_TRUE(SUCCEEDED(hr), E_FAIL); D3DSURFACE_DESC desc; @@ -75,7 +75,7 @@ D3D9SurfaceImage::SetData(const Data& aData) // image, we're less likely to need to wait for the draw operation to // complete. RefPtr query; - hr = device->CreateQuery(D3DQUERYTYPE_EVENT, byRef(query)); + hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query)); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); hr = query->Issue(D3DISSUE_END); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); @@ -170,7 +170,7 @@ D3D9SurfaceImage::GetAsSourceSurface() mSize.height, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, - byRef(systemMemorySurface), + getter_AddRefs(systemMemorySurface), 0); NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); diff --git a/gfx/layers/Effects.h b/gfx/layers/Effects.h index 53d397a195..8ae40100e6 100644 --- a/gfx/layers/Effects.h +++ b/gfx/layers/Effects.h @@ -119,7 +119,7 @@ struct EffectVRDistortion : public Effect virtual const char* Name() { return "EffectVRDistortion"; } virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix); - nsRefPtr mHMD; + RefPtr mHMD; RefPtr mRenderTarget; TextureSource* mTexture; diff --git a/gfx/layers/GLImages.cpp b/gfx/layers/GLImages.cpp index 598e2f7e6f..c3d01029fd 100644 --- a/gfx/layers/GLImages.cpp +++ b/gfx/layers/GLImages.cpp @@ -14,7 +14,7 @@ using namespace mozilla::gl; namespace mozilla { namespace layers { -static nsRefPtr sSnapshotContext; +static RefPtr sSnapshotContext; EGLImageImage::~EGLImageImage() { diff --git a/gfx/layers/GrallocImages.h b/gfx/layers/GrallocImages.h index 121015e0a9..727235fc0f 100644 --- a/gfx/layers/GrallocImages.h +++ b/gfx/layers/GrallocImages.h @@ -49,7 +49,7 @@ class GrallocImage : public PlanarYCbCrImage static int32_t sColorIdMap[]; public: struct GrallocData { - nsRefPtr mGraphicBuffer; + RefPtr mGraphicBuffer; gfx::IntSize mPicSize; }; diff --git a/gfx/layers/IMFYCbCrImage.cpp b/gfx/layers/IMFYCbCrImage.cpp index 0e84290c18..dde6849265 100644 --- a/gfx/layers/IMFYCbCrImage.cpp +++ b/gfx/layers/IMFYCbCrImage.cpp @@ -34,7 +34,7 @@ struct AutoLockTexture { AutoLockTexture(ID3D11Texture2D* aTexture) { - aTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mMutex)); + aTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex)); HRESULT hr = mMutex->AcquireSync(0, 10000); if (hr == WAIT_TIMEOUT) { MOZ_CRASH(); @@ -71,7 +71,7 @@ InitTextures(IDirect3DDevice9* aDevice, RefPtr result; if (FAILED(aDevice->CreateTexture(aSize.width, aSize.height, 1, 0, aFormat, D3DPOOL_DEFAULT, - byRef(result), &aHandle))) { + getter_AddRefs(result), &aHandle))) { return nullptr; } if (!result) { @@ -81,14 +81,14 @@ InitTextures(IDirect3DDevice9* aDevice, RefPtr tmpTexture; if (FAILED(aDevice->CreateTexture(aSize.width, aSize.height, 1, 0, aFormat, D3DPOOL_SYSTEMMEM, - byRef(tmpTexture), nullptr))) { + getter_AddRefs(tmpTexture), nullptr))) { return nullptr; } if (!tmpTexture) { return nullptr; } - tmpTexture->GetSurfaceLevel(0, byRef(aSurface)); + tmpTexture->GetSurfaceLevel(0, getter_AddRefs(aSurface)); aSurface->LockRect(&aLockedRect, nullptr, 0); if (!aLockedRect.pBits) { NS_WARNING("Could not lock surface"); @@ -108,7 +108,7 @@ FinishTextures(IDirect3DDevice9* aDevice, } aSurface->UnlockRect(); - nsRefPtr dstSurface; + RefPtr dstSurface; aTexture->GetSurfaceLevel(0, getter_AddRefs(dstSurface)); aDevice->UpdateSurface(aSurface, nullptr, dstSurface, nullptr); } @@ -168,7 +168,7 @@ IMFYCbCrImage::GetD3D9TextureClient(CompositableClient* aClient) } RefPtr query; - HRESULT hr = device->CreateQuery(D3DQUERYTYPE_EVENT, byRef(query)); + HRESULT hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query)); hr = query->Issue(D3DISSUE_END); int iterations = 0; @@ -224,7 +224,7 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient) } RefPtr ctx; - device->GetImmediateContext(byRef(ctx)); + device->GetImmediateContext(getter_AddRefs(ctx)); CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_R8_UNORM, mData.mYSize.width, mData.mYSize.height, 1, 1); @@ -232,18 +232,18 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient) newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; RefPtr textureY; - HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, byRef(textureY)); + HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureY)); NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); newDesc.Width = mData.mCbCrSize.width; newDesc.Height = mData.mCbCrSize.height; RefPtr textureCb; - hr = device->CreateTexture2D(&newDesc, nullptr, byRef(textureCb)); + hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCb)); NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); RefPtr textureCr; - hr = device->CreateTexture2D(&newDesc, nullptr, byRef(textureCr)); + hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCr)); NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); { @@ -262,15 +262,15 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient) RefPtr resource; HANDLE shareHandleY; - textureY->QueryInterface((IDXGIResource**)byRef(resource)); + textureY->QueryInterface((IDXGIResource**)getter_AddRefs(resource)); hr = resource->GetSharedHandle(&shareHandleY); HANDLE shareHandleCb; - textureCb->QueryInterface((IDXGIResource**)byRef(resource)); + textureCb->QueryInterface((IDXGIResource**)getter_AddRefs(resource)); hr = resource->GetSharedHandle(&shareHandleCb); HANDLE shareHandleCr; - textureCr->QueryInterface((IDXGIResource**)byRef(resource)); + textureCr->QueryInterface((IDXGIResource**)getter_AddRefs(resource)); hr = resource->GetSharedHandle(&shareHandleCr); mTextureClient = DXGIYCbCrTextureClient::Create(aClient->GetForwarder(), diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 61cbd3a087..32863b95be 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -57,7 +57,7 @@ ImageFactory::CreateImage(ImageFormat aFormat, const gfx::IntSize &, BufferRecycleBin *aRecycleBin) { - nsRefPtr img; + RefPtr img; #ifdef MOZ_WIDGET_GONK if (aFormat == ImageFormat::GRALLOC_PLANAR_YCBCR) { img = new GrallocImage(); @@ -227,7 +227,7 @@ ImageContainer::CreateImage(ImageFormat aFormat) } #endif if (mImageClient) { - nsRefPtr img = mImageClient->CreateImage(aFormat); + RefPtr img = mImageClient->CreateImage(aFormat); if (img) { return img.forget(); } diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index ae03564fde..70743ecced 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -397,7 +397,7 @@ public: struct OwningImage { OwningImage() : mFrameID(0), mProducerID(0), mComposited(false) {} - nsRefPtr mImage; + RefPtr mImage; TimeStamp mTimeStamp; FrameID mFrameID; ProducerID mProducerID; @@ -528,11 +528,11 @@ private: // This is the image factory used by this container, layer managers using // this container can set an alternative image factory that will be used to // create images for this container. - nsRefPtr mImageFactory; + RefPtr mImageFactory; gfx::IntSize mScaleHint; - nsRefPtr mRecycleBin; + RefPtr mRecycleBin; // This member points to an ImageClient if this ImageContainer was // sucessfully created with ENABLE_ASYNC, or points to null otherwise. @@ -729,7 +729,7 @@ protected: gfx::IntSize mSize; gfxImageFormat mOffscreenFormat; nsCountedRef mSourceSurface; - nsRefPtr mRecycleBin; + RefPtr mRecycleBin; }; /** diff --git a/gfx/layers/ImageLayers.h b/gfx/layers/ImageLayers.h index 35ca592c96..4597a78f60 100644 --- a/gfx/layers/ImageLayers.h +++ b/gfx/layers/ImageLayers.h @@ -93,7 +93,7 @@ protected: virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override; virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override; - nsRefPtr mContainer; + RefPtr mContainer; gfx::Filter mFilter; gfx::IntSize mScaleToSize; ScaleMode mScaleMode; diff --git a/gfx/layers/LayerScope.cpp b/gfx/layers/LayerScope.cpp index 2047dc29f3..964aeeadf5 100644 --- a/gfx/layers/LayerScope.cpp +++ b/gfx/layers/LayerScope.cpp @@ -115,7 +115,7 @@ private: MutexAutoLock lock(mHandlerMutex); - nsRefPtr temp = new SocketHandler(); + RefPtr temp = new SocketHandler(); temp->OpenStream(aTransport); mHandlers.AppendElement(temp.get()); } @@ -199,9 +199,9 @@ private: bool mConnected; }; - nsTArray > mHandlers; + nsTArray > mHandlers; nsCOMPtr mDebugSenderThread; - nsRefPtr mCurrentSender; + RefPtr mCurrentSender; nsCOMPtr mServerSocket; // Keep mHandlers accessing thread safe. @@ -773,7 +773,7 @@ public: // Keep a strong reference to DebugDataSender to prevent this object // accessing mHost on mThread, when it's been destroyed on the main // thread. - nsRefPtr mHost; + RefPtr mHost; }; // Clear all DebugData in mList on mThead. @@ -793,7 +793,7 @@ public: private: virtual ~ClearTask() { } - nsRefPtr mHost; + RefPtr mHost; }; // Send all DebugData in mList via websocket, and then, clean up @@ -825,7 +825,7 @@ public: private: virtual ~SendTask() { } - nsRefPtr mHost; + RefPtr mHost; }; explicit DebugDataSender(nsIThread *thread) diff --git a/gfx/layers/LayerTreeInvalidation.cpp b/gfx/layers/LayerTreeInvalidation.cpp index ac1422f987..7c1457b11b 100644 --- a/gfx/layers/LayerTreeInvalidation.cpp +++ b/gfx/layers/LayerTreeInvalidation.cpp @@ -221,7 +221,7 @@ struct LayerPropertiesBase : public LayerProperties return IntRect(); } - nsRefPtr mLayer; + RefPtr mLayer; UniquePtr mMaskLayer; nsTArray> mAncestorMaskLayers; nsIntRegion mVisibleRegion; @@ -454,8 +454,8 @@ struct ImageLayerProperties : public LayerPropertiesBase return IntRect(); } - nsRefPtr mContainer; - nsRefPtr mImageHost; + RefPtr mContainer; + RefPtr mImageHost; Filter mFilter; gfx::IntSize mScaleToSize; ScaleMode mScaleMode; diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 6b7dd12fa6..f8f54128ad 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -25,12 +25,15 @@ #include "mozilla/gfx/2D.h" // for DrawTarget #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/Matrix.h" // for Matrix4x4 +#include "mozilla/layers/CompositableClient.h" // for CompositableClient #include "mozilla/layers/Compositor.h" // for Compositor #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper #include "mozilla/layers/LayersMessages.h" // for TransformFunction, etc +#include "mozilla/layers/LayersTypes.h" // for TextureDumpMode #include "mozilla/layers/PersistentBufferProvider.h" +#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer #include "nsAString.h" #include "nsCSSValue.h" // for nsCSSValue::Array, etc #include "nsPrintfCString.h" // for nsPrintfCString @@ -191,7 +194,7 @@ LayerManager::Mutated(Layer* aLayer) already_AddRefed LayerManager::CreateImageContainer(ImageContainer::Mode flag) { - nsRefPtr container = new ImageContainer(flag); + RefPtr container = new ImageContainer(flag); return container.forget(); } @@ -298,7 +301,7 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) nsAutoPtr result; nsCSSValueList** resultTail = getter_Transfers(result); for (uint32_t i = 0; i < aFunctions.Length(); i++) { - nsRefPtr arr; + RefPtr arr; switch (aFunctions[i].type()) { case TransformFunction::TRotationX: { @@ -1668,11 +1671,20 @@ void WriteSnapshotToDumpFile(Compositor* aCompositor, DrawTarget* aTarget) void Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) { +#ifdef MOZ_DUMP_PAINTING + bool dumpCompositorTexture = gfxUtils::sDumpCompositorTextures && AsLayerComposite() && + AsLayerComposite()->GetCompositableHost(); + bool dumpClientTexture = gfxUtils::sDumpPainting && AsShadowableLayer() && + AsShadowableLayer()->GetCompositableClient(); + nsCString layerId(Name()); + layerId.Append('-'); + layerId.AppendInt((uint64_t)this); +#endif if (aDumpHtml) { aStream << nsPrintfCString("
  • "; @@ -1680,8 +1692,17 @@ Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) DumpSelf(aStream, aPrefix); #ifdef MOZ_DUMP_PAINTING - if (gfxUtils::sDumpPainting && AsLayerComposite() && AsLayerComposite()->GetCompositableHost()) { + if (dumpCompositorTexture) { AsLayerComposite()->GetCompositableHost()->Dump(aStream, aPrefix, aDumpHtml); + } else if (dumpClientTexture) { + if (aDumpHtml) { + aStream << nsPrintfCString(""; + } } #endif diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index f6bb181fb9..29ad35fb00 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -676,7 +676,7 @@ public: } protected: - nsRefPtr mRoot; + RefPtr mRoot; gfx::UserData mUserData; bool mDestroyed; bool mSnapEffectiveTransforms; @@ -1062,7 +1062,7 @@ public: * CONSTRUCTION PHASE ONLY * Add a FrameMetrics-associated mask layer. */ - void SetAncestorMaskLayers(const nsTArray>& aLayers) { + void SetAncestorMaskLayers(const nsTArray>& aLayers) { if (aLayers != mAncestorMaskLayers) { MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) AncestorMaskLayers", this)); mAncestorMaskLayers = aLayers; @@ -1771,8 +1771,8 @@ protected: Layer* mNextSibling; Layer* mPrevSibling; void* mImplData; - nsRefPtr mMaskLayer; - nsTArray> mAncestorMaskLayers; + RefPtr mMaskLayer; + nsTArray> mAncestorMaskLayers; gfx::UserData mUserData; gfx::IntRect mLayerBounds; nsIntRegion mVisibleRegion; @@ -1796,7 +1796,7 @@ protected: Maybe mClipRect; gfx::IntRect mTileSourceRect; nsIntRegion mInvalidRegion; - nsTArray > mApzcs; + nsTArray > mApzcs; uint32_t mContentFlags; bool mUseTileSourceRect; bool mIsFixedPosition; @@ -2192,7 +2192,7 @@ protected: // the intermediate surface. bool mChildrenChanged; EventRegionsOverride mEventRegionsOverride; - nsRefPtr mHMDInfo; + RefPtr mHMDInfo; }; /** diff --git a/gfx/layers/ReadbackProcessor.cpp b/gfx/layers/ReadbackProcessor.cpp index b31775407f..657e6b9382 100644 --- a/gfx/layers/ReadbackProcessor.cpp +++ b/gfx/layers/ReadbackProcessor.cpp @@ -114,7 +114,7 @@ ReadbackProcessor::BuildUpdatesForLayer(ReadbackLayer* aLayer) aLayer->mBackgroundColor = colorLayer->GetColor(); NS_ASSERTION(aLayer->mBackgroundColor.a == 1.f, "Color layer said it was opaque!"); - nsRefPtr ctx = + RefPtr ctx = aLayer->mSink->BeginUpdate(aLayer->GetRect(), aLayer->AllocateSequenceNumber()); if (ctx) { diff --git a/gfx/layers/TextureDIB.cpp b/gfx/layers/TextureDIB.cpp index 4b3dc034cc..5d0001d56e 100644 --- a/gfx/layers/TextureDIB.cpp +++ b/gfx/layers/TextureDIB.cpp @@ -61,7 +61,7 @@ TextureClientDIB::UpdateFromSurface(gfx::SourceSurface* aSurface) { MOZ_ASSERT(mIsLocked && IsAllocated()); - nsRefPtr imgSurf = mSurface->GetAsImageSurface(); + RefPtr imgSurf = mSurface->GetAsImageSurface(); RefPtr srcSurf = aSurface->GetDataSurface(); @@ -334,7 +334,7 @@ DIBTextureHost::UpdatedInternal(const nsIntRegion* aRegion) mTextureSource = mCompositor->CreateDataTextureSource(mFlags); } - nsRefPtr imgSurf = mSurface->GetAsImageSurface(); + RefPtr imgSurf = mSurface->GetAsImageSurface(); RefPtr surf = Factory::CreateWrappingDataSourceSurface(imgSurf->Data(), imgSurf->Stride(), mSize, mFormat); diff --git a/gfx/layers/TextureDIB.h b/gfx/layers/TextureDIB.h index 5983ce4a41..9c2eaba588 100644 --- a/gfx/layers/TextureDIB.h +++ b/gfx/layers/TextureDIB.h @@ -45,7 +45,7 @@ protected: , mIsLocked(false) { } - nsRefPtr mSurface; + RefPtr mSurface; RefPtr mDrawTarget; gfx::IntSize mSize; gfx::SurfaceFormat mFormat; @@ -167,7 +167,7 @@ public: protected: virtual void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override; - nsRefPtr mSurface; + RefPtr mSurface; }; class TextureHostFileMapping : public TextureHostDirectUpload diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 9d46c2a993..cf07e27bb7 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -74,7 +74,7 @@ struct APZCTreeManager::TreeBuildingState { // A list of nodes that need to be destroyed at the end of the tree building. // This is initialized with all nodes in the old tree, and nodes are removed // from it as we reuse them in the new tree. - nsTArray> mNodesToDestroy; + nsTArray> mNodesToDestroy; // This map is populated as we place APZCs into the new tree. Its purpose is // to facilitate re-using the same APZC for different layers that scroll @@ -132,7 +132,7 @@ APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId, /* Flatten the tree of nodes into the given nsTArray */ static void -Collect(HitTestingTreeNode* aNode, nsTArray>* aCollection) +Collect(HitTestingTreeNode* aNode, nsTArray>* aCollection) { if (aNode) { aCollection->AppendElement(aNode); @@ -299,14 +299,14 @@ APZCTreeManager::RecycleOrCreateNode(TreeBuildingState& aState, // actually changes, this loop should generally do an early-return on the // first iteration, so it should be cheap in the common case. for (size_t i = 0; i < aState.mNodesToDestroy.Length(); i++) { - nsRefPtr node = aState.mNodesToDestroy[i]; + RefPtr node = aState.mNodesToDestroy[i]; if (!node->IsPrimaryHolder()) { aState.mNodesToDestroy.RemoveElement(node); node->RecycleWith(aApzc, aLayersId); return node.forget(); } } - nsRefPtr node = new HitTestingTreeNode(aApzc, false, aLayersId); + RefPtr node = new HitTestingTreeNode(aApzc, false, aLayersId); return node.forget(); } @@ -330,7 +330,7 @@ APZCTreeManager::StartScrollbarDrag(const ScrollableLayerGuid& aGuid, const AsyncDragMetrics& aDragMetrics) { - nsRefPtr apzc = GetTargetAPZC(aGuid); + RefPtr apzc = GetTargetAPZC(aGuid); if (!apzc) { return; } @@ -361,7 +361,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, needsApzc = false; } - nsRefPtr node = nullptr; + RefPtr node = nullptr; if (!needsApzc) { node = RecycleOrCreateNode(aState, nullptr, aLayersId); AttachNodeToTree(node, aParent, aNextSibling); @@ -421,7 +421,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, // We leave non-primary-holder nodes in the destroy list because we don't // care about those nodes getting destroyed. for (size_t i = 0; i < aState.mNodesToDestroy.Length(); i++) { - nsRefPtr n = aState.mNodesToDestroy[i]; + RefPtr n = aState.mNodesToDestroy[i]; if (n->IsPrimaryHolder() && n->GetApzc() && n->GetApzc()->Matches(guid)) { node = n; if (apzc != nullptr) { @@ -443,7 +443,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, // Look up the paint throttler for this layers id, or create it if // this is the first APZC for this layers id. auto throttlerInsertResult = mPaintThrottlerMap.insert( - std::make_pair(aLayersId, nsRefPtr())); + std::make_pair(aLayersId, RefPtr())); if (throttlerInsertResult.second) { throttlerInsertResult.first->second = new TaskThrottler( GetFrameTime(), TimeDuration::FromMilliseconds(500)); @@ -672,7 +672,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent, } case MOUSE_INPUT: { MouseInput& mouseInput = aEvent.AsMouseInput(); - nsRefPtr apzc = GetTargetAPZC(mouseInput.mOrigin, + RefPtr apzc = GetTargetAPZC(mouseInput.mOrigin, &hitResult); if (apzc) { result = mInputQueue->ReceiveInputEvent( @@ -701,7 +701,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent, return result; } - nsRefPtr apzc = GetTargetAPZC(wheelInput.mOrigin, + RefPtr apzc = GetTargetAPZC(wheelInput.mOrigin, &hitResult); if (apzc) { MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion); @@ -738,7 +738,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent, return result; } - nsRefPtr apzc = GetTargetAPZC(panInput.mPanStartPoint, + RefPtr apzc = GetTargetAPZC(panInput.mPanStartPoint, &hitResult); if (apzc) { MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion); @@ -771,7 +771,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent, break; } case PINCHGESTURE_INPUT: { // note: no one currently sends these PinchGestureInput& pinchInput = aEvent.AsPinchGestureInput(); - nsRefPtr apzc = GetTargetAPZC(pinchInput.mFocusPoint, + RefPtr apzc = GetTargetAPZC(pinchInput.mFocusPoint, &hitResult); if (apzc) { MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion); @@ -792,7 +792,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent, break; } case TAPGESTURE_INPUT: { // note: no one currently sends these TapGestureInput& tapInput = aEvent.AsTapGestureInput(); - nsRefPtr apzc = GetTargetAPZC(tapInput.mPoint, + RefPtr apzc = GetTargetAPZC(tapInput.mPoint, &hitResult); if (apzc) { MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion); @@ -819,7 +819,7 @@ already_AddRefed APZCTreeManager::GetTouchInputBlockAPZC(const MultiTouchInput& aEvent, HitTestResult* aOutHitResult) { - nsRefPtr apzc; + RefPtr apzc; if (aEvent.mTouches.Length() == 0) { return apzc.forget(); } @@ -828,7 +828,7 @@ APZCTreeManager::GetTouchInputBlockAPZC(const MultiTouchInput& aEvent, apzc = GetTargetAPZC(aEvent.mTouches[0].mScreenPoint, aOutHitResult); for (size_t i = 1; i < aEvent.mTouches.Length(); i++) { - nsRefPtr apzc2 = GetTargetAPZC(aEvent.mTouches[i].mScreenPoint, aOutHitResult); + RefPtr apzc2 = GetTargetAPZC(aEvent.mTouches[i].mScreenPoint, aOutHitResult); apzc = GetMultitouchTarget(apzc, apzc2); APZCTM_LOG("Using APZC %p as the root APZC for multi-touch\n", apzc.get()); } @@ -926,7 +926,7 @@ APZCTreeManager::TransformCoordinateToGecko(const ScreenIntPoint& aPoint, LayoutDeviceIntPoint* aOutTransformedPoint) { MOZ_ASSERT(aOutTransformedPoint); - nsRefPtr apzc = GetTargetAPZC(aPoint, nullptr); + RefPtr apzc = GetTargetAPZC(aPoint, nullptr); if (apzc && aOutTransformedPoint) { Matrix4x4 transformToApzc = GetScreenToApzcTransform(apzc); Matrix4x4 transformToGecko = GetApzcToGeckoTransform(apzc); @@ -993,7 +993,7 @@ APZCTreeManager::ProcessEvent(WidgetInputEvent& aEvent, // Transform the refPoint. // If the event hits an overscrolled APZC, instruct the caller to ignore it. HitTestResult hitResult = HitNothing; - nsRefPtr apzc = GetTargetAPZC(ScreenPoint(aEvent.refPoint.x, aEvent.refPoint.y), + RefPtr apzc = GetTargetAPZC(ScreenPoint(aEvent.refPoint.x, aEvent.refPoint.y), &hitResult); if (apzc) { MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion); @@ -1107,7 +1107,7 @@ void APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid, const CSSRect& aRect) { - nsRefPtr apzc = GetTargetAPZC(aGuid); + RefPtr apzc = GetTargetAPZC(aGuid); if (apzc) { apzc->ZoomToRect(aRect); } @@ -1127,12 +1127,12 @@ APZCTreeManager::SetTargetAPZC(uint64_t aInputBlockId, { APZThreadUtils::AssertOnControllerThread(); - nsRefPtr target = nullptr; + RefPtr target = nullptr; if (aTargets.Length() > 0) { target = GetTargetAPZC(aTargets[0]); } for (size_t i = 1; i < aTargets.Length(); i++) { - nsRefPtr apzc = GetTargetAPZC(aTargets[i]); + RefPtr apzc = GetTargetAPZC(aTargets[i]); target = GetMultitouchTarget(target, apzc); } mInputQueue->SetConfirmedTargetApzc(aInputBlockId, target); @@ -1143,7 +1143,7 @@ APZCTreeManager::SetTargetAPZC(uint64_t aInputBlockId, const ScrollableLayerGuid { APZThreadUtils::AssertOnControllerThread(); - nsRefPtr apzc = GetTargetAPZC(aTarget); + RefPtr apzc = GetTargetAPZC(aTarget); mInputQueue->SetConfirmedTargetApzc(aInputBlockId, apzc); } @@ -1152,7 +1152,7 @@ APZCTreeManager::UpdateZoomConstraints(const ScrollableLayerGuid& aGuid, const Maybe& aConstraints) { MonitorAutoLock lock(mTreeLock); - nsRefPtr node = GetTargetNode(aGuid, nullptr); + RefPtr node = GetTargetNode(aGuid, nullptr); MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC // Propagate the zoom constraints down to the subtree, stopping at APZCs @@ -1253,7 +1253,7 @@ APZCTreeManager::FlushPendingRepaintRecursively(HitTestingTreeNode* aNode, uint6 void APZCTreeManager::CancelAnimation(const ScrollableLayerGuid &aGuid) { - nsRefPtr apzc = GetTargetAPZC(aGuid); + RefPtr apzc = GetTargetAPZC(aGuid); if (apzc) { apzc->CancelAnimation(); } @@ -1273,7 +1273,7 @@ APZCTreeManager::ClearTree() // This can be done as part of a tree walk but it's easier to // just re-use the Collect method that we need in other places. // If this is too slow feel free to change it to a recursive walk. - nsTArray> nodesToDestroy; + nsTArray> nodesToDestroy; Collect(mRootNode, &nodesToDestroy); for (size_t i = 0; i < nodesToDestroy.Length(); i++) { nodesToDestroy[i]->Destroy(); @@ -1281,7 +1281,7 @@ APZCTreeManager::ClearTree() mRootNode = nullptr; } -nsRefPtr +RefPtr APZCTreeManager::GetRootNode() const { MonitorAutoLock lock(mTreeLock); @@ -1336,7 +1336,7 @@ APZCTreeManager::DispatchScroll(AsyncPanZoomController* aPrev, { const OverscrollHandoffChain& overscrollHandoffChain = aOverscrollHandoffState.mChain; uint32_t overscrollHandoffChainIndex = aOverscrollHandoffState.mChainIndex; - nsRefPtr next; + RefPtr next; // If we have reached the end of the overscroll handoff chain, there is // nothing more to scroll, so we ignore the rest of the pan gesture. if (overscrollHandoffChainIndex >= overscrollHandoffChain.Length()) { @@ -1374,10 +1374,10 @@ APZCTreeManager::DispatchScroll(AsyncPanZoomController* aPrev, void APZCTreeManager::DispatchFling(AsyncPanZoomController* aPrev, ParentLayerPoint& aVelocity, - nsRefPtr aOverscrollHandoffChain, + RefPtr aOverscrollHandoffChain, bool aHandoff) { - nsRefPtr current; + RefPtr current; uint32_t aOverscrollHandoffChainLength = aOverscrollHandoffChain->Length(); uint32_t startIndex; @@ -1454,7 +1454,7 @@ APZCTreeManager::DispatchFling(AsyncPanZoomController* aPrev, bool APZCTreeManager::HitTestAPZC(const ScreenIntPoint& aPoint) { - nsRefPtr target = GetTargetAPZC(aPoint, nullptr); + RefPtr target = GetTargetAPZC(aPoint, nullptr); return target != nullptr; } @@ -1462,9 +1462,9 @@ already_AddRefed APZCTreeManager::GetTargetAPZC(const ScrollableLayerGuid& aGuid) { MonitorAutoLock lock(mTreeLock); - nsRefPtr node = GetTargetNode(aGuid, nullptr); + RefPtr node = GetTargetNode(aGuid, nullptr); MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC - nsRefPtr apzc = node ? node->GetApzc() : nullptr; + RefPtr apzc = node ? node->GetApzc() : nullptr; return apzc.forget(); } @@ -1473,7 +1473,7 @@ APZCTreeManager::GetTargetNode(const ScrollableLayerGuid& aGuid, GuidComparator aComparator) { mTreeLock.AssertCurrentThreadOwns(); - nsRefPtr target = FindTargetNode(mRootNode, aGuid, aComparator); + RefPtr target = FindTargetNode(mRootNode, aGuid, aComparator); return target.forget(); } @@ -1484,7 +1484,7 @@ APZCTreeManager::GetTargetAPZC(const ScreenPoint& aPoint, HitTestResult* aOutHit HitTestResult hitResult = HitNothing; ParentLayerPoint point = ViewAs(aPoint, PixelCastJustification::ScreenIsParentLayerForRoot); - nsRefPtr target = GetAPZCAtPoint(mRootNode, point, &hitResult); + RefPtr target = GetAPZCAtPoint(mRootNode, point, &hitResult); if (aOutHitResult) { *aOutHitResult = hitResult; @@ -1499,8 +1499,8 @@ GuidComparatorIgnoringPresShell(const ScrollableLayerGuid& aOne, const Scrollabl && aOne.mScrollId == aTwo.mScrollId; } -nsRefPtr -APZCTreeManager::BuildOverscrollHandoffChain(const nsRefPtr& aInitialTarget) +RefPtr +APZCTreeManager::BuildOverscrollHandoffChain(const RefPtr& aInitialTarget) { // Scroll grabbing is a mechanism that allows content to specify that // the initial target of a pan should be not the innermost scrollable @@ -1556,7 +1556,7 @@ APZCTreeManager::BuildOverscrollHandoffChain(const nsRefPtrGetGuid().mLayersId, 0, apzc->GetScrollHandoffParentId()); - nsRefPtr node = GetTargetNode(guid, &GuidComparatorIgnoringPresShell); + RefPtr node = GetTargetNode(guid, &GuidComparatorIgnoringPresShell); MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC scrollParent = node ? node->GetApzc() : nullptr; } @@ -1606,7 +1606,7 @@ APZCTreeManager::FindTargetNode(HitTestingTreeNode* aNode, return nullptr; } -nsRefPtr +RefPtr APZCTreeManager::FindScrollNode(const AsyncDragMetrics& aDragMetrics) { MonitorAutoLock lock(mTreeLock); @@ -1892,7 +1892,7 @@ already_AddRefed APZCTreeManager::GetMultitouchTarget(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const { MonitorAutoLock lock(mTreeLock); - nsRefPtr apzc; + RefPtr apzc; // For now, we only ever want to do pinching on the root-content APZC for // a given layers id. if (aApzc1 && aApzc2 && aApzc1->GetLayersId() == aApzc2->GetLayersId()) { @@ -1916,7 +1916,7 @@ already_AddRefed APZCTreeManager::CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const { mTreeLock.AssertCurrentThreadOwns(); - nsRefPtr ancestor; + RefPtr ancestor; // If either aApzc1 or aApzc2 is null, min(depth1, depth2) will be 0 and this function // will return null. diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 1397965fbc..1e168a48ab 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -301,7 +301,7 @@ public: * Find the hit testing node for the scrollbar thumb that matches these * drag metrics. */ - nsRefPtr FindScrollNode(const AsyncDragMetrics& aDragMetrics); + RefPtr FindScrollNode(const AsyncDragMetrics& aDragMetrics); /** * Sets allowed touch behavior values for current touch-session for specific @@ -391,7 +391,7 @@ public: */ void DispatchFling(AsyncPanZoomController* aApzc, ParentLayerPoint& aVelocity, - nsRefPtr aOverscrollHandoffChain, + RefPtr aOverscrollHandoffChain, bool aHandoff); void StartScrollbarDrag(const ScrollableLayerGuid& aGuid, @@ -400,7 +400,7 @@ public: /* * Build the chain of APZCs that will handle overscroll for a pan starting at |aInitialTarget|. */ - nsRefPtr BuildOverscrollHandoffChain(const nsRefPtr& aInitialTarget); + RefPtr BuildOverscrollHandoffChain(const RefPtr& aInitialTarget); protected: // Protected destructor, to discourage deletion outside of Release(): @@ -421,7 +421,7 @@ public: about it going away. These are public for testing code and generally should not be used by other production code. */ - nsRefPtr GetRootNode() const; + RefPtr GetRootNode() const; already_AddRefed GetTargetAPZC(const ScreenPoint& aPoint, HitTestResult* aOutHitResult); gfx::Matrix4x4 GetScreenToApzcTransform(const AsyncPanZoomController *aApzc) const; @@ -515,7 +515,7 @@ protected: /* The input queue where input events are held until we know enough to * figure out where they're going. Protected so gtests can access it. */ - nsRefPtr mInputQueue; + RefPtr mInputQueue; private: /* Whenever walking or mutating the tree rooted at mRootNode, mTreeLock must be held. @@ -526,20 +526,20 @@ private: * Finally, the lock needs to be held when accessing mZoomConstraints. * IMPORTANT: See the note about lock ordering at the top of this file. */ mutable mozilla::Monitor mTreeLock; - nsRefPtr mRootNode; + RefPtr mRootNode; /* Holds the zoom constraints for scrollable layers, as determined by the * the main-thread gecko code. */ std::map mZoomConstraints; /* Stores a paint throttler for each layers id. There is one for each layers * id to ensure that one child process painting slowly doesn't hold up * another. */ - std::map> mPaintThrottlerMap; + std::map> mPaintThrottlerMap; /* This tracks the APZC that should receive all inputs for the current input event block. * This allows touch points to move outside the thing they started on, but still have the * touch events delivered to the same initial APZC. This will only ever be touched on the * input delivery thread, and so does not require locking. */ - nsRefPtr mApzcForInputBlock; + RefPtr mApzcForInputBlock; /* The hit result for the current input event block; this should always be in * sync with mApzcForInputBlock. */ diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 9f004ad252..5f0a025e78 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -422,7 +422,7 @@ private: class FlingAnimation: public AsyncPanZoomAnimation { public: FlingAnimation(AsyncPanZoomController& aApzc, - const nsRefPtr& aOverscrollHandoffChain, + const RefPtr& aOverscrollHandoffChain, bool aApplyAcceleration) : AsyncPanZoomAnimation(TimeDuration::FromMilliseconds(gfxPrefs::APZFlingRepaintInterval())) , mApzc(aApzc) @@ -578,7 +578,7 @@ private: } AsyncPanZoomController& mApzc; - nsRefPtr mOverscrollHandoffChain; + RefPtr mOverscrollHandoffChain; }; class ZoomAnimation: public AsyncPanZoomAnimation { @@ -807,7 +807,7 @@ AsyncPanZoomController::InitializeGlobalState() AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId, APZCTreeManager* aTreeManager, - const nsRefPtr& aInputQueue, + const RefPtr& aInputQueue, GeckoContentController* aGeckoContentController, TaskThrottler* aPaintThrottler, GestureBehavior aGestures) @@ -861,18 +861,18 @@ AsyncPanZoomController::GetSharedFrameMetricsCompositor() already_AddRefed AsyncPanZoomController::GetGeckoContentController() const { MonitorAutoLock lock(mRefPtrMonitor); - nsRefPtr controller = mGeckoContentController; + RefPtr controller = mGeckoContentController; return controller.forget(); } already_AddRefed AsyncPanZoomController::GetGestureEventListener() const { MonitorAutoLock lock(mRefPtrMonitor); - nsRefPtr listener = mGestureEventListener; + RefPtr listener = mGestureEventListener; return listener.forget(); } -const nsRefPtr& +const RefPtr& AsyncPanZoomController::GetInputQueue() const { return mInputQueue; } @@ -992,7 +992,7 @@ static float GetAxisScale(AsyncDragMetrics::DragDirection aDir, T aValue) { nsEventStatus AsyncPanZoomController::HandleDragEvent(const MouseInput& aEvent, const AsyncDragMetrics& aDragMetrics) { - nsRefPtr node = + RefPtr node = GetApzcTreeManager()->FindScrollNode(aDragMetrics); if (!node) { return nsEventStatus_eConsumeNoDefault; @@ -1055,7 +1055,7 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent, return rv; } - nsRefPtr listener = GetGestureEventListener(); + RefPtr listener = GetGestureEventListener(); if (listener) { rv = listener->HandleInputEvent(multiTouchInput); if (rv == nsEventStatus_eConsumeNoDefault) { @@ -1187,7 +1187,7 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent case NOTHING: { mX.StartTouch(point.x, aEvent.mTime); mY.StartTouch(point.y, aEvent.mTime); - if (nsRefPtr controller = GetGeckoContentController()) { + if (RefPtr controller = GetGeckoContentController()) { controller->NotifyAPZStateChange( GetGuid(), APZStateChange::StartTouch, CurrentTouchBlock()->GetOverscrollHandoffChain()->CanBePanned(this)); @@ -1654,7 +1654,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEve { // We can't scroll this apz anymore, so we simply drop the event. if (gfxPrefs::MouseScrollTestingEnabled()) { - if (nsRefPtr controller = GetGeckoContentController()) { + if (RefPtr controller = GetGeckoContentController()) { controller->NotifyMozMouseScrollEvent( mFrameMetrics.GetScrollId(), NS_LITERAL_STRING("MozMouseScrollFailed")); @@ -1723,7 +1723,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEve void AsyncPanZoomController::NotifyMozMouseScrollEvent(const nsString& aString) const { - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (!controller) { return; } @@ -1883,7 +1883,7 @@ nsEventStatus AsyncPanZoomController::OnPanMomentumEnd(const PanGestureInput& aE nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent) { APZC_LOG("%p got a long-press in state %d\n", this, mState); - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { CSSPoint geckoScreenPoint; if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) { @@ -1905,7 +1905,7 @@ nsEventStatus AsyncPanZoomController::OnLongPressUp(const TapGestureInput& aEven } nsEventStatus AsyncPanZoomController::GenerateSingleTap(const ScreenIntPoint& aPoint, mozilla::Modifiers aModifiers) { - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { CSSPoint geckoScreenPoint; if (ConvertToGecko(aPoint, &geckoScreenPoint)) { @@ -1929,7 +1929,7 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(const ScreenIntPoint& aP } void AsyncPanZoomController::OnTouchEndOrCancel() { - if (nsRefPtr controller = GetGeckoContentController()) { + if (RefPtr controller = GetGeckoContentController()) { controller->NotifyAPZStateChange( GetGuid(), APZStateChange::EndTouch, CurrentTouchBlock()->SingleTapOccurred()); } @@ -1952,7 +1952,7 @@ nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent) { APZC_LOG("%p got a double-tap in state %d\n", this, mState); - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { if (mZoomConstraints.mAllowDoubleTapZoom && CurrentTouchBlock()->TouchActionAllowsDoubleTapZoom()) { CSSPoint geckoScreenPoint; @@ -2083,7 +2083,7 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) { void AsyncPanZoomController::HandlePanning(double aAngle) { ReentrantMonitorAutoEnter lock(mMonitor); - nsRefPtr overscrollHandoffChain = + RefPtr overscrollHandoffChain = GetInputQueue()->CurrentBlock()->GetOverscrollHandoffChain(); bool canScrollHorizontal = !mX.IsAxisLocked() && overscrollHandoffChain->CanScrollInDirection(this, Layer::HORIZONTAL); @@ -2160,7 +2160,7 @@ nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent } if (IsInPanningState()) { - if (nsRefPtr controller = GetGeckoContentController()) { + if (RefPtr controller = GetGeckoContentController()) { controller->NotifyAPZStateChange(GetGuid(), APZStateChange::StartPanning); } return nsEventStatus_eConsumeNoDefault; @@ -2287,7 +2287,7 @@ void AsyncPanZoomController::OverscrollBy(ParentLayerPoint& aOverscroll) { } } -nsRefPtr AsyncPanZoomController::BuildOverscrollHandoffChain() { +RefPtr AsyncPanZoomController::BuildOverscrollHandoffChain() { if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) { return treeManagerLocal->BuildOverscrollHandoffChain(this); } @@ -2300,7 +2300,7 @@ nsRefPtr AsyncPanZoomController::BuildOverscrollHa } void AsyncPanZoomController::AcceptFling(ParentLayerPoint& aVelocity, - const nsRefPtr& aOverscrollHandoffChain, + const RefPtr& aOverscrollHandoffChain, bool aHandoff) { ReentrantMonitorAutoEnter lock(mMonitor); @@ -2339,7 +2339,7 @@ void AsyncPanZoomController::AcceptFling(ParentLayerPoint& aVelocity, bool flingWillOverscroll = IsOverscrolled() && ((velocity.x * mX.GetOverscroll() >= 0) || (velocity.y * mY.GetOverscroll() >= 0)); if (!flingWillOverscroll) { - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { APZC_LOG("%p fling snapping. friction: %f velocity: %f, %f " "predictedDelta: %f, %f position: %f, %f " @@ -2357,7 +2357,7 @@ void AsyncPanZoomController::AcceptFling(ParentLayerPoint& aVelocity, } bool AsyncPanZoomController::AttemptFling(ParentLayerPoint& aVelocity, - const nsRefPtr& aOverscrollHandoffChain, + const RefPtr& aOverscrollHandoffChain, bool aHandoff) { // If we are pannable, take over the fling ourselves. if (IsPannable()) { @@ -2371,7 +2371,7 @@ bool AsyncPanZoomController::AttemptFling(ParentLayerPoint& aVelocity, } void AsyncPanZoomController::HandleFlingOverscroll(const ParentLayerPoint& aVelocity, - const nsRefPtr& aOverscrollHandoffChain) { + const RefPtr& aOverscrollHandoffChain) { APZCTreeManager* treeManagerLocal = GetApzcTreeManager(); ParentLayerPoint velocity = aVelocity; if (treeManagerLocal) { @@ -2678,7 +2678,7 @@ bool AsyncPanZoomController::IsPannable() const { } int32_t AsyncPanZoomController::GetLastTouchIdentifier() const { - nsRefPtr listener = GetGestureEventListener(); + RefPtr listener = GetGestureEventListener(); return listener ? listener->GetLastTouchIdentifier() : -1; } @@ -2740,7 +2740,7 @@ GetDisplayPortRect(const FrameMetrics& aFrameMetrics) void AsyncPanZoomController::DispatchRepaintRequest(const FrameMetrics& aFrameMetrics) { - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { APZC_LOG_FM(aFrameMetrics, "%p requesting content repaint", this); LogRendertraceRect(GetGuid(), "requested displayport", "yellow", GetDisplayPortRect(aFrameMetrics)); @@ -3168,7 +3168,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri // scroll offset updates from APZ until we acknowledge the update it sent. // This prevents APZ updates from clobbering scroll updates from other // more "legitimate" sources like content scripts. - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { APZC_LOG("%p sending scroll update acknowledgement with gen %u\n", this, aLayerMetrics.GetScrollGeneration()); controller->AcknowledgeScrollUpdate(aLayerMetrics.GetScrollId(), @@ -3311,7 +3311,7 @@ AsyncPanZoomController::ResetInputState() // a fake cancel touch event here but on the assumption that none of the // code in GEL assumes a CurrentTouchBlock() MultiTouchInput cancel(MultiTouchInput::MULTITOUCH_CANCEL, 0, TimeStamp::Now(), 0); - nsRefPtr listener = GetGestureEventListener(); + RefPtr listener = GetGestureEventListener(); if (listener) { listener->HandleInputEvent(cancel); } @@ -3357,7 +3357,7 @@ void AsyncPanZoomController::DispatchStateChangeNotification(PanZoomState aOldSt } } - if (nsRefPtr controller = GetGeckoContentController()) { + if (RefPtr controller = GetGeckoContentController()) { if (!IsTransformingState(aOldState) && IsTransformingState(aNewState)) { controller->NotifyAPZStateChange( GetGuid(), APZStateChange::TransformBegin); @@ -3402,14 +3402,14 @@ AsyncPanZoomController::GetZoomConstraints() const void AsyncPanZoomController::PostDelayedTask(Task* aTask, int aDelayMs) { APZThreadUtils::AssertOnControllerThread(); - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (controller) { controller->PostDelayedTask(aTask, aDelayMs); } } void AsyncPanZoomController::SendAsyncScrollEvent() { - nsRefPtr controller = GetGeckoContentController(); + RefPtr controller = GetGeckoContentController(); if (!controller) { return; } @@ -3517,7 +3517,7 @@ void AsyncPanZoomController::OverscrollAnimationEnding() { // snap point, so we request one now. If there are no snap points, this will // do nothing. If there are snap points, we'll get a scrollTo that snaps us // back to the nearest valid snap point. - if (nsRefPtr controller = GetGeckoContentController()) { + if (RefPtr controller = GetGeckoContentController()) { controller->RequestFlingSnap(mFrameMetrics.GetScrollId(), mFrameMetrics.GetScrollOffset()); } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 4d4b7d8fbe..c36db4e124 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -102,7 +102,7 @@ public: AsyncPanZoomController(uint64_t aLayersId, APZCTreeManager* aTreeManager, - const nsRefPtr& aInputQueue, + const RefPtr& aInputQueue, GeckoContentController* aController, TaskThrottler* aPaintThrottler, GestureBehavior aGestures = DEFAULT_GESTURES); @@ -615,7 +615,7 @@ protected: /** * Gets a ref to the input queue that is shared across the entire tree manager. */ - const nsRefPtr& GetInputQueue() const; + const RefPtr& GetInputQueue() const; /** * Timeout function for mozbrowserasyncscroll event. Because we throttle @@ -652,14 +652,14 @@ protected: void OverscrollAnimationEnding(); uint64_t mLayersId; - nsRefPtr mCompositorParent; - nsRefPtr mPaintThrottler; + RefPtr mCompositorParent; + RefPtr mPaintThrottler; /* Access to the following two fields is protected by the mRefPtrMonitor, since they are accessed on the UI thread but can be cleared on the compositor thread. */ - nsRefPtr mGeckoContentController; - nsRefPtr mGestureEventListener; + RefPtr mGeckoContentController; + RefPtr mGestureEventListener; mutable Monitor mRefPtrMonitor; // This is a raw pointer to avoid introducing a reference cycle between @@ -744,7 +744,7 @@ private: // ensures the last mozbrowserasyncscroll event is always been fired. CancelableTask* mAsyncScrollTimeoutTask; - nsRefPtr mAnimation; + RefPtr mAnimation; friend class Axis; @@ -840,7 +840,7 @@ public: private: void CancelAnimationAndGestureState(); - nsRefPtr mInputQueue; + RefPtr mInputQueue; TouchBlockState* CurrentTouchBlock(); bool HasReadyTouchBlock(); @@ -869,7 +869,7 @@ public: * fling. */ bool AttemptFling(ParentLayerPoint& aVelocity, - const nsRefPtr& aOverscrollHandoffChain, + const RefPtr& aOverscrollHandoffChain, bool aHandoff); private: @@ -889,13 +889,13 @@ private: // later in the handoff chain, or if there are no takers, continuing the // fling and entering an overscrolled state. void HandleFlingOverscroll(const ParentLayerPoint& aVelocity, - const nsRefPtr& aOverscrollHandoffChain); + const RefPtr& aOverscrollHandoffChain); void HandleSmoothScrollOverscroll(const ParentLayerPoint& aVelocity); // Helper function used by TakeOverFling() and HandleFlingOverscroll(). void AcceptFling(ParentLayerPoint& aVelocity, - const nsRefPtr& aOverscrollHandoffChain, + const RefPtr& aOverscrollHandoffChain, bool aHandoff); // Start an overscroll animation with the given initial velocity. @@ -941,7 +941,7 @@ private: // |mTreeManager| belongs in this section but it's declaration is a bit // further above due to initialization-order constraints. - nsRefPtr mParent; + RefPtr mParent; /* =================================================================== @@ -997,16 +997,16 @@ public: * - When passing the chain to a function that uses it without storing it, * pass it by reference-to-const (as in |const OverscrollHandoffChain&|). * - When storing the chain, store it by RefPtr-to-const (as in - * |nsRefPtr|). This ensures the chain is + * |RefPtr|). This ensures the chain is * kept alive. Note that queueing a task that uses the chain as an * argument constitutes storing, as the task may outlive its queuer. * - When passing the chain to a function that will store it, pass it as - * |const nsRefPtr&|. This allows the - * function to copy it into the |nsRefPtr| + * |const RefPtr&|. This allows the + * function to copy it into the |RefPtr| * that will store it, while avoiding an unnecessary copy (and thus * AddRef() and Release()) when passing it. */ - nsRefPtr BuildOverscrollHandoffChain(); + RefPtr BuildOverscrollHandoffChain(); private: /** @@ -1075,7 +1075,7 @@ private: * shared FrameMeterics used in progressive tile painting. */ const uint32_t mAPZCId; - nsRefPtr mSharedFrameMetricsBuffer; + RefPtr mSharedFrameMetricsBuffer; CrossProcessMutex* mSharedLock; /** * Called when ever mFrameMetrics is updated so that if it is being diff --git a/gfx/layers/apz/src/GestureEventListener.h b/gfx/layers/apz/src/GestureEventListener.h index 516702432a..b1b351c6e8 100644 --- a/gfx/layers/apz/src/GestureEventListener.h +++ b/gfx/layers/apz/src/GestureEventListener.h @@ -140,7 +140,7 @@ private: */ void SetState(GestureState aState); - nsRefPtr mAsyncPanZoomController; + RefPtr mAsyncPanZoomController; /** * Array containing all active touches. When a touch happens it, gets added to diff --git a/gfx/layers/apz/src/HitTestingTreeNode.h b/gfx/layers/apz/src/HitTestingTreeNode.h index b34803a5c6..0bf8cf6970 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.h +++ b/gfx/layers/apz/src/HitTestingTreeNode.h @@ -13,7 +13,7 @@ #include "mozilla/gfx/Matrix.h" // for Matrix4x4 #include "mozilla/layers/LayersTypes.h" // for EventRegions #include "mozilla/Maybe.h" // for Maybe -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr namespace mozilla { namespace layers { @@ -111,11 +111,11 @@ public: private: void SetApzcParent(AsyncPanZoomController* aApzc); - nsRefPtr mLastChild; - nsRefPtr mPrevSibling; - nsRefPtr mParent; + RefPtr mLastChild; + RefPtr mPrevSibling; + RefPtr mParent; - nsRefPtr mApzc; + RefPtr mApzc; bool mIsPrimaryApzcHolder; uint64_t mLayersId; diff --git a/gfx/layers/apz/src/InputBlockState.cpp b/gfx/layers/apz/src/InputBlockState.cpp index d143a13c7a..aaa5b28d74 100644 --- a/gfx/layers/apz/src/InputBlockState.cpp +++ b/gfx/layers/apz/src/InputBlockState.cpp @@ -19,7 +19,7 @@ namespace layers { static uint64_t sBlockCounter = InputBlockState::NO_BLOCK_ID + 1; -InputBlockState::InputBlockState(const nsRefPtr& aTargetApzc, +InputBlockState::InputBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed) : mTargetApzc(aTargetApzc) , mTargetConfirmed(aTargetConfirmed) @@ -32,7 +32,7 @@ InputBlockState::InputBlockState(const nsRefPtr& aTarget } bool -InputBlockState::SetConfirmedTargetApzc(const nsRefPtr& aTargetApzc) +InputBlockState::SetConfirmedTargetApzc(const RefPtr& aTargetApzc) { if (mTargetConfirmed) { return false; @@ -53,7 +53,7 @@ InputBlockState::SetConfirmedTargetApzc(const nsRefPtr& } void -InputBlockState::UpdateTargetApzc(const nsRefPtr& aTargetApzc) +InputBlockState::UpdateTargetApzc(const RefPtr& aTargetApzc) { // note that aTargetApzc MAY be null here. mTargetApzc = aTargetApzc; @@ -61,13 +61,13 @@ InputBlockState::UpdateTargetApzc(const nsRefPtr& aTarge mOverscrollHandoffChain = (mTargetApzc ? mTargetApzc->BuildOverscrollHandoffChain() : nullptr); } -const nsRefPtr& +const RefPtr& InputBlockState::GetTargetApzc() const { return mTargetApzc; } -const nsRefPtr& +const RefPtr& InputBlockState::GetOverscrollHandoffChain() const { return mOverscrollHandoffChain; @@ -85,7 +85,7 @@ InputBlockState::IsTargetConfirmed() const return mTargetConfirmed; } -CancelableBlockState::CancelableBlockState(const nsRefPtr& aTargetApzc, +CancelableBlockState::CancelableBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed) : InputBlockState(aTargetApzc, aTargetConfirmed) , mPreventDefault(false) @@ -163,7 +163,7 @@ CancelableBlockState::DispatchEvent(const InputData& aEvent) const // This is used to track the current wheel transaction. static uint64_t sLastWheelBlockId = InputBlockState::NO_BLOCK_ID; -WheelBlockState::WheelBlockState(const nsRefPtr& aTargetApzc, +WheelBlockState::WheelBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed, const ScrollWheelInput& aInitialEvent) : CancelableBlockState(aTargetApzc, aTargetConfirmed) @@ -176,7 +176,7 @@ WheelBlockState::WheelBlockState(const nsRefPtr& aTarget // If we get a content confirmation later that the apzc is different, then // content should have found a scrollable apzc, so we don't need to handle // that case. - nsRefPtr apzc = + RefPtr apzc = mOverscrollHandoffChain->FindFirstScrollable(aInitialEvent); // If nothing is scrollable, we don't consider this block as starting a @@ -202,12 +202,12 @@ WheelBlockState::SetContentResponse(bool aPreventDefault) } bool -WheelBlockState::SetConfirmedTargetApzc(const nsRefPtr& aTargetApzc) +WheelBlockState::SetConfirmedTargetApzc(const RefPtr& aTargetApzc) { // The APZC that we find via APZCCallbackHelpers may not be the same APZC // ESM or OverscrollHandoff would have computed. Make sure we get the right // one by looking for the first apzc the next pending event can scroll. - nsRefPtr apzc = aTargetApzc; + RefPtr apzc = aTargetApzc; if (apzc && mEvents.Length() > 0) { const ScrollWheelInput& event = mEvents.ElementAt(0); apzc = apzc->BuildOverscrollHandoffChain()->FindFirstScrollable(event); @@ -232,7 +232,7 @@ WheelBlockState::Update(const ScrollWheelInput& aEvent) // // We skip this check if the target is not yet confirmed, so that when it is // confirmed, we don't timeout the transaction. - nsRefPtr apzc = GetTargetApzc(); + RefPtr apzc = GetTargetApzc(); if (IsTargetConfirmed() && !apzc->CanScroll(aEvent)) { return; } @@ -303,7 +303,7 @@ WheelBlockState::ShouldAcceptNewEvent() const return false; } - nsRefPtr apzc = GetTargetApzc(); + RefPtr apzc = GetTargetApzc(); if (apzc->IsDestroyed()) { return false; } @@ -348,7 +348,7 @@ WheelBlockState::MaybeTimeout(const TimeStamp& aTimeStamp) TBS_LOG("%p wheel transaction timed out\n", this); if (gfxPrefs::MouseScrollTestingEnabled()) { - nsRefPtr apzc = GetTargetApzc(); + RefPtr apzc = GetTargetApzc(); apzc->NotifyMozMouseScrollEvent(NS_LITERAL_STRING("MozMouseScrollTransactionTimeout")); } @@ -379,7 +379,7 @@ WheelBlockState::OnMouseMove(const ScreenIntPoint& aPoint) } void -WheelBlockState::UpdateTargetApzc(const nsRefPtr& aTargetApzc) +WheelBlockState::UpdateTargetApzc(const RefPtr& aTargetApzc) { InputBlockState::UpdateTargetApzc(aTargetApzc); @@ -421,7 +421,7 @@ WheelBlockState::EndTransaction() mTransactionEnded = true; } -PanGestureBlockState::PanGestureBlockState(const nsRefPtr& aTargetApzc, +PanGestureBlockState::PanGestureBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed, const PanGestureInput& aInitialEvent) : CancelableBlockState(aTargetApzc, aTargetConfirmed) @@ -433,7 +433,7 @@ PanGestureBlockState::PanGestureBlockState(const nsRefPtr apzc = + RefPtr apzc = mOverscrollHandoffChain->FindFirstScrollable(aInitialEvent); if (apzc && apzc != GetTargetApzc()) { @@ -443,15 +443,15 @@ PanGestureBlockState::PanGestureBlockState(const nsRefPtr& aTargetApzc) +PanGestureBlockState::SetConfirmedTargetApzc(const RefPtr& aTargetApzc) { // The APZC that we find via APZCCallbackHelpers may not be the same APZC // ESM or OverscrollHandoff would have computed. Make sure we get the right // one by looking for the first apzc the next pending event can scroll. - nsRefPtr apzc = aTargetApzc; + RefPtr apzc = aTargetApzc; if (apzc && mEvents.Length() > 0) { const PanGestureInput& event = mEvents.ElementAt(0); - nsRefPtr scrollableApzc = + RefPtr scrollableApzc = apzc->BuildOverscrollHandoffChain()->FindFirstScrollable(event); if (scrollableApzc) { apzc = scrollableApzc; @@ -540,7 +540,7 @@ PanGestureBlockState::SetNeedsToWaitForContentResponse(bool aWaitForContentRespo mWaitingForContentResponse = aWaitForContentResponse; } -TouchBlockState::TouchBlockState(const nsRefPtr& aTargetApzc, +TouchBlockState::TouchBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed, TouchCounter& aCounter) : CancelableBlockState(aTargetApzc, aTargetConfirmed) , mAllowedTouchBehaviorSet(false) diff --git a/gfx/layers/apz/src/InputBlockState.h b/gfx/layers/apz/src/InputBlockState.h index b6a9e9d6be..a9ba145f46 100644 --- a/gfx/layers/apz/src/InputBlockState.h +++ b/gfx/layers/apz/src/InputBlockState.h @@ -34,27 +34,27 @@ class InputBlockState public: static const uint64_t NO_BLOCK_ID = 0; - explicit InputBlockState(const nsRefPtr& aTargetApzc, + explicit InputBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed); virtual ~InputBlockState() {} - virtual bool SetConfirmedTargetApzc(const nsRefPtr& aTargetApzc); - const nsRefPtr& GetTargetApzc() const; - const nsRefPtr& GetOverscrollHandoffChain() const; + virtual bool SetConfirmedTargetApzc(const RefPtr& aTargetApzc); + const RefPtr& GetTargetApzc() const; + const RefPtr& GetOverscrollHandoffChain() const; uint64_t GetBlockId() const; bool IsTargetConfirmed() const; protected: - virtual void UpdateTargetApzc(const nsRefPtr& aTargetApzc); + virtual void UpdateTargetApzc(const RefPtr& aTargetApzc); private: - nsRefPtr mTargetApzc; + RefPtr mTargetApzc; bool mTargetConfirmed; const uint64_t mBlockId; protected: - nsRefPtr mOverscrollHandoffChain; + RefPtr mOverscrollHandoffChain; // Used to transform events from global screen space to |mTargetApzc|'s // screen space. It's cached at the beginning of the input block so that @@ -77,7 +77,7 @@ protected: class CancelableBlockState : public InputBlockState { public: - CancelableBlockState(const nsRefPtr& aTargetApzc, + CancelableBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed); virtual TouchBlockState *AsTouchBlock() { @@ -172,7 +172,7 @@ private: class WheelBlockState : public CancelableBlockState { public: - WheelBlockState(const nsRefPtr& aTargetApzc, + WheelBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed, const ScrollWheelInput& aEvent); @@ -183,7 +183,7 @@ public: void HandleEvents() override; bool MustStayActive() override; const char* Type() override; - bool SetConfirmedTargetApzc(const nsRefPtr& aTargetApzc) override; + bool SetConfirmedTargetApzc(const RefPtr& aTargetApzc) override; void AddEvent(const ScrollWheelInput& aEvent); @@ -242,7 +242,7 @@ public: void Update(const ScrollWheelInput& aEvent); protected: - void UpdateTargetApzc(const nsRefPtr& aTargetApzc) override; + void UpdateTargetApzc(const RefPtr& aTargetApzc) override; private: nsTArray mEvents; @@ -257,7 +257,7 @@ private: class PanGestureBlockState : public CancelableBlockState { public: - PanGestureBlockState(const nsRefPtr& aTargetApzc, + PanGestureBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed, const PanGestureInput& aEvent); @@ -268,7 +268,7 @@ public: void HandleEvents() override; bool MustStayActive() override; const char* Type() override; - bool SetConfirmedTargetApzc(const nsRefPtr& aTargetApzc) override; + bool SetConfirmedTargetApzc(const RefPtr& aTargetApzc) override; void AddEvent(const PanGestureInput& aEvent); @@ -317,7 +317,7 @@ private: class TouchBlockState : public CancelableBlockState { public: - explicit TouchBlockState(const nsRefPtr& aTargetApzc, + explicit TouchBlockState(const RefPtr& aTargetApzc, bool aTargetConfirmed, TouchCounter& aTouchCounter); TouchBlockState *AsTouchBlock() override { diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index a5559d751b..aad5c959a9 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -28,7 +28,7 @@ InputQueue::~InputQueue() { } nsEventStatus -InputQueue::ReceiveInputEvent(const nsRefPtr& aTarget, +InputQueue::ReceiveInputEvent(const RefPtr& aTarget, bool aTargetConfirmed, const InputData& aEvent, uint64_t* aOutInputBlockId) { @@ -63,7 +63,7 @@ bool InputQueue::MaybeHandleCurrentBlock(CancelableBlockState *block, const InputData& aEvent) { if (block == CurrentBlock() && block->IsReadyForHandling()) { - const nsRefPtr& target = block->GetTargetApzc(); + const RefPtr& target = block->GetTargetApzc(); INPQ_LOG("current block is ready with target %p preventdefault %d\n", target.get(), block->IsDefaultPrevented()); if (!target || block->IsDefaultPrevented()) { @@ -77,7 +77,7 @@ InputQueue::MaybeHandleCurrentBlock(CancelableBlockState *block, } nsEventStatus -InputQueue::ReceiveTouchInput(const nsRefPtr& aTarget, +InputQueue::ReceiveTouchInput(const RefPtr& aTarget, bool aTargetConfirmed, const MultiTouchInput& aEvent, uint64_t* aOutInputBlockId) { @@ -143,7 +143,7 @@ InputQueue::ReceiveTouchInput(const nsRefPtr& aTarget, // target set on the block. In this case the confirmed target (which may be // null) should take priority. This is equivalent to just always using the // target (confirmed or not) from the block. - nsRefPtr target = block->GetTargetApzc(); + RefPtr target = block->GetTargetApzc(); nsEventStatus result = nsEventStatus_eIgnore; @@ -163,7 +163,7 @@ InputQueue::ReceiveTouchInput(const nsRefPtr& aTarget, } nsEventStatus -InputQueue::ReceiveScrollWheelInput(const nsRefPtr& aTarget, +InputQueue::ReceiveScrollWheelInput(const RefPtr& aTarget, bool aTargetConfirmed, const ScrollWheelInput& aEvent, uint64_t* aOutInputBlockId) { @@ -220,13 +220,13 @@ CanScrollTargetHorizontally(const PanGestureInput& aInitialEvent, { PanGestureInput horizontalComponent = aInitialEvent; horizontalComponent.mPanDisplacement.y = 0; - nsRefPtr horizontallyScrollableAPZC = + RefPtr horizontallyScrollableAPZC = aBlock->GetOverscrollHandoffChain()->FindFirstScrollable(horizontalComponent); return horizontallyScrollableAPZC && horizontallyScrollableAPZC == aBlock->GetTargetApzc(); } nsEventStatus -InputQueue::ReceivePanGestureInput(const nsRefPtr& aTarget, +InputQueue::ReceivePanGestureInput(const RefPtr& aTarget, bool aTargetConfirmed, const PanGestureInput& aEvent, uint64_t* aOutInputBlockId) { @@ -306,7 +306,7 @@ InputQueue::CancelAnimationsForNewBlock(CancelableBlockState* aBlock) } void -InputQueue::MaybeRequestContentResponse(const nsRefPtr& aTarget, +InputQueue::MaybeRequestContentResponse(const RefPtr& aTarget, CancelableBlockState* aBlock) { bool waitForMainThread = false; @@ -361,7 +361,7 @@ InputQueue::SweepDepletedBlocks() } TouchBlockState* -InputQueue::StartNewTouchBlock(const nsRefPtr& aTarget, +InputQueue::StartNewTouchBlock(const RefPtr& aTarget, bool aTargetConfirmed, bool aCopyPropertiesFromCurrent) { @@ -446,7 +446,7 @@ InputQueue::AllowScrollHandoff() const } void -InputQueue::ScheduleMainThreadTimeout(const nsRefPtr& aTarget, uint64_t aInputBlockId) { +InputQueue::ScheduleMainThreadTimeout(const RefPtr& aTarget, uint64_t aInputBlockId) { INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get()); aTarget->PostDelayedTask( NewRunnableMethod(this, &InputQueue::MainThreadTimeout, aInputBlockId), @@ -493,7 +493,7 @@ InputQueue::ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefau } void -InputQueue::SetConfirmedTargetApzc(uint64_t aInputBlockId, const nsRefPtr& aTargetApzc) { +InputQueue::SetConfirmedTargetApzc(uint64_t aInputBlockId, const RefPtr& aTargetApzc) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n", @@ -545,7 +545,7 @@ InputQueue::ProcessInputBlocks() { INPQ_LOG("processing input block %p; preventDefault %d target %p\n", curBlock, curBlock->IsDefaultPrevented(), curBlock->GetTargetApzc().get()); - nsRefPtr target = curBlock->GetTargetApzc(); + RefPtr target = curBlock->GetTargetApzc(); // target may be null here if the initial target was unconfirmed and then // we later got a confirmed null target. in that case drop the events. if (!target) { @@ -575,7 +575,7 @@ InputQueue::ProcessInputBlocks() { } void -InputQueue::UpdateActiveApzc(const nsRefPtr& aNewActive) { +InputQueue::UpdateActiveApzc(const RefPtr& aNewActive) { if (mLastActiveApzc && mLastActiveApzc != aNewActive && mTouchCounter.GetActiveTouchCount() > 0) { mLastActiveApzc->ResetInputState(); diff --git a/gfx/layers/apz/src/InputQueue.h b/gfx/layers/apz/src/InputQueue.h index b589ebe995..002dfe77a7 100644 --- a/gfx/layers/apz/src/InputQueue.h +++ b/gfx/layers/apz/src/InputQueue.h @@ -42,7 +42,7 @@ public: * See the documentation on APZCTreeManager::ReceiveInputEvent for info on * return values from this function, including |aOutInputBlockId|. */ - nsEventStatus ReceiveInputEvent(const nsRefPtr& aTarget, + nsEventStatus ReceiveInputEvent(const RefPtr& aTarget, bool aTargetConfirmed, const InputData& aEvent, uint64_t* aOutInputBlockId); @@ -59,7 +59,7 @@ public: * we may need to query the layout engine to know for sure. The input block * this applies to should be specified via the |aInputBlockId| parameter. */ - void SetConfirmedTargetApzc(uint64_t aInputBlockId, const nsRefPtr& aTargetApzc); + void SetConfirmedTargetApzc(uint64_t aInputBlockId, const RefPtr& aTargetApzc); /** * This function should be invoked to notify the InputQueue of the touch- * action properties for the different touch points in an input block. The @@ -110,7 +110,7 @@ public: private: ~InputQueue(); - TouchBlockState* StartNewTouchBlock(const nsRefPtr& aTarget, + TouchBlockState* StartNewTouchBlock(const RefPtr& aTarget, bool aTargetConfirmed, bool aCopyPropertiesFromCurrent); @@ -123,18 +123,18 @@ private: /** * If we need to wait for a content response, schedule that now. */ - void MaybeRequestContentResponse(const nsRefPtr& aTarget, + void MaybeRequestContentResponse(const RefPtr& aTarget, CancelableBlockState* aBlock); - nsEventStatus ReceiveTouchInput(const nsRefPtr& aTarget, + nsEventStatus ReceiveTouchInput(const RefPtr& aTarget, bool aTargetConfirmed, const MultiTouchInput& aEvent, uint64_t* aOutInputBlockId); - nsEventStatus ReceiveScrollWheelInput(const nsRefPtr& aTarget, + nsEventStatus ReceiveScrollWheelInput(const RefPtr& aTarget, bool aTargetConfirmed, const ScrollWheelInput& aEvent, uint64_t* aOutInputBlockId); - nsEventStatus ReceivePanGestureInput(const nsRefPtr& aTarget, + nsEventStatus ReceivePanGestureInput(const RefPtr& aTarget, bool aTargetConfirmed, const PanGestureInput& aEvent, uint64_t* aOutInputBlockId); @@ -151,10 +151,10 @@ private: bool MaybeHandleCurrentBlock(CancelableBlockState* block, const InputData& aEvent); - void ScheduleMainThreadTimeout(const nsRefPtr& aTarget, uint64_t aInputBlockId); + void ScheduleMainThreadTimeout(const RefPtr& aTarget, uint64_t aInputBlockId); void MainThreadTimeout(const uint64_t& aInputBlockId); void ProcessInputBlocks(); - void UpdateActiveApzc(const nsRefPtr& aNewActive); + void UpdateActiveApzc(const RefPtr& aNewActive); private: // The queue of touch blocks that have not yet been fully processed. @@ -162,7 +162,7 @@ private: nsTArray> mInputBlockQueue; // The APZC to which the last event was delivered - nsRefPtr mLastActiveApzc; + RefPtr mLastActiveApzc; // Track touches so we know when to clear mLastActiveApzc TouchCounter mTouchCounter; diff --git a/gfx/layers/apz/src/OverscrollHandoffState.cpp b/gfx/layers/apz/src/OverscrollHandoffState.cpp index 8bcce1d2e1..150c52c695 100644 --- a/gfx/layers/apz/src/OverscrollHandoffState.cpp +++ b/gfx/layers/apz/src/OverscrollHandoffState.cpp @@ -23,8 +23,8 @@ OverscrollHandoffChain::Add(AsyncPanZoomController* aApzc) struct CompareByScrollPriority { - bool operator()(const nsRefPtr& a, - const nsRefPtr& b) const + bool operator()(const RefPtr& a, + const RefPtr& b) const { return a->HasScrollgrab() && !b->HasScrollgrab(); } @@ -41,7 +41,7 @@ OverscrollHandoffChain::SortByScrollPriority() std::stable_sort(mChain.begin(), mChain.end(), CompareByScrollPriority()); } -const nsRefPtr& +const RefPtr& OverscrollHandoffChain::GetApzcAtIndex(uint32_t aIndex) const { MOZ_ASSERT(aIndex < Length()); @@ -160,7 +160,7 @@ OverscrollHandoffChain::HasFastFlungApzc() const return AnyApzc(&AsyncPanZoomController::IsFlingingFast); } -nsRefPtr +RefPtr OverscrollHandoffChain::FindFirstScrollable(const InputData& aInput) const { for (size_t i = 0; i < Length(); i++) { diff --git a/gfx/layers/apz/src/OverscrollHandoffState.h b/gfx/layers/apz/src/OverscrollHandoffState.h index 77e798c7aa..2c20215da5 100644 --- a/gfx/layers/apz/src/OverscrollHandoffState.h +++ b/gfx/layers/apz/src/OverscrollHandoffState.h @@ -22,7 +22,7 @@ class AsyncPanZoomController; /** * A variant of NS_INLINE_DECL_THREADSAFE_REFCOUNTING which makes the refcount * variable |mutable|, and the AddRef and Release methods |const|, to allow - * using an |nsRefPtr|, and thereby enforcing better const-correctness. + * using an |RefPtr|, and thereby enforcing better const-correctness. * This is currently here because OverscrollHandoffChain is the only thing * currently using it. As a follow-up, we can move this to xpcom/glue, write * a corresponding version for non-threadsafe refcounting, and perhaps @@ -68,7 +68,7 @@ public: // Threadsafe so that the controller and compositor threads can both maintain // nsRefPtrs to the same handoff chain. // Mutable so that we can pass around the class by - // nsRefPtr and thus enforce that, once built, + // RefPtr and thus enforce that, once built, // the chain is not modified. NS_INLINE_DECL_THREADSAFE_MUTABLE_REFCOUNTING(OverscrollHandoffChain) @@ -83,7 +83,7 @@ public: * Methods for accessing the handoff chain. */ uint32_t Length() const { return mChain.size(); } - const nsRefPtr& GetApzcAtIndex(uint32_t aIndex) const; + const RefPtr& GetApzcAtIndex(uint32_t aIndex) const; // Returns Length() if |aApzc| is not on this chain. uint32_t IndexOf(const AsyncPanZoomController* aApzc) const; @@ -119,10 +119,10 @@ public: // Determine whether any APZC along this handoff chain has been flung fast. bool HasFastFlungApzc() const; - nsRefPtr FindFirstScrollable(const InputData& aInput) const; + RefPtr FindFirstScrollable(const InputData& aInput) const; private: - std::vector> mChain; + std::vector> mChain; typedef void (AsyncPanZoomController::*APZCMethod)(); typedef bool (AsyncPanZoomController::*APZCPredicate)() const; diff --git a/gfx/layers/apz/src/TaskThrottler.cpp b/gfx/layers/apz/src/TaskThrottler.cpp index a0c2a33a1f..a601650bc0 100644 --- a/gfx/layers/apz/src/TaskThrottler.cpp +++ b/gfx/layers/apz/src/TaskThrottler.cpp @@ -45,7 +45,7 @@ TaskThrottler::PostTask(const tracked_objects::Location& aLocation, // even if we don't get a TaskComplete() until then. TimeDuration timeout = mMaxWait - TimeSinceLastRequest(aTimeStamp); TimeStamp timeoutTime = mStartTime + mMaxWait; - nsRefPtr refPtrThis = this; + RefPtr refPtrThis = this; mTimer->InitWithCallback(NewTimerCallback( [refPtrThis, timeoutTime]() { diff --git a/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp b/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp index 2f1962a11a..a32f15e70d 100644 --- a/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp @@ -125,7 +125,7 @@ private: class TestAPZCTreeManager : public APZCTreeManager { public: - nsRefPtr GetInputQueue() const { + RefPtr GetInputQueue() const { return mInputQueue; } @@ -159,7 +159,7 @@ public: } void ConfirmTarget(uint64_t aInputBlockId) { - nsRefPtr target = this; + RefPtr target = this; GetInputQueue()->SetConfirmedTargetApzc(aInputBlockId, target); } @@ -279,9 +279,9 @@ protected: AsyncPanZoomController::GestureBehavior mGestureBehavior; TimeStamp testStartTime; - nsRefPtr mcc; - nsRefPtr tm; - nsRefPtr apzc; + RefPtr mcc; + RefPtr tm; + RefPtr apzc; }; class APZCGestureDetectorTester : public APZCBasicTester { @@ -326,7 +326,7 @@ CreatePinchGestureInput(PinchGestureInput::PinchGestureType aType, } template static nsEventStatus -TouchDown(const nsRefPtr& aTarget, int aX, int aY, int aTime, uint64_t* aOutInputBlockId = nullptr) +TouchDown(const RefPtr& aTarget, int aX, int aY, int aTime, uint64_t* aOutInputBlockId = nullptr) { MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime, TimeStamp(), 0); mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY)); @@ -334,7 +334,7 @@ TouchDown(const nsRefPtr& aTarget, int aX, int aY, int aTime, uin } template static nsEventStatus -TouchMove(const nsRefPtr& aTarget, int aX, int aY, int aTime) +TouchMove(const RefPtr& aTarget, int aX, int aY, int aTime) { MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime, TimeStamp(), 0); mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY)); @@ -342,7 +342,7 @@ TouchMove(const nsRefPtr& aTarget, int aX, int aY, int aTime) } template static nsEventStatus -TouchUp(const nsRefPtr& aTarget, int aX, int aY, int aTime) +TouchUp(const RefPtr& aTarget, int aX, int aY, int aTime) { MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime, TimeStamp(), 0); mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY)); @@ -350,7 +350,7 @@ TouchUp(const nsRefPtr& aTarget, int aX, int aY, int aTime) } template static void -Tap(const nsRefPtr& aTarget, int aX, int aY, int& aTime, int aTapLength, +Tap(const RefPtr& aTarget, int aX, int aY, int& aTime, int aTapLength, nsEventStatus (*aOutEventStatuses)[2] = nullptr, uint64_t* aOutInputBlockId = nullptr) { @@ -366,7 +366,7 @@ Tap(const nsRefPtr& aTarget, int aX, int aY, int& aTime, int aTap } template static void -TapAndCheckStatus(const nsRefPtr& aTarget, int aX, int aY, int& aTime, int aTapLength) +TapAndCheckStatus(const RefPtr& aTarget, int aX, int aY, int& aTime, int aTapLength) { nsEventStatus statuses[2]; Tap(aTarget, aX, aY, aTime, aTapLength, &statuses); @@ -375,7 +375,7 @@ TapAndCheckStatus(const nsRefPtr& aTarget, int aX, int aY, int& a } template static void -Pan(const nsRefPtr& aTarget, +Pan(const RefPtr& aTarget, int& aTime, int aTouchStartY, int aTouchEndY, @@ -444,7 +444,7 @@ Pan(const nsRefPtr& aTarget, * consumed them and triggered scrolling behavior. */ template static void -PanAndCheckStatus(const nsRefPtr& aTarget, +PanAndCheckStatus(const RefPtr& aTarget, int& aTime, int aTouchStartY, int aTouchEndY, @@ -468,7 +468,7 @@ PanAndCheckStatus(const nsRefPtr& aTarget, } static void -ApzcPanNoFling(const nsRefPtr& aApzc, +ApzcPanNoFling(const RefPtr& aApzc, int& aTime, int aTouchStartY, int aTouchEndY, @@ -479,7 +479,7 @@ ApzcPanNoFling(const nsRefPtr& aApzc, } template static void -PinchWithPinchInput(const nsRefPtr& aTarget, +PinchWithPinchInput(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, nsEventStatus (*aOutEventStatuses)[3] = nullptr) { @@ -509,7 +509,7 @@ PinchWithPinchInput(const nsRefPtr& aTarget, } template static void -PinchWithPinchInputAndCheckStatus(const nsRefPtr& aTarget, +PinchWithPinchInputAndCheckStatus(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, bool aShouldTriggerPinch) { @@ -524,7 +524,7 @@ PinchWithPinchInputAndCheckStatus(const nsRefPtr& aTarget, } template static void -PinchWithTouchInput(const nsRefPtr& aTarget, +PinchWithTouchInput(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, int& inputId, nsTArray* aAllowedTouchBehaviors = nullptr, @@ -583,7 +583,7 @@ PinchWithTouchInput(const nsRefPtr& aTarget, } template static void -PinchWithTouchInputAndCheckStatus(const nsRefPtr& aTarget, +PinchWithTouchInputAndCheckStatus(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, int& inputId, bool aShouldTriggerPinch, nsTArray* aAllowedTouchBehaviors) @@ -802,7 +802,7 @@ TEST_F(APZCBasicTester, ComplexTransform) { // CSS pixels). The displayport is 1 extra CSS pixel on all // sides. - nsRefPtr childApzc = new TestAsyncPanZoomController(0, mcc, tm); + RefPtr childApzc = new TestAsyncPanZoomController(0, mcc, tm); const char* layerTreeSyntax = "c(c)"; // LayerID 0 1 @@ -817,9 +817,9 @@ TEST_F(APZCBasicTester, ComplexTransform) { transforms[0].PostScale(0.5f, 0.5f, 1.0f); // this results from the 2.0 resolution on the root layer transforms[1].PostScale(2.0f, 1.0f, 1.0f); // this is the 2.0 x-axis CSS transform on the child layer - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers); + nsTArray > layers; + RefPtr lm; + RefPtr root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers); FrameMetrics metrics; metrics.SetCompositionBounds(ParentLayerRect(0, 0, 24, 24)); @@ -1479,7 +1479,7 @@ TEST_F(APZCLongPressTester, LongPressPreventDefaultWithTouchAction) { } template static void -DoubleTap(const nsRefPtr& aTarget, int aX, int aY, int& aTime, +DoubleTap(const RefPtr& aTarget, int aX, int aY, int& aTime, nsEventStatus (*aOutEventStatuses)[4] = nullptr, uint64_t (*aOutInputBlockIds)[2] = nullptr) { @@ -1512,7 +1512,7 @@ DoubleTap(const nsRefPtr& aTarget, int aX, int aY, int& aTime, } template static void -DoubleTapAndCheckStatus(const nsRefPtr& aTarget, int aX, int aY, int& aTime, uint64_t (*aOutInputBlockIds)[2] = nullptr) +DoubleTapAndCheckStatus(const RefPtr& aTarget, int aX, int aY, int& aTime, uint64_t (*aOutInputBlockIds)[2] = nullptr) { nsEventStatus statuses[4]; DoubleTap(aTarget, aX, aY, aTime, &statuses, aOutInputBlockIds); @@ -1676,13 +1676,13 @@ protected: } TimeStamp testStartTime; - nsRefPtr mcc; + RefPtr mcc; - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root; + nsTArray > layers; + RefPtr lm; + RefPtr root; - nsRefPtr manager; + RefPtr manager; protected: static void SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId, @@ -1762,7 +1762,7 @@ protected: Matrix4x4 transformToGecko; already_AddRefed GetTargetAPZC(const ScreenPoint& aPoint) { - nsRefPtr hit = manager->GetTargetAPZC(aPoint, nullptr); + RefPtr hit = manager->GetTargetAPZC(aPoint, nullptr); if (hit) { transformToApzc = manager->GetScreenToApzcTransform(hit.get()); transformToGecko = manager->GetApzcToGeckoTransform(hit.get()); @@ -1849,7 +1849,7 @@ TEST_F(APZHitTestingTester, HitTesting1) { ScopedLayerTreeRegistration registration(0, root, mcc); // No APZC attached so hit testing will return no APZC at (20,20) - nsRefPtr hit = GetTargetAPZC(ScreenPoint(20, 20)); + RefPtr hit = GetTargetAPZC(ScreenPoint(20, 20)); TestAsyncPanZoomController* nullAPZC = nullptr; EXPECT_EQ(nullAPZC, hit.get()); EXPECT_EQ(Matrix4x4(), transformToApzc); @@ -1926,7 +1926,7 @@ TEST_F(APZHitTestingTester, HitTesting2) { TestAsyncPanZoomController* apzc3 = ApzcOf(layers[3]); // Hit an area that's clearly on the root layer but not any of the child layers. - nsRefPtr hit = GetTargetAPZC(ScreenPoint(75, 25)); + RefPtr hit = GetTargetAPZC(ScreenPoint(75, 25)); EXPECT_EQ(apzcroot, hit.get()); EXPECT_EQ(Point(75, 25), transformToApzc * Point(75, 25)); EXPECT_EQ(Point(75, 25), transformToGecko * Point(75, 25)); @@ -2055,9 +2055,9 @@ TEST_F(APZCTreeManagerTester, Bug1068268) { ScopedLayerTreeRegistration registration(0, root, mcc); manager->UpdateHitTestingTree(nullptr, root, false, 0, 0); - nsRefPtr root = manager->GetRootNode(); - nsRefPtr node2 = root->GetFirstChild()->GetFirstChild(); - nsRefPtr node5 = root->GetLastChild()->GetLastChild(); + RefPtr root = manager->GetRootNode(); + RefPtr node2 = root->GetFirstChild()->GetFirstChild(); + RefPtr node5 = root->GetLastChild()->GetLastChild(); EXPECT_EQ(ApzcOf(layers[2]), node5->GetApzc()); EXPECT_EQ(ApzcOf(layers[2]), node2->GetApzc()); @@ -2126,16 +2126,16 @@ TEST_F(APZHitTestingTester, ComplexMultiLayerTree) { EXPECT_EQ(layers4_6_8, layer7->GetParent()); EXPECT_EQ(nullptr, layer9->GetParent()); // Ensure the hit-testing tree looks like the layer tree - nsRefPtr root = manager->GetRootNode(); - nsRefPtr node5 = root->GetLastChild(); - nsRefPtr node4 = node5->GetPrevSibling(); - nsRefPtr node2 = node4->GetPrevSibling(); - nsRefPtr node1 = node2->GetPrevSibling(); - nsRefPtr node3 = node2->GetLastChild(); - nsRefPtr node9 = node5->GetLastChild(); - nsRefPtr node8 = node9->GetPrevSibling(); - nsRefPtr node6 = node8->GetPrevSibling(); - nsRefPtr node7 = node6->GetLastChild(); + RefPtr root = manager->GetRootNode(); + RefPtr node5 = root->GetLastChild(); + RefPtr node4 = node5->GetPrevSibling(); + RefPtr node2 = node4->GetPrevSibling(); + RefPtr node1 = node2->GetPrevSibling(); + RefPtr node3 = node2->GetLastChild(); + RefPtr node9 = node5->GetLastChild(); + RefPtr node8 = node9->GetPrevSibling(); + RefPtr node6 = node8->GetPrevSibling(); + RefPtr node7 = node6->GetLastChild(); EXPECT_EQ(nullptr, node1->GetPrevSibling()); EXPECT_EQ(nullptr, node3->GetPrevSibling()); EXPECT_EQ(nullptr, node6->GetPrevSibling()); @@ -2147,7 +2147,7 @@ TEST_F(APZHitTestingTester, ComplexMultiLayerTree) { EXPECT_EQ(nullptr, node8->GetLastChild()); EXPECT_EQ(nullptr, node9->GetLastChild()); - nsRefPtr hit = GetTargetAPZC(ScreenPoint(25, 25)); + RefPtr hit = GetTargetAPZC(ScreenPoint(25, 25)); EXPECT_EQ(ApzcOf(layers[1]), hit.get()); hit = GetTargetAPZC(ScreenPoint(275, 375)); EXPECT_EQ(ApzcOf(layers[9]), hit.get()); @@ -2418,7 +2418,7 @@ TEST_F(APZOverscrollHandoffTester, LayerStructureChangesWhileEventsArePending) { // Modify the APZC tree to insert a new APZC 'middle' into the handoff chain // between the child and the root. CreateOverscrollHandoffLayerTree2(); - nsRefPtr middle = layers[1]; + RefPtr middle = layers[1]; childApzc->SetWaitForMainThread(); TestAsyncPanZoomController* middleApzc = ApzcOf(middle); @@ -2490,10 +2490,10 @@ TEST_F(APZOverscrollHandoffTester, SimultaneousFlings) { // Set up an initial APZC tree. CreateOverscrollHandoffLayerTree3(); - nsRefPtr parent1 = ApzcOf(layers[1]); - nsRefPtr child1 = ApzcOf(layers[2]); - nsRefPtr parent2 = ApzcOf(layers[3]); - nsRefPtr child2 = ApzcOf(layers[4]); + RefPtr parent1 = ApzcOf(layers[1]); + RefPtr child1 = ApzcOf(layers[2]); + RefPtr parent2 = ApzcOf(layers[3]); + RefPtr child2 = ApzcOf(layers[4]); // Pan on the lower child. int time = 0; @@ -2522,7 +2522,7 @@ TEST_F(APZOverscrollHandoffTester, Scrollgrab) { // Set up the layer tree CreateScrollgrabLayerTree(); - nsRefPtr childApzc = ApzcOf(layers[1]); + RefPtr childApzc = ApzcOf(layers[1]); // Pan on the child, enough to fully scroll the scrollgrab parent (20 px) // and leave some more (another 15 px) for the child. @@ -2538,7 +2538,7 @@ TEST_F(APZOverscrollHandoffTester, ScrollgrabFling) { // Set up the layer tree CreateScrollgrabLayerTree(); - nsRefPtr childApzc = ApzcOf(layers[1]); + RefPtr childApzc = ApzcOf(layers[1]); // Pan on the child, not enough to fully scroll the scrollgrab parent. int time = 0; @@ -2779,7 +2779,7 @@ TEST_F(APZEventRegionsTester, Obscuration) { ApzcPanNoFling(parent, time, 75, 25); HitTestResult result; - nsRefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 75), &result); + RefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 75), &result); EXPECT_EQ(child, hit.get()); EXPECT_EQ(HitTestResult::HitLayer, result); } @@ -2788,7 +2788,7 @@ TEST_F(APZEventRegionsTester, Bug1119497) { CreateBug1119497LayerTree(); HitTestResult result; - nsRefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 50), &result); + RefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 50), &result); // We should hit layers[2], so |result| will be HitLayer but there's no // actual APZC on layers[2], so it will be the APZC of the root layer. EXPECT_EQ(ApzcOf(layers[0]), hit.get()); diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index b02d920fc2..6133585adf 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -691,7 +691,7 @@ public: } private: - nsRefPtr mPresShell; + RefPtr mPresShell; uint64_t mInputBlockId; nsTArray mTargets; }; diff --git a/gfx/layers/apz/util/APZEventState.cpp b/gfx/layers/apz/util/APZEventState.cpp index 3e2203f417..4deb86e279 100644 --- a/gfx/layers/apz/util/APZEventState.cpp +++ b/gfx/layers/apz/util/APZEventState.cpp @@ -191,7 +191,7 @@ APZEventState::ProcessSingleTap(const CSSPoint& aPoint, APZES_LOG("Active element uses style, scheduling timer for click event\n"); nsCOMPtr timer = do_CreateInstance(NS_TIMER_CONTRACTID); - nsRefPtr callback = + RefPtr callback = new DelayedFireSingleTapEvent(mWidget, currentPoint, aModifiers, timer); nsresult rv = timer->InitWithCallback(callback, sActiveDurationMs, diff --git a/gfx/layers/apz/util/APZEventState.h b/gfx/layers/apz/util/APZEventState.h index 95257b4422..ca9b260d2f 100644 --- a/gfx/layers/apz/util/APZEventState.h +++ b/gfx/layers/apz/util/APZEventState.h @@ -13,7 +13,7 @@ #include "mozilla/EventForwards.h" #include "mozilla/Function.h" #include "mozilla/layers/GeckoContentController.h" // for APZStateChange -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsCOMPtr.h" #include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING #include "nsIWeakReferenceUtils.h" // for nsWeakPtr @@ -71,7 +71,7 @@ private: already_AddRefed GetWidget() const; private: nsWeakPtr mWidget; - nsRefPtr mActiveElementManager; + RefPtr mActiveElementManager; ContentReceivedInputBlockCallback mContentReceivedInputBlockCallback; bool mPendingTouchPreventedResponse; ScrollableLayerGuid mPendingTouchPreventedGuid; diff --git a/gfx/layers/apz/util/ChromeProcessController.h b/gfx/layers/apz/util/ChromeProcessController.h index 6580e1ec5b..ccfed2d1a9 100644 --- a/gfx/layers/apz/util/ChromeProcessController.h +++ b/gfx/layers/apz/util/ChromeProcessController.h @@ -8,7 +8,7 @@ #include "mozilla/layers/GeckoContentController.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" class nsIDOMWindowUtils; class nsIDocument; @@ -59,7 +59,7 @@ public: virtual void NotifyFlushComplete() override; private: nsCOMPtr mWidget; - nsRefPtr mAPZEventState; + RefPtr mAPZEventState; MessageLoop* mUILoop; void InitializeRoot(); diff --git a/gfx/layers/basic/BasicCanvasLayer.cpp b/gfx/layers/basic/BasicCanvasLayer.cpp index 6d4d977c34..72ae95a037 100644 --- a/gfx/layers/basic/BasicCanvasLayer.cpp +++ b/gfx/layers/basic/BasicCanvasLayer.cpp @@ -65,7 +65,7 @@ already_AddRefed BasicLayerManager::CreateCanvasLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicCanvasLayer(this); + RefPtr layer = new BasicCanvasLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/BasicColorLayer.cpp b/gfx/layers/basic/BasicColorLayer.cpp index f91de3d230..3281574be7 100644 --- a/gfx/layers/basic/BasicColorLayer.cpp +++ b/gfx/layers/basic/BasicColorLayer.cpp @@ -76,7 +76,7 @@ already_AddRefed BasicLayerManager::CreateColorLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicColorLayer(this); + RefPtr layer = new BasicColorLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index 7530af5a6a..9b4afa5bdd 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -160,7 +160,7 @@ already_AddRefed BasicLayerManager::CreateContainerLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicContainerLayer(this); + RefPtr layer = new BasicContainerLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/BasicImageLayer.cpp b/gfx/layers/basic/BasicImageLayer.cpp index ade40a758e..3023b6f641 100644 --- a/gfx/layers/basic/BasicImageLayer.cpp +++ b/gfx/layers/basic/BasicImageLayer.cpp @@ -69,7 +69,7 @@ BasicImageLayer::Paint(DrawTarget* aDT, return; } - nsRefPtr originalIF = mContainer->GetImageFactory(); + RefPtr originalIF = mContainer->GetImageFactory(); mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory()); AutoLockImage autoLock(mContainer); @@ -112,7 +112,7 @@ already_AddRefed BasicLayerManager::CreateImageLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicImageLayer(this); + RefPtr layer = new BasicImageLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/BasicImages.cpp b/gfx/layers/basic/BasicImages.cpp index 897c291268..e1cf5ee9a3 100644 --- a/gfx/layers/basic/BasicImages.cpp +++ b/gfx/layers/basic/BasicImages.cpp @@ -82,7 +82,7 @@ public: const gfx::IntSize &aScaleHint, BufferRecycleBin *aRecycleBin) { - nsRefPtr image; + RefPtr image; if (aFormat == ImageFormat::PLANAR_YCBCR) { image = new BasicPlanarYCbCrImage(aScaleHint, gfxPlatform::GetPlatform()->GetOffscreenFormat(), aRecycleBin); return image.forget(); diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 0f014bb332..e9ea650bab 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -90,7 +90,7 @@ BasicLayerManager::PushGroupForLayer(gfxContext* aContext, Layer* aLayer, // area first to minimize the size of the temporary surface. bool didCompleteClip = ClipToContain(aContext, aRegion.GetBounds()); - nsRefPtr result; + RefPtr result; if (aLayer->CanUseOpaqueSurface() && ((didCompleteClip && aRegion.GetNumRects() == 1) || !aContext->CurrentMatrix().HasNonIntegerTranslation())) { @@ -769,8 +769,8 @@ Transform3D(RefPtr aSource, aDestRect.RoundOut(); // Create a surface the size of the transformed object. - nsRefPtr dest = aDest->CurrentSurface(); - nsRefPtr destImage = new gfxImageSurface(IntSize(aDestRect.width, + RefPtr dest = aDest->CurrentSurface(); + RefPtr destImage = new gfxImageSurface(IntSize(aDestRect.width, aDestRect.height), gfxImageFormat::ARGB32); gfxPoint offset = aDestRect.TopLeft(); @@ -969,7 +969,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, if (is2D) { if (needsGroup) { - nsRefPtr groupTarget = PushGroupForLayer(aTarget, aLayer, aLayer->GetEffectiveVisibleRegion(), + RefPtr groupTarget = PushGroupForLayer(aTarget, aLayer, aLayer->GetEffectiveVisibleRegion(), &needsClipToVisibleRegion); PaintSelfOrChildren(paintLayerContext, groupTarget); aTarget->PopGroupToSource(); @@ -991,7 +991,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, return; } - nsRefPtr groupTarget = new gfxContext(untransformedDT, + RefPtr groupTarget = new gfxContext(untransformedDT, Point(bounds.x, bounds.y)); PaintSelfOrChildren(paintLayerContext, groupTarget); @@ -1007,13 +1007,13 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, (aLayer->GetDebugColorIndex() & 2) ? 1.f : 0.f, (aLayer->GetDebugColorIndex() & 4) ? 1.f : 0.f); - nsRefPtr temp = new gfxContext(untransformedDT, Point(bounds.x, bounds.y)); + RefPtr temp = new gfxContext(untransformedDT, Point(bounds.x, bounds.y)); temp->SetColor(color); temp->Paint(); } #endif Matrix4x4 effectiveTransform = aLayer->GetEffectiveTransform(); - nsRefPtr result = + RefPtr result = Transform3D(untransformedDT->Snapshot(), aTarget, bounds, effectiveTransform, destRect); @@ -1054,7 +1054,7 @@ already_AddRefed BasicLayerManager::CreateReadbackLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicReadbackLayer(this); + RefPtr layer = new BasicReadbackLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/BasicLayers.h b/gfx/layers/basic/BasicLayers.h index 4b3f378ea4..a80abddf0a 100644 --- a/gfx/layers/basic/BasicLayers.h +++ b/gfx/layers/basic/BasicLayers.h @@ -182,11 +182,11 @@ protected: // buffers. nsIWidget* mWidget; // The default context for BeginTransaction. - nsRefPtr mDefaultTarget; + RefPtr mDefaultTarget; // The context to draw into. - nsRefPtr mTarget; + RefPtr mTarget; // Image factory we use. - nsRefPtr mFactory; + RefPtr mFactory; BufferMode mDoubleBuffering; BasicLayerManagerType mType; diff --git a/gfx/layers/basic/BasicLayersImpl.h b/gfx/layers/basic/BasicLayersImpl.h index b1381e6598..2ce1616f05 100644 --- a/gfx/layers/basic/BasicLayersImpl.h +++ b/gfx/layers/basic/BasicLayersImpl.h @@ -42,7 +42,7 @@ public: } } private: - nsRefPtr mContext; + RefPtr mContext; }; class BasicReadbackLayer : public ReadbackLayer, diff --git a/gfx/layers/basic/BasicPaintedLayer.cpp b/gfx/layers/basic/BasicPaintedLayer.cpp index 8ce4d57ec5..a2d8fbf89b 100644 --- a/gfx/layers/basic/BasicPaintedLayer.cpp +++ b/gfx/layers/basic/BasicPaintedLayer.cpp @@ -79,7 +79,7 @@ BasicPaintedLayer::PaintThebes(gfxContext* aContext, bool needsGroup = opacity != 1.0 || effectiveOperator != CompositionOp::OP_OVER || aMaskLayer; - nsRefPtr groupContext; + RefPtr groupContext; if (needsGroup) { groupContext = BasicManager()->PushGroupForLayer(aContext, this, toDraw, @@ -181,7 +181,7 @@ BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback, RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds()); - nsRefPtr ctx = gfxContext::ContextForDrawTarget(target); + RefPtr ctx = gfxContext::ContextForDrawTarget(target); PaintBuffer(ctx, state.mRegionToDraw, state.mRegionToDraw, state.mRegionToInvalidate, state.mDidSelfCopy, @@ -204,7 +204,7 @@ BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback, for (uint32_t i = 0; i < readbackUpdates.Length(); ++i) { ReadbackProcessor::Update& update = readbackUpdates[i]; nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset(); - nsRefPtr ctx = + RefPtr ctx = update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset, update.mSequenceCounter); if (ctx) { @@ -222,7 +222,7 @@ already_AddRefed BasicLayerManager::CreatePaintedLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicPaintedLayer(this); + RefPtr layer = new BasicPaintedLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/TextureClientX11.cpp b/gfx/layers/basic/TextureClientX11.cpp index 3748177ef9..7865663512 100644 --- a/gfx/layers/basic/TextureClientX11.cpp +++ b/gfx/layers/basic/TextureClientX11.cpp @@ -119,7 +119,7 @@ TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aText return false; } gfxImageFormat imageFormat = SurfaceFormatToImageFormat(mFormat); - nsRefPtr surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, imageFormat); + RefPtr surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, imageFormat); if (!surface || surface->GetType() != gfxSurfaceType::Xlib) { NS_ERROR("creating Xlib surface failed!"); return false; diff --git a/gfx/layers/basic/X11BasicCompositor.cpp b/gfx/layers/basic/X11BasicCompositor.cpp index b3e98e6260..eaeb1d45c9 100644 --- a/gfx/layers/basic/X11BasicCompositor.cpp +++ b/gfx/layers/basic/X11BasicCompositor.cpp @@ -26,7 +26,7 @@ X11DataTextureSourceBasic::Update(gfx::DataSourceSurface* aSurface, (aSurface->GetSize() != mBufferDrawTarget->GetSize()) || (aSurface->GetFormat() != mBufferDrawTarget->GetFormat())) { - nsRefPtr surf; + RefPtr surf; gfxImageFormat imageFormat = SurfaceFormatToImageFormat(aSurface->GetFormat()); Display *display = DefaultXDisplay(); Screen *screen = DefaultScreenOfDisplay(display); diff --git a/gfx/layers/client/ClientCanvasLayer.cpp b/gfx/layers/client/ClientCanvasLayer.cpp index 0e1fcdf6c5..6334debb98 100644 --- a/gfx/layers/client/ClientCanvasLayer.cpp +++ b/gfx/layers/client/ClientCanvasLayer.cpp @@ -199,7 +199,7 @@ already_AddRefed ClientLayerManager::CreateCanvasLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = + RefPtr layer = new ClientCanvasLayer(this); CREATE_SHADOW(Canvas); return layer.forget(); diff --git a/gfx/layers/client/ClientColorLayer.cpp b/gfx/layers/client/ClientColorLayer.cpp index 932809ce03..9452b15d78 100644 --- a/gfx/layers/client/ClientColorLayer.cpp +++ b/gfx/layers/client/ClientColorLayer.cpp @@ -70,7 +70,7 @@ already_AddRefed ClientLayerManager::CreateColorLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = + RefPtr layer = new ClientColorLayer(this); CREATE_SHADOW(Color); return layer.forget(); diff --git a/gfx/layers/client/ClientContainerLayer.cpp b/gfx/layers/client/ClientContainerLayer.cpp index 4727287e53..5928cde580 100644 --- a/gfx/layers/client/ClientContainerLayer.cpp +++ b/gfx/layers/client/ClientContainerLayer.cpp @@ -17,7 +17,7 @@ already_AddRefed ClientLayerManager::CreateContainerLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = + RefPtr layer = new ClientContainerLayer(this); CREATE_SHADOW(Container); return layer.forget(); @@ -27,7 +27,7 @@ already_AddRefed ClientLayerManager::CreateRefLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = + RefPtr layer = new ClientRefLayer(this); CREATE_SHADOW(Ref); return layer.forget(); diff --git a/gfx/layers/client/ClientImageLayer.cpp b/gfx/layers/client/ClientImageLayer.cpp index bc92c4aac3..d3104fbead 100644 --- a/gfx/layers/client/ClientImageLayer.cpp +++ b/gfx/layers/client/ClientImageLayer.cpp @@ -165,7 +165,7 @@ already_AddRefed ClientLayerManager::CreateImageLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = + RefPtr layer = new ClientImageLayer(this); CREATE_SHADOW(Image); return layer.forget(); diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 9a58b32829..397704b248 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -171,7 +171,7 @@ ClientLayerManager::Mutated(Layer* aLayer) already_AddRefed ClientLayerManager::CreateReadbackLayer() { - nsRefPtr layer = new ClientReadbackLayer(this); + RefPtr layer = new ClientReadbackLayer(this); return layer.forget(); } @@ -190,7 +190,7 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) mPhase = PHASE_CONSTRUCTION; MOZ_ASSERT(mKeepAlive.IsEmpty(), "uncommitted txn?"); - nsRefPtr targetContext = aTarget; + RefPtr targetContext = aTarget; // If the last transaction was incomplete (a failed DoEmptyTransaction), // don't signal a new transaction to ShadowLayerForwarder. Carry on adding diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 9defd20bdf..a242ab1f3e 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -39,7 +39,7 @@ class TextureClientPool; class ClientLayerManager final : public LayerManager { - typedef nsTArray > LayerRefArray; + typedef nsTArray > LayerRefArray; public: explicit ClientLayerManager(nsIWidget* aWidget); @@ -321,9 +321,9 @@ private: // we send a message to our remote side to capture the actual pixels // being drawn to the default target, and then copy those pixels // back to mShadowTarget. - nsRefPtr mShadowTarget; + RefPtr mShadowTarget; - nsRefPtr mTransactionIdAllocator; + RefPtr mTransactionIdAllocator; uint64_t mLatestTransactionId; // Sometimes we draw to targets that don't natively support @@ -351,7 +351,7 @@ private: nsAutoTArray mOverfillCallbacks; mozilla::TimeStamp mTransactionStart; - nsRefPtr mMemoryPressureObserver; + RefPtr mMemoryPressureObserver; }; class ClientLayer : public ShadowableLayer diff --git a/gfx/layers/client/ClientPaintedLayer.cpp b/gfx/layers/client/ClientPaintedLayer.cpp index ac4e60e62a..69ed841d57 100644 --- a/gfx/layers/client/ClientPaintedLayer.cpp +++ b/gfx/layers/client/ClientPaintedLayer.cpp @@ -82,7 +82,7 @@ ClientPaintedLayer::PaintThebes() while (DrawTarget* target = mContentClient->BorrowDrawTargetForPainting(state, &iter)) { SetAntialiasingFlags(this, target); - nsRefPtr ctx = gfxContext::ContextForDrawTarget(target); + RefPtr ctx = gfxContext::ContextForDrawTarget(target); ClientManager()->GetPaintedLayerCallback()(this, ctx, @@ -159,11 +159,11 @@ ClientLayerManager::CreatePaintedLayerWithHint(PaintedLayerCreationHint aHint) AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D11) #endif ) { - nsRefPtr layer = new ClientTiledPaintedLayer(this, aHint); + RefPtr layer = new ClientTiledPaintedLayer(this, aHint); CREATE_SHADOW(Painted); return layer.forget(); } else { - nsRefPtr layer = new ClientPaintedLayer(this, aHint); + RefPtr layer = new ClientPaintedLayer(this, aHint); CREATE_SHADOW(Painted); return layer.forget(); } diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index cbe3f68b16..3e98eaf90c 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -184,7 +184,7 @@ public: continue; } - nsRefPtr ctx = + RefPtr ctx = sink->BeginUpdate(update.mUpdateRect + offset, update.mSequenceCounter); if (!ctx) { diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 719b03d335..f9029b551a 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -320,7 +320,7 @@ ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag already_AddRefed ImageClientSingle::CreateImage(ImageFormat aFormat) { - nsRefPtr img; + RefPtr img; switch (aFormat) { case ImageFormat::PLANAR_YCBCR: img = new SharedPlanarYCbCrImage(this); @@ -376,7 +376,7 @@ ImageClientOverlay::UpdateImage(ImageContainer* aContainer, uint32_t aContentFla already_AddRefed ImageClientOverlay::CreateImage(ImageFormat aFormat) { - nsRefPtr img; + RefPtr img; switch (aFormat) { case ImageFormat::OVERLAY_IMAGE: img = new OverlayImage(); diff --git a/gfx/layers/client/SingleTiledContentClient.cpp b/gfx/layers/client/SingleTiledContentClient.cpp index b6f64f80f9..b8096a05ff 100644 --- a/gfx/layers/client/SingleTiledContentClient.cpp +++ b/gfx/layers/client/SingleTiledContentClient.cpp @@ -191,7 +191,7 @@ ClientSingleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, } { - nsRefPtr ctx = new gfxContext(dt); + RefPtr ctx = new gfxContext(dt); ctx->SetMatrix(ctx->CurrentMatrix().Translate(-mTilingOrigin.x, -mTilingOrigin.y)); aCallback(mPaintedLayer, ctx, paintRegion, paintRegion, DrawRegionClip::DRAW, nsIntRegion(), aCallbackData); diff --git a/gfx/layers/client/SingleTiledContentClient.h b/gfx/layers/client/SingleTiledContentClient.h index be7f19b3f9..26dd109a49 100644 --- a/gfx/layers/client/SingleTiledContentClient.h +++ b/gfx/layers/client/SingleTiledContentClient.h @@ -131,7 +131,7 @@ public: virtual bool SupportsLayerSize(const IntSize& aSize, ClientLayerManager* aManager) const override; private: - nsRefPtr mTiledBuffer; + RefPtr mTiledBuffer; }; } diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index f85e913d83..a51cd8976f 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -91,7 +91,7 @@ class TextureChild final : public PTextureChild ~TextureChild() { if (mKeep && mMainThreadOnly && !NS_IsMainThread()) { - nsRefPtr release = new ReleaseKeepAlive(); + RefPtr release = new ReleaseKeepAlive(); release->mKeep = Move(mKeep); NS_DispatchToMainThread(release); } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 72f1116501..f7710db22a 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -580,7 +580,7 @@ public: } private: - mozilla::RefPtr mTextureClient; + RefPtr mTextureClient; }; /** diff --git a/gfx/layers/client/TextureClientPool.h b/gfx/layers/client/TextureClientPool.h index e4ec86632a..b08c9674ea 100644 --- a/gfx/layers/client/TextureClientPool.h +++ b/gfx/layers/client/TextureClientPool.h @@ -131,7 +131,7 @@ private: // Since JB, fence wait happens explicitly when fetching a client from the pool. std::stack > mTextureClients; std::stack > mTextureClientsDeferred; - nsRefPtr mTimer; + RefPtr mTimer; RefPtr mSurfaceAllocator; }; diff --git a/gfx/layers/client/TextureClientRecycleAllocator.cpp b/gfx/layers/client/TextureClientRecycleAllocator.cpp index d88b82ac3c..1a136b3f71 100644 --- a/gfx/layers/client/TextureClientRecycleAllocator.cpp +++ b/gfx/layers/client/TextureClientRecycleAllocator.cpp @@ -67,7 +67,7 @@ public: } private: - mozilla::RefPtr mTextureClient; + RefPtr mTextureClient; TextureFlags mFlags; }; diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 7020f3c56d..5217df0369 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -929,7 +929,7 @@ ClientMultiTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, NS_ASSERTION(!aPaintRegion.GetBounds().IsEmpty(), "Empty paint region\n"); if (!gfxPrefs::TiledDrawTargetEnabled()) { - nsRefPtr ctxt; + RefPtr ctxt; const IntRect bounds = aPaintRegion.GetBounds(); { diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index ade863f1b1..0e7284a765 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -118,7 +118,7 @@ public: static already_AddRefed Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::layers::ShmemSection& aShmemSection) { - nsRefPtr readLock = new gfxShmSharedReadLock(aAllocator, aShmemSection); + RefPtr readLock = new gfxShmSharedReadLock(aAllocator, aShmemSection); return readLock.forget(); } diff --git a/gfx/layers/composite/AsyncCompositionManager.h b/gfx/layers/composite/AsyncCompositionManager.h index 4432b125bd..df6590e7cf 100644 --- a/gfx/layers/composite/AsyncCompositionManager.h +++ b/gfx/layers/composite/AsyncCompositionManager.h @@ -16,7 +16,7 @@ #include "mozilla/gfx/Matrix.h" // for Matrix4x4 #include "mozilla/layers/FrameUniformityData.h" // For FrameUniformityData #include "mozilla/layers/LayersMessages.h" // for TargetConfig -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for LayerManager::AddRef, etc namespace mozilla { @@ -200,7 +200,7 @@ private: TargetConfig mTargetConfig; CSSRect mContentRect; - nsRefPtr mLayerManager; + RefPtr mLayerManager; // When this flag is set, the next composition will be the first for a // particular document (i.e. the document displayed on the screen will change). // This happens when loading a new page or switching tabs. We notify the diff --git a/gfx/layers/composite/CanvasLayerComposite.cpp b/gfx/layers/composite/CanvasLayerComposite.cpp index 8734a4aaf6..daab686554 100644 --- a/gfx/layers/composite/CanvasLayerComposite.cpp +++ b/gfx/layers/composite/CanvasLayerComposite.cpp @@ -14,7 +14,7 @@ #include "mozilla/layers/Effects.h" // for EffectChain #include "mozilla/mozalloc.h" // for operator delete #include "nsAString.h" -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsString.h" // for nsAutoCString #include "gfxVR.h" diff --git a/gfx/layers/composite/CompositableHost.cpp b/gfx/layers/composite/CompositableHost.cpp index 3e77cfed4c..23929c926e 100644 --- a/gfx/layers/composite/CompositableHost.cpp +++ b/gfx/layers/composite/CompositableHost.cpp @@ -14,7 +14,7 @@ #include "mozilla/layers/ImageContainerParent.h" #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor #include "mozilla/layers/TextureHost.h" // for TextureHost, etc -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsDebug.h" // for NS_WARNING #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "gfxPlatform.h" // for gfxPlatform diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 20f14f840a..661fb3ec74 100755 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -24,7 +24,7 @@ #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper #include "mozilla/mozalloc.h" // for operator delete, etc -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE @@ -707,7 +707,7 @@ ContainerRender(ContainerT* aContainer, } gfx::Rect visibleRect(aContainer->GetEffectiveVisibleRegion().GetBounds()); - nsRefPtr compositor = aManager->GetCompositor(); + RefPtr compositor = aManager->GetCompositor(); #ifdef MOZ_DUMP_PAINTING if (gfxUtils::sDumpPainting) { RefPtr surf = surface->Dump(compositor); @@ -717,7 +717,7 @@ ContainerRender(ContainerT* aContainer, } #endif - nsRefPtr container = aContainer; + RefPtr container = aContainer; RenderWithAllMasks(aContainer, compositor, aClipRect, [&, surface, compositor, container](EffectChain& effectChain, const Rect& clipRect) { effectChain.mPrimaryEffect = new EffectRenderTarget(surface); diff --git a/gfx/layers/composite/ContainerLayerComposite.h b/gfx/layers/composite/ContainerLayerComposite.h index ec506022a4..141815136b 100644 --- a/gfx/layers/composite/ContainerLayerComposite.h +++ b/gfx/layers/composite/ContainerLayerComposite.h @@ -182,7 +182,7 @@ public: virtual const char* Name() const override { return "RefLayerComposite"; } UniquePtr mPrepared; RefPtr mLastIntermediateSurface; - nsRefPtr mVRRenderTargetSet; + RefPtr mVRRenderTargetSet; }; } // namespace layers diff --git a/gfx/layers/composite/ImageLayerComposite.cpp b/gfx/layers/composite/ImageLayerComposite.cpp index 2e3ee0619b..a0d3c5d50a 100644 --- a/gfx/layers/composite/ImageLayerComposite.cpp +++ b/gfx/layers/composite/ImageLayerComposite.cpp @@ -18,7 +18,7 @@ #include "mozilla/layers/TextureHost.h" // for TextureHost, etc #include "mozilla/mozalloc.h" // for operator delete #include "nsAString.h" -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsString.h" // for nsAutoCString diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 740a56bc3b..2241b6a930 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -44,7 +44,7 @@ #include "ipc/ShadowLayerUtils.h" #include "mozilla/mozalloc.h" // for operator new, etc #include "nsAppRunner.h" -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_WARNING, NS_RUNTIMEABORT, etc #include "nsISupportsImpl.h" // for Layer::AddRef, etc @@ -336,7 +336,7 @@ LayerManagerComposite::CreatePaintedLayer() { MOZ_ASSERT(gIsGtest, "Unless you're testing the compositor using GTest," "this should only be called on the drawing side"); - nsRefPtr layer = new PaintedLayerComposite(this); + RefPtr layer = new PaintedLayerComposite(this); return layer.forget(); } @@ -345,7 +345,7 @@ LayerManagerComposite::CreateContainerLayer() { MOZ_ASSERT(gIsGtest, "Unless you're testing the compositor using GTest," "this should only be called on the drawing side"); - nsRefPtr layer = new ContainerLayerComposite(this); + RefPtr layer = new ContainerLayerComposite(this); return layer.forget(); } @@ -361,7 +361,7 @@ LayerManagerComposite::CreateColorLayer() { MOZ_ASSERT(gIsGtest, "Unless you're testing the compositor using GTest," "this should only be called on the drawing side"); - nsRefPtr layer = new ColorLayerComposite(this); + RefPtr layer = new ColorLayerComposite(this); return layer.forget(); } @@ -654,7 +654,7 @@ LayerManagerComposite::Render() } /** Our more efficient but less powerful alter ego, if one is available. */ - nsRefPtr composer2D; + RefPtr composer2D; composer2D = mCompositor->GetWidget()->GetComposer2D(); // We can't use composert2D if we have layer effects @@ -905,7 +905,7 @@ LayerManagerComposite::RenderToPresentationSurface() EGLSurface surface = mirrorScreen->GetEGLSurface(); if (surface == LOCAL_EGL_NO_SURFACE) { // Create GLContext - nsRefPtr gl = gl::GLContextProvider::CreateForWindow(mirrorScreenWidget); + RefPtr gl = gl::GLContextProvider::CreateForWindow(mirrorScreenWidget); mirrorScreenWidget->SetNativeData(NS_NATIVE_OPENGL_CONTEXT, reinterpret_cast(gl.get())); surface = mirrorScreen->GetEGLSurface(); @@ -986,7 +986,7 @@ LayerManagerComposite::RenderToPresentationSurface() mCompositor->SetDispAcquireFence(mRoot, mirrorScreenWidget); // Call after EndFrame() - nsRefPtr composer2D; + RefPtr composer2D; composer2D = mCompositor->GetWidget()->GetComposer2D(); if (composer2D) { composer2D->Render(mirrorScreenWidget); @@ -1216,7 +1216,7 @@ LayerManagerComposite::CreatePaintedLayerComposite() NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new PaintedLayerComposite(this)).forget(); + return RefPtr(new PaintedLayerComposite(this)).forget(); } already_AddRefed @@ -1226,7 +1226,7 @@ LayerManagerComposite::CreateContainerLayerComposite() NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new ContainerLayerComposite(this)).forget(); + return RefPtr(new ContainerLayerComposite(this)).forget(); } already_AddRefed @@ -1236,7 +1236,7 @@ LayerManagerComposite::CreateImageLayerComposite() NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new ImageLayerComposite(this)).forget(); + return RefPtr(new ImageLayerComposite(this)).forget(); } already_AddRefed @@ -1246,7 +1246,7 @@ LayerManagerComposite::CreateColorLayerComposite() NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new ColorLayerComposite(this)).forget(); + return RefPtr(new ColorLayerComposite(this)).forget(); } already_AddRefed @@ -1256,7 +1256,7 @@ LayerManagerComposite::CreateCanvasLayerComposite() NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new CanvasLayerComposite(this)).forget(); + return RefPtr(new CanvasLayerComposite(this)).forget(); } already_AddRefed @@ -1266,7 +1266,7 @@ LayerManagerComposite::CreateRefLayerComposite() NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new RefLayerComposite(this)).forget(); + return RefPtr(new RefLayerComposite(this)).forget(); } LayerManagerComposite::AutoAddMaskEffect::AutoAddMaskEffect(Layer* aMaskLayer, diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index 20e80dccf5..711dc9b8b3 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -25,7 +25,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/UniquePtr.h" #include "nsAString.h" -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for Layer::AddRef, etc diff --git a/gfx/layers/composite/PaintedLayerComposite.cpp b/gfx/layers/composite/PaintedLayerComposite.cpp index 79cd7368fa..33e9e7a393 100644 --- a/gfx/layers/composite/PaintedLayerComposite.cpp +++ b/gfx/layers/composite/PaintedLayerComposite.cpp @@ -18,7 +18,7 @@ #include "mozilla/layers/Effects.h" // for EffectChain #include "mozilla/mozalloc.h" // for operator delete #include "nsAString.h" -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsMathUtils.h" // for NS_lround #include "nsString.h" // for nsAutoCString diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 1dd02a2e45..42e9294b93 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -17,7 +17,7 @@ #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL #include "mozilla/layers/YCbCrImageDataSerializer.h" #include "nsAString.h" -#include "mozilla/nsRefPtr.h" // for nsRefPtr +#include "mozilla/RefPtr.h" // for nsRefPtr #include "nsPrintfCString.h" // for nsPrintfCString #include "mozilla/layers/PTextureParent.h" #include "mozilla/unused.h" @@ -174,7 +174,7 @@ TextureHost::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle) FenceHandle TextureHost::GetAndResetAcquireFenceHandle() { - nsRefPtr fdObj = mAcquireFenceHandle.GetAndResetFdObj(); + RefPtr fdObj = mAcquireFenceHandle.GetAndResetFdObj(); return FenceHandle(fdObj); } diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 3093276ceb..b51c9c478b 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -144,7 +144,7 @@ bool GetCopyOnWriteLock(const TileLock& ipcLock, TileHost& aTile, ISurfaceAllocator* aAllocator) { MOZ_ASSERT(aAllocator); - nsRefPtr sharedLock; + RefPtr sharedLock; if (ipcLock.type() == TileLock::TShmemSection) { sharedLock = gfxShmSharedReadLock::Open(aAllocator, ipcLock.get_ShmemSection()); } else { diff --git a/gfx/layers/composite/X11TextureHost.cpp b/gfx/layers/composite/X11TextureHost.cpp index 614510740e..58702780db 100644 --- a/gfx/layers/composite/X11TextureHost.cpp +++ b/gfx/layers/composite/X11TextureHost.cpp @@ -22,7 +22,7 @@ X11TextureHost::X11TextureHost(TextureFlags aFlags, const SurfaceDescriptorX11& aDescriptor) : TextureHost(aFlags) { - nsRefPtr surface = aDescriptor.OpenForeign(); + RefPtr surface = aDescriptor.OpenForeign(); mSurface = surface.get(); if (!(aFlags & TextureFlags::DEALLOCATE_CLIENT)) { diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 8c3aaad8bd..130e6832a1 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -108,10 +108,10 @@ struct DeviceAttachmentsD3D11 private: void InitVertexShader(const ShaderBytes& aShader, VertexShaderArray& aArray, MaskType aMaskType) { - InitVertexShader(aShader, byRef(aArray[aMaskType])); + InitVertexShader(aShader, getter_AddRefs(aArray[aMaskType])); } void InitPixelShader(const ShaderBytes& aShader, PixelShaderArray& aArray, MaskType aMaskType) { - InitPixelShader(aShader, byRef(aArray[aMaskType])); + InitPixelShader(aShader, getter_AddRefs(aArray[aMaskType])); } void InitVertexShader(const ShaderBytes& aShader, ID3D11VertexShader** aOut) { if (!mInitOkay) { @@ -194,7 +194,7 @@ CompositorD3D11::Initialize() return false; } - mDevice->GetImmediateContext(byRef(mContext)); + mDevice->GetImmediateContext(getter_AddRefs(mContext)); if (!mContext) { gfxCriticalError(CriticalLog::DefaultOptions(false)) @@ -235,7 +235,7 @@ CompositorD3D11::Initialize() sizeof(layout) / sizeof(D3D11_INPUT_ELEMENT_DESC), LayerQuadVS, sizeof(LayerQuadVS), - byRef(mAttachments->mInputLayout)); + getter_AddRefs(mAttachments->mInputLayout)); if (Failed(hr, "CreateInputLayout")) { return false; @@ -246,7 +246,7 @@ CompositorD3D11::Initialize() D3D11_SUBRESOURCE_DATA data; data.pSysMem = (void*)vertices; - hr = mDevice->CreateBuffer(&bufferDesc, &data, byRef(mAttachments->mVertexBuffer)); + hr = mDevice->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mAttachments->mVertexBuffer)); if (Failed(hr, "create vertex buffer")) { return false; @@ -261,13 +261,13 @@ CompositorD3D11::Initialize() D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE); - hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, byRef(mAttachments->mVSConstantBuffer)); + hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mAttachments->mVSConstantBuffer)); if (Failed(hr, "create vs buffer")) { return false; } cBufferDesc.ByteWidth = sizeof(PixelShaderConstants); - hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, byRef(mAttachments->mPSConstantBuffer)); + hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mAttachments->mPSConstantBuffer)); if (Failed(hr, "create ps buffer")) { return false; } @@ -276,19 +276,19 @@ CompositorD3D11::Initialize() rastDesc.CullMode = D3D11_CULL_NONE; rastDesc.ScissorEnable = TRUE; - hr = mDevice->CreateRasterizerState(&rastDesc, byRef(mAttachments->mRasterizerState)); + hr = mDevice->CreateRasterizerState(&rastDesc, getter_AddRefs(mAttachments->mRasterizerState)); if (Failed(hr, "create rasterizer")) { return false; } CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT); - hr = mDevice->CreateSamplerState(&samplerDesc, byRef(mAttachments->mLinearSamplerState)); + hr = mDevice->CreateSamplerState(&samplerDesc, getter_AddRefs(mAttachments->mLinearSamplerState)); if (Failed(hr, "create linear sampler")) { return false; } samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; - hr = mDevice->CreateSamplerState(&samplerDesc, byRef(mAttachments->mPointSamplerState)); + hr = mDevice->CreateSamplerState(&samplerDesc, getter_AddRefs(mAttachments->mPointSamplerState)); if (Failed(hr, "create point sampler")) { return false; } @@ -301,7 +301,7 @@ CompositorD3D11::Initialize() D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendPremul; - hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mPremulBlendState)); + hr = mDevice->CreateBlendState(&blendDesc, getter_AddRefs(mAttachments->mPremulBlendState)); if (Failed(hr, "create pm blender")) { return false; } @@ -313,7 +313,7 @@ CompositorD3D11::Initialize() D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendMultiplyPremul; - hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mPremulBlendMultiplyState)); + hr = mDevice->CreateBlendState(&blendDesc, getter_AddRefs(mAttachments->mPremulBlendMultiplyState)); if (Failed(hr, "create pm-mul blender")) { return false; } @@ -325,7 +325,7 @@ CompositorD3D11::Initialize() D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendScreenPremul; - hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mPremulBlendScreenState)); + hr = mDevice->CreateBlendState(&blendDesc, getter_AddRefs(mAttachments->mPremulBlendScreenState)); if (Failed(hr, "create pm-scn blender")) { return false; } @@ -337,7 +337,7 @@ CompositorD3D11::Initialize() D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendNonPremul; - hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mNonPremulBlendState)); + hr = mDevice->CreateBlendState(&blendDesc, getter_AddRefs(mAttachments->mNonPremulBlendState)); if (Failed(hr, "create npm blender")) { return false; } @@ -354,7 +354,7 @@ CompositorD3D11::Initialize() D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendComponent; - hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mComponentBlendState)); + hr = mDevice->CreateBlendState(&blendDesc, getter_AddRefs(mAttachments->mComponentBlendState)); if (Failed(hr, "create component blender")) { return false; } @@ -367,7 +367,7 @@ CompositorD3D11::Initialize() D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendDisabled; - hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mDisabledBlendState)); + hr = mDevice->CreateBlendState(&blendDesc, getter_AddRefs(mAttachments->mDisabledBlendState)); if (Failed(hr, "create null blender")) { return false; } @@ -392,27 +392,27 @@ CompositorD3D11::Initialize() sizeof(vrlayout) / sizeof(D3D11_INPUT_ELEMENT_DESC), Oculus050VRDistortionVS, sizeof(Oculus050VRDistortionVS), - byRef(mAttachments->mVRDistortionInputLayout[VRHMDType::Oculus050])); + getter_AddRefs(mAttachments->mVRDistortionInputLayout[VRHMDType::Oculus050])); // XXX shared for now, rename mAttachments->mVRDistortionInputLayout[VRHMDType::Cardboard] = mAttachments->mVRDistortionInputLayout[VRHMDType::Oculus050]; cBufferDesc.ByteWidth = sizeof(gfx::VRDistortionConstants); - hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, byRef(mAttachments->mVRDistortionConstants)); + hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mAttachments->mVRDistortionConstants)); if (Failed(hr, "create vr buffer ")) { return false; } } - nsRefPtr dxgiDevice; - nsRefPtr dxgiAdapter; + RefPtr dxgiDevice; + RefPtr dxgiAdapter; mDevice->QueryInterface(dxgiDevice.StartAssignment()); dxgiDevice->GetAdapter(getter_AddRefs(dxgiAdapter)); { - nsRefPtr dxgiFactory; + RefPtr dxgiFactory; dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment())); DXGI_SWAP_CHAIN_DESC swapDesc; @@ -437,7 +437,7 @@ CompositorD3D11::Initialize() * the window we draw to. The front buffer is the full screen front * buffer. */ - hr = dxgiFactory->CreateSwapChain(dxgiDevice, &swapDesc, byRef(mSwapChain)); + hr = dxgiFactory->CreateSwapChain(dxgiDevice, &swapDesc, getter_AddRefs(mSwapChain)); if (Failed(hr, "create swap chain")) { return false; } @@ -508,7 +508,7 @@ CompositorD3D11::CreateRenderTarget(const gfx::IntRect& aRect, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET); RefPtr texture; - HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); + HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture)); if (Failed(hr) || !texture) { gfxCriticalError(gfxCriticalError::DefaultOptions(false)) << "Failed in CreateRenderTarget"; return nullptr; @@ -541,7 +541,7 @@ CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET); RefPtr texture; - HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); + HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture)); NS_ASSERTION(texture, "Could not create texture"); if (Failed(hr) || !texture) { gfxCriticalError(gfxCriticalError::DefaultOptions(false)) << "Failed in CreateRenderTargetFromSource"; @@ -713,7 +713,7 @@ CompositorD3D11::DrawVRDistortion(const gfx::Rect& aRect, desc.ByteWidth = mesh.mVertices.Length() * sizeof(gfx::VRDistortionVertex); sdata.pSysMem = mesh.mVertices.Elements(); - hr = mDevice->CreateBuffer(&desc, &sdata, byRef(mAttachments->mVRDistortionVertices[eye])); + hr = mDevice->CreateBuffer(&desc, &sdata, getter_AddRefs(mAttachments->mVRDistortionVertices[eye])); if (FAILED(hr)) { NS_WARNING("CreateBuffer failed"); return; @@ -723,7 +723,7 @@ CompositorD3D11::DrawVRDistortion(const gfx::Rect& aRect, desc.ByteWidth = mesh.mIndices.Length() * sizeof(uint16_t); sdata.pSysMem = mesh.mIndices.Elements(); - hr = mDevice->CreateBuffer(&desc, &sdata, byRef(mAttachments->mVRDistortionIndices[eye])); + hr = mDevice->CreateBuffer(&desc, &sdata, getter_AddRefs(mAttachments->mVRDistortionIndices[eye])); if (FAILED(hr)) { NS_WARNING("CreateBuffer failed"); return; @@ -1147,7 +1147,7 @@ CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion, if (mAttachments->mSyncTexture) { RefPtr mutex; - mAttachments->mSyncTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + mAttachments->mSyncTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); MOZ_ASSERT(mutex); HRESULT hr = mutex->AcquireSync(0, 10000); @@ -1185,7 +1185,7 @@ CompositorD3D11::EndFrame() if (oldSize == mSize) { RefPtr chain; - HRESULT hr = mSwapChain->QueryInterface((IDXGISwapChain1**)byRef(chain)); + HRESULT hr = mSwapChain->QueryInterface((IDXGISwapChain1**)getter_AddRefs(chain)); if (SUCCEEDED(hr) && chain) { DXGI_PRESENT_PARAMETERS params; PodZero(¶ms); @@ -1317,7 +1317,7 @@ CompositorD3D11::UpdateRenderTarget() HRESULT hr; - nsRefPtr backBuf; + RefPtr backBuf; hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)backBuf.StartAssignment()); if (hr == DXGI_ERROR_INVALID_CALL) { @@ -1352,12 +1352,12 @@ DeviceAttachmentsD3D11::InitSyncObject() desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; RefPtr texture; - HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); + HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture)); if (Failed(hr, "create sync texture")) { return false; } - hr = texture->QueryInterface((IDXGIResource**)byRef(mSyncTexture)); + hr = texture->QueryInterface((IDXGIResource**)getter_AddRefs(mSyncTexture)); if (Failed(hr, "QI sync texture")) { return false; } @@ -1396,8 +1396,8 @@ DeviceAttachmentsD3D11::CreateShaders() InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, MaskType::Mask2d); } - InitVertexShader(sOculus050VRDistortionVS, byRef(mVRDistortionVS[VRHMDType::Oculus050])); - InitPixelShader(sOculus050VRDistortionPS, byRef(mVRDistortionPS[VRHMDType::Oculus050])); + InitVertexShader(sOculus050VRDistortionVS, getter_AddRefs(mVRDistortionVS[VRHMDType::Oculus050])); + InitPixelShader(sOculus050VRDistortionPS, getter_AddRefs(mVRDistortionPS[VRHMDType::Oculus050])); // These are shared // XXX rename Oculus050 shaders to something more generic @@ -1459,7 +1459,7 @@ CompositorD3D11::SetSamplerForFilter(Filter aFilter) void CompositorD3D11::PaintToTarget() { - nsRefPtr backBuf; + RefPtr backBuf; HRESULT hr; hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)backBuf.StartAssignment()); @@ -1477,7 +1477,7 @@ CompositorD3D11::PaintToTarget() softDesc.Usage = D3D11_USAGE_STAGING; softDesc.BindFlags = 0; - nsRefPtr readTexture; + RefPtr readTexture; hr = mDevice->CreateTexture2D(&softDesc, nullptr, getter_AddRefs(readTexture)); if (Failed(hr)) { diff --git a/gfx/layers/d3d11/ReadbackManagerD3D11.cpp b/gfx/layers/d3d11/ReadbackManagerD3D11.cpp index 28d7f5146d..27c664fb9e 100644 --- a/gfx/layers/d3d11/ReadbackManagerD3D11.cpp +++ b/gfx/layers/d3d11/ReadbackManagerD3D11.cpp @@ -24,7 +24,7 @@ namespace layers { // destroyed on the main thread! struct ReadbackTask { // The texture that we copied the contents of the paintedlayer to. - nsRefPtr mReadbackTexture; + RefPtr mReadbackTexture; // The sink that we're trying to read back to. RefPtr mSink; }; diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 4ca5ec8674..d09b485d43 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -72,8 +72,8 @@ TextureSourceD3D11::GetShaderResourceView() if (!mSRV && mTexture) { RefPtr device; - mTexture->GetDevice(byRef(device)); - HRESULT hr = device->CreateShaderResourceView(mTexture, nullptr, byRef(mSRV)); + mTexture->GetDevice(getter_AddRefs(device)); + HRESULT hr = device->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRV)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(false)) << "[D3D11] TextureSourceD3D11:GetShaderResourceView CreateSRV failure " << gfx::hexa(hr); return nullptr; @@ -127,7 +127,7 @@ static bool LockD3DTexture(T* aTexture) { MOZ_ASSERT(aTexture); RefPtr mutex; - aTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + aTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); // Textures created by the DXVA decoders don't have a mutex for synchronization if (mutex) { HRESULT hr = mutex->AcquireSync(0, 10000); @@ -148,7 +148,7 @@ static void UnlockD3DTexture(T* aTexture) { MOZ_ASSERT(aTexture); RefPtr mutex; - aTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + aTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); if (mutex) { HRESULT hr = mutex->ReleaseSync(0); if (FAILED(hr)) { @@ -379,7 +379,7 @@ TextureClientD3D11::Unlock() desc.MiscFlags = 0; RefPtr tex; - HRESULT hr = device->CreateTexture2D(&desc, nullptr, byRef(tex)); + HRESULT hr = device->CreateTexture2D(&desc, nullptr, getter_AddRefs(tex)); if (SUCCEEDED(hr)) { device->CopyResource(tex, mTexture10); @@ -458,9 +458,9 @@ TextureClientD3D11::UpdateFromSurface(gfx::SourceSurface* aSurface) if (mTexture) { RefPtr device; - mTexture->GetDevice(byRef(device)); + mTexture->GetDevice(getter_AddRefs(device)); RefPtr ctx; - device->GetImmediateContext(byRef(ctx)); + device->GetImmediateContext(getter_AddRefs(ctx)); D3D11_BOX box; box.front = 0; @@ -472,7 +472,7 @@ TextureClientD3D11::UpdateFromSurface(gfx::SourceSurface* aSurface) ctx->UpdateSubresource(mTexture, 0, &box, sourceMap.mData, sourceMap.mStride, 0); } else { RefPtr device; - mTexture10->GetDevice(byRef(device)); + mTexture10->GetDevice(getter_AddRefs(device)); D3D10_BOX box; box.front = 0; @@ -550,7 +550,7 @@ TextureClientD3D11::AllocateD3D11Surface(ID3D11Device* aDevice, const gfx::IntSi newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; } - HRESULT hr = aDevice->CreateTexture2D(&newDesc, nullptr, byRef(mTexture)); + HRESULT hr = aDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(mTexture)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "[D3D11] 2 CreateTexture2D failure " << aSize << " Code: " << gfx::hexa(hr); return false; @@ -595,7 +595,7 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag newDesc.MiscFlags = D3D10_RESOURCE_MISC_SHARED; - hr = device->CreateTexture2D(&newDesc, nullptr, byRef(mTexture10)); + hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(mTexture10)); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "[D3D10] 2 CreateTexture2D failure " << aSize << " Code: " << gfx::hexa(hr); return false; @@ -622,9 +622,9 @@ TextureClientD3D11::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) } RefPtr resource; if (mTexture) { - mTexture->QueryInterface((IDXGIResource**)byRef(resource)); + mTexture->QueryInterface((IDXGIResource**)getter_AddRefs(resource)); } else { - mTexture10->QueryInterface((IDXGIResource**)byRef(resource)); + mTexture10->QueryInterface((IDXGIResource**)getter_AddRefs(resource)); } HANDLE sharedHandle; @@ -752,7 +752,7 @@ DXGITextureHostD3D11::OpenSharedHandle() HRESULT hr = GetDevice()->OpenSharedResource((HANDLE)mHandle, __uuidof(ID3D11Texture2D), - (void**)(ID3D11Texture2D**)byRef(mTexture)); + (void**)(ID3D11Texture2D**)getter_AddRefs(mTexture)); if (FAILED(hr)) { NS_WARNING("Failed to open shared texture"); return false; @@ -835,7 +835,7 @@ DXGIYCbCrTextureHostD3D11::OpenSharedHandle() HRESULT hr = GetDevice()->OpenSharedResource((HANDLE)mHandles[0], __uuidof(ID3D11Texture2D), - (void**)(ID3D11Texture2D**)byRef(mTextures[0])); + (void**)(ID3D11Texture2D**)getter_AddRefs(mTextures[0])); if (FAILED(hr)) { NS_WARNING("Failed to open shared texture for Y Plane"); return false; @@ -843,7 +843,7 @@ DXGIYCbCrTextureHostD3D11::OpenSharedHandle() hr = GetDevice()->OpenSharedResource((HANDLE)mHandles[1], __uuidof(ID3D11Texture2D), - (void**)(ID3D11Texture2D**)byRef(mTextures[1])); + (void**)(ID3D11Texture2D**)getter_AddRefs(mTextures[1])); if (FAILED(hr)) { NS_WARNING("Failed to open shared texture for Cb Plane"); return false; @@ -851,7 +851,7 @@ DXGIYCbCrTextureHostD3D11::OpenSharedHandle() hr = GetDevice()->OpenSharedResource((HANDLE)mHandles[2], __uuidof(ID3D11Texture2D), - (void**)(ID3D11Texture2D**)byRef(mTextures[2])); + (void**)(ID3D11Texture2D**)getter_AddRefs(mTextures[2])); if (FAILED(hr)) { NS_WARNING("Failed to open shared texture for Cr Plane"); return false; @@ -961,7 +961,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface, } if (!mTexture) { - hr = mCompositor->GetDevice()->CreateTexture2D(&desc, nullptr, byRef(mTexture)); + hr = mCompositor->GetDevice()->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture)); mIsTiled = false; if (FAILED(hr) || !mTexture) { Reset(); @@ -1020,7 +1020,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface, tileRect.x * bpp; initData.SysMemPitch = aSurface->Stride(); - hr = mCompositor->GetDevice()->CreateTexture2D(&desc, &initData, byRef(mTileTextures[i])); + hr = mCompositor->GetDevice()->CreateTexture2D(&desc, &initData, getter_AddRefs(mTileTextures[i])); if (FAILED(hr) || !mTileTextures[i]) { Reset(); return false; @@ -1047,8 +1047,8 @@ DataTextureSourceD3D11::GetShaderResourceView() } RefPtr device; - mTileTextures[mCurrentTile]->GetDevice(byRef(device)); - HRESULT hr = device->CreateShaderResourceView(mTileTextures[mCurrentTile], nullptr, byRef(mTileSRVs[mCurrentTile])); + mTileTextures[mCurrentTile]->GetDevice(getter_AddRefs(device)); + HRESULT hr = device->CreateShaderResourceView(mTileTextures[mCurrentTile], nullptr, getter_AddRefs(mTileSRVs[mCurrentTile])); if (FAILED(hr)) { gfxCriticalError(CriticalLog::DefaultOptions(false)) << "[D3D11] DataTextureSourceD3D11:GetShaderResourceView CreateSRV failure " << gfx::hexa(hr); return nullptr; @@ -1104,9 +1104,9 @@ CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTex mTexture = aTexture; RefPtr device; - mTexture->GetDevice(byRef(device)); + mTexture->GetDevice(getter_AddRefs(device)); - HRESULT hr = device->CreateRenderTargetView(mTexture, nullptr, byRef(mRTView)); + HRESULT hr = device->CreateRenderTargetView(mTexture, nullptr, getter_AddRefs(mRTView)); if (FAILED(hr)) { LOGD3D11("Failed to create RenderTargetView."); @@ -1158,7 +1158,7 @@ SyncObjectD3D11::FinalizeFrame() if (!mD3D10Texture && mD3D10SyncedTextures.size()) { ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); - hr = device->OpenSharedResource(mHandle, __uuidof(ID3D10Texture2D), (void**)(ID3D10Texture2D**)byRef(mD3D10Texture)); + hr = device->OpenSharedResource(mHandle, __uuidof(ID3D10Texture2D), (void**)(ID3D10Texture2D**)getter_AddRefs(mD3D10Texture)); if (FAILED(hr) || !mD3D10Texture) { gfxCriticalError() << "Failed to D3D10 OpenSharedResource for frame finalization: " << hexa(hr); @@ -1172,7 +1172,7 @@ SyncObjectD3D11::FinalizeFrame() // test QI RefPtr mutex; - hr = mD3D10Texture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + hr = mD3D10Texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); if (FAILED(hr) || !mutex) { gfxCriticalError() << "Failed to get KeyedMutex: " << hexa(hr); @@ -1183,7 +1183,7 @@ SyncObjectD3D11::FinalizeFrame() if (!mD3D11Texture && mD3D11SyncedTextures.size()) { ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice(); - hr = device->OpenSharedResource(mHandle, __uuidof(ID3D11Texture2D), (void**)(ID3D11Texture2D**)byRef(mD3D11Texture)); + hr = device->OpenSharedResource(mHandle, __uuidof(ID3D11Texture2D), (void**)(ID3D11Texture2D**)getter_AddRefs(mD3D11Texture)); if (FAILED(hr) || !mD3D11Texture) { gfxCriticalError() << "Failed to D3D11 OpenSharedResource for frame finalization: " << hexa(hr); @@ -1197,7 +1197,7 @@ SyncObjectD3D11::FinalizeFrame() // test QI RefPtr mutex; - hr = mD3D11Texture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + hr = mD3D11Texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); if (FAILED(hr) || !mutex) { gfxCriticalError() << "Failed to get KeyedMutex: " << hexa(hr); @@ -1207,7 +1207,7 @@ SyncObjectD3D11::FinalizeFrame() if (mD3D10SyncedTextures.size()) { RefPtr mutex; - hr = mD3D10Texture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + hr = mD3D10Texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); hr = mutex->AcquireSync(0, 20000); if (hr == WAIT_TIMEOUT) { @@ -1235,7 +1235,7 @@ SyncObjectD3D11::FinalizeFrame() if (mD3D11SyncedTextures.size()) { RefPtr mutex; - hr = mD3D11Texture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex)); + hr = mD3D11Texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex)); hr = mutex->AcquireSync(0, 20000); if (hr == WAIT_TIMEOUT) { @@ -1260,7 +1260,7 @@ SyncObjectD3D11::FinalizeFrame() } RefPtr ctx; - dev->GetImmediateContext(byRef(ctx)); + dev->GetImmediateContext(getter_AddRefs(ctx)); for (auto iter = mD3D11SyncedTextures.begin(); iter != mD3D11SyncedTextures.end(); iter++) { ctx->CopySubresourceRegion(mD3D11Texture, 0, 0, 0, 0, *iter, 0, &box); diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index ab703aa288..633c0cb5be 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -117,7 +117,7 @@ CompositorD3D9::CreateRenderTarget(const gfx::IntRect &aRect, RefPtr texture; HRESULT hr = device()->CreateTexture(aRect.width, aRect.height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, - D3DPOOL_DEFAULT, byRef(texture), + D3DPOOL_DEFAULT, getter_AddRefs(texture), nullptr); if (FAILED(hr)) { ReportFailure(NS_LITERAL_CSTRING("CompositorD3D9::CreateRenderTarget: Failed to create texture"), @@ -146,7 +146,7 @@ CompositorD3D9::CreateRenderTargetFromSource(const gfx::IntRect &aRect, RefPtr texture; HRESULT hr = device()->CreateTexture(aRect.width, aRect.height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, - D3DPOOL_DEFAULT, byRef(texture), + D3DPOOL_DEFAULT, getter_AddRefs(texture), nullptr); if (FAILED(hr)) { ReportFailure(NS_LITERAL_CSTRING("CompositorD3D9::CreateRenderTargetFromSource: Failed to create texture"), @@ -155,10 +155,10 @@ CompositorD3D9::CreateRenderTargetFromSource(const gfx::IntRect &aRect, } if (aSource) { - nsRefPtr sourceSurface = + RefPtr sourceSurface = static_cast(aSource)->GetD3D9Surface(); - nsRefPtr destSurface; + RefPtr destSurface; hr = texture->GetSurfaceLevel(0, getter_AddRefs(destSurface)); if (FAILED(hr)) { NS_WARNING("Failed to get texture surface level for dest."); @@ -411,7 +411,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect, if (source->AsSourceD3D9()->GetStereoMode() != StereoMode::MONO) { mDeviceManager->GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE); - nsRefPtr renderTarget; + RefPtr renderTarget; d3d9Device->GetRenderTarget(0, getter_AddRefs(renderTarget)); mDeviceManager->GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)aRect.width, (unsigned int)aRect.height, @@ -651,7 +651,7 @@ CompositorD3D9::BeginFrame(const nsIntRegion& aInvalidRegion, } device()->SetScissorRect(&r); - nsRefPtr backBuffer = mSwapChain->GetBackBuffer(); + RefPtr backBuffer = mSwapChain->GetBackBuffer(); mDefaultRT = new CompositingRenderTargetD3D9(backBuffer, INIT_MODE_CLEAR, IntRect(0, 0, mSize.width, mSize.height)); @@ -734,8 +734,8 @@ CompositorD3D9::PaintToTarget() return; } - nsRefPtr backBuff; - nsRefPtr destSurf; + RefPtr backBuff; + RefPtr destSurf; device()->GetRenderTarget(0, getter_AddRefs(backBuff)); D3DSURFACE_DESC desc; diff --git a/gfx/layers/d3d9/CompositorD3D9.h b/gfx/layers/d3d9/CompositorD3D9.h index 53c8bdaefb..70cbc82677 100644 --- a/gfx/layers/d3d9/CompositorD3D9.h +++ b/gfx/layers/d3d9/CompositorD3D9.h @@ -158,10 +158,10 @@ private: } /* Device manager instance for this compositor */ - nsRefPtr mDeviceManager; + RefPtr mDeviceManager; /* Swap chain associated with this compositor */ - nsRefPtr mSwapChain; + RefPtr mSwapChain; /* Widget associated with this layer manager */ nsIWidget *mWidget; diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.cpp b/gfx/layers/d3d9/DeviceManagerD3D9.cpp index 22dedb68d3..9c4373af97 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp +++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp @@ -79,7 +79,7 @@ SwapChainD3D9::Init(HWND hWnd) already_AddRefed SwapChainD3D9::GetBackBuffer() { - nsRefPtr backBuffer; + RefPtr backBuffer; mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, getter_AddRefs(backBuffer)); @@ -104,7 +104,7 @@ SwapChainD3D9::PrepareForRendering() } if (mSwapChain) { - nsRefPtr backBuffer = GetBackBuffer(); + RefPtr backBuffer = GetBackBuffer(); D3DSURFACE_DESC desc; backBuffer->GetDesc(&desc); @@ -566,7 +566,7 @@ DeviceManagerD3D9::SetupRenderState() already_AddRefed DeviceManagerD3D9::CreateSwapChain(HWND hWnd) { - nsRefPtr swapChain = new SwapChainD3D9(this); + RefPtr swapChain = new SwapChainD3D9(this); // See bug 604647. This line means that if we create a window while the // device is lost LayerManager initialization will fail, this window @@ -861,7 +861,7 @@ DeviceManagerD3D9::CreateTexture(const IntSize &aSize, RefPtr result; if (FAILED(device()->CreateTexture(aSize.width, aSize.height, 1, 0, aFormat, aPool, - byRef(result), nullptr))) { + getter_AddRefs(result), nullptr))) { return nullptr; } diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.h b/gfx/layers/d3d9/DeviceManagerD3D9.h index 6b8cb7c526..01120bc6e8 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.h +++ b/gfx/layers/d3d9/DeviceManagerD3D9.h @@ -119,8 +119,8 @@ private: */ void Reset(); - nsRefPtr mSwapChain; - nsRefPtr mDeviceManager; + RefPtr mSwapChain; + RefPtr mDeviceManager; HWND mWnd; }; @@ -238,54 +238,54 @@ private: nsTArray mSwapChains; /* The D3D device we use */ - nsRefPtr mDevice; + RefPtr mDevice; /* The D3D9Ex device - only valid on Vista+ with WDDM */ - nsRefPtr mDeviceEx; + RefPtr mDeviceEx; /* An instance of the D3D9 object */ - nsRefPtr mD3D9; + RefPtr mD3D9; /* An instance of the D3D9Ex object - only valid on Vista+ with WDDM */ - nsRefPtr mD3D9Ex; + RefPtr mD3D9Ex; /* Vertex shader used for layer quads */ - nsRefPtr mLayerVS; + RefPtr mLayerVS; /* Pixel shader used for RGB textures */ - nsRefPtr mRGBPS; + RefPtr mRGBPS; /* Pixel shader used for RGBA textures */ - nsRefPtr mRGBAPS; + RefPtr mRGBAPS; /* Pixel shader used for component alpha textures (pass 1) */ - nsRefPtr mComponentPass1PS; + RefPtr mComponentPass1PS; /* Pixel shader used for component alpha textures (pass 2) */ - nsRefPtr mComponentPass2PS; + RefPtr mComponentPass2PS; /* Pixel shader used for RGB textures */ - nsRefPtr mYCbCrPS; + RefPtr mYCbCrPS; /* Pixel shader used for solid colors */ - nsRefPtr mSolidColorPS; + RefPtr mSolidColorPS; /* As above, but using a mask layer */ - nsRefPtr mLayerVSMask; - nsRefPtr mLayerVSMask3D; - nsRefPtr mRGBPSMask; - nsRefPtr mRGBAPSMask; - nsRefPtr mRGBAPSMask3D; - nsRefPtr mComponentPass1PSMask; - nsRefPtr mComponentPass2PSMask; - nsRefPtr mYCbCrPSMask; - nsRefPtr mSolidColorPSMask; + RefPtr mLayerVSMask; + RefPtr mLayerVSMask3D; + RefPtr mRGBPSMask; + RefPtr mRGBAPSMask; + RefPtr mRGBAPSMask3D; + RefPtr mComponentPass1PSMask; + RefPtr mComponentPass2PSMask; + RefPtr mYCbCrPSMask; + RefPtr mSolidColorPSMask; /* Vertex buffer containing our basic vertex structure */ - nsRefPtr mVB; + RefPtr mVB; /* Our vertex declaration */ - nsRefPtr mVD; + RefPtr mVD; /* We maintain a doubly linked list of all d3d9 texture hosts which host * d3d9 textures created by this device manager. diff --git a/gfx/layers/d3d9/Nv3DVUtils.h b/gfx/layers/d3d9/Nv3DVUtils.h index f0e240373e..0712dd8882 100644 --- a/gfx/layers/d3d9/Nv3DVUtils.h +++ b/gfx/layers/d3d9/Nv3DVUtils.h @@ -75,7 +75,7 @@ public: private: /* Nv3DVStreaming interface pointer */ - nsRefPtr m3DVStreaming; + RefPtr m3DVStreaming; }; diff --git a/gfx/layers/d3d9/TextureD3D9.cpp b/gfx/layers/d3d9/TextureD3D9.cpp index 17ea1e48c3..1c8066b163 100644 --- a/gfx/layers/d3d9/TextureD3D9.cpp +++ b/gfx/layers/d3d9/TextureD3D9.cpp @@ -191,7 +191,7 @@ TextureSourceD3D9::InitTextures(DeviceManagerD3D9* aDeviceManager, return nullptr; } - tmpTexture->GetSurfaceLevel(0, byRef(aSurface)); + tmpTexture->GetSurfaceLevel(0, getter_AddRefs(aSurface)); HRESULT hr = aSurface->LockRect(&aLockedRect, nullptr, 0); if (FAILED(hr) || !aLockedRect.pBits) { @@ -215,7 +215,7 @@ FinishTextures(DeviceManagerD3D9* aDeviceManager, } aSurface->UnlockRect(); - nsRefPtr dstSurface; + RefPtr dstSurface; aTexture->GetSurfaceLevel(0, getter_AddRefs(dstSurface)); aDeviceManager->device()->UpdateSurface(aSurface, nullptr, dstSurface, nullptr); @@ -549,7 +549,7 @@ TextureClientD3D9::BorrowDrawTarget() } if (ContentForFormat(mFormat) == gfxContentType::COLOR) { - nsRefPtr surface = new gfxWindowsSurface(mD3D9Surface); + RefPtr surface = new gfxWindowsSurface(mD3D9Surface); if (!surface || surface->CairoStatus()) { NS_WARNING("Could not create surface for d3d9 surface"); return nullptr; @@ -693,7 +693,7 @@ SharedTextureClientD3D9::Create(ISurfaceAllocator* aAllocator, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, - byRef(texture), + getter_AddRefs(texture), &shareHandle); NS_ENSURE_TRUE(SUCCEEDED(hr) && shareHandle, nullptr); @@ -715,7 +715,7 @@ already_AddRefed SharedTextureClientD3D9::GetD3D9Surface() const { RefPtr textureSurface; - HRESULT hr = mTexture->GetSurfaceLevel(0, byRef(textureSurface)); + HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(textureSurface)); NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); return textureSurface.forget(); @@ -805,11 +805,11 @@ DataTextureSourceD3D9::UpdateFromTexture(IDirect3DTexture9* aTexture, RefPtr srcSurface; RefPtr dstSurface; - hr = aTexture->GetSurfaceLevel(0, byRef(srcSurface)); + hr = aTexture->GetSurfaceLevel(0, getter_AddRefs(srcSurface)); if (FAILED(hr)) { return false; } - hr = mTexture->GetSurfaceLevel(0, byRef(dstSurface)); + hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(dstSurface)); if (FAILED(hr)) { return false; } @@ -937,7 +937,7 @@ DXGITextureHostD3D9::OpenSharedHandle() return; } - nsRefPtr texture; + RefPtr texture; HRESULT hr = GetDevice()->CreateTexture(mSize.width, mSize.height, 1, D3DUSAGE_RENDERTARGET, SurfaceFormatToD3D9Format(mFormat), @@ -1039,19 +1039,19 @@ DXGIYCbCrTextureHostD3D9::Lock() if (FAILED(GetDevice()->CreateTexture(mSizeY.width, mSizeY.height, 1, 0, D3DFMT_A8, D3DPOOL_DEFAULT, - byRef(mTextures[0]), &mHandles[0]))) { + getter_AddRefs(mTextures[0]), &mHandles[0]))) { return false; } if (FAILED(GetDevice()->CreateTexture(mSizeCbCr.width, mSizeCbCr.height, 1, 0, D3DFMT_A8, D3DPOOL_DEFAULT, - byRef(mTextures[1]), &mHandles[1]))) { + getter_AddRefs(mTextures[1]), &mHandles[1]))) { return false; } if (FAILED(GetDevice()->CreateTexture(mSizeCbCr.width, mSizeCbCr.height, 1, 0, D3DFMT_A8, D3DPOOL_DEFAULT, - byRef(mTextures[2]), &mHandles[2]))) { + getter_AddRefs(mTextures[2]), &mHandles[2]))) { return false; } diff --git a/gfx/layers/d3d9/TextureD3D9.h b/gfx/layers/d3d9/TextureD3D9.h index 5708775af9..46f9234fc7 100644 --- a/gfx/layers/d3d9/TextureD3D9.h +++ b/gfx/layers/d3d9/TextureD3D9.h @@ -215,7 +215,7 @@ public: private: RefPtr mTexture; - nsRefPtr mD3D9Surface; + RefPtr mD3D9Surface; RefPtr mDrawTarget; gfx::IntSize mSize; gfx::SurfaceFormat mFormat; @@ -439,7 +439,7 @@ public: private: friend class CompositorD3D9; - nsRefPtr mSurface; + RefPtr mSurface; SurfaceInitMode mInitMode; bool mInitialized; }; diff --git a/gfx/layers/ipc/CompositorChild.cpp b/gfx/layers/ipc/CompositorChild.cpp index 99930feb39..d7cadb2bca 100644 --- a/gfx/layers/ipc/CompositorChild.cpp +++ b/gfx/layers/ipc/CompositorChild.cpp @@ -51,8 +51,8 @@ CompositorChild::~CompositorChild() } } -static void DeferredDestroyCompositor(nsRefPtr aCompositorParent, - nsRefPtr aCompositorChild) +static void DeferredDestroyCompositor(RefPtr aCompositorParent, + RefPtr aCompositorChild) { // Bug 848949 needs to be fixed before // we can close the channel properly @@ -74,7 +74,7 @@ CompositorChild::Destroy() // Destroying the layer manager may cause all sorts of things to happen, so // let's make sure there is still a reference to keep this alive whatever // happens. - nsRefPtr selfRef = this; + RefPtr selfRef = this; SendWillStop(); // The call just made to SendWillStop can result in IPC from the @@ -126,7 +126,7 @@ CompositorChild::Create(Transport* aTransport, ProcessId aOtherPid) // There's only one compositor per child process. MOZ_ASSERT(!sCompositor); - nsRefPtr child(new CompositorChild(nullptr)); + RefPtr child(new CompositorChild(nullptr)); if (!child->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ChildSide)) { NS_RUNTIMEABORT("Couldn't Open() Compositor channel."); return nullptr; @@ -346,10 +346,10 @@ CompositorChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTransact { if (mLayerManager) { MOZ_ASSERT(aId == 0); - nsRefPtr m = mLayerManager; + RefPtr m = mLayerManager; m->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd); } else if (aId != 0) { - nsRefPtr child = dom::TabChild::GetFrom(aId); + RefPtr child = dom::TabChild::GetFrom(aId); if (child) { child->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd); } @@ -498,7 +498,7 @@ CompositorChild::RecvRemotePaintIsReady() // XPCOM gives a soup of compiler errors when trying to do_QueryReference // so I'm using static_cast<> MOZ_LAYERS_LOG(("[RemoteGfx] CompositorChild received RemotePaintIsReady")); - nsRefPtr iTabChildBase(do_QueryReferent(mWeakTabChild)); + RefPtr iTabChildBase(do_QueryReferent(mWeakTabChild)); if (!iTabChildBase) { MOZ_LAYERS_LOG(("[RemoteGfx] Note: TabChild was released before RemotePaintIsReady. " "MozAfterRemotePaint will not be sent to listener.")); @@ -524,7 +524,7 @@ CompositorChild::RequestNotifyAfterRemotePaint(TabChild* aTabChild) void CompositorChild::CancelNotifyAfterRemotePaint(TabChild* aTabChild) { - nsRefPtr iTabChildBase(do_QueryReferent(mWeakTabChild)); + RefPtr iTabChildBase(do_QueryReferent(mWeakTabChild)); if (!iTabChildBase) { return; } diff --git a/gfx/layers/ipc/CompositorChild.h b/gfx/layers/ipc/CompositorChild.h index ebaf3dcfe6..1dec93de11 100644 --- a/gfx/layers/ipc/CompositorChild.h +++ b/gfx/layers/ipc/CompositorChild.h @@ -168,17 +168,17 @@ private: private: // Pointer to the class that allows access to the shared memory that contains // the shared FrameMetrics - nsRefPtr mBuffer; + RefPtr mBuffer; CrossProcessMutex* mMutex; uint64_t mLayersId; // Unique ID of the APZC that is sharing the FrameMetrics uint32_t mAPZCId; }; - nsRefPtr mLayerManager; + RefPtr mLayerManager; // When not multi-process, hold a reference to the CompositorParent to keep it // alive. This reference should be null in multi-process. - nsRefPtr mCompositorParent; + RefPtr mCompositorParent; // The ViewID of the FrameMetrics is used as the key for this hash table. // While this should be safe to use since the ViewID is unique diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 591dd2e109..d9ef5330e3 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -1306,7 +1306,7 @@ CompositorParent::GetAPZTestData(const LayerTransactionParent* aLayerTree, class NotifyAPZConfirmedTargetTask : public Task { public: - explicit NotifyAPZConfirmedTargetTask(const nsRefPtr& aAPZCTM, + explicit NotifyAPZConfirmedTargetTask(const RefPtr& aAPZCTM, const uint64_t& aInputBlockId, const nsTArray& aTargets) : mAPZCTM(aAPZCTM), @@ -1320,7 +1320,7 @@ public: } private: - nsRefPtr mAPZCTM; + RefPtr mAPZCTM; uint64_t mInputBlockId; nsTArray mTargets; }; @@ -1728,10 +1728,10 @@ private: // There can be many CPCPs, and IPDL-generated code doesn't hold a // reference to top-level actors. So we hold a reference to // ourself. This is released (deferred) in ActorDestroy(). - nsRefPtr mSelfRef; + RefPtr mSelfRef; Transport* mTransport; - nsRefPtr mCompositorThreadHolder; + RefPtr mCompositorThreadHolder; // If true, we should send a RemotePaintIsReady message when the layer transaction // is received bool mNotifyAfterRemotePaint; @@ -1778,7 +1778,7 @@ CompositorParent::Create(Transport* aTransport, ProcessId aOtherPid) { gfxPlatform::InitLayersIPC(); - nsRefPtr cpcp = + RefPtr cpcp = new CrossProcessCompositorParent(aTransport); cpcp->mSelfRef = cpcp; @@ -1831,7 +1831,7 @@ CompositorParent::GetIndirectShadowTree(uint64_t aId) bool CrossProcessCompositorParent::RecvNotifyHidden(const uint64_t& id) { - nsRefPtr lru = CompositorLRU::GetSingleton(); + RefPtr lru = CompositorLRU::GetSingleton(); lru->Add(this, id); return true; } @@ -1839,7 +1839,7 @@ CrossProcessCompositorParent::RecvNotifyHidden(const uint64_t& id) bool CrossProcessCompositorParent::RecvNotifyVisible(const uint64_t& id) { - nsRefPtr lru = CompositorLRU::GetSingleton(); + RefPtr lru = CompositorLRU::GetSingleton(); lru->Remove(this, id); return true; } @@ -1854,7 +1854,7 @@ CrossProcessCompositorParent::RecvRequestNotifyAfterRemotePaint() void CrossProcessCompositorParent::ActorDestroy(ActorDestroyReason aWhy) { - nsRefPtr lru = CompositorLRU::GetSingleton(); + RefPtr lru = CompositorLRU::GetSingleton(); lru->Remove(this); MessageLoop::current()->PostTask( @@ -1965,7 +1965,7 @@ CrossProcessCompositorParent::ShadowLayersUpdated( } if (state->mLayerTreeReadyObserver) { - nsRefPtr observer = state->mLayerTreeReadyObserver; + RefPtr observer = state->mLayerTreeReadyObserver; state->mLayerTreeReadyObserver = nullptr; observer->ObserveUpdate(id, true); } @@ -2079,7 +2079,7 @@ CrossProcessCompositorParent::NotifyClearCachedResources(LayerTransactionParent* uint64_t id = aLayerTree->GetId(); MOZ_ASSERT(id != 0); - nsRefPtr observer; + RefPtr observer; { // scope lock MonitorAutoLock lock(*sIndirectLayerTreesLock); observer = sIndirectLayerTrees[id].mLayerTreeClearedObserver; diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 9fbef355b6..3aca54229b 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -161,8 +161,8 @@ private: bool mNeedsComposite; bool mIsObservingVsync; int32_t mVsyncNotificationsSkipped; - nsRefPtr mCompositorVsyncDispatcher; - nsRefPtr mVsyncObserver; + RefPtr mCompositorVsyncDispatcher; + RefPtr mVsyncObserver; mozilla::Monitor mCurrentCompositeTaskMonitor; @@ -356,8 +356,8 @@ public: struct LayerTreeState { LayerTreeState(); ~LayerTreeState(); - nsRefPtr mRoot; - nsRefPtr mController; + RefPtr mRoot; + RefPtr mController; CompositorParent* mParent; LayerManagerComposite* mLayerManager; // Pointer to the CrossProcessCompositorParent. Used by APZCs to share @@ -369,8 +369,8 @@ public: LayerTransactionParent* mLayerTree; nsTArray mPluginData; bool mUpdatedPluginDataAvailable; - nsRefPtr mLayerTreeReadyObserver; - nsRefPtr mLayerTreeClearedObserver; + RefPtr mLayerTreeReadyObserver; + RefPtr mLayerTreeClearedObserver; }; /** @@ -441,8 +441,8 @@ protected: void DidComposite(TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd); - nsRefPtr mLayerManager; - nsRefPtr mCompositor; + RefPtr mLayerManager; + RefPtr mCompositor; RefPtr mCompositionManager; nsIWidget* mWidget; TimeStamp mTestTime; @@ -464,10 +464,10 @@ protected: bool mOverrideComposeReadiness; CancelableTask* mForceCompositionTask; - nsRefPtr mApzcTreeManager; + RefPtr mApzcTreeManager; - nsRefPtr mCompositorThreadHolder; - nsRefPtr mCompositorScheduler; + RefPtr mCompositorThreadHolder; + RefPtr mCompositorScheduler; DISALLOW_EVIL_CONSTRUCTORS(CompositorParent); }; diff --git a/gfx/layers/ipc/FenceUtils.cpp b/gfx/layers/ipc/FenceUtils.cpp index 573f9100cf..f31dc77c2f 100644 --- a/gfx/layers/ipc/FenceUtils.cpp +++ b/gfx/layers/ipc/FenceUtils.cpp @@ -26,7 +26,7 @@ ParamTraits::Write(Message* aMsg, MOZ_ASSERT(handle.IsValid()); #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 - nsRefPtr fence = handle.GetAndResetFdObj(); + RefPtr fence = handle.GetAndResetFdObj(); aMsg->WriteFileDescriptor(base::FileDescriptor(fence->GetAndResetFd(), true)); #endif } @@ -90,7 +90,7 @@ FenceHandle::TransferToAnotherFenceHandle(FenceHandle& aFenceHandle) already_AddRefed FenceHandle::GetAndResetFdObj() { - nsRefPtr fence = mFence; + RefPtr fence = mFence; mFence = new FdObj(); return fence.forget(); } @@ -98,7 +98,7 @@ FenceHandle::GetAndResetFdObj() already_AddRefed FenceHandle::GetDupFdObj() { - nsRefPtr fdObj; + RefPtr fdObj; if (IsValid()) { fdObj = new FenceHandle::FdObj(dup(mFence->mFd)); } else { diff --git a/gfx/layers/ipc/FenceUtils.h b/gfx/layers/ipc/FenceUtils.h index d256d8c4e1..f7e42fe5a0 100644 --- a/gfx/layers/ipc/FenceUtils.h +++ b/gfx/layers/ipc/FenceUtils.h @@ -63,7 +63,7 @@ public: already_AddRefed GetDupFdObj(); private: - nsRefPtr mFence; + RefPtr mFence; }; } // namespace layers diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index 0fb1a57941..643a7a1700 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -434,7 +434,7 @@ void ImageBridgeChild::DispatchImageClientUpdate(ImageClient* aClient, NewRunnableFunction< void (*)(ImageClient*, ImageContainer*), ImageClient*, - nsRefPtr >(&UpdateImageClientNow, aClient, aContainer)); + RefPtr >(&UpdateImageClientNow, aClient, aContainer)); } static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer, diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 74c58adf51..c7ae6f1e2d 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -176,7 +176,7 @@ ConnectImageBridgeInParentProcess(ImageBridgeParent* aBridge, ImageBridgeParent::Create(Transport* aTransport, ProcessId aChildProcessId) { MessageLoop* loop = CompositorParent::CompositorLoop(); - nsRefPtr bridge = new ImageBridgeParent(loop, aTransport, aChildProcessId); + RefPtr bridge = new ImageBridgeParent(loop, aTransport, aChildProcessId); bridge->mSelfRef = bridge; loop->PostTask(FROM_HERE, NewRunnableFunction(ConnectImageBridgeInParentProcess, diff --git a/gfx/layers/ipc/ImageBridgeParent.h b/gfx/layers/ipc/ImageBridgeParent.h index ab6374653a..1c305dcf7d 100644 --- a/gfx/layers/ipc/ImageBridgeParent.h +++ b/gfx/layers/ipc/ImageBridgeParent.h @@ -156,7 +156,7 @@ private: Transport* mTransport; // This keeps us alive until ActorDestroy(), at which point we do a // deferred destruction of ourselves. - nsRefPtr mSelfRef; + RefPtr mSelfRef; bool mSetChildThreadPriority; @@ -167,7 +167,7 @@ private: static MessageLoop* sMainLoop; - nsRefPtr mCompositorThreadHolder; + RefPtr mCompositorThreadHolder; }; } // namespace layers diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 4c6e488db8..11af5864f3 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -257,7 +257,7 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray&& cset, case Edit::TOpCreatePaintedLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreatePaintedLayer")); - nsRefPtr layer = + RefPtr layer = layer_manager()->CreatePaintedLayerComposite(); AsLayerComposite(edit.get_OpCreatePaintedLayer())->Bind(layer); break; @@ -265,14 +265,14 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray&& cset, case Edit::TOpCreateContainerLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateContainerLayer")); - nsRefPtr layer = layer_manager()->CreateContainerLayerComposite(); + RefPtr layer = layer_manager()->CreateContainerLayerComposite(); AsLayerComposite(edit.get_OpCreateContainerLayer())->Bind(layer); break; } case Edit::TOpCreateImageLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateImageLayer")); - nsRefPtr layer = + RefPtr layer = layer_manager()->CreateImageLayerComposite(); AsLayerComposite(edit.get_OpCreateImageLayer())->Bind(layer); break; @@ -280,14 +280,14 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray&& cset, case Edit::TOpCreateColorLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateColorLayer")); - nsRefPtr layer = layer_manager()->CreateColorLayerComposite(); + RefPtr layer = layer_manager()->CreateColorLayerComposite(); AsLayerComposite(edit.get_OpCreateColorLayer())->Bind(layer); break; } case Edit::TOpCreateCanvasLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateCanvasLayer")); - nsRefPtr layer = + RefPtr layer = layer_manager()->CreateCanvasLayerComposite(); AsLayerComposite(edit.get_OpCreateCanvasLayer())->Bind(layer); break; @@ -295,7 +295,7 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray&& cset, case Edit::TOpCreateRefLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateRefLayer")); - nsRefPtr layer = + RefPtr layer = layer_manager()->CreateRefLayerComposite(); AsLayerComposite(edit.get_OpCreateRefLayer())->Bind(layer); break; @@ -348,7 +348,7 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray&& cset, layer->SetFrameMetrics(common.metrics()); layer->SetDisplayListLog(common.displayListLog().get()); - nsTArray> maskLayers; + nsTArray> maskLayers; for (size_t i = 0; i < common.ancestorMaskLayersParent().Length(); i++) { Layer* maskLayer = cast(common.ancestorMaskLayersParent().ElementAt(i))->AsLayer(); maskLayers.AppendElement(maskLayer); diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h index 7a10c51046..74abd705f6 100644 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ b/gfx/layers/ipc/LayerTransactionParent.h @@ -176,11 +176,11 @@ protected: friend class layout::RenderFrameParent; private: - nsRefPtr mLayerManager; + RefPtr mLayerManager; ShadowLayersManager* mShadowLayersManager; // Hold the root because it might be grafted under various // containers in the "real" layer tree - nsRefPtr mRoot; + RefPtr mRoot; // When this is nonzero, it refers to a layer tree owned by the // compositor thread. It is always true that // mId != 0 => mRoot == null diff --git a/gfx/layers/ipc/ShadowLayerParent.h b/gfx/layers/ipc/ShadowLayerParent.h index 30c7f9eb1a..5ad143683e 100644 --- a/gfx/layers/ipc/ShadowLayerParent.h +++ b/gfx/layers/ipc/ShadowLayerParent.h @@ -50,7 +50,7 @@ private: void Disconnect(); - nsRefPtr mLayer; + RefPtr mLayer; }; } // namespace layers diff --git a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp index 4ca4c1dc4d..9408b1f2e5 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp @@ -94,7 +94,7 @@ SurfaceDescriptorX11::OpenForeign() const Display* display = DefaultXDisplay(); Screen* screen = DefaultScreenOfDisplay(display); - nsRefPtr surf; + RefPtr surf; XRenderPictFormat* pictFormat = GetXRenderPictFormatFromId(display, mFormat); if (pictFormat) { surf = new gfxXlibSurface(screen, mId, pictFormat, mSize); diff --git a/gfx/layers/ipc/SharedRGBImage.cpp b/gfx/layers/ipc/SharedRGBImage.cpp index 5338fab290..4061482f72 100644 --- a/gfx/layers/ipc/SharedRGBImage.cpp +++ b/gfx/layers/ipc/SharedRGBImage.cpp @@ -41,14 +41,14 @@ CreateSharedRGBImage(ImageContainer *aImageContainer, return nullptr; } - nsRefPtr image = aImageContainer->CreateImage(ImageFormat::SHARED_RGB); + RefPtr image = aImageContainer->CreateImage(ImageFormat::SHARED_RGB); if (!image) { NS_WARNING("Failed to create SharedRGBImage"); return nullptr; } - nsRefPtr rgbImage = static_cast(image.get()); + RefPtr rgbImage = static_cast(image.get()); if (!rgbImage->Allocate(aSize, gfx::ImageFormatToSurfaceFormat(aImageFormat))) { NS_WARNING("Failed to allocate a shared image"); return nullptr; diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index a6c60dca9f..7222418cdd 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -101,7 +101,7 @@ CompositorOGL::~CompositorOGL() already_AddRefed CompositorOGL::CreateContext() { - nsRefPtr context; + RefPtr context; // Used by mock widget to create an offscreen context void* widgetOpenGLContext = mWidget->GetNativeData(NS_NATIVE_OPENGL_CONTEXT); @@ -168,7 +168,7 @@ CompositorOGL::CleanupResources() reinterpret_cast(nullptr)); #endif - nsRefPtr ctx = mGLContext->GetSharedContext(); + RefPtr ctx = mGLContext->GetSharedContext(); if (!ctx) { ctx = mGLContext; } @@ -1497,7 +1497,7 @@ CompositorOGL::GetReleaseFence() return FenceHandle(); } - nsRefPtr fdObj = mReleaseFenceHandle.GetDupFdObj(); + RefPtr fdObj = mReleaseFenceHandle.GetDupFdObj(); return FenceHandle(fdObj); } diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index a0de8304df..a7eeb6c3ed 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -331,7 +331,7 @@ private: /** Widget associated with this compositor */ nsIWidget *mWidget; gfx::IntSize mWidgetSize; - nsRefPtr mGLContext; + RefPtr mGLContext; UniquePtr mBlitTextureImageHelper; gfx::Matrix4x4 mProjMatrix; diff --git a/gfx/layers/opengl/GrallocTextureClient.cpp b/gfx/layers/opengl/GrallocTextureClient.cpp index 5e6b5195c4..78bb32060e 100644 --- a/gfx/layers/opengl/GrallocTextureClient.cpp +++ b/gfx/layers/opengl/GrallocTextureClient.cpp @@ -95,7 +95,7 @@ GrallocTextureClientOGL::WaitForBufferOwnership(bool aWaitReleaseFence) #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 if (mReleaseFenceHandle.IsValid()) { - nsRefPtr fdObj = mReleaseFenceHandle.GetAndResetFdObj(); + RefPtr fdObj = mReleaseFenceHandle.GetAndResetFdObj(); android::sp fence = new Fence(fdObj->GetAndResetFd()); #if ANDROID_VERSION == 17 fence->waitForever(1000, "GrallocTextureClientOGL::Lock"); @@ -135,7 +135,7 @@ GrallocTextureClientOGL::Lock(OpenMode aMode) usage |= GRALLOC_USAGE_SW_WRITE_OFTEN; } #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21 - nsRefPtr fdObj = mReleaseFenceHandle.GetAndResetFdObj(); + RefPtr fdObj = mReleaseFenceHandle.GetAndResetFdObj(); int32_t rv = mGraphicBuffer->lockAsync(usage, reinterpret_cast(&mMappedBuffer), fdObj->GetAndResetFd()); diff --git a/gfx/layers/opengl/GrallocTextureHost.cpp b/gfx/layers/opengl/GrallocTextureHost.cpp index 3909472d27..49141b5852 100644 --- a/gfx/layers/opengl/GrallocTextureHost.cpp +++ b/gfx/layers/opengl/GrallocTextureHost.cpp @@ -397,7 +397,7 @@ GrallocTextureHostOGL::WaitAcquireFenceHandleSyncComplete() return; } - nsRefPtr fence = mAcquireFenceHandle.GetAndResetFdObj(); + RefPtr fence = mAcquireFenceHandle.GetAndResetFdObj(); int fenceFd = fence->GetAndResetFd(); EGLint attribs[] = { diff --git a/gfx/layers/opengl/OGLShaderProgram.cpp b/gfx/layers/opengl/OGLShaderProgram.cpp index f330eff965..4aa8d17a90 100644 --- a/gfx/layers/opengl/OGLShaderProgram.cpp +++ b/gfx/layers/opengl/OGLShaderProgram.cpp @@ -518,7 +518,7 @@ ShaderProgramOGL::~ShaderProgramOGL() return; } - nsRefPtr ctx = mGL->GetSharedContext(); + RefPtr ctx = mGL->GetSharedContext(); if (!ctx) { ctx = mGL; } diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index fe3e9990e7..d028cad8e6 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -211,7 +211,7 @@ public: } protected: - nsRefPtr mTexImage; + RefPtr mTexImage; RefPtr mCompositor; TextureFlags mFlags; bool mIterating; diff --git a/gfx/layers/opengl/X11TextureSourceOGL.h b/gfx/layers/opengl/X11TextureSourceOGL.h index 097d5c1a22..6f1bf86717 100644 --- a/gfx/layers/opengl/X11TextureSourceOGL.h +++ b/gfx/layers/opengl/X11TextureSourceOGL.h @@ -51,7 +51,7 @@ public: protected: RefPtr mCompositor; - nsRefPtr mSurface; + RefPtr mSurface; RefPtr mSourceSurface; GLuint mTexture; bool mUpdated; diff --git a/gfx/src/gfxCrashReporterUtils.cpp b/gfx/src/gfxCrashReporterUtils.cpp index 79f0138618..e25ab9a037 100644 --- a/gfx/src/gfxCrashReporterUtils.cpp +++ b/gfx/src/gfxCrashReporterUtils.cpp @@ -78,7 +78,7 @@ public: nsCOMPtr observerService = mozilla::services::GetObserverService(); if (!observerService) return NS_OK; - nsRefPtr observer = new ObserverToDestroyFeaturesAlreadyReported; + RefPtr observer = new ObserverToDestroyFeaturesAlreadyReported; observerService->AddObserver(observer, "xpcom-shutdown", false); return NS_OK; } diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 4c0f06bb89..f26c32a19b 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -396,7 +396,7 @@ nsDeviceContext::CreateRenderingContext() { MOZ_ASSERT(mWidth > 0 && mHeight > 0); - nsRefPtr printingSurface = mPrintingSurface; + RefPtr printingSurface = mPrintingSurface; #ifdef XP_MACOSX // CreateRenderingContext() can be called (on reflow) after EndPage() // but before BeginPage(). On OS X (and only there) mPrintingSurface @@ -425,7 +425,7 @@ nsDeviceContext::CreateRenderingContext() #endif dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr); - nsRefPtr pContext = new gfxContext(dt); + RefPtr pContext = new gfxContext(dt); pContext->SetMatrix(gfxMatrix::Scaling(mPrintingScale, mPrintingScale)); return pContext.forget(); } diff --git a/gfx/src/nsDeviceContext.h b/gfx/src/nsDeviceContext.h index 9d0a22a5c5..3f54e61adc 100644 --- a/gfx/src/nsDeviceContext.h +++ b/gfx/src/nsDeviceContext.h @@ -277,9 +277,9 @@ private: nsCOMPtr mWidget; nsCOMPtr mScreenManager; nsCOMPtr mDeviceContextSpec; - nsRefPtr mPrintingSurface; + RefPtr mPrintingSurface; #ifdef XP_MACOSX - nsRefPtr mCachedPrintingSurface; + RefPtr mCachedPrintingSurface; #endif }; diff --git a/gfx/src/nsFont.h b/gfx/src/nsFont.h index 753d4ecf37..dce9b12401 100644 --- a/gfx/src/nsFont.h +++ b/gfx/src/nsFont.h @@ -99,7 +99,7 @@ struct nsFont { nsTArray alternateValues; // -- object used to look these up once the font is matched - nsRefPtr featureValueLookup; + RefPtr featureValueLookup; // Font features from CSS font-feature-settings nsTArray fontFeatureSettings; diff --git a/gfx/src/nsFontMetrics.h b/gfx/src/nsFontMetrics.h index c685b1b4a5..da80023683 100644 --- a/gfx/src/nsFontMetrics.h +++ b/gfx/src/nsFontMetrics.h @@ -242,7 +242,7 @@ private: GetMetrics(const gfxFont::Orientation aFontOrientation) const; nsFont mFont; - nsRefPtr mFontGroup; + RefPtr mFontGroup; nsCOMPtr mLanguage; nsDeviceContext *mDeviceContext; int32_t mP2A; diff --git a/gfx/src/nsRenderingContext.h b/gfx/src/nsRenderingContext.h index 9983096683..9ec42967ae 100644 --- a/gfx/src/nsRenderingContext.h +++ b/gfx/src/nsRenderingContext.h @@ -9,7 +9,7 @@ #include "gfxContext.h" #include "mozilla/Attributes.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" namespace mozilla { namespace gfx { @@ -44,7 +44,7 @@ public: DrawTarget *GetDrawTarget() { return mThebes->GetDrawTarget(); } private: - nsRefPtr mThebes; + RefPtr mThebes; }; #endif // NSRENDERINGCONTEXT__H__ diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index 4536bba12c..ae98a1c0f2 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -140,7 +140,7 @@ class TestAPZCTreeManager : public APZCTreeManager { public: explicit TestAPZCTreeManager(MockContentControllerDelayed* aMcc) : mcc(aMcc) {} - nsRefPtr GetInputQueue() const { + RefPtr GetInputQueue() const { return mInputQueue; } @@ -154,7 +154,7 @@ protected: } private: - nsRefPtr mcc; + RefPtr mcc; }; class TestAsyncPanZoomController : public AsyncPanZoomController { @@ -186,7 +186,7 @@ public: } void ConfirmTarget(uint64_t aInputBlockId) { - nsRefPtr target = this; + RefPtr target = this; GetInputQueue()->SetConfirmedTargetApzc(aInputBlockId, target); } @@ -372,10 +372,10 @@ protected: void TestOverscroll(); AsyncPanZoomController::GestureBehavior mGestureBehavior; - nsRefPtr mcc; - nsRefPtr mPaintThrottler; - nsRefPtr tm; - nsRefPtr apzc; + RefPtr mcc; + RefPtr mPaintThrottler; + RefPtr tm; + RefPtr apzc; }; class APZCGestureDetectorTester : public APZCBasicTester { @@ -422,7 +422,7 @@ CreatePinchGestureInput(PinchGestureInput::PinchGestureType aType, } template static void -SetDefaultAllowedTouchBehavior(const nsRefPtr& aTarget, +SetDefaultAllowedTouchBehavior(const RefPtr& aTarget, uint64_t aInputBlockId, int touchPoints = 1) { @@ -450,7 +450,7 @@ CreateMultiTouchInput(MultiTouchInput::MultiTouchType aType, TimeStamp aTime) } template static nsEventStatus -TouchDown(const nsRefPtr& aTarget, int aX, int aY, TimeStamp aTime, uint64_t* aOutInputBlockId = nullptr) +TouchDown(const RefPtr& aTarget, int aX, int aY, TimeStamp aTime, uint64_t* aOutInputBlockId = nullptr) { MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime); mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY)); @@ -458,7 +458,7 @@ TouchDown(const nsRefPtr& aTarget, int aX, int aY, TimeStamp aTim } template static nsEventStatus -TouchMove(const nsRefPtr& aTarget, int aX, int aY, TimeStamp aTime) +TouchMove(const RefPtr& aTarget, int aX, int aY, TimeStamp aTime) { MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime); mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY)); @@ -466,7 +466,7 @@ TouchMove(const nsRefPtr& aTarget, int aX, int aY, TimeStamp aTim } template static nsEventStatus -TouchUp(const nsRefPtr& aTarget, int aX, int aY, TimeStamp aTime) +TouchUp(const RefPtr& aTarget, int aX, int aY, TimeStamp aTime) { MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime); mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY)); @@ -474,7 +474,7 @@ TouchUp(const nsRefPtr& aTarget, int aX, int aY, TimeStamp aTime) } template static void -Tap(const nsRefPtr& aTarget, int aX, int aY, MockContentControllerDelayed* aMcc, +Tap(const RefPtr& aTarget, int aX, int aY, MockContentControllerDelayed* aMcc, TimeDuration aTapLength, nsEventStatus (*aOutEventStatuses)[2] = nullptr, uint64_t* aOutInputBlockId = nullptr) @@ -505,7 +505,7 @@ Tap(const nsRefPtr& aTarget, int aX, int aY, MockContentControlle } template static void -TapAndCheckStatus(const nsRefPtr& aTarget, int aX, int aY, +TapAndCheckStatus(const RefPtr& aTarget, int aX, int aY, MockContentControllerDelayed* aMcc, TimeDuration aTapLength) { nsEventStatus statuses[2]; @@ -515,7 +515,7 @@ TapAndCheckStatus(const nsRefPtr& aTarget, int aX, int aY, } template static void -Pan(const nsRefPtr& aTarget, +Pan(const RefPtr& aTarget, MockContentControllerDelayed* aMcc, const ScreenPoint& aTouchStart, const ScreenPoint& aTouchEnd, @@ -590,7 +590,7 @@ Pan(const nsRefPtr& aTarget, // for the touch start and end points, and uses 10 for the x coordinates. // This is for convenience, as most tests only need to pan in one direction. template static void -Pan(const nsRefPtr& aTarget, +Pan(const RefPtr& aTarget, MockContentControllerDelayed* aMcc, int aTouchStartY, int aTouchEndY, @@ -608,7 +608,7 @@ Pan(const nsRefPtr& aTarget, * consumed them and triggered scrolling behavior. */ template static void -PanAndCheckStatus(const nsRefPtr& aTarget, +PanAndCheckStatus(const RefPtr& aTarget, MockContentControllerDelayed* aMcc, int aTouchStartY, int aTouchEndY, @@ -632,7 +632,7 @@ PanAndCheckStatus(const nsRefPtr& aTarget, } static void -ApzcPanNoFling(const nsRefPtr& aApzc, +ApzcPanNoFling(const RefPtr& aApzc, MockContentControllerDelayed* aMcc, int aTouchStartY, int aTouchEndY, @@ -643,7 +643,7 @@ ApzcPanNoFling(const nsRefPtr& aApzc, } template static void -PinchWithPinchInput(const nsRefPtr& aTarget, +PinchWithPinchInput(const RefPtr& aTarget, int aFocusX, int aFocusY, int aSecondFocusX, int aSecondFocusY, float aScale, nsEventStatus (*aOutEventStatuses)[3] = nullptr) { @@ -673,7 +673,7 @@ PinchWithPinchInput(const nsRefPtr& aTarget, } template static void -PinchWithPinchInputAndCheckStatus(const nsRefPtr& aTarget, +PinchWithPinchInputAndCheckStatus(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, bool aShouldTriggerPinch) { @@ -688,7 +688,7 @@ PinchWithPinchInputAndCheckStatus(const nsRefPtr& aTarget, } template static void -PinchWithTouchInput(const nsRefPtr& aTarget, +PinchWithTouchInput(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, int& inputId, nsTArray* aAllowedTouchBehaviors = nullptr, @@ -750,7 +750,7 @@ PinchWithTouchInput(const nsRefPtr& aTarget, } template static void -PinchWithTouchInputAndCheckStatus(const nsRefPtr& aTarget, +PinchWithTouchInputAndCheckStatus(const RefPtr& aTarget, int aFocusX, int aFocusY, float aScale, int& inputId, bool aShouldTriggerPinch, nsTArray* aAllowedTouchBehaviors) @@ -971,7 +971,7 @@ TEST_F(APZCBasicTester, ComplexTransform) { // CSS pixels). The displayport is 1 extra CSS pixel on all // sides. - nsRefPtr childApzc = + RefPtr childApzc = new TestAsyncPanZoomController(0, mcc, tm, mPaintThrottler); const char* layerTreeSyntax = "c(c)"; @@ -987,9 +987,9 @@ TEST_F(APZCBasicTester, ComplexTransform) { transforms[0].PostScale(0.5f, 0.5f, 1.0f); // this results from the 2.0 resolution on the root layer transforms[1].PostScale(2.0f, 1.0f, 1.0f); // this is the 2.0 x-axis CSS transform on the child layer - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers); + nsTArray > layers; + RefPtr lm; + RefPtr root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers); FrameMetrics metrics; metrics.SetCompositionBounds(ParentLayerRect(0, 0, 24, 24)); @@ -1717,7 +1717,7 @@ TEST_F(APZCLongPressTester, LongPressPreventDefaultWithTouchAction) { } template static void -DoubleTap(const nsRefPtr& aTarget, int aX, int aY, MockContentControllerDelayed* aMcc, +DoubleTap(const RefPtr& aTarget, int aX, int aY, MockContentControllerDelayed* aMcc, nsEventStatus (*aOutEventStatuses)[4] = nullptr, uint64_t (*aOutInputBlockIds)[2] = nullptr) { @@ -1762,7 +1762,7 @@ DoubleTap(const nsRefPtr& aTarget, int aX, int aY, MockContentCon } template static void -DoubleTapAndCheckStatus(const nsRefPtr& aTarget, int aX, int aY, +DoubleTapAndCheckStatus(const RefPtr& aTarget, int aX, int aY, MockContentControllerDelayed* aMcc, uint64_t (*aOutInputBlockIds)[2] = nullptr) { nsEventStatus statuses[4]; @@ -1927,20 +1927,20 @@ protected: ViewTransform viewTransformOut; mcc->AdvanceBy(increment); - for (const nsRefPtr& layer : layers) { + for (const RefPtr& layer : layers) { if (TestAsyncPanZoomController* apzc = ApzcOf(layer)) { apzc->SampleContentTransformForFrame(&viewTransformOut, pointOut); } } } - nsRefPtr mcc; + RefPtr mcc; - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root; + nsTArray > layers; + RefPtr lm; + RefPtr root; - nsRefPtr manager; + RefPtr manager; protected: static void SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId, @@ -2016,7 +2016,7 @@ protected: Matrix4x4 transformToGecko; already_AddRefed GetTargetAPZC(const ScreenPoint& aPoint) { - nsRefPtr hit = manager->GetTargetAPZC(aPoint, nullptr); + RefPtr hit = manager->GetTargetAPZC(aPoint, nullptr); if (hit) { transformToApzc = manager->GetScreenToApzcTransform(hit.get()); transformToGecko = manager->GetApzcToGeckoTransform(hit.get()); @@ -2103,7 +2103,7 @@ TEST_F(APZHitTestingTester, HitTesting1) { ScopedLayerTreeRegistration registration(0, root, mcc); // No APZC attached so hit testing will return no APZC at (20,20) - nsRefPtr hit = GetTargetAPZC(ScreenPoint(20, 20)); + RefPtr hit = GetTargetAPZC(ScreenPoint(20, 20)); TestAsyncPanZoomController* nullAPZC = nullptr; EXPECT_EQ(nullAPZC, hit.get()); EXPECT_EQ(Matrix4x4(), transformToApzc); @@ -2180,7 +2180,7 @@ TEST_F(APZHitTestingTester, HitTesting2) { TestAsyncPanZoomController* apzc3 = ApzcOf(layers[3]); // Hit an area that's clearly on the root layer but not any of the child layers. - nsRefPtr hit = GetTargetAPZC(ScreenPoint(75, 25)); + RefPtr hit = GetTargetAPZC(ScreenPoint(75, 25)); EXPECT_EQ(apzcroot, hit.get()); EXPECT_EQ(Point(75, 25), transformToApzc * Point(75, 25)); EXPECT_EQ(Point(75, 25), transformToGecko * Point(75, 25)); @@ -2308,9 +2308,9 @@ TEST_F(APZCTreeManagerTester, Bug1068268) { ScopedLayerTreeRegistration registration(0, root, mcc); manager->UpdateHitTestingTree(nullptr, root, false, 0, 0); - nsRefPtr root = manager->GetRootNode(); - nsRefPtr node2 = root->GetFirstChild()->GetFirstChild(); - nsRefPtr node5 = root->GetLastChild()->GetLastChild(); + RefPtr root = manager->GetRootNode(); + RefPtr node2 = root->GetFirstChild()->GetFirstChild(); + RefPtr node5 = root->GetLastChild()->GetLastChild(); EXPECT_EQ(ApzcOf(layers[2]), node5->GetApzc()); EXPECT_EQ(ApzcOf(layers[2]), node2->GetApzc()); @@ -2379,16 +2379,16 @@ TEST_F(APZHitTestingTester, ComplexMultiLayerTree) { EXPECT_EQ(layers4_6_8, layer7->GetParent()); EXPECT_EQ(nullptr, layer9->GetParent()); // Ensure the hit-testing tree looks like the layer tree - nsRefPtr root = manager->GetRootNode(); - nsRefPtr node5 = root->GetLastChild(); - nsRefPtr node4 = node5->GetPrevSibling(); - nsRefPtr node2 = node4->GetPrevSibling(); - nsRefPtr node1 = node2->GetPrevSibling(); - nsRefPtr node3 = node2->GetLastChild(); - nsRefPtr node9 = node5->GetLastChild(); - nsRefPtr node8 = node9->GetPrevSibling(); - nsRefPtr node6 = node8->GetPrevSibling(); - nsRefPtr node7 = node6->GetLastChild(); + RefPtr root = manager->GetRootNode(); + RefPtr node5 = root->GetLastChild(); + RefPtr node4 = node5->GetPrevSibling(); + RefPtr node2 = node4->GetPrevSibling(); + RefPtr node1 = node2->GetPrevSibling(); + RefPtr node3 = node2->GetLastChild(); + RefPtr node9 = node5->GetLastChild(); + RefPtr node8 = node9->GetPrevSibling(); + RefPtr node6 = node8->GetPrevSibling(); + RefPtr node7 = node6->GetLastChild(); EXPECT_EQ(nullptr, node1->GetPrevSibling()); EXPECT_EQ(nullptr, node3->GetPrevSibling()); EXPECT_EQ(nullptr, node6->GetPrevSibling()); @@ -2400,7 +2400,7 @@ TEST_F(APZHitTestingTester, ComplexMultiLayerTree) { EXPECT_EQ(nullptr, node8->GetLastChild()); EXPECT_EQ(nullptr, node9->GetLastChild()); - nsRefPtr hit = GetTargetAPZC(ScreenPoint(25, 25)); + RefPtr hit = GetTargetAPZC(ScreenPoint(25, 25)); EXPECT_EQ(ApzcOf(layers[1]), hit.get()); hit = GetTargetAPZC(ScreenPoint(275, 375)); EXPECT_EQ(ApzcOf(layers[9]), hit.get()); @@ -2627,7 +2627,7 @@ protected: const float kAcceleration = 100.0f; SCOPED_GFX_PREF(APZFlingAccelBaseMultiplier, float, kAcceleration); - nsRefPtr childApzc = ApzcOf(layers[1]); + RefPtr childApzc = ApzcOf(layers[1]); // Pan once, enough to fully scroll the scrollgrab parent and then scroll // and fling the child. @@ -2707,7 +2707,7 @@ TEST_F(APZOverscrollHandoffTester, LayerStructureChangesWhileEventsArePending) { // Modify the APZC tree to insert a new APZC 'middle' into the handoff chain // between the child and the root. CreateOverscrollHandoffLayerTree2(); - nsRefPtr middle = layers[1]; + RefPtr middle = layers[1]; childApzc->SetWaitForMainThread(); TestAsyncPanZoomController* middleApzc = ApzcOf(middle); @@ -2784,8 +2784,8 @@ TEST_F(APZOverscrollHandoffTester, PartialFlingHandoff) { // off to the parent APZC. Pan(manager, mcc, ScreenPoint(90, 90), ScreenPoint(55, 55)); - nsRefPtr parent = ApzcOf(root); - nsRefPtr child = ApzcOf(layers[1]); + RefPtr parent = ApzcOf(root); + RefPtr child = ApzcOf(layers[1]); // Advance the child's fling animation once to give the partial handoff // a chance to occur. @@ -2803,10 +2803,10 @@ TEST_F(APZOverscrollHandoffTester, SimultaneousFlings) { // Set up an initial APZC tree. CreateOverscrollHandoffLayerTree3(); - nsRefPtr parent1 = ApzcOf(layers[1]); - nsRefPtr child1 = ApzcOf(layers[2]); - nsRefPtr parent2 = ApzcOf(layers[3]); - nsRefPtr child2 = ApzcOf(layers[4]); + RefPtr parent1 = ApzcOf(layers[1]); + RefPtr child1 = ApzcOf(layers[2]); + RefPtr parent2 = ApzcOf(layers[3]); + RefPtr child2 = ApzcOf(layers[4]); // Pan on the lower child. Pan(child2, mcc, 45, 5); @@ -2833,7 +2833,7 @@ TEST_F(APZOverscrollHandoffTester, Scrollgrab) { // Set up the layer tree CreateScrollgrabLayerTree(); - nsRefPtr childApzc = ApzcOf(layers[1]); + RefPtr childApzc = ApzcOf(layers[1]); // Pan on the child, enough to fully scroll the scrollgrab parent (20 px) // and leave some more (another 15 px) for the child. @@ -2848,7 +2848,7 @@ TEST_F(APZOverscrollHandoffTester, ScrollgrabFling) { // Set up the layer tree CreateScrollgrabLayerTree(); - nsRefPtr childApzc = ApzcOf(layers[1]); + RefPtr childApzc = ApzcOf(layers[1]); // Pan on the child, not enough to fully scroll the scrollgrab parent. Pan(childApzc, mcc, 80, 70); @@ -3095,7 +3095,7 @@ TEST_F(APZEventRegionsTester, Obscuration) { ApzcPanNoFling(parent, mcc, 75, 25); HitTestResult result; - nsRefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 75), &result); + RefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 75), &result); EXPECT_EQ(child, hit.get()); EXPECT_EQ(HitTestResult::HitLayer, result); } @@ -3104,7 +3104,7 @@ TEST_F(APZEventRegionsTester, Bug1119497) { CreateBug1119497LayerTree(); HitTestResult result; - nsRefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 50), &result); + RefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 50), &result); // We should hit layers[2], so |result| will be HitLayer but there's no // actual APZC in that parent chain, so |hit| should be nullptr. EXPECT_EQ(nullptr, hit.get()); @@ -3201,7 +3201,7 @@ protected: } TimeStamp now; - nsRefPtr throttler; + RefPtr throttler; TaskRunMetrics metrics; }; diff --git a/gfx/tests/gtest/TestCompositor.cpp b/gfx/tests/gtest/TestCompositor.cpp index 2cf535ef92..c3665f4684 100644 --- a/gfx/tests/gtest/TestCompositor.cpp +++ b/gfx/tests/gtest/TestCompositor.cpp @@ -44,7 +44,7 @@ public: mozilla::gl::SurfaceCaps caps = mozilla::gl::SurfaceCaps::ForRGB(); caps.preserve = false; caps.bpp16 = false; - nsRefPtr context = GLContextProvider::CreateOffscreen( + RefPtr context = GLContextProvider::CreateOffscreen( IntSize(gCompWidth, gCompHeight), caps, CreateContextFlags::REQUIRE_COMPAT_PROFILE); return context.forget().take(); @@ -88,7 +88,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(MockWidget, nsBaseWidget) struct LayerManagerData { RefPtr mWidget; RefPtr mCompositor; - nsRefPtr mLayerManager; + RefPtr mLayerManager; LayerManagerData(Compositor* compositor, MockWidget* widget, LayerManagerComposite* layerManager) : mWidget(widget) @@ -142,7 +142,7 @@ static std::vector GetLayerManagers(std::vector RefPtr widget = new MockWidget(); RefPtr compositor = CreateTestCompositor(backend, widget); - nsRefPtr layerManager = new LayerManagerComposite(compositor); + RefPtr layerManager = new LayerManagerComposite(compositor); layerManager->Initialize(); @@ -177,7 +177,7 @@ static already_AddRefed CreateDT() IntSize(gCompWidth, gCompHeight), SurfaceFormat::B8G8R8A8); } -static bool CompositeAndCompare(nsRefPtr layerManager, DrawTarget* refDT) +static bool CompositeAndCompare(RefPtr layerManager, DrawTarget* refDT) { RefPtr drawTarget = CreateDT(); @@ -226,16 +226,16 @@ TEST(Gfx, CompositorSimpleTree) { auto layerManagers = GetLayerManagers(GetPlatformBackends()); for (size_t i = 0; i < layerManagers.size(); i++) { - nsRefPtr layerManager = layerManagers[i].mLayerManager; - nsRefPtr lmBase = layerManager.get(); - nsTArray> layers; + RefPtr layerManager = layerManagers[i].mLayerManager; + RefPtr lmBase = layerManager.get(); + nsTArray> layers; nsIntRegion layerVisibleRegion[] = { nsIntRegion(IntRect(0, 0, gCompWidth, gCompHeight)), nsIntRegion(IntRect(0, 0, gCompWidth, gCompHeight)), nsIntRegion(IntRect(0, 0, 100, 100)), nsIntRegion(IntRect(0, 50, 100, 100)), }; - nsRefPtr root = CreateLayerTree("c(ooo)", layerVisibleRegion, nullptr, lmBase, layers); + RefPtr root = CreateLayerTree("c(ooo)", layerVisibleRegion, nullptr, lmBase, layers); { // background ColorLayer* colorLayer = layers[1]->AsColorLayer(); diff --git a/gfx/tests/gtest/TestLayers.cpp b/gfx/tests/gtest/TestLayers.cpp index 8bbbc808fa..9ffa4528fb 100644 --- a/gfx/tests/gtest/TestLayers.cpp +++ b/gfx/tests/gtest/TestLayers.cpp @@ -59,7 +59,7 @@ public: virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) { return false; } virtual already_AddRefed CreateContainerLayer() { - nsRefPtr layer = new TestContainerLayer(this); + RefPtr layer = new TestContainerLayer(this); return layer.forget(); } virtual void GetBackendName(nsAString& aName) {} @@ -70,7 +70,7 @@ public: return nullptr; } virtual already_AddRefed CreatePaintedLayer() { - nsRefPtr layer = new TestPaintedLayer(this); + RefPtr layer = new TestPaintedLayer(this); return layer.forget(); } virtual already_AddRefed CreateColorLayer() { @@ -167,7 +167,7 @@ TEST(Layers, UserData) { static already_AddRefed CreateLayer(char aLayerType, LayerManager* aManager) { - nsRefPtr layer = nullptr; + RefPtr layer = nullptr; if (aLayerType == 'c') { layer = aManager->CreateContainerLayer(); } else if (aLayerType == 't') { @@ -182,8 +182,8 @@ already_AddRefed CreateLayerTree( const char* aLayerTreeDescription, nsIntRegion* aVisibleRegions, const Matrix4x4* aTransforms, - nsRefPtr& manager, - nsTArray >& aLayersOut) { + RefPtr& manager, + nsTArray >& aLayersOut) { aLayersOut.Clear(); @@ -191,9 +191,9 @@ already_AddRefed CreateLayerTree( manager = new TestLayerManager(); } - nsRefPtr rootLayer = nullptr; - nsRefPtr parentContainerLayer = nullptr; - nsRefPtr lastLayer = nullptr; + RefPtr rootLayer = nullptr; + RefPtr parentContainerLayer = nullptr; + RefPtr lastLayer = nullptr; int layerNumber = 0; for (size_t i = 0; i < strlen(aLayerTreeDescription); i++) { if (aLayerTreeDescription[i] == '(') { @@ -210,7 +210,7 @@ already_AddRefed CreateLayerTree( parentContainerLayer = parentContainerLayer->GetParent(); lastLayer = nullptr; } else { - nsRefPtr layer = CreateLayer(aLayerTreeDescription[i], manager.get()); + RefPtr layer = CreateLayer(aLayerTreeDescription[i], manager.get()); if (aVisibleRegions) { layer->SetVisibleRegion(aVisibleRegions[layerNumber]); layer->SetEventRegions(EventRegions(aVisibleRegions[layerNumber])); @@ -258,10 +258,10 @@ TEST(Layers, LayerTree) { Matrix4x4(), Matrix4x4(), }; - nsTArray > layers; + nsTArray > layers; - nsRefPtr lm; - nsRefPtr root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers); + RefPtr lm; + RefPtr root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers); // B2G g++ doesn't like ASSERT_NE with nullptr directly. It thinks it's // an int. @@ -291,7 +291,7 @@ static void ValidateTreePointers(Layer* aLayer) { } } -static void ValidateTreePointers(nsTArray >& aLayers) { +static void ValidateTreePointers(nsTArray >& aLayers) { for (uint32_t i = 0; i < aLayers.Length(); i++) { ValidateTreePointers(aLayers[i]); } @@ -300,9 +300,9 @@ static void ValidateTreePointers(nsTArray >& aLayers) { TEST(Layers, RepositionChild) { const char* layerTreeSyntax = "c(ttt)"; - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root = CreateLayerTree(layerTreeSyntax, nullptr, nullptr, lm, layers); + nsTArray > layers; + RefPtr lm; + RefPtr root = CreateLayerTree(layerTreeSyntax, nullptr, nullptr, lm, layers); ContainerLayer* parent = root->AsContainerLayer(); ValidateTreePointers(layers); @@ -351,9 +351,9 @@ TEST(Layers, RepositionChild) { } TEST(LayerMetricsWrapper, SimpleTree) { - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root = CreateLayerTree("c(c(c(tt)c(t)))", nullptr, nullptr, lm, layers); + nsTArray > layers; + RefPtr lm; + RefPtr root = CreateLayerTree("c(c(c(tt)c(t)))", nullptr, nullptr, lm, layers); LayerMetricsWrapper wrapper(root); ASSERT_EQ(root.get(), wrapper.GetLayer()); @@ -395,9 +395,9 @@ MakeMetrics(FrameMetrics::ViewID aId) { } TEST(LayerMetricsWrapper, MultiFramemetricsTree) { - nsTArray > layers; - nsRefPtr lm; - nsRefPtr root = CreateLayerTree("c(c(c(tt)c(t)))", nullptr, nullptr, lm, layers); + nsTArray > layers; + RefPtr lm; + RefPtr root = CreateLayerTree("c(c(c(tt)c(t)))", nullptr, nullptr, lm, layers); nsTArray metrics; metrics.InsertElementAt(0, MakeMetrics(FrameMetrics::START_SCROLL_ID + 0)); // topmost of root layer diff --git a/gfx/tests/gtest/TestLayers.h b/gfx/tests/gtest/TestLayers.h index f918ef6c31..18e351f771 100644 --- a/gfx/tests/gtest/TestLayers.h +++ b/gfx/tests/gtest/TestLayers.h @@ -28,8 +28,8 @@ already_AddRefed CreateLayerTree( const char* aLayerTreeDescription, nsIntRegion* aVisibleRegions, const mozilla::gfx::Matrix4x4* aTransforms, - nsRefPtr& aLayerManager, - nsTArray >& aLayersOut); + RefPtr& aLayerManager, + nsTArray >& aLayersOut); #endif diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index 3d50550855..6159f35de5 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -187,7 +187,7 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface) if (host->Lock()) { RefPtr hostDataSurface = host->GetAsSurface(); - nsRefPtr hostSurface = + RefPtr hostSurface = new gfxImageSurface(hostDataSurface->GetData(), hostDataSurface->GetSize(), hostDataSurface->Stride(), diff --git a/gfx/tests/gtest/TestVsync.cpp b/gfx/tests/gtest/TestVsync.cpp index 45a71564d7..18237b02ee 100644 --- a/gfx/tests/gtest/TestVsync.cpp +++ b/gfx/tests/gtest/TestVsync.cpp @@ -9,7 +9,7 @@ #include "gfxPrefs.h" #include "MainThreadUtils.h" #include "nsIThread.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "SoftwareVsyncSource.h" #include "VsyncSource.h" #include "mozilla/Monitor.h" @@ -87,7 +87,7 @@ protected: mVsyncSource = nullptr; } - nsRefPtr mVsyncSource; + RefPtr mVsyncSource; }; static void @@ -130,8 +130,8 @@ TEST_F(VsyncTester, CompositorGetVsyncNotifications) globalDisplay.DisableVsync(); ASSERT_FALSE(globalDisplay.IsVsyncEnabled()); - nsRefPtr vsyncDispatcher = new CompositorVsyncDispatcher(); - nsRefPtr testVsyncObserver = new TestVsyncObserver(); + RefPtr vsyncDispatcher = new CompositorVsyncDispatcher(); + RefPtr testVsyncObserver = new TestVsyncObserver(); vsyncDispatcher->SetCompositorVsyncObserver(testVsyncObserver); FlushMainThreadLoop(); @@ -155,10 +155,10 @@ TEST_F(VsyncTester, ParentRefreshDriverGetVsyncNotifications) globalDisplay.DisableVsync(); ASSERT_FALSE(globalDisplay.IsVsyncEnabled()); - nsRefPtr vsyncDispatcher = globalDisplay.GetRefreshTimerVsyncDispatcher(); + RefPtr vsyncDispatcher = globalDisplay.GetRefreshTimerVsyncDispatcher(); ASSERT_TRUE(vsyncDispatcher != nullptr); - nsRefPtr testVsyncObserver = new TestVsyncObserver(); + RefPtr testVsyncObserver = new TestVsyncObserver(); vsyncDispatcher->SetParentRefreshTimer(testVsyncObserver); ASSERT_TRUE(globalDisplay.IsVsyncEnabled()); @@ -185,10 +185,10 @@ TEST_F(VsyncTester, ChildRefreshDriverGetVsyncNotifications) globalDisplay.DisableVsync(); ASSERT_FALSE(globalDisplay.IsVsyncEnabled()); - nsRefPtr vsyncDispatcher = globalDisplay.GetRefreshTimerVsyncDispatcher(); + RefPtr vsyncDispatcher = globalDisplay.GetRefreshTimerVsyncDispatcher(); ASSERT_TRUE(vsyncDispatcher != nullptr); - nsRefPtr testVsyncObserver = new TestVsyncObserver(); + RefPtr testVsyncObserver = new TestVsyncObserver(); vsyncDispatcher->AddChildRefreshTimer(testVsyncObserver); ASSERT_TRUE(globalDisplay.IsVsyncEnabled()); diff --git a/gfx/tests/gtest/gfxFontSelectionTest.cpp b/gfx/tests/gtest/gfxFontSelectionTest.cpp index ca5e72b02c..31c11afbfd 100644 --- a/gfx/tests/gtest/gfxFontSelectionTest.cpp +++ b/gfx/tests/gtest/gfxFontSelectionTest.cpp @@ -191,7 +191,7 @@ MakeContext () RefPtr drawTarget = gfxPlatform::GetPlatform()-> CreateOffscreenContentDrawTarget(IntSize(size, size), SurfaceFormat::B8G8R8X8); - nsRefPtr ctx = new gfxContext(drawTarget); + RefPtr ctx = new gfxContext(drawTarget); return ctx.forget(); } @@ -247,7 +247,7 @@ void SetupTests(nsTArray& testList); static bool RunTest (TestEntry *test, gfxContext *ctx) { - nsRefPtr fontGroup; + RefPtr fontGroup; fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle, nullptr, nullptr); @@ -295,7 +295,7 @@ TEST(Gfx, FontSelection) { nsTArray testList; SetupTests(testList); - nsRefPtr context = MakeContext(); + RefPtr context = MakeContext(); for (uint32_t test = 0; test < testList.Length(); diff --git a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp index f24959964c..d874584910 100644 --- a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp +++ b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp @@ -44,7 +44,7 @@ TestNewSurface () { int failures = 0; int destroyed = 0; - nsRefPtr s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), gfxImageFormat::ARGB32); + RefPtr s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), gfxImageFormat::ARGB32); cairo_surface_t *cs = s->CairoSurface(); cairo_surface_set_user_data (cs, &destruction_key, &destroyed, SurfaceDestroyNotifier); @@ -98,7 +98,7 @@ TestExistingSurface () { failures += CheckInt (cairo_surface_get_reference_count(cs), 1); failures += CheckInt (destroyed, 0); - nsRefPtr s = gfxASurface::Wrap(cs); + RefPtr s = gfxASurface::Wrap(cs); failures += CheckInt (GetASurfaceRefCount(s.get()), 2); diff --git a/gfx/tests/gtest/gfxTextRunPerfTest.cpp b/gfx/tests/gtest/gfxTextRunPerfTest.cpp index c321b0ff67..2e3298b08d 100644 --- a/gfx/tests/gtest/gfxTextRunPerfTest.cpp +++ b/gfx/tests/gtest/gfxTextRunPerfTest.cpp @@ -43,7 +43,7 @@ MakeContext () RefPtr drawTarget = gfxPlatform::GetPlatform()-> CreateOffscreenContentDrawTarget(IntSize(size, size), SurfaceFormat::B8G8R8X8); - nsRefPtr ctx = new gfxContext(drawTarget); + RefPtr ctx = new gfxContext(drawTarget); return ctx.forget(); } @@ -52,7 +52,7 @@ const char* lastFamilies = nullptr; static void RunTest (TestEntry *test, gfxContext *ctx) { - nsRefPtr fontGroup; + RefPtr fontGroup; if (!lastFamilies || strcmp(lastFamilies, test->mFamilies)) { gfxFontStyle style_western_normal_16 (mozilla::gfx::FontStyle::NORMAL, 400, @@ -101,7 +101,7 @@ RunTest (TestEntry *test, gfxContext *ctx) { uint32_t iterations = 1; TEST(Gfx, TextRunPref) { - nsRefPtr context = MakeContext(); + RefPtr context = MakeContext(); // Start timing PRIntervalTime start = PR_IntervalNow(); diff --git a/gfx/tests/gtest/gfxWordCacheTest.cpp b/gfx/tests/gtest/gfxWordCacheTest.cpp index 5352add078..70d11810b1 100644 --- a/gfx/tests/gtest/gfxWordCacheTest.cpp +++ b/gfx/tests/gtest/gfxWordCacheTest.cpp @@ -89,7 +89,7 @@ MakeContext () RefPtr drawTarget = gfxPlatform::GetPlatform()-> CreateOffscreenContentDrawTarget(IntSize(size, size), SurfaceFormat::B8G8R8X8); - nsRefPtr ctx = new gfxContext(drawTarget); + RefPtr ctx = new gfxContext(drawTarget); return ctx.forget(); } @@ -97,7 +97,7 @@ MakeContext () TEST(Gfx, WordCache) { gTextRuns = new FrameTextRunCache(); - nsRefPtr ctx = MakeContext(); + RefPtr ctx = MakeContext(); { gfxFontStyle style(mozilla::gfx::FontStyle::NORMAL, 139, @@ -108,7 +108,7 @@ TEST(Gfx, WordCache) { false, false, NS_LITERAL_STRING("")); - nsRefPtr fontGroup = + RefPtr fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup( NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style, nullptr, nullptr); diff --git a/gfx/thebes/SoftwareVsyncSource.h b/gfx/thebes/SoftwareVsyncSource.h index f4923b274a..e648b64b6e 100644 --- a/gfx/thebes/SoftwareVsyncSource.h +++ b/gfx/thebes/SoftwareVsyncSource.h @@ -57,7 +57,7 @@ public: } private: - nsRefPtr mGlobalDisplay; + RefPtr mGlobalDisplay; }; #endif /* GFX_SOFTWARE_VSYNC_SOURCE_H */ diff --git a/gfx/thebes/VsyncSource.cpp b/gfx/thebes/VsyncSource.cpp index 8624c64921..d25119d9af 100644 --- a/gfx/thebes/VsyncSource.cpp +++ b/gfx/thebes/VsyncSource.cpp @@ -31,7 +31,7 @@ VsyncSource::RemoveCompositorVsyncDispatcher(CompositorVsyncDispatcher* aComposi GetGlobalDisplay().RemoveCompositorVsyncDispatcher(aCompositorVsyncDispatcher); } -nsRefPtr +RefPtr VsyncSource::GetRefreshTimerVsyncDispatcher() { MOZ_ASSERT(XRE_IsParentProcess()); @@ -130,7 +130,7 @@ VsyncSource::Display::UpdateVsyncStatus() } } -nsRefPtr +RefPtr VsyncSource::Display::GetRefreshTimerVsyncDispatcher() { return mRefreshTimerVsyncDispatcher; diff --git a/gfx/thebes/VsyncSource.h b/gfx/thebes/VsyncSource.h index b068728f39..bd1b5bb0b2 100644 --- a/gfx/thebes/VsyncSource.h +++ b/gfx/thebes/VsyncSource.h @@ -7,7 +7,7 @@ #define GFX_VSYNCSOURCE_H #include "nsTArray.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "mozilla/Mutex.h" #include "mozilla/TimeStamp.h" #include "nsISupportsImpl.h" @@ -45,7 +45,7 @@ public: // Large parts of Gecko assume TimeStamps should not be in the future such as animations virtual void NotifyVsync(TimeStamp aVsyncTimestamp); - nsRefPtr GetRefreshTimerVsyncDispatcher(); + RefPtr GetRefreshTimerVsyncDispatcher(); void AddCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher); void RemoveCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher); @@ -61,14 +61,14 @@ public: Mutex mDispatcherLock; bool mRefreshTimerNeedsVsync; - nsTArray> mCompositorVsyncDispatchers; - nsRefPtr mRefreshTimerVsyncDispatcher; + nsTArray> mCompositorVsyncDispatchers; + RefPtr mRefreshTimerVsyncDispatcher; }; void AddCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher); void RemoveCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher); - nsRefPtr GetRefreshTimerVsyncDispatcher(); + RefPtr GetRefreshTimerVsyncDispatcher(); virtual Display& GetGlobalDisplay() = 0; // Works across all displays protected: diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 78db721361..828bd5807a 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -156,7 +156,7 @@ gfxASurface::SetSurfaceWrapper(cairo_surface_t *csurf, gfxASurface *asurf) already_AddRefed gfxASurface::Wrap (cairo_surface_t *csurf, const IntSize& aSize) { - nsRefPtr result; + RefPtr result; /* Do we already have a wrapper for this surface? */ result = GetSurfaceWrapper(csurf); @@ -334,7 +334,7 @@ gfxASurface::CreateSimilarSurface(gfxContentType aContent, return nullptr; } - nsRefPtr result = Wrap(surface, aSize); + RefPtr result = Wrap(surface, aSize); cairo_surface_destroy(surface); return result.forget(); } @@ -342,7 +342,7 @@ gfxASurface::CreateSimilarSurface(gfxContentType aContent, already_AddRefed gfxASurface::GetAsReadableARGB32ImageSurface() { - nsRefPtr imgSurface = GetAsImageSurface(); + RefPtr imgSurface = GetAsImageSurface(); if (!imgSurface || imgSurface->Format() != gfxImageFormat::ARGB32) { imgSurface = CopyToARGB32ImageSurface(); } @@ -357,7 +357,7 @@ gfxASurface::CopyToARGB32ImageSurface() } const IntSize size = GetSize(); - nsRefPtr imgSurface = + RefPtr imgSurface = new gfxImageSurface(size, gfxImageFormat::ARGB32); RefPtr dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height)); diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index ef563b78b5..7212f9f6df 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -125,7 +125,7 @@ already_AddRefed gfxAndroidPlatform::CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) { - nsRefPtr newSurface; + RefPtr newSurface; newSurface = new gfxImageSurface(aSize, aFormat); return newSurface.forget(); @@ -499,7 +499,7 @@ gfxAndroidPlatform::CreateHardwareVsyncSource() // L is android version 21, L-MR1 is 22, kit-kat is 19, 20 is kit-kat for // wearables. #if defined(MOZ_WIDGET_GONK) && (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21) - nsRefPtr vsyncSource = new GonkVsyncSource(); + RefPtr vsyncSource = new GonkVsyncSource(); VsyncSource::Display& display = vsyncSource->GetGlobalDisplay(); display.EnableVsync(); if (!display.IsVsyncEnabled()) { diff --git a/gfx/thebes/gfxBaseSharedMemorySurface.h b/gfx/thebes/gfxBaseSharedMemorySurface.h index 98451189c2..06dbebb3f7 100644 --- a/gfx/thebes/gfxBaseSharedMemorySurface.h +++ b/gfx/thebes/gfxBaseSharedMemorySurface.h @@ -81,7 +81,7 @@ public: gfxImageFormat format = (gfxImageFormat)shmInfo->format; long stride = gfxImageSurface::ComputeStride(size, format); - nsRefPtr s = + RefPtr s = new Sub(size, stride, format, @@ -179,7 +179,7 @@ private: return nullptr; } - nsRefPtr s = + RefPtr s = new Sub(aSize, stride, aFormat, shmem); if (s->CairoStatus() != 0) { aAllocator->DeallocShmem(shmem); diff --git a/gfx/thebes/gfxBlur.cpp b/gfx/thebes/gfxBlur.cpp index 8036fb456d..94b2afef2b 100644 --- a/gfx/thebes/gfxBlur.cpp +++ b/gfx/thebes/gfxBlur.cpp @@ -69,7 +69,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect, } memset(mData, 0, blurDataSize); - mozilla::RefPtr dt = + RefPtr dt = gfxPlatform::GetPlatform()->CreateDrawTargetForData(mData, size, mBlur->GetStride(), SurfaceFormat::A8); @@ -94,7 +94,7 @@ DrawBlur(gfxContext* aDestinationCtx, { DrawTarget *dest = aDestinationCtx->GetDrawTarget(); - nsRefPtr thebesPat = aDestinationCtx->GetPattern(); + RefPtr thebesPat = aDestinationCtx->GetPattern(); Pattern* pat = thebesPat->GetPattern(dest, nullptr); Matrix oldTransform = dest->GetTransform(); diff --git a/gfx/thebes/gfxBlur.h b/gfx/thebes/gfxBlur.h index 7f69288fe1..c39410f995 100644 --- a/gfx/thebes/gfxBlur.h +++ b/gfx/thebes/gfxBlur.h @@ -177,7 +177,7 @@ protected: /** * The context of the temporary alpha surface. */ - nsRefPtr mContext; + RefPtr mContext; /** * The temporary alpha surface. diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 403d0aedc4..dc6a0de597 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -89,7 +89,7 @@ gfxContext::gfxContext(DrawTarget *aTarget, const Point& aDeviceOffset) gfxContext::ContextForDrawTarget(DrawTarget* aTarget) { Matrix transform = aTarget->GetTransform(); - nsRefPtr result = new gfxContext(aTarget); + RefPtr result = new gfxContext(aTarget); result->SetMatrix(ThebesMatrix(transform)); return result.forget(); } @@ -763,7 +763,7 @@ gfxContext::SetPattern(gfxPattern *pattern) already_AddRefed gfxContext::GetPattern() { - nsRefPtr pat; + RefPtr pat; AzureState &state = CurrentState(); if (state.pattern) { @@ -962,7 +962,7 @@ gfxContext::PopGroup() mat.Invert(); mat.PreTranslate(deviceOffset.x, deviceOffset.y); // device offset translation - nsRefPtr pat = new gfxPattern(src, mat); + RefPtr pat = new gfxPattern(src, mat); return pat.forget(); } diff --git a/gfx/thebes/gfxContext.h b/gfx/thebes/gfxContext.h index ead7e5f8f6..fb4be6d36e 100644 --- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -502,14 +502,14 @@ private: mozilla::gfx::CompositionOp op; Color color; - nsRefPtr pattern; - nsRefPtr sourceSurfCairo; - mozilla::RefPtr sourceSurface; + RefPtr pattern; + RefPtr sourceSurfCairo; + RefPtr sourceSurface; mozilla::gfx::Point sourceSurfaceDeviceOffset; Matrix surfTransform; Matrix transform; struct PushedClip { - mozilla::RefPtr path; + RefPtr path; Rect rect; Matrix transform; }; @@ -518,8 +518,8 @@ private: bool clipWasReset; mozilla::gfx::FillRule fillRule; StrokeOptions strokeOptions; - mozilla::RefPtr drawTarget; - mozilla::RefPtr parentTarget; + RefPtr drawTarget; + RefPtr parentTarget; mozilla::gfx::AntialiasMode aaMode; bool patternTransformChanged; Matrix patternTransform; @@ -545,8 +545,8 @@ private: bool mTransformChanged; Matrix mPathTransform; Rect mRect; - mozilla::RefPtr mPathBuilder; - mozilla::RefPtr mPath; + RefPtr mPathBuilder; + RefPtr mPath; Matrix mTransform; nsTArray mStateStack; @@ -555,8 +555,8 @@ private: cairo_t *mRefCairo; - mozilla::RefPtr mDT; - mozilla::RefPtr mOriginalDT; + RefPtr mDT; + RefPtr mOriginalDT; }; /** @@ -671,7 +671,7 @@ public: } private: - mozilla::RefPtr mDT; + RefPtr mDT; bool mSubpixelAntialiasingEnabled; }; diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index 7e7a897745..9cd719523e 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -63,7 +63,7 @@ GetDirectWriteFontName(IDWriteFont *aFont, nsAString& aFontName) { HRESULT hr; - nsRefPtr names; + RefPtr names; hr = aFont->GetFaceNames(getter_AddRefs(names)); if (FAILED(hr)) { return hr; @@ -108,7 +108,7 @@ GetDirectWriteFaceName(IDWriteFont *aFont, HRESULT hr; BOOL exists; - nsRefPtr infostrings; + RefPtr infostrings; hr = aFont->GetInformationalStrings(aWhichName, getter_AddRefs(infostrings), &exists); if (FAILED(hr) || !exists) { return E_FAIL; @@ -158,7 +158,7 @@ gfxDWriteFontFamily::FindStyleVariations(FontInfoData *aFontInfoData) aFontInfoData; for (UINT32 i = 0; i < mDWFamily->GetFontCount(); i++) { - nsRefPtr font; + RefPtr font; hr = mDWFamily->GetFont(i, getter_AddRefs(font)); if (FAILED(hr)) { // This should never happen. @@ -278,7 +278,7 @@ gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName) localeName.AssignLiteral("en-us"); } - nsRefPtr names; + RefPtr names; hr = mDWFamily->GetFamilyNames(getter_AddRefs(names)); if (FAILED(hr)) { @@ -415,7 +415,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, return NS_ERROR_FAILURE; } - nsRefPtr fontFace; + RefPtr fontFace; nsresult rv = CreateFontFace(getter_AddRefs(fontFace)); if (NS_FAILED(rv)) { return rv; @@ -465,7 +465,7 @@ public: } private: - nsRefPtr mFontFace; + RefPtr mFontFace; void *mContext; }; @@ -510,7 +510,7 @@ gfxDWriteFontEntry::ReadCMAP(FontInfoData *aFontInfoData) return NS_OK; } - nsRefPtr charmap; + RefPtr charmap; nsresult rv; bool symbolFont; @@ -791,7 +791,7 @@ gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName, return nullptr; } - nsRefPtr fontFile; + RefPtr fontFile; HRESULT hr; /** @@ -890,7 +890,7 @@ gfxDWriteFontList::InitFontList() QueryPerformanceCounter(&t2); // base-class/interop initialization - nsRefPtr factory = + RefPtr factory = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory(); hr = factory->GetSystemFontCollection(getter_AddRefs(mSystemFonts)); @@ -949,7 +949,7 @@ gfxDWriteFontList::InitFontList() if (gillSansFamily && gillSansMTFamily) { gillSansFamily->FindStyleVariations(); - nsTArray >& faces = gillSansFamily->GetFontList(); + nsTArray >& faces = gillSansFamily->GetFontList(); uint32_t i; bool allUltraBold = true; @@ -1047,10 +1047,10 @@ void gfxDWriteFontList::GetFontsFromCollection(IDWriteFontCollection* aCollection) { for (UINT32 i = 0; i < aCollection->GetFontFamilyCount(); i++) { - nsRefPtr family; + RefPtr family; aCollection->GetFontFamily(i, getter_AddRefs(family)); - nsRefPtr names; + RefPtr names; HRESULT hr = family->GetFamilyNames(getter_AddRefs(names)); if (FAILED(hr)) { continue; @@ -1089,7 +1089,7 @@ gfxDWriteFontList::GetFontsFromCollection(IDWriteFontCollection* aCollection) nsAutoString name(enName.Elements()); BuildKeyNameFromFontName(name); - nsRefPtr fam; + RefPtr fam; if (mFontFamilies.GetWeak(name)) { continue; @@ -1305,7 +1305,7 @@ gfxDWriteFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName) { HRESULT hr; - nsRefPtr family; + RefPtr family; // clean out previous value aFamilyName.Truncate(); @@ -1315,7 +1315,7 @@ static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName) return hr; } - nsRefPtr familyNames; + RefPtr familyNames; hr = family->GetFamilyNames(getter_AddRefs(familyNames)); if (FAILED(hr)) { @@ -1375,7 +1375,7 @@ IFACEMETHODIMP FontFallbackRenderer::DrawGlyphRun( HRESULT hr = S_OK; - nsRefPtr font; + RefPtr font; hr = mSystemFonts->GetFontFromFontFace(glyphRun->fontFace, getter_AddRefs(font)); if (FAILED(hr)) { @@ -1416,7 +1416,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh, HRESULT hr; - nsRefPtr dwFactory = + RefPtr dwFactory = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory(); if (!dwFactory) { return nullptr; @@ -1456,7 +1456,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh, } // set up layout - nsRefPtr fallbackLayout; + RefPtr fallbackLayout; hr = dwFactory->CreateTextLayout(str, strLen, mFallbackFormat, 200.0f, 200.0f, @@ -1511,9 +1511,9 @@ public: virtual void LoadFontFamilyData(const nsAString& aFamilyName); private: - nsRefPtr mSystemFonts; + RefPtr mSystemFonts; #ifdef MOZ_BUNDLED_FONTS - nsRefPtr mBundledFonts; + RefPtr mBundledFonts; #endif }; @@ -1534,7 +1534,7 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName) BOOL exists = false; uint32_t index; - nsRefPtr family; + RefPtr family; hr = mSystemFonts->FindFamilyName(famName.Elements(), &index, &exists); if (SUCCEEDED(hr) && exists) { mSystemFonts->GetFontFamily(index, getter_AddRefs(family)); @@ -1561,7 +1561,7 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName) for (uint32_t i = 0; i < family->GetFontCount(); i++) { // get the font - nsRefPtr dwFont; + RefPtr dwFont; hr = family->GetFont(i, getter_AddRefs(dwFont)); if (FAILED(hr)) { // This should never happen. @@ -1589,7 +1589,7 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName) FontFaceData fontData; bool haveData = true; - nsRefPtr dwFontFace; + RefPtr dwFontFace; if (mLoadFaceNames) { // try to load using DirectWrite first @@ -1660,7 +1660,7 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName) if (SUCCEEDED(hr)) { bool cmapLoaded = false; bool unicodeFont = false, symbolFont = false; - nsRefPtr charmap = new gfxCharacterMap(); + RefPtr charmap = new gfxCharacterMap(); uint32_t offset; if (cmapData && @@ -1692,7 +1692,7 @@ gfxDWriteFontList::CreateFontInfoData() bool loadCmaps = !UsesSystemFallback() || gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback(); - nsRefPtr fi = + RefPtr fi = new DirectWriteFontInfo(false, NeedFullnamePostscriptNames(), loadCmaps, mSystemFonts #ifdef MOZ_BUNDLED_FONTS @@ -1743,7 +1743,7 @@ private: BundledFontFileEnumerator& operator=(const BundledFontFileEnumerator&) = delete; virtual ~BundledFontFileEnumerator() {} - nsRefPtr mFactory; + RefPtr mFactory; nsCOMPtr mFontDir; nsCOMPtr mEntries; @@ -1840,13 +1840,13 @@ gfxDWriteFontList::CreateBundledFontsCollection(IDWriteFactory* aFactory) return nullptr; } - nsRefPtr loader = new BundledFontLoader(); + RefPtr loader = new BundledFontLoader(); if (FAILED(aFactory->RegisterFontCollectionLoader(loader))) { return nullptr; } const void *key = localDir.get(); - nsRefPtr collection; + RefPtr collection; HRESULT hr = aFactory->CreateCustomFontCollection(loader, &key, sizeof(key), getter_AddRefs(collection)); diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 9d2920d717..ce034a2164 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -59,7 +59,7 @@ public: protected: /** This font family's directwrite fontfamily object */ - nsRefPtr mDWFamily; + RefPtr mDWFamily; bool mForceGDIClassic; }; @@ -180,12 +180,12 @@ protected: * A fontentry only needs to have either of these. If it has both only * the IDWriteFont will be used. */ - nsRefPtr mFont; - nsRefPtr mFontFile; + RefPtr mFont; + RefPtr mFontFile; // font face corresponding to the mFont/mFontFile *without* any DWrite // style simulations applied - nsRefPtr mFontFace; + RefPtr mFontFace; DWRITE_FONT_FACE_TYPE mFaceType; @@ -327,7 +327,7 @@ public: protected: long mRefCount; - nsRefPtr mSystemFonts; + RefPtr mSystemFonts; nsString mFamilyName; }; @@ -416,14 +416,14 @@ private: // whether to use GDI font table access routines bool mGDIFontTableAccess; - nsRefPtr mGDIInterop; + RefPtr mGDIInterop; - nsRefPtr mFallbackRenderer; - nsRefPtr mFallbackFormat; + RefPtr mFallbackRenderer; + RefPtr mFallbackFormat; - nsRefPtr mSystemFonts; + RefPtr mSystemFonts; #ifdef MOZ_BUNDLED_FONTS - nsRefPtr mBundledFonts; + RefPtr mBundledFonts; #endif }; diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 04e67b66fb..3f387615a7 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -143,7 +143,7 @@ gfxDWriteFont::GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics) return false; } - nsRefPtr font = fe->FindOrMakeFont(&style, needsBold); + RefPtr font = fe->FindOrMakeFont(&style, needsBold); gfxDWriteFont *dwFont = static_cast(font.get()); dwFont->mFontFace->GetMetrics(aFontMetrics); diff --git a/gfx/thebes/gfxDWriteFonts.h b/gfx/thebes/gfxDWriteFonts.h index 834913548f..89c085e6d6 100644 --- a/gfx/thebes/gfxDWriteFonts.h +++ b/gfx/thebes/gfxDWriteFonts.h @@ -90,7 +90,7 @@ protected: DWRITE_MEASURING_MODE GetMeasuringMode(); bool GetForceGDIClassic(); - nsRefPtr mFontFace; + RefPtr mFontFace; cairo_font_face_t *mCairoFontFace; Metrics *mMetrics; diff --git a/gfx/thebes/gfxDrawable.cpp b/gfx/thebes/gfxDrawable.cpp index ec78b59c68..0cabbf20ad 100644 --- a/gfx/thebes/gfxDrawable.cpp +++ b/gfx/thebes/gfxDrawable.cpp @@ -126,12 +126,12 @@ gfxCallbackDrawable::MakeSurfaceDrawable(const Filter aFilter) if (!dt) return nullptr; - nsRefPtr ctx = new gfxContext(dt); + RefPtr ctx = new gfxContext(dt); Draw(ctx, gfxRect(0, 0, mSize.width, mSize.height), false, aFilter); RefPtr surface = dt->Snapshot(); if (surface) { - nsRefPtr drawable = new gfxSurfaceDrawable(surface, mSize); + RefPtr drawable = new gfxSurfaceDrawable(surface, mSize); return drawable.forget(); } return nullptr; @@ -188,15 +188,15 @@ public: aTransform); } private: - nsRefPtr mDrawable; + RefPtr mDrawable; }; already_AddRefed gfxPatternDrawable::MakeCallbackDrawable() { - nsRefPtr callback = + RefPtr callback = new DrawingCallbackFromDrawable(this); - nsRefPtr callbackDrawable = + RefPtr callbackDrawable = new gfxCallbackDrawable(callback, mSize); return callbackDrawable.forget(); } @@ -222,7 +222,7 @@ gfxPatternDrawable::Draw(gfxContext* aContext, // gfxCallbackDrawable and gfxSurfaceDrawable already know how to do // those things, so we use them here. Drawing mPattern into the surface // will happen through this Draw() method with aRepeat = false. - nsRefPtr callbackDrawable = MakeCallbackDrawable(); + RefPtr callbackDrawable = MakeCallbackDrawable(); return callbackDrawable->Draw(aContext, aFillRect, true, aFilter, aOpacity, aTransform); } diff --git a/gfx/thebes/gfxDrawable.h b/gfx/thebes/gfxDrawable.h index e1a470146d..efb6d9212b 100644 --- a/gfx/thebes/gfxDrawable.h +++ b/gfx/thebes/gfxDrawable.h @@ -89,7 +89,7 @@ protected: gfxFloat aOpacity, const gfxMatrix& aTransform = gfxMatrix()); - mozilla::RefPtr mSourceSurface; + RefPtr mSourceSurface; const gfxMatrix mTransform; }; @@ -137,8 +137,8 @@ public: protected: already_AddRefed MakeSurfaceDrawable(mozilla::gfx::Filter aFilter = mozilla::gfx::Filter::LINEAR); - nsRefPtr mCallback; - nsRefPtr mSurfaceDrawable; + RefPtr mCallback; + RefPtr mSurfaceDrawable; }; /** @@ -161,7 +161,7 @@ public: protected: already_AddRefed MakeCallbackDrawable(); - nsRefPtr mPattern; + RefPtr mPattern; }; #endif /* GFX_DRAWABLE_H */ diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 4433fb4ce6..839c4bede7 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -98,7 +98,7 @@ public: // have created the font entry. The only legitimate runtime failure // here would be memory allocation, in which case mFace remains null. if (aFontEntry->mFilename[0] != '/') { - nsRefPtr reader = + RefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); nsZipItem *item = reader->GetItem(aFontEntry->mFilename.get()); NS_ASSERTION(item, "failed to find zip entry"); @@ -460,7 +460,7 @@ FT2FontEntry::ReadCMAP(FontInfoData *aFontInfoData) return NS_OK; } - nsRefPtr charmap = new gfxCharacterMap(); + RefPtr charmap = new gfxCharacterMap(); AutoFallibleTArray buffer; nsresult rv = CopyFontTable(TTAG_cmap, buffer); @@ -986,7 +986,7 @@ gfxFT2FontList::FindFontsInOmnijar(FontNameCache *aCache) static const char* sJarSearchPaths[] = { "res/fonts/*.ttf$", }; - nsRefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); + RefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); for (unsigned i = 0; i < ArrayLength(sJarSearchPaths); i++) { nsZipFind* find; if (NS_SUCCEEDED(reader->FindInit(sJarSearchPaths[i], &find))) { @@ -1125,7 +1125,7 @@ gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive, // if aUserArg is non-null (i.e. we're using it as a boolean flag) static void FinalizeFamilyMemberList(nsStringHashKey::KeyType aKey, - nsRefPtr& aFamily, + RefPtr& aFamily, bool aSortFaces) { gfxFontFamily *family = aFamily.get(); @@ -1164,12 +1164,12 @@ gfxFT2FontList::FindFonts() // so we just maintain the existing order) for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsStringHashKey::KeyType key = iter.Key(); - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); FinalizeFamilyMemberList(key, family, /* aSortFaces */ false); } for (auto iter = mHiddenFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsStringHashKey::KeyType key = iter.Key(); - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); FinalizeFamilyMemberList(key, family, /* aSortFaces */ false ); } @@ -1237,12 +1237,12 @@ gfxFT2FontList::FindFonts() // Passing non-null userData here says that we want faces to be sorted. for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsStringHashKey::KeyType key = iter.Key(); - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); FinalizeFamilyMemberList(key, family, /* aSortFaces */ true); } for (auto iter = mHiddenFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsStringHashKey::KeyType key = iter.Key(); - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); FinalizeFamilyMemberList(key, family, /* aSortFaces */ true); } } @@ -1363,7 +1363,7 @@ LoadSkipSpaceLookupCheck(nsTHashtable& aSkipSpaceLookupCheck) void PreloadAsUserFontFaces(nsStringHashKey::KeyType aKey, - nsRefPtr& aFamily) + RefPtr& aFamily) { gfxFontFamily *family = aFamily.get(); @@ -1431,7 +1431,7 @@ gfxFT2FontList::InitFontList() for (auto iter = mHiddenFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsStringHashKey::KeyType key = iter.Key(); - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); PreloadAsUserFontFaces(key, family); } return NS_OK; @@ -1455,7 +1455,7 @@ gfxFT2FontList::LookupLocalFont(const nsAString& aFontName, for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { // Check family name, based on the assumption that the // first part of the full name is the family name - nsRefPtr& fontFamily = iter.Data(); + RefPtr& fontFamily = iter.Data(); // does the family name match up to the length of the family name? const nsString& family = fontFamily->Name(); @@ -1465,7 +1465,7 @@ gfxFT2FontList::LookupLocalFont(const nsAString& aFontName, // if so, iterate over faces in this family to see if there is a match if (family.Equals(fullNameFamily, nsCaseInsensitiveStringComparator())) { - nsTArray >& fontList = fontFamily->GetFontList(); + nsTArray >& fontList = fontFamily->GetFontList(); int index, len = fontList.Length(); for (index = 0; index < len; index++) { gfxFontEntry* fe = fontList[index]; @@ -1542,14 +1542,14 @@ gfxFT2FontList::MakePlatformFont(const nsAString& aFontName, } void -gfxFT2FontList::GetFontFamilyList(nsTArray >& aFamilyArray) +gfxFT2FontList::GetFontFamilyList(nsTArray >& aFamilyArray) { for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); aFamilyArray.AppendElement(family); } for (auto iter = mHiddenFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); aFamilyArray.AppendElement(family); } } diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index adb10ebba5..ecccf2b12e 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -140,7 +140,7 @@ public: return static_cast(gfxPlatformFontList::PlatformFontList()); } - virtual void GetFontFamilyList(nsTArray >& aFamilyArray); + virtual void GetFontFamilyList(nsTArray >& aFamilyArray); protected: typedef enum { diff --git a/gfx/thebes/gfxFT2Utils.h b/gfx/thebes/gfxFT2Utils.h index c41d007c32..35958bbf79 100644 --- a/gfx/thebes/gfxFT2Utils.h +++ b/gfx/thebes/gfxFT2Utils.h @@ -87,7 +87,7 @@ protected: FT_ULong variantSelector); CharVariantFunction FindCharVariantFunction(); - nsRefPtr mGfxFont; + RefPtr mGfxFont; FT_Face mFace; }; diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index 389a9f46f6..47e070f646 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -349,7 +349,7 @@ gfxFontconfigFontEntry::ReadCMAP(FontInfoData *aFontInfoData) return NS_OK; } - nsRefPtr charmap; + RefPtr charmap; nsresult rv; bool symbolFont = false; // currently ignored @@ -469,7 +469,7 @@ gfxFontconfigFontEntry::GetAspect() // create a font to calculate x-height / em-height gfxFontStyle s; s.size = 100.0; // pick large size to avoid possible hinting artifacts - nsRefPtr font = FindOrMakeFont(&s, false); + RefPtr font = FindOrMakeFont(&s, false); if (font) { const gfxFont::Metrics& metrics = font->GetMetrics(gfxFont::eHorizontal); @@ -1329,7 +1329,7 @@ gfxFcPlatformFontList::GetFTLibrary() if (!fe) { return nullptr; } - nsRefPtr font = fe->FindOrMakeFont(&style, false); + RefPtr font = fe->FindOrMakeFont(&style, false); if (!font) { return nullptr; } diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index c20dd920e4..73f0122686 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -81,7 +81,7 @@ public: } private: - nsRefPtr mUserFontData; + RefPtr mUserFontData; }; // The names for the font entry and font classes should really @@ -148,7 +148,7 @@ protected: nsCountedRef mFontPattern; // user font data, when needed - nsRefPtr mUserFontData; + RefPtr mUserFontData; // FTFace - initialized when needed FT_Face mFTFace; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index fb59326e42..0b2aaa17c0 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -231,7 +231,7 @@ gfxFontCache::Lookup(const gfxFontEntry* aFontEntry, if (!entry) return nullptr; - nsRefPtr font = entry->mFont; + RefPtr font = entry->mFont; return font.forget(); } @@ -1516,7 +1516,7 @@ private: if (state.pattern || mFontParams.contextPaint) { Pattern *pat; - nsRefPtr fillPattern; + RefPtr fillPattern; if (!mFontParams.contextPaint || !(fillPattern = mFontParams.contextPaint->GetFillPattern( mRunParams.context->GetDrawTarget(), @@ -1600,7 +1600,7 @@ private: RefPtr path = mFontParams.scaledFont->GetPathForGlyphs(aBuf, mRunParams.dt); if (mFontParams.contextPaint) { - nsRefPtr strokePattern = + RefPtr strokePattern = mFontParams.contextPaint->GetStrokePattern( mRunParams.context->GetDrawTarget(), mRunParams.context->CurrentMatrix()); @@ -1902,7 +1902,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd, // If no pattern is specified for fill, use the current pattern NS_ASSERTION((int(aRunParams.drawMode) & int(DrawMode::GLYPH_STROKE)) == 0, "no pattern supplied for stroking text"); - nsRefPtr fillPattern = aRunParams.context->GetPattern(); + RefPtr fillPattern = aRunParams.context->GetPattern(); contextPaint = new SimpleTextContextPaint(fillPattern, nullptr, aRunParams.context->CurrentMatrix()); @@ -2920,7 +2920,7 @@ gfxFont::InitFakeSmallCapsRun(gfxContext *aContext, { bool ok = true; - nsRefPtr smallCapsFont = GetSmallCapsFont(); + RefPtr smallCapsFont = GetSmallCapsFont(); enum RunCaseAction { kNoChange, diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 6c228759da..1fb2c25f75 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -82,7 +82,7 @@ struct gfxFontStyle { // the language (may be an internal langGroup code rather than an actual // language code) specified in the document or element's lang property, // or inferred from the charset - nsRefPtr language; + RefPtr language; // Features are composed of (1) features from style rules (2) features // from feature setttings rules and (3) family-specific features. (1) and @@ -99,7 +99,7 @@ struct gfxFontStyle { nsTArray alternateValues; // -- object used to look these up once the font is matched - nsRefPtr featureValueLookup; + RefPtr featureValueLookup; // The logical size of the font, in pixels gfxFloat size; @@ -233,7 +233,7 @@ struct gfxTextRange { { } uint32_t Length() const { return end - start; } uint32_t start, end; - nsRefPtr font; + RefPtr font; uint8_t matchType; uint16_t orientation; }; @@ -1942,7 +1942,7 @@ protected: static nsDataHashtable *sScriptTagToCode; static nsTHashtable *sDefaultFeatures; - nsRefPtr mFontEntry; + RefPtr mFontEntry; struct CacheHashKey { union { @@ -2059,9 +2059,9 @@ protected: // if a userfont with unicode-range specified, contains map of *possible* // ranges supported by font - nsRefPtr mUnicodeRangeMap; + RefPtr mUnicodeRangeMap; - mozilla::RefPtr mAzureScaledFont; + RefPtr mAzureScaledFont; // For vertical metrics, created on demand. nsAutoPtr mVerticalMetrics; @@ -2116,7 +2116,7 @@ protected: // are dependent on the specific font, so they are set per GlyphRun. struct TextRunDrawParams { - mozilla::RefPtr dt; + RefPtr dt; gfxContext *context; gfxFont::Spacing *spacing; gfxTextRunDrawCallbacks *callbacks; @@ -2131,8 +2131,8 @@ struct TextRunDrawParams { }; struct FontDrawParams { - mozilla::RefPtr scaledFont; - mozilla::RefPtr renderingOptions; + RefPtr scaledFont; + RefPtr renderingOptions; gfxTextContextPaint *contextPaint; mozilla::gfx::Matrix *passedInvMatrix; mozilla::gfx::Matrix matInv; diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 0596580d37..0ae9184ecf 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -284,7 +284,7 @@ gfxFontEntry::FindOrMakeFont(const gfxFontStyle *aStyle, gfxCharacterMap* aUnicodeRangeMap) { // the font entry name is the psname, not the family name - nsRefPtr font = gfxFontCache::GetCache()->Lookup(this, aStyle); + RefPtr font = gfxFontCache::GetCache()->Lookup(this, aStyle); if (!font) { gfxFont *newFont = CreateFontInstance(aStyle, aNeedsBold); @@ -1119,10 +1119,10 @@ gfxFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, // because during style matching, later entries will replace earlier ones class FontEntryStandardFaceComparator { public: - bool Equals(const nsRefPtr& a, const nsRefPtr& b) const { + bool Equals(const RefPtr& a, const RefPtr& b) const { return a->mStandardFace == b->mStandardFace; } - bool LessThan(const nsRefPtr& a, const nsRefPtr& b) const { + bool LessThan(const RefPtr& a, const RefPtr& b) const { return (a->mStandardFace == false && b->mStandardFace == true); } }; diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index 9a5c7f0ccb..c1e1a365d5 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -424,7 +424,7 @@ public: uint16_t mWeight; int16_t mStretch; - nsRefPtr mCharacterMap; + RefPtr mCharacterMap; uint32_t mUVSOffset; nsAutoArrayPtr mUVSData; nsAutoPtr mUserFontData; @@ -641,8 +641,8 @@ struct GlobalFontMatch { int32_t mRunScript; // Unicode script for the codepoint const gfxFontStyle* mStyle; // style to match int32_t mMatchRank; // metric indicating closest match - nsRefPtr mBestMatch; // current best match - nsRefPtr mMatchedFamily; // the family it belongs to + RefPtr mBestMatch; // current best match + RefPtr mMatchedFamily; // the family it belongs to uint32_t mCount; // number of fonts matched uint32_t mCmapsTested; // number of cmaps tested }; @@ -668,9 +668,9 @@ public: virtual void LocalizedName(nsAString& aLocalizedName); virtual bool HasOtherFamilyNames(); - nsTArray >& GetFontList() { return mAvailableFonts; } + nsTArray >& GetFontList() { return mAvailableFonts; } - void AddFontEntry(nsRefPtr aFontEntry) { + void AddFontEntry(RefPtr aFontEntry) { // bug 589682 - set the IgnoreGDEF flag on entries for Italic faces // of Times New Roman, because of buggy table in those fonts if (aFontEntry->IsItalic() && !aFontEntry->IsUserFont() && @@ -809,7 +809,7 @@ protected: } nsString mName; - nsTArray > mAvailableFonts; + nsTArray > mAvailableFonts; gfxSparseBitSet mFamilyCharacterMap; bool mOtherFamilyNamesInitialized : 1; bool mHasOtherFamilyNames : 1; diff --git a/gfx/thebes/gfxFontInfoLoader.cpp b/gfx/thebes/gfxFontInfoLoader.cpp index 3b33725495..62e8b39524 100644 --- a/gfx/thebes/gfxFontInfoLoader.cpp +++ b/gfx/thebes/gfxFontInfoLoader.cpp @@ -43,7 +43,7 @@ class FontInfoLoadCompleteEvent : public nsRunnable { NS_IMETHOD Run() override; - nsRefPtr mFontInfo; + RefPtr mFontInfo; }; class AsyncFontInfoLoader : public nsRunnable { @@ -59,8 +59,8 @@ class AsyncFontInfoLoader : public nsRunnable { NS_IMETHOD Run() override; - nsRefPtr mFontInfo; - nsRefPtr mCompleteEvent; + RefPtr mFontInfo; + RefPtr mCompleteEvent; }; class ShutdownThreadEvent : public nsRunnable { diff --git a/gfx/thebes/gfxFontInfoLoader.h b/gfx/thebes/gfxFontInfoLoader.h index 74354c0028..f474c5a912 100644 --- a/gfx/thebes/gfxFontInfoLoader.h +++ b/gfx/thebes/gfxFontInfoLoader.h @@ -33,7 +33,7 @@ struct FontFaceData { nsString mFullName; nsString mPostscriptName; - nsRefPtr mCharacterMap; + RefPtr mCharacterMap; uint32_t mUVSOffset; bool mSymbolFont; }; @@ -88,7 +88,7 @@ public: aUVSOffset = faceData.mUVSOffset; aSymbolFont = faceData.mSymbolFont; - nsRefPtr cmap = faceData.mCharacterMap; + RefPtr cmap = faceData.mCharacterMap; return cmap.forget(); } @@ -244,7 +244,7 @@ protected: TimerState mState; // after async font loader completes, data is stored here - nsRefPtr mFontInfo; + RefPtr mFontInfo; // time spent on the loader thread mozilla::TimeDuration mLoadTime; diff --git a/gfx/thebes/gfxFontconfigFonts.cpp b/gfx/thebes/gfxFontconfigFonts.cpp index 7255777d08..7fd8526838 100644 --- a/gfx/thebes/gfxFontconfigFonts.cpp +++ b/gfx/thebes/gfxFontconfigFonts.cpp @@ -751,7 +751,7 @@ private: struct FontEntry { explicit FontEntry(FcPattern *aPattern) : mPattern(aPattern) {} nsCountedRef mPattern; - nsRefPtr mFont; + RefPtr mFont; }; struct LangSupportEntry { @@ -775,7 +775,7 @@ private: // The requested pattern nsCountedRef mSortPattern; // Fonts from @font-face rules - nsRefPtr mUserFontSet; + RefPtr mUserFontSet; // A (trimmed) list of font patterns and fonts that is built up as // required. nsTArray mFonts; @@ -1487,7 +1487,7 @@ gfxPangoFontGroup::MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor, { const char *lang = pango_language_to_string(aLang); - nsRefPtr langGroup; + RefPtr langGroup; if (aLang != mPangoLanguage) { // Set up langGroup for Mozilla's font prefs. langGroup = do_GetAtom(lang); @@ -1505,7 +1505,7 @@ gfxPangoFontGroup::MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor, PrepareSortPattern(pattern, mStyle.size, aSizeAdjustFactor, mStyle.printerFont); - nsRefPtr fontset = + RefPtr fontset = new gfxFcFontSet(pattern, mUserFontSet); mSkipDrawing = fontset->WaitingForUserFont(); @@ -1536,7 +1536,7 @@ gfxPangoFontGroup::GetFontSet(PangoLanguage *aLang) return mFontSets[i].mFontSet; } - nsRefPtr fontSet = + RefPtr fontSet = MakeFontSet(aLang, mSizeAdjustFactor); mFontSets.AppendElement(FontSetByLangEntry(aLang, fontSet)); @@ -1555,7 +1555,7 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, // actually be rendered (see bug 716229) uint8_t category = GetGeneralCategory(aCh); if (category == HB_UNICODE_GENERAL_CATEGORY_CONTROL) { - return nsRefPtr(aPrevMatchedFont).forget(); + return RefPtr(aPrevMatchedFont).forget(); } // if this character is a join-control or the previous is a join-causer, @@ -1563,7 +1563,7 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, if (gfxFontUtils::IsJoinControl(aCh) || gfxFontUtils::IsJoinCauser(aPrevCh)) { if (aPrevMatchedFont->HasCharacter(aCh)) { - return nsRefPtr(aPrevMatchedFont).forget(); + return RefPtr(aPrevMatchedFont).forget(); } } } @@ -1573,7 +1573,7 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, // otherwise the text run will be divided. if (gfxFontUtils::IsVarSelector(aCh)) { if (aPrevMatchedFont) { - return nsRefPtr(aPrevMatchedFont).forget(); + return RefPtr(aPrevMatchedFont).forget(); } // VS alone. it's meaningless to search different fonts return nullptr; @@ -1618,7 +1618,7 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, basePattern = fontSet->GetFontPatternAt(0); if (HasChar(basePattern, aCh)) { *aMatchType = gfxTextRange::kFontGroup; - return nsRefPtr(GetBaseFont()).forget(); + return RefPtr(GetBaseFont()).forget(); } nextFont = 1; @@ -1646,7 +1646,7 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, if (HasChar(pattern, aCh)) { *aMatchType = gfxTextRange::kFontGroup; - return nsRefPtr(fontSet->GetFontAt(i, GetStyle())).forget(); + return RefPtr(fontSet->GetFontAt(i, GetStyle())).forget(); } } @@ -1700,7 +1700,7 @@ already_AddRefed gfxFcFont::MakeScaledFont(gfxFontStyle *aFontStyle, gfxFloat aScaleFactor) { gfxFcFontEntry* fe = static_cast(GetFontEntry()); - nsRefPtr font = gfxFontCache::GetCache()->Lookup(fe, aFontStyle); + RefPtr font = gfxFontCache::GetCache()->Lookup(fe, aFontStyle); if (font) { return font.forget(); } @@ -1811,7 +1811,7 @@ gfxPangoFontGroup::GetFTLibrary() // font properties requested here are chosen to get an FT_Face that is // likely to be also used elsewhere. gfxFontStyle style; - nsRefPtr fontGroup = + RefPtr fontGroup = new gfxPangoFontGroup(FontFamilyList(eFamily_sans_serif), &style, nullptr); @@ -1912,7 +1912,7 @@ gfxFcFont::GetOrMakeFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern, cairo_ft_font_face_create_for_pattern(renderPattern); // Reuse an existing font entry if available. - nsRefPtr fe = gfxFcFontEntry::LookupFontEntry(face); + RefPtr fe = gfxFcFontEntry::LookupFontEntry(face); if (!fe) { gfxDownloadedFcFontEntry *downloadedFontEntry = GetDownloadedFontEntry(aFontPattern); @@ -1960,7 +1960,7 @@ gfxFcFont::GetOrMakeFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern, style.style = gfxFontconfigUtils::GetThebesStyle(renderPattern); style.weight = gfxFontconfigUtils::GetThebesWeight(renderPattern); - nsRefPtr font = gfxFontCache::GetCache()->Lookup(fe, &style); + RefPtr font = gfxFontCache::GetCache()->Lookup(fe, &style); if (!font) { // Note that a file/index pair (or FT_Face) and the gfxFontStyle are // not necessarily enough to provide a key that will describe a unique @@ -1977,7 +1977,7 @@ gfxFcFont::GetOrMakeFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern, cairo_font_face_destroy(face); - nsRefPtr retval(static_cast(font.get())); + RefPtr retval(static_cast(font.get())); return retval.forget(); } @@ -1989,7 +1989,7 @@ gfxPangoFontGroup::GetBaseFontSet() mSizeAdjustFactor = 1.0; // will be adjusted below if necessary nsAutoRef pattern; - nsRefPtr fontSet = + RefPtr fontSet = MakeFontSet(mPangoLanguage, mSizeAdjustFactor, &pattern); double size = GetPixelSize(pattern); diff --git a/gfx/thebes/gfxFontconfigFonts.h b/gfx/thebes/gfxFontconfigFonts.h index 1a7c1dbf3b..fe77332e89 100644 --- a/gfx/thebes/gfxFontconfigFonts.h +++ b/gfx/thebes/gfxFontconfigFonts.h @@ -68,7 +68,7 @@ private: public: FontSetByLangEntry(PangoLanguage *aLang, gfxFcFontSet *aFontSet); PangoLanguage *mLang; - nsRefPtr mFontSet; + RefPtr mFontSet; }; // There is only one of entry in this array unless characters from scripts // of other languages are measured. diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index b992099d62..089f67cc39 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -157,7 +157,7 @@ GDIFontEntry::ReadCMAP(FontInfoData *aFontInfoData) return NS_ERROR_FAILURE; } - nsRefPtr charmap; + RefPtr charmap; nsresult rv; bool unicodeFont = false, symbolFont = false; @@ -311,7 +311,7 @@ GDIFontEntry::TestCharacterMap(uint32_t aCh) fakeStyle.style = NS_FONT_STYLE_ITALIC; fakeStyle.weight = mWeight * 100; - nsRefPtr tempFont = FindOrMakeFont(&fakeStyle, false); + RefPtr tempFont = FindOrMakeFont(&fakeStyle, false); if (!tempFont || !tempFont->Valid()) return false; gfxGDIFont *font = static_cast(tempFont.get()); @@ -690,7 +690,7 @@ gfxGDIFontList::EnumFontFamExProc(ENUMLOGFONTEXW *lpelfe, if (!fontList->mFontFamilies.GetWeak(name)) { nsDependentString faceName(lf.lfFaceName); - nsRefPtr family = new GDIFontFamily(faceName); + RefPtr family = new GDIFontFamily(faceName); fontList->mFontFamilies.Put(name, family); // if locale is such that CJK font names are the default coming from @@ -1085,7 +1085,7 @@ int CALLBACK GDIFontInfo::EnumerateFontsForFamily( ::GetFontData(hdc, kCMAP, 0, cmapData.Elements(), cmapSize); bool cmapLoaded = false; bool unicodeFont = false, symbolFont = false; - nsRefPtr charmap = new gfxCharacterMap(); + RefPtr charmap = new gfxCharacterMap(); uint32_t offset; if (NS_SUCCEEDED(gfxFontUtils::ReadCMAP(cmapData.Elements(), @@ -1138,7 +1138,7 @@ gfxGDIFontList::CreateFontInfoData() bool loadCmaps = !UsesSystemFallback() || gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback(); - nsRefPtr fi = + RefPtr fi = new GDIFontInfo(true, NeedFullnamePostscriptNames(), loadCmaps); return fi.forget(); diff --git a/gfx/thebes/gfxImageSurface.cpp b/gfx/thebes/gfxImageSurface.cpp index 3374bb1204..013f056e8d 100644 --- a/gfx/thebes/gfxImageSurface.cpp +++ b/gfx/thebes/gfxImageSurface.cpp @@ -257,7 +257,7 @@ FormatsAreCompatible(gfxImageFormat a1, gfxImageFormat a2) bool gfxImageSurface::CopyFrom (SourceSurface *aSurface) { - mozilla::RefPtr data = aSurface->GetDataSurface(); + RefPtr data = aSurface->GetDataSurface(); if (!data) { return false; @@ -297,7 +297,7 @@ gfxImageSurface::CopyFrom(gfxImageSurface *other) bool gfxImageSurface::CopyTo(SourceSurface *aSurface) { - mozilla::RefPtr data = aSurface->GetDataSurface(); + RefPtr data = aSurface->GetDataSurface(); if (!data) { return false; @@ -348,7 +348,7 @@ gfxImageSurface::GetSubimage(const gfxRect& aRect) format = gfxImageFormat::RGB24; } - nsRefPtr image = + RefPtr image = new gfxSubimageSurface(this, subData, IntSize((int)r.Width(), (int)r.Height()), format); @@ -368,6 +368,6 @@ gfxSubimageSurface::gfxSubimageSurface(gfxImageSurface* aParent, already_AddRefed gfxImageSurface::GetAsImageSurface() { - nsRefPtr surface = this; + RefPtr surface = this; return surface.forget(); } diff --git a/gfx/thebes/gfxImageSurface.h b/gfx/thebes/gfxImageSurface.h index 0d96f16132..d7d495d02c 100644 --- a/gfx/thebes/gfxImageSurface.h +++ b/gfx/thebes/gfxImageSurface.h @@ -164,7 +164,7 @@ protected: const mozilla::gfx::IntSize& aSize, gfxImageFormat aFormat); private: - nsRefPtr mParent; + RefPtr mParent; }; #endif /* GFX_IMAGESURFACE_H */ diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 9c60598db1..c1ea0411f6 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -158,7 +158,7 @@ MacOSFontEntry::ReadCMAP(FontInfoData *aFontInfoData) return NS_OK; } - nsRefPtr charmap; + RefPtr charmap; nsresult rv; bool symbolFont = false; // currently ignored @@ -1116,7 +1116,7 @@ MacFontInfo::LoadFontFamilyData(const nsAString& aFamilyName) const uint8_t *cmapData = (const uint8_t*)CFDataGetBytePtr(cmapTable); uint32_t cmapLen = CFDataGetLength(cmapTable); - nsRefPtr charmap = new gfxCharacterMap(); + RefPtr charmap = new gfxCharacterMap(); uint32_t offset; bool unicodeFont = false; // ignored bool symbolFont = false; @@ -1170,7 +1170,7 @@ gfxMacPlatformFontList::CreateFontInfoData() bool loadCmaps = !UsesSystemFallback() || gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback(); - nsRefPtr fi = + RefPtr fi = new MacFontInfo(true, NeedFullnamePostscriptNames(), loadCmaps); return fi.forget(); } diff --git a/gfx/thebes/gfxPattern.h b/gfx/thebes/gfxPattern.h index 845d8dcc17..8dfc111d8b 100644 --- a/gfx/thebes/gfxPattern.h +++ b/gfx/thebes/gfxPattern.h @@ -68,9 +68,9 @@ private: ~gfxPattern() {} mozilla::gfx::GeneralPattern mGfxPattern; - mozilla::RefPtr mSourceSurface; + RefPtr mSourceSurface; mozilla::gfx::Matrix mPatternToUserSpace; - mozilla::RefPtr mStops; + RefPtr mStops; nsTArray mStopsList; mozilla::gfx::ExtendMode mExtend; }; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 411edea7d5..fe2cd75d32 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -787,7 +787,7 @@ UserDataKey kThebesSurface; struct DependentSourceSurfaceUserData { - nsRefPtr mSurface; + RefPtr mSurface; }; void SourceSurfaceDestroyed(void *aData) @@ -938,7 +938,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa already_AddRefed gfxPlatform::GetWrappedDataSourceSurface(gfxASurface* aSurface) { - nsRefPtr image = aSurface->GetAsImageSurface(); + RefPtr image = aSurface->GetAsImageSurface(); if (!image) { return nullptr; } @@ -1115,7 +1115,7 @@ gfxPlatform::GetSkiaGLGlue() * FIXME: This should be stored in TLS or something, since there needs to be one for each thread using it. As it * stands, this only works on the main thread. */ - nsRefPtr glContext; + RefPtr glContext; glContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE | CreateContextFlags::ALLOW_OFFLINE_RENDERER); if (!glContext) { @@ -1168,7 +1168,7 @@ gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSi // CreateOffscreenSurface() and CreateDrawTargetForSurface() for all // backends). if (aBackend == BackendType::CAIRO) { - nsRefPtr surf = CreateOffscreenSurface(aSize, SurfaceFormatToImageFormat(aFormat)); + RefPtr surf = CreateOffscreenSurface(aSize, SurfaceFormatToImageFormat(aFormat)); if (!surf || surf->CairoStatus()) { return nullptr; } @@ -2046,7 +2046,7 @@ already_AddRefed gfxPlatform::CreateHardwareVsyncSource() { NS_WARNING("Hardware Vsync support not yet implemented. Falling back to software timers"); - nsRefPtr softwareVsync = new SoftwareVsyncSource(); + RefPtr softwareVsync = new SoftwareVsyncSource(); return softwareVsync.forget(); } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 2a9e61dc8c..2b23ce625d 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -716,9 +716,9 @@ protected: uint32_t mTotalSystemMemory; // Hardware vsync source. Only valid on parent process - nsRefPtr mVsyncSource; + RefPtr mVsyncSource; - mozilla::RefPtr mScreenReferenceDrawTarget; + RefPtr mScreenReferenceDrawTarget; private: /** @@ -746,7 +746,7 @@ private: */ void PopulateScreenInfo(); - nsRefPtr mScreenReferenceSurface; + RefPtr mScreenReferenceSurface; nsCOMPtr mSRGBOverrideObserver; nsCOMPtr mFontPrefsObserver; nsCOMPtr mMemoryPressureObserver; @@ -766,8 +766,8 @@ private: mozilla::widget::GfxInfoCollector mAzureCanvasBackendCollector; mozilla::widget::GfxInfoCollector mApzSupportCollector; - mozilla::RefPtr mRecorder; - mozilla::RefPtr mSkiaGlue; + RefPtr mRecorder; + RefPtr mSkiaGlue; // Backend that we are compositing with. NONE, if no compositor has been // created yet. diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 95e10665d2..3e4dc1270e 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -268,7 +268,7 @@ gfxPlatformFontList::InitOtherFamilyNames() bool timedOut = false; for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); family->ReadOtherFamilyNames(this); TimeDuration elapsed = TimeStamp::Now() - start; if (elapsed.ToMilliseconds() > OTHERNAMES_TIMEOUT) { @@ -310,7 +310,7 @@ gfxPlatformFontList::SearchFamiliesForFaceName(const nsAString& aFaceName) for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsStringHashKey::KeyType key = iter.Key(); - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); // when filtering, skip names that don't start with the filter character if (firstChar && ToLowerCase(key.CharAt(0)) != firstChar) { @@ -432,14 +432,14 @@ gfxPlatformFontList::GetFontList(nsIAtom *aLangGroup, nsTArray& aListOfFonts) { for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); // use the first variation for now. This data should be the same // for all the variations and should probably be moved up to // the Family gfxFontStyle style; style.language = aLangGroup; bool needsBold; - nsRefPtr fontEntry = family->FindFontForStyle(style, needsBold); + RefPtr fontEntry = family->FindFontForStyle(style, needsBold); NS_ASSERTION(fontEntry, "couldn't find any font entry in family"); if (!fontEntry) { continue; @@ -463,10 +463,10 @@ gfxPlatformFontList::GetFontList(nsIAtom *aLangGroup, } void -gfxPlatformFontList::GetFontFamilyList(nsTArray >& aFamilyArray) +gfxPlatformFontList::GetFontFamilyList(nsTArray >& aFamilyArray) { for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); aFamilyArray.AppendElement(family); } } @@ -608,7 +608,7 @@ gfxPlatformFontList::GlobalFontFallback(const uint32_t aCh, // iterate over all font families to find a font that support the character for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); // evaluate all fonts in this family for a match family->FindFontForChar(&data); } @@ -811,7 +811,7 @@ void gfxPlatformFontList::ResolveGenericFontNames( FontFamilyType aGenericType, eFontPrefLang aPrefLang, - nsTArray>* aGenericFamilies + nsTArray>* aGenericFamilies ) { const char* langGroupStr = GetPrefLangName(aPrefLang); @@ -874,7 +874,7 @@ gfxPlatformFontList::ResolveGenericFontNames( // lookup and add platform fonts uniquely for (const nsString& genericFamily : genericFamilies) { - nsRefPtr family = + RefPtr family = FindFamily(genericFamily, langGroup, false); if (family) { bool notFound = true; @@ -900,7 +900,7 @@ gfxPlatformFontList::ResolveGenericFontNames( #endif } -nsTArray>* +nsTArray>* gfxPlatformFontList::GetPrefFontsLangGroup(mozilla::FontFamilyType aGenericType, eFontPrefLang aPrefLang) { @@ -942,7 +942,7 @@ gfxPlatformFontList::AddGenericFonts(mozilla::FontFamilyType aGenericType, eFontPrefLang prefLang = GetFontPrefLangFor(langGroup); // lookup pref fonts - nsTArray>* prefFonts = + nsTArray>* prefFonts = GetPrefFontsLangGroup(aGenericType, prefLang); if (!prefFonts->IsEmpty()) { @@ -1224,7 +1224,7 @@ void gfxPlatformFontList::GetFontFamilyNames(nsTArray& aFontFamilyNames) { for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr& family = iter.Data(); + RefPtr& family = iter.Data(); aFontFamilyNames.AppendElement(family->Name()); } } diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index ea8d41633a..b16c38b3e3 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -122,7 +122,7 @@ public: void ClearLangGroupPrefFonts(); - virtual void GetFontFamilyList(nsTArray >& aFamilyArray); + virtual void GetFontFamilyList(nsTArray >& aFamilyArray); gfxFontEntry* SystemFindFontForChar(uint32_t aCh, uint32_t aNextCh, @@ -205,7 +205,7 @@ public: nsIAtom* aLanguage, nsTArray& aFamilyList); - nsTArray>* + nsTArray>* GetPrefFontsLangGroup(mozilla::FontFamilyType aGenericType, eFontPrefLang aPrefLang); @@ -310,7 +310,7 @@ protected: static PLDHashOperator HashEnumFuncForFamilies(nsStringHashKey::KeyType aKey, - nsRefPtr& aFamilyEntry, + RefPtr& aFamilyEntry, void* aUserArg); virtual void GetFontFamilyNames(nsTArray& aFontFamilyNames); @@ -331,7 +331,7 @@ protected: void ResolveGenericFontNames(mozilla::FontFamilyType aGenericType, eFontPrefLang aPrefLang, - nsTArray>* aGenericFamilies); + nsTArray>* aGenericFamilies); typedef nsRefPtrHashtable FontFamilyTable; typedef nsRefPtrHashtable FontEntryTable; @@ -378,7 +378,7 @@ protected: // localized family names missed when face name loading takes a long time nsAutoPtr > mOtherNamesMissed; - typedef nsTArray> PrefFontList; + typedef nsTArray> PrefFontList; typedef mozilla::RangedArray, mozilla::eFamily_generic_first, mozilla::eFamily_generic_count> PrefFontsForLangGroup; @@ -391,7 +391,7 @@ protected: // the family to use for U+FFFD fallback, to avoid expensive search every time // on pages with lots of problems - nsRefPtr mReplacementCharFallbackFamily; + RefPtr mReplacementCharFallbackFamily; nsTHashtable mBadUnderlineFamilyNames; @@ -400,7 +400,7 @@ protected: nsTHashtable mSharedCmaps; // data used as part of the font cmap loading process - nsTArray > mFontFamiliesToLoad; + nsTArray > mFontFamiliesToLoad; uint32_t mStartIndex; uint32_t mIncrement; uint32_t mNumFamilies; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index dc1bde896d..a77ec23950 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -104,7 +104,7 @@ already_AddRefed gfxPlatformGtk::CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) { - nsRefPtr newSurface; + RefPtr newSurface; bool needsClear = true; #ifdef MOZ_X11 // XXX we really need a different interface here, something that passes diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index 6cfb0bd06f..bf891f2ad4 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -119,7 +119,7 @@ already_AddRefed gfxPlatformMac::CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) { - nsRefPtr newSurface = + RefPtr newSurface = new gfxQuartzSurface(aSize, aFormat); return newSurface.forget(); } @@ -563,7 +563,7 @@ public: private: // Manages the display link render thread CVDisplayLinkRef mDisplayLink; - nsRefPtr mTimer; + RefPtr mTimer; }; // OSXDisplay private: @@ -611,7 +611,7 @@ static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink, already_AddRefed gfxPlatformMac::CreateHardwareVsyncSource() { - nsRefPtr osxVsyncSource = new OSXVsyncSource(); + RefPtr osxVsyncSource = new OSXVsyncSource(); VsyncSource::Display& primaryDisplay = osxVsyncSource->GetGlobalDisplay(); primaryDisplay.EnableVsync(); if (!primaryDisplay.IsVsyncEnabled()) { diff --git a/gfx/thebes/gfxQPainterSurface.cpp b/gfx/thebes/gfxQPainterSurface.cpp index 23c41eca73..31e809a184 100644 --- a/gfx/thebes/gfxQPainterSurface.cpp +++ b/gfx/thebes/gfxQPainterSurface.cpp @@ -71,7 +71,7 @@ gfxQPainterSurface::GetAsImageSurface() assert(cairo_surface_get_type(isurf) == CAIRO_SURFACE_TYPE_IMAGE); - nsRefPtr asurf = new gfxImageSurface(isurf); + RefPtr asurf = new gfxImageSurface(isurf); asurf->SetOpaqueRect(GetOpaqueRect()); return asurf.forget(); } diff --git a/gfx/thebes/gfxQtNativeRenderer.cpp b/gfx/thebes/gfxQtNativeRenderer.cpp index 947e7534c8..f9ee28ead3 100644 --- a/gfx/thebes/gfxQtNativeRenderer.cpp +++ b/gfx/thebes/gfxQtNativeRenderer.cpp @@ -28,7 +28,7 @@ gfxQtNativeRenderer::Draw(gfxContext* ctx, mozilla::gfx::IntSize size, visual = vinfo.visual; } - nsRefPtr xsurf = + RefPtr xsurf = gfxXlibSurface::Create(screen, visual, mozilla::gfx::IntSize(size.width, size.height)); diff --git a/gfx/thebes/gfxQtPlatform.cpp b/gfx/thebes/gfxQtPlatform.cpp index 272a6996e7..371d847618 100644 --- a/gfx/thebes/gfxQtPlatform.cpp +++ b/gfx/thebes/gfxQtPlatform.cpp @@ -92,7 +92,7 @@ already_AddRefed gfxQtPlatform::CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) { - nsRefPtr newSurface = + RefPtr newSurface = new gfxImageSurface(aSize, aFormat); return newSurface.forget(); diff --git a/gfx/thebes/gfxQuartzImageSurface.cpp b/gfx/thebes/gfxQuartzImageSurface.cpp index a2f7862c39..0bb2fa2cb4 100644 --- a/gfx/thebes/gfxQuartzImageSurface.cpp +++ b/gfx/thebes/gfxQuartzImageSurface.cpp @@ -49,7 +49,7 @@ gfxQuartzImageSurface::KnownMemoryUsed() { // This surface doesn't own any memory itself, but we want to report here the // amount of memory that the surface it wraps uses. - nsRefPtr imgSurface = GetAsImageSurface(); + RefPtr imgSurface = GetAsImageSurface(); if (imgSurface) return imgSurface->KnownMemoryUsed(); return 0; @@ -67,7 +67,7 @@ gfxQuartzImageSurface::GetAsImageSurface() return nullptr; } - nsRefPtr result = gfxASurface::Wrap(isurf).downcast(); + RefPtr result = gfxASurface::Wrap(isurf).downcast(); result->SetOpaqueRect(GetOpaqueRect()); return result.forget(); diff --git a/gfx/thebes/gfxQuartzNativeDrawing.h b/gfx/thebes/gfxQuartzNativeDrawing.h index d584c1fb22..736f9ce836 100644 --- a/gfx/thebes/gfxQuartzNativeDrawing.h +++ b/gfx/thebes/gfxQuartzNativeDrawing.h @@ -59,8 +59,8 @@ private: const gfxQuartzNativeDrawing& operator=(const gfxQuartzNativeDrawing&) = delete; // Final destination context - mozilla::RefPtr mDrawTarget; - mozilla::RefPtr mTempDrawTarget; + RefPtr mDrawTarget; + RefPtr mTempDrawTarget; mozilla::gfx::BorrowedCGContext mBorrowedContext; mozilla::gfx::Rect mNativeRect; diff --git a/gfx/thebes/gfxQuartzSurface.cpp b/gfx/thebes/gfxQuartzSurface.cpp index 33401d9bef..a5069d8429 100644 --- a/gfx/thebes/gfxQuartzSurface.cpp +++ b/gfx/thebes/gfxQuartzSurface.cpp @@ -156,7 +156,7 @@ gfxQuartzSurface::CreateSimilarSurface(gfxContentType aType, return nullptr; } - nsRefPtr result = Wrap(surface, aSize); + RefPtr result = Wrap(surface, aSize); cairo_surface_destroy(surface); return result.forget(); } @@ -173,7 +173,7 @@ already_AddRefed gfxQuartzSurface::GetAsImageSurface() if (!surface || cairo_surface_status(surface)) return nullptr; - nsRefPtr img = Wrap(surface); + RefPtr img = Wrap(surface); // cairo_quartz_surface_get_image returns a referenced image, and thebes // shares the refcounts of Cairo surfaces. However, Wrap also adds a diff --git a/gfx/thebes/gfxReusableImageSurfaceWrapper.h b/gfx/thebes/gfxReusableImageSurfaceWrapper.h index 675ead5461..f6c340a882 100644 --- a/gfx/thebes/gfxReusableImageSurfaceWrapper.h +++ b/gfx/thebes/gfxReusableImageSurfaceWrapper.h @@ -32,7 +32,7 @@ public: } private: - nsRefPtr mSurface; + RefPtr mSurface; }; #endif // GFXMEMCOWSURFACEWRAPPER diff --git a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp index 3ab4134b1f..28ac7c877d 100644 --- a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp +++ b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp @@ -55,7 +55,7 @@ gfxReusableSharedImageSurfaceWrapper::GetWritable(gfxImageSurface** aSurface) } // Something else is reading the surface, copy it - nsRefPtr copySurface = + RefPtr copySurface = gfxSharedImageSurface::CreateUnsafe(mAllocator.get(), mSurface->GetSize(), mSurface->Format()); copySurface->CopyFrom(mSurface); *aSurface = copySurface; @@ -91,8 +91,8 @@ gfxReusableSharedImageSurfaceWrapper::GetShmem() /* static */ already_AddRefed gfxReusableSharedImageSurfaceWrapper::Open(ISurfaceAllocator* aAllocator, const Shmem& aShmem) { - nsRefPtr sharedImage = gfxSharedImageSurface::Open(aShmem); - nsRefPtr wrapper = new gfxReusableSharedImageSurfaceWrapper(aAllocator, sharedImage); + RefPtr sharedImage = gfxSharedImageSurface::Open(aShmem); + RefPtr wrapper = new gfxReusableSharedImageSurfaceWrapper(aAllocator, sharedImage); wrapper->ReadUnlock(); return wrapper.forget(); } diff --git a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h index 4b30b23899..2c337edc04 100644 --- a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h +++ b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h @@ -56,8 +56,8 @@ public: Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem); private: - mozilla::RefPtr mAllocator; - nsRefPtr mSurface; + RefPtr mAllocator; + RefPtr mSurface; }; #endif // GFXSHMCOWSURFACEWRAPPER diff --git a/gfx/thebes/gfxSVGGlyphs.h b/gfx/thebes/gfxSVGGlyphs.h index 223f01f492..130ac86b47 100644 --- a/gfx/thebes/gfxSVGGlyphs.h +++ b/gfx/thebes/gfxSVGGlyphs.h @@ -260,7 +260,7 @@ public: if (mFillPattern) { mFillPattern->SetMatrix(aCTM * mFillMatrix); } - nsRefPtr fillPattern = mFillPattern; + RefPtr fillPattern = mFillPattern; return fillPattern.forget(); } @@ -270,7 +270,7 @@ public: if (mStrokePattern) { mStrokePattern->SetMatrix(aCTM * mStrokeMatrix); } - nsRefPtr strokePattern = mStrokePattern; + RefPtr strokePattern = mStrokePattern; return strokePattern.forget(); } @@ -283,8 +283,8 @@ public: } private: - nsRefPtr mFillPattern; - nsRefPtr mStrokePattern; + RefPtr mFillPattern; + RefPtr mStrokePattern; // Device space to pattern space transforms gfxMatrix mFillMatrix; diff --git a/gfx/thebes/gfxTeeSurface.cpp b/gfx/thebes/gfxTeeSurface.cpp index 84296040e8..834475d695 100644 --- a/gfx/thebes/gfxTeeSurface.cpp +++ b/gfx/thebes/gfxTeeSurface.cpp @@ -28,18 +28,18 @@ gfxTeeSurface::gfxTeeSurface(gfxASurface **aSurfaces, int32_t aSurfaceCount) const mozilla::gfx::IntSize gfxTeeSurface::GetSize() const { - nsRefPtr master = Wrap(cairo_tee_surface_index(mSurface, 0)); + RefPtr master = Wrap(cairo_tee_surface_index(mSurface, 0)); return master->GetSize(); } void -gfxTeeSurface::GetSurfaces(nsTArray >* aSurfaces) +gfxTeeSurface::GetSurfaces(nsTArray >* aSurfaces) { for (int32_t i = 0; ; ++i) { cairo_surface_t *csurf = cairo_tee_surface_index(mSurface, i); if (cairo_surface_status(csurf)) break; - nsRefPtr *elem = aSurfaces->AppendElement(); + RefPtr *elem = aSurfaces->AppendElement(); if (!elem) return; *elem = Wrap(csurf); diff --git a/gfx/thebes/gfxTeeSurface.h b/gfx/thebes/gfxTeeSurface.h index be638fe379..b12f9d5e35 100644 --- a/gfx/thebes/gfxTeeSurface.h +++ b/gfx/thebes/gfxTeeSurface.h @@ -31,7 +31,7 @@ public: /** * Returns the list of underlying surfaces. */ - void GetSurfaces(nsTArray > *aSurfaces); + void GetSurfaces(nsTArray > *aSurfaces); }; #endif /* GFX_TEESURFACE_H */ diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index d54367769b..f7b4270d41 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -1674,7 +1674,7 @@ gfxFontGroup::GetFontAt(int32_t i, uint32_t aCh) return nullptr; } - nsRefPtr font = ff.Font(); + RefPtr font = ff.Font(); if (!font) { gfxFontEntry* fe = mFonts[i].FontEntry(); gfxCharacterMap* unicodeRangeMap = nullptr; @@ -1792,7 +1792,7 @@ gfxFontGroup::GetDefaultFont() // that assumes it will be able to get valid metrics for layout, // just look for the first usable font and put in the list. // (see bug 554544) - nsAutoTArray,200> familyList; + nsAutoTArray,200> familyList; pfl->GetFontFamilyList(familyList); numFonts = familyList.Length(); for (uint32_t i = 0; i < numFonts; ++i) { @@ -1959,7 +1959,7 @@ gfxFontGroup::MakeSpaceTextRun(const Parameters *aParams, uint32_t aFlags) // In case the primary font doesn't have (bug 970891), // find one that does. uint8_t matchType; - nsRefPtr spaceFont = + RefPtr spaceFont = FindFontForChar(' ', 0, 0, MOZ_SCRIPT_LATIN, nullptr, &matchType); if (spaceFont) { @@ -2016,7 +2016,7 @@ gfxFloat gfxFontGroup::GetHyphenWidth(gfxTextRun::PropertyProvider *aProvider) { if (mHyphenWidth < 0) { - nsRefPtr ctx(aProvider->GetContext()); + RefPtr ctx(aProvider->GetContext()); if (ctx) { nsAutoPtr hyphRun(MakeHyphenTextRun(ctx, @@ -2343,7 +2343,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext, return; } - nsRefPtr subSuperFont = + RefPtr subSuperFont = matchedFont->GetSubSuperscriptFont(aTextRun->GetAppUnitsPerDevUnit()); aTextRun->AddGlyphRun(subSuperFont, range.matchType, aOffset + runStart, (matchedLength > 0), @@ -2518,7 +2518,7 @@ gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags, : nsDependentString(kASCIIPeriodsChar, ArrayLength(kASCIIPeriodsChar) - 1); - nsRefPtr refCtx = aRefContextGetter.GetRefContext(); + RefPtr refCtx = aRefContextGetter.GetRefContext(); Parameters params = { refCtx, nullptr, nullptr, nullptr, 0, aAppUnitsPerDevPixel }; @@ -2550,7 +2550,7 @@ gfxFontGroup::FindNonItalicFaceForChar(gfxFontFamily* aFamily, uint32_t aCh) return nullptr; } - nsRefPtr font = fe->FindOrMakeFont(&mStyle, needsBold); + RefPtr font = fe->FindOrMakeFont(&mStyle, needsBold); return font.forget(); } @@ -2567,7 +2567,7 @@ gfxFontGroup::GetUnderlineOffset() !ff.FontEntry()->IsUserFont() && ff.Family() && ff.Family()->IsBadUnderlineFamily()) { - nsRefPtr font = GetFontAt(i); + RefPtr font = GetFontAt(i); if (!font) { continue; } @@ -2599,7 +2599,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, // the font group because it avoids breaks in shaping within a cluster. if (aPrevMatchedFont && IsClusterExtender(aCh) && aPrevMatchedFont->HasCharacter(aCh)) { - nsRefPtr ret = aPrevMatchedFont; + RefPtr ret = aPrevMatchedFont; return ret.forget(); } @@ -2611,7 +2611,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, bool isVarSelector = gfxFontUtils::IsVarSelector(aCh); if (!isJoinControl && !wasJoinCauser && !isVarSelector) { - nsRefPtr firstFont = GetFontAt(0, aCh); + RefPtr firstFont = GetFontAt(0, aCh); if (firstFont) { if (firstFont->HasCharacter(aCh)) { *aMatchType = gfxTextRange::kFontGroup; @@ -2622,7 +2622,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, // Only do this for platform fonts, not userfonts. if (mStyle.style != NS_FONT_STYLE_NORMAL && !firstFont->GetFontEntry()->IsUserFont()) { - nsRefPtr font = + RefPtr font = FindNonItalicFaceForChar(mFonts[0].Family(), aCh); if (font) { *aMatchType = gfxTextRange::kFontGroup; @@ -2641,7 +2641,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, // actually be rendered (see bug 716229) if (isJoinControl || GetGeneralCategory(aCh) == HB_UNICODE_GENERAL_CATEGORY_CONTROL) { - nsRefPtr ret = aPrevMatchedFont; + RefPtr ret = aPrevMatchedFont; return ret.forget(); } @@ -2649,7 +2649,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, // use the same font as the previous range if we can if (wasJoinCauser) { if (aPrevMatchedFont->HasCharacter(aCh)) { - nsRefPtr ret = aPrevMatchedFont; + RefPtr ret = aPrevMatchedFont; return ret.forget(); } } @@ -2660,7 +2660,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, // otherwise the text run will be divided. if (isVarSelector) { if (aPrevMatchedFont) { - nsRefPtr ret = aPrevMatchedFont; + RefPtr ret = aPrevMatchedFont; return ret.forget(); } // VS alone. it's meaningless to search different fonts @@ -2676,7 +2676,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, } // if available, use already made gfxFont and check for character - nsRefPtr font = ff.Font(); + RefPtr font = ff.Font(); if (font) { if (font->HasCharacter(aCh)) { return font.forget(); @@ -2736,7 +2736,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, } if (fontListLength == 0) { - nsRefPtr defaultFont = GetDefaultFont(); + RefPtr defaultFont = GetDefaultFont(); if (defaultFont->HasCharacter(aCh)) { *aMatchType = gfxTextRange::kFontGroup; return defaultFont.forget(); @@ -2748,7 +2748,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, return nullptr; // 2. search pref fonts - nsRefPtr font = WhichPrefFontSupportsChar(aCh); + RefPtr font = WhichPrefFontSupportsChar(aCh); if (font) { *aMatchType = gfxTextRange::kPrefsFallback; return font.forget(); @@ -2758,7 +2758,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, // -- before searching for something else check the font used for the previous character if (aPrevMatchedFont && aPrevMatchedFont->HasCharacter(aCh)) { *aMatchType = gfxTextRange::kSystemFallback; - nsRefPtr ret = aPrevMatchedFont; + RefPtr ret = aPrevMatchedFont; return ret.forget(); } @@ -2843,7 +2843,7 @@ void gfxFontGroup::ComputeRanges(nsTArray& aRanges, } // find the font for this char - nsRefPtr font = + RefPtr font = FindFontForChar(ch, prevCh, nextCh, aRunScript, prevFont, &matchType); @@ -3024,11 +3024,11 @@ gfxFontGroup::ContainsUserFont(const gfxUserFontEntry* aUserFont) } struct PrefFontCallbackData { - explicit PrefFontCallbackData(nsTArray >& aFamiliesArray) + explicit PrefFontCallbackData(nsTArray >& aFamiliesArray) : mPrefFamilies(aFamiliesArray) {} - nsTArray >& mPrefFamilies; + nsTArray >& mPrefFamilies; static bool AddFontFamilyEntry(eFontPrefLang aLang, const nsAString& aName, void *aClosure) { @@ -3048,7 +3048,7 @@ struct PrefFontCallbackData { already_AddRefed gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh) { - nsRefPtr font; + RefPtr font; // get the pref font list if it hasn't been set up already uint32_t unicodeRange = FindCharUnicodeRange(aCh); @@ -3072,7 +3072,7 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh) eFontPrefLang currentLang = prefLangs[i]; mozilla::FontFamilyType defaultGeneric = pfl->GetDefaultGeneric(currentLang); - nsTArray>* families = + nsTArray>* families = pfl->GetPrefFontsLangGroup(defaultGeneric, currentLang); NS_ASSERTION(families, "no pref font families found"); @@ -3097,7 +3097,7 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh) gfxFontEntry *fe = family->FindFontForStyle(mStyle, needsBold); // if ch in cmap, create and return a gfxFont if (fe && fe->HasCharacter(aCh)) { - nsRefPtr prefFont = fe->FindOrMakeFont(&mStyle, needsBold); + RefPtr prefFont = fe->FindOrMakeFont(&mStyle, needsBold); if (!prefFont) continue; mLastPrefFamily = family; mLastPrefFont = prefFont; @@ -3121,7 +3121,7 @@ gfxFontGroup::WhichSystemFontSupportsChar(uint32_t aCh, uint32_t aNextCh, SystemFindFontForChar(aCh, aNextCh, aRunScript, &mStyle); if (fe) { bool wantBold = mStyle.ComputeWeight() >= 6; - nsRefPtr font = + RefPtr font = fe->FindOrMakeFont(&mStyle, wantBold && !fe->IsBold()); return font.forget(); } diff --git a/gfx/thebes/gfxTextRun.h b/gfx/thebes/gfxTextRun.h index 95b4cc9690..00b231d93c 100644 --- a/gfx/thebes/gfxTextRun.h +++ b/gfx/thebes/gfxTextRun.h @@ -413,7 +413,7 @@ public: // The text is divided into GlyphRuns as necessary struct GlyphRun { - nsRefPtr mFont; // never null + RefPtr mFont; // never null uint32_t mCharacterOffset; // into original UTF16 string uint8_t mMatchType; uint16_t mOrientation; // gfxTextRunFactory::TEXT_ORIENT_* value @@ -1004,7 +1004,7 @@ protected: bool EqualsUserFont(const gfxUserFontEntry* aUserFont) const; private: - nsRefPtr mFamily; + RefPtr mFamily; // either a font or a font entry exists union { gfxFont* mFont; @@ -1025,13 +1025,13 @@ protected: // Code should be careful about addressing this array directly. nsTArray mFonts; - nsRefPtr mDefaultFont; + RefPtr mDefaultFont; gfxFontStyle mStyle; gfxFloat mUnderlineOffset; gfxFloat mHyphenWidth; - nsRefPtr mUserFontSet; + RefPtr mUserFontSet; uint64_t mCurrGeneration; // track the current user font set generation, rebuild font list if needed gfxTextPerfMetrics *mTextPerf; @@ -1041,8 +1041,8 @@ protected: nsAutoPtr mCachedEllipsisTextRun; // cache the most recent pref font to avoid general pref font lookup - nsRefPtr mLastPrefFamily; - nsRefPtr mLastPrefFont; + RefPtr mLastPrefFamily; + RefPtr mLastPrefFont; eFontPrefLang mLastPrefLang; // lang group for last pref font eFontPrefLang mPageLang; bool mLastPrefFirstFont; // is this the first font in the list of pref fonts for this lang group? diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index 88056c2472..2e576040f2 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -758,7 +758,7 @@ gfxUserFontSet::FindOrCreateUserFontEntry( uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { - nsRefPtr entry; + RefPtr entry; // If there's already a userfont entry in the family whose descriptors all match, // we can just move it to the end of the list instead of adding a new @@ -795,7 +795,7 @@ gfxUserFontSet::CreateUserFontEntry( gfxSparseBitSet* aUnicodeRanges) { - nsRefPtr userFontEntry = + RefPtr userFontEntry = new gfxUserFontEntry(this, aFontFaceSrcList, aWeight, aStretch, aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); @@ -816,7 +816,7 @@ gfxUserFontSet::FindExistingUserFontEntry( MOZ_ASSERT(aWeight != 0, "aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead"); - nsTArray>& fontList = aFamily->GetFontList(); + nsTArray>& fontList = aFamily->GetFontList(); for (size_t i = 0, count = fontList.Length(); i < count; i++) { if (!fontList[i]->mIsUserFontContainer) { diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index ce2bb34e7e..8fde8272bf 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -57,7 +57,7 @@ struct gfxFontFaceSrc { mozilla::net::ReferrerPolicy mReferrerPolicy; nsCOMPtr mOriginPrincipal; // principal if url - nsRefPtr mBuffer; + RefPtr mBuffer; }; inline bool @@ -137,7 +137,7 @@ public: // add the given font entry to the end of the family's list void AddFontEntry(gfxFontEntry* aFontEntry) { // keep ref while removing existing entry - nsRefPtr fe = aFontEntry; + RefPtr fe = aFontEntry; // remove existing entry, if already present mAvailableFonts.RemoveElement(aFontEntry); // insert at the beginning so that the last-defined font is the first @@ -648,7 +648,7 @@ protected: bool mUnsupportedFormat; - nsRefPtr mPlatformFontEntry; + RefPtr mPlatformFontEntry; nsTArray mSrcList; uint32_t mSrcIndex; // index of loading src item // This field is managed by the nsFontFaceLoader. In the destructor and Cancel() diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index b336c08953..6b92bbd498 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -451,13 +451,13 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable, return nullptr; } - nsRefPtr tmpCtx = new gfxContext(target); + RefPtr tmpCtx = new gfxContext(target); tmpCtx->SetOp(OptimalFillOp()); aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), true, Filter::LINEAR, 1.0, gfxMatrix::Translation(needed.TopLeft())); RefPtr surface = target->Snapshot(); - nsRefPtr drawable = new gfxSurfaceDrawable(surface, size, gfxMatrix::Translation(-needed.TopLeft())); + RefPtr drawable = new gfxSurfaceDrawable(surface, size, gfxMatrix::Translation(-needed.TopLeft())); return drawable.forget(); } #endif // !MOZ_GFX_OPTIMIZE_MOBILE && !MOZ_WIDGET_COCOA @@ -530,7 +530,7 @@ static gfxMatrix DeviceToImageTransform(gfxContext* aContext) { gfxFloat deviceX, deviceY; - nsRefPtr currentTarget = + RefPtr currentTarget = aContext->CurrentSurface(&deviceX, &deviceY); gfxMatrix deviceToUser = aContext->CurrentMatrix(); if (!deviceToUser.Invert()) { @@ -675,7 +675,7 @@ PrescaleAndTileDrawable(gfxDrawable* aDrawable, return false; } - nsRefPtr tmpCtx = new gfxContext(scaledDT); + RefPtr tmpCtx = new gfxContext(scaledDT); scaledDT->SetTransform(ToMatrix(scaleMatrix)); gfxRect gfxImageRect(aImageRect.x, aImageRect.y, aImageRect.width, aImageRect.height); aDrawable->Draw(tmpCtx, gfxImageRect, true, aFilter, 1.0, gfxMatrix()); @@ -721,7 +721,7 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext, bool doTile = !imageRect.Contains(region) && !(aImageFlags & imgIContainer::FLAG_CLAMP); - nsRefPtr currentTarget = aContext->CurrentSurface(); + RefPtr currentTarget = aContext->CurrentSurface(); gfxMatrix deviceSpaceToImageSpace = DeviceToImageTransform(aContext); AutoCairoPixmanBugWorkaround workaround(aContext, deviceSpaceToImageSpace, @@ -729,7 +729,7 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext, if (!workaround.Succeeded()) return; - nsRefPtr drawable = aDrawable; + RefPtr drawable = aDrawable; aFilter = ReduceResamplingFilter(aFilter, imageRect.Width(), imageRect.Height(), @@ -759,7 +759,7 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext, // allocating very large temporary surfaces, especially since we'll // do full-page snapshots often (see bug 749426). #if !defined(MOZ_GFX_OPTIMIZE_MOBILE) && !defined(MOZ_WIDGET_COCOA) - nsRefPtr restrictedDrawable = + RefPtr restrictedDrawable = CreateSamplingRestrictedDrawable(aDrawable, aContext, aRegion, aFormat); if (restrictedDrawable) { @@ -1458,7 +1458,7 @@ gfxUtils::WriteAsPNG(nsIPresShell* aShell, const char* aFile) SurfaceFormat::B8G8R8A8); NS_ENSURE_TRUE(dt, /*void*/); - nsRefPtr context = new gfxContext(dt); + RefPtr context = new gfxContext(dt); aShell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context); WriteAsPNG(dt.get(), aFile); } diff --git a/gfx/thebes/gfxWindowsNativeDrawing.cpp b/gfx/thebes/gfxWindowsNativeDrawing.cpp index e6f7282f3b..08bb04a0db 100644 --- a/gfx/thebes/gfxWindowsNativeDrawing.cpp +++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp @@ -42,7 +42,7 @@ HDC gfxWindowsNativeDrawing::BeginNativeDrawing() { if (mRenderState == RENDER_STATE_INIT) { - nsRefPtr surf; + RefPtr surf; if (mContext->GetCairo()) { surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y); @@ -192,7 +192,7 @@ gfxWindowsNativeDrawing::IsDoublePass() return true; } - nsRefPtr surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y); + RefPtr surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y); if (!surf || surf->CairoStatus()) return false; if (surf->GetType() != gfxSurfaceType::Win32 && @@ -263,8 +263,8 @@ gfxWindowsNativeDrawing::PaintToContext() // nothing to do, it already went to the context mRenderState = RENDER_STATE_DONE; } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE) { - nsRefPtr black = mBlackSurface->GetAsImageSurface(); - nsRefPtr white = mWhiteSurface->GetAsImageSurface(); + RefPtr black = mBlackSurface->GetAsImageSurface(); + RefPtr white = mWhiteSurface->GetAsImageSurface(); if (!gfxAlphaRecovery::RecoverAlpha(black, white)) { NS_ERROR("Alpha recovery failure"); return; @@ -281,7 +281,7 @@ gfxWindowsNativeDrawing::PaintToContext() mContext->NewPath(); mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.Size())); - nsRefPtr pat = new gfxPattern(source, Matrix()); + RefPtr pat = new gfxPattern(source, Matrix()); gfxMatrix m; m.Scale(mScale.width, mScale.height); diff --git a/gfx/thebes/gfxWindowsNativeDrawing.h b/gfx/thebes/gfxWindowsNativeDrawing.h index d13b31f42f..ab2544736e 100644 --- a/gfx/thebes/gfxWindowsNativeDrawing.h +++ b/gfx/thebes/gfxWindowsNativeDrawing.h @@ -87,7 +87,7 @@ public: private: - nsRefPtr mContext; + RefPtr mContext; gfxRect mNativeRect; uint32_t mNativeDrawFlags; @@ -95,7 +95,7 @@ private: uint8_t mRenderState; gfxPoint mDeviceOffset; - nsRefPtr mBlackPattern, mWhitePattern; + RefPtr mBlackPattern, mWhitePattern; enum TransformType { TRANSLATION_ONLY, @@ -109,7 +109,7 @@ private: XFORM mWorldTransform; // saved state - nsRefPtr mWinSurface, mBlackSurface, mWhiteSurface; + RefPtr mWinSurface, mBlackSurface, mWhiteSurface; HDC mDC; XFORM mOldWorldTransform; POINT mOrigViewportOrigin; diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 3765b35191..da45b650c8 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -453,7 +453,7 @@ gfxWindowsPlatform::InitDWriteSupport() HRESULT hr = createDWriteFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), - (IUnknown **)((IDWriteFactory **)byRef(factory))); + (IUnknown **)((IDWriteFactory **)getter_AddRefs(factory))); if (FAILED(hr) || !factory) { return false; } @@ -567,7 +567,7 @@ gfxWindowsPlatform::GetContentBackendFor(mozilla::layers::LayersBackend aLayers) #ifdef CAIRO_HAS_D2D_SURFACE HRESULT -gfxWindowsPlatform::CreateDevice(nsRefPtr &adapter1, +gfxWindowsPlatform::CreateDevice(RefPtr &adapter1, int featureLevelIndex) { nsModuleHandle d3d10module(LoadLibrarySystem32(L"d3d10_1.dll")); @@ -633,7 +633,7 @@ gfxWindowsPlatform::VerifyD2DDevice(bool aAttemptForce) int supportedFeatureLevelsCount = ArrayLength(kSupportedFeatureLevels); - nsRefPtr adapter1 = GetDXGIAdapter(); + RefPtr adapter1 = GetDXGIAdapter(); if (!adapter1) { // Unable to create adapter, abort acceleration. @@ -731,7 +731,7 @@ already_AddRefed gfxWindowsPlatform::CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) { - nsRefPtr surf = nullptr; + RefPtr surf = nullptr; #ifdef CAIRO_HAS_WIN32_SURFACE if (mRenderMode == RENDER_GDI || mRenderMode == RENDER_DIRECT2D) @@ -1471,7 +1471,7 @@ gfxWindowsPlatform::SetupClearTypeParams() break; } - nsRefPtr defaultRenderingParams; + RefPtr defaultRenderingParams; GetDWriteFactory()->CreateRenderingParams(getter_AddRefs(defaultRenderingParams)); // For EnhancedContrast, we override the default if the user has not set it // in the registry (by using the ClearType Tuner). @@ -1629,7 +1629,7 @@ gfxWindowsPlatform::GetDXGIAdapter() // Try to use a DXGI 1.1 adapter in order to share resources // across processes. if (createDXGIFactory1) { - nsRefPtr factory1; + RefPtr factory1; HRESULT hr = createDXGIFactory1(__uuidof(IDXGIFactory1), getter_AddRefs(factory1)); @@ -1639,7 +1639,7 @@ gfxWindowsPlatform::GetDXGIAdapter() return nullptr; } - hr = factory1->EnumAdapters1(0, byRef(mAdapter)); + hr = factory1->EnumAdapters1(0, getter_AddRefs(mAdapter)); if (FAILED(hr)) { // We should return and not accelerate if we can't obtain // an adapter. @@ -1691,12 +1691,12 @@ bool DoesD3D11DeviceWork(ID3D11Device *device) static void CheckForAdapterMismatch(ID3D11Device *device) { - nsRefPtr dxgiDevice; + RefPtr dxgiDevice; if (FAILED(device->QueryInterface(__uuidof(IDXGIDevice), getter_AddRefs(dxgiDevice)))) { return; } - nsRefPtr dxgiAdapter; + RefPtr dxgiAdapter; if (FAILED(dxgiDevice->GetAdapter(getter_AddRefs(dxgiAdapter)))) { return; } @@ -1720,11 +1720,11 @@ void CheckIfRenderTargetViewNeedsRecreating(ID3D11Device *device) return; } - nsRefPtr deviceContext; + RefPtr deviceContext; device->GetImmediateContext(getter_AddRefs(deviceContext)); int backbufferWidth = 32; int backbufferHeight = 32; - nsRefPtr offscreenTexture; - nsRefPtr keyedMutex; + RefPtr offscreenTexture; + RefPtr keyedMutex; D3D11_TEXTURE2D_DESC offscreenTextureDesc = { 0 }; offscreenTextureDesc.Width = backbufferWidth; @@ -1748,7 +1748,7 @@ void CheckIfRenderTargetViewNeedsRecreating(ID3D11Device *device) offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; offscreenRTVDesc.Texture2D.MipSlice = 0; - nsRefPtr offscreenRTView; + RefPtr offscreenRTView; result = device->CreateRenderTargetView(offscreenTexture, &offscreenRTVDesc, getter_AddRefs(offscreenRTView)); // Acquire and clear @@ -1835,12 +1835,12 @@ bool DoesD3D11TextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT forma desc.CPUAccessFlags = 0; desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; desc.BindFlags = bindflags; - if (FAILED(device->CreateTexture2D(&desc, NULL, byRef(texture)))) { + if (FAILED(device->CreateTexture2D(&desc, NULL, getter_AddRefs(texture)))) { return false; } HANDLE shareHandle; - nsRefPtr otherResource; + RefPtr otherResource; if (FAILED(texture->QueryInterface(__uuidof(IDXGIResource), getter_AddRefs(otherResource)))) { @@ -1851,8 +1851,8 @@ bool DoesD3D11TextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT forma return false; } - nsRefPtr sharedResource; - nsRefPtr sharedTexture; + RefPtr sharedResource; + RefPtr sharedTexture; if (FAILED(device->OpenSharedResource(shareHandle, __uuidof(ID3D11Resource), getter_AddRefs(sharedResource)))) { @@ -1869,7 +1869,7 @@ bool DoesD3D11TextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT forma RefPtr sharedView; // This if(FAILED()) is the one that actually fails on systems affected by bug 1083071. - if (FAILED(device->CreateShaderResourceView(sharedTexture, NULL, byRef(sharedView)))) { + if (FAILED(device->CreateShaderResourceView(sharedTexture, NULL, getter_AddRefs(sharedView)))) { gfxCriticalError(CriticalLog::DefaultOptions(false)) << "CreateShaderResourceView failed for format" << format; return false; } @@ -1971,7 +1971,7 @@ gfxWindowsPlatform::AttemptD3D11DeviceCreation() // to prevent bug 1092260. IE 11 also uses this flag. D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS, mFeatureLevels.Elements(), mFeatureLevels.Length(), - D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr); + D3D11_SDK_VERSION, getter_AddRefs(mD3D11Device), nullptr, nullptr); } MOZ_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { gfxCriticalError() << "Crash during D3D11 device creation"; return; @@ -2007,7 +2007,7 @@ gfxWindowsPlatform::AttemptWARPDeviceCreation() // to prevent bug 1092260. IE 11 also uses this flag. D3D11_CREATE_DEVICE_BGRA_SUPPORT, mFeatureLevels.Elements(), mFeatureLevels.Length(), - D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr); + D3D11_SDK_VERSION, getter_AddRefs(mD3D11Device), nullptr, nullptr); if (FAILED(hr)) { // This should always succeed... in theory. @@ -2050,7 +2050,7 @@ gfxWindowsPlatform::AttemptD3D11ContentDeviceCreation() nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT, mFeatureLevels.Elements(), mFeatureLevels.Length(), - D3D11_SDK_VERSION, byRef(mD3D11ContentDevice), nullptr, nullptr); + D3D11_SDK_VERSION, getter_AddRefs(mD3D11ContentDevice), nullptr, nullptr); } MOZ_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { return false; } @@ -2072,7 +2072,7 @@ gfxWindowsPlatform::AttemptD3D11ContentDeviceCreation() mD3D11ContentDevice->SetExceptionMode(0); - nsRefPtr multi; + RefPtr multi; mD3D11ContentDevice->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi)); multi->SetMultithreadProtected(TRUE); @@ -2089,7 +2089,7 @@ gfxWindowsPlatform::AttemptD3D11ImageBridgeDeviceCreation() sD3D11CreateDeviceFn(GetDXGIAdapter(), D3D_DRIVER_TYPE_UNKNOWN, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT, mFeatureLevels.Elements(), mFeatureLevels.Length(), - D3D11_SDK_VERSION, byRef(mD3D11ImageBridgeDevice), nullptr, nullptr); + D3D11_SDK_VERSION, getter_AddRefs(mD3D11ImageBridgeDevice), nullptr, nullptr); } MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { return; } @@ -2407,7 +2407,7 @@ gfxWindowsPlatform::CreateD3D11DecoderDevice() hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr, D3D11_CREATE_DEVICE_VIDEO_SUPPORT, featureLevels.Elements(), featureLevels.Length(), - D3D11_SDK_VERSION, byRef(device), nullptr, nullptr); + D3D11_SDK_VERSION, getter_AddRefs(device), nullptr, nullptr); } MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { return nullptr; } @@ -2416,7 +2416,7 @@ gfxWindowsPlatform::CreateD3D11DecoderDevice() return nullptr; } - nsRefPtr multi; + RefPtr multi; device->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi)); multi->SetMultithreadProtected(TRUE); @@ -2592,7 +2592,7 @@ private: virtual ~D3DVsyncSource() { } - nsRefPtr mPrimaryDisplay; + RefPtr mPrimaryDisplay; }; // end D3DVsyncSource already_AddRefed @@ -2611,7 +2611,7 @@ gfxWindowsPlatform::CreateHardwareVsyncSource() return gfxPlatform::CreateHardwareVsyncSource(); } - nsRefPtr d3dVsyncSource = new D3DVsyncSource(); + RefPtr d3dVsyncSource = new D3DVsyncSource(); return d3dVsyncSource.forget(); } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 0de0dfbccd..c3183830f4 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -158,7 +158,7 @@ public: void VerifyD2DDevice(bool aAttemptForce); #ifdef CAIRO_HAS_D2D_SURFACE - HRESULT CreateDevice(nsRefPtr &adapter1, int featureLevelIndex); + HRESULT CreateDevice(RefPtr &adapter1, int featureLevelIndex); #endif /** @@ -329,17 +329,17 @@ private: bool IsDeviceReset(HRESULT hr, DeviceResetReason* aReason); #ifdef CAIRO_HAS_DWRITE_FONT - nsRefPtr mDWriteFactory; - nsRefPtr mRenderingParams[TEXT_RENDERING_COUNT]; + RefPtr mDWriteFactory; + RefPtr mRenderingParams[TEXT_RENDERING_COUNT]; DWRITE_MEASURING_MODE mMeasuringMode; #endif - mozilla::RefPtr mAdapter; - nsRefPtr mDeviceManager; - mozilla::RefPtr mD3D10Device; - mozilla::RefPtr mD3D11Device; - mozilla::RefPtr mD3D11ContentDevice; - mozilla::RefPtr mD3D11ImageBridgeDevice; - mozilla::RefPtr mD3D11ReadbackManager; + RefPtr mAdapter; + RefPtr mDeviceManager; + RefPtr mD3D10Device; + RefPtr mD3D11Device; + RefPtr mD3D11ContentDevice; + RefPtr mD3D11ImageBridgeDevice; + RefPtr mD3D11ReadbackManager; bool mIsWARP; bool mHasDeviceReset; bool mHasFakeDeviceReset; diff --git a/gfx/thebes/gfxWindowsSurface.cpp b/gfx/thebes/gfxWindowsSurface.cpp index c093099119..868d5efa6d 100644 --- a/gfx/thebes/gfxWindowsSurface.cpp +++ b/gfx/thebes/gfxWindowsSurface.cpp @@ -152,7 +152,7 @@ gfxWindowsSurface::CreateSimilarSurface(gfxContentType aContent, return nullptr; } - nsRefPtr result = Wrap(surface, aSize); + RefPtr result = Wrap(surface, aSize); cairo_surface_destroy(surface); return result.forget(); } @@ -197,7 +197,7 @@ gfxWindowsSurface::GetAsImageSurface() if (!isurf) return nullptr; - nsRefPtr result = gfxASurface::Wrap(isurf).downcast(); + RefPtr result = gfxASurface::Wrap(isurf).downcast(); result->SetOpaqueRect(GetOpaqueRect()); return result.forget(); diff --git a/gfx/thebes/gfxXlibNativeRenderer.cpp b/gfx/thebes/gfxXlibNativeRenderer.cpp index 28b44867f2..6f5abcae96 100644 --- a/gfx/thebes/gfxXlibNativeRenderer.cpp +++ b/gfx/thebes/gfxXlibNativeRenderer.cpp @@ -451,7 +451,7 @@ CopyXlibSurfaceToImage(cairo_surface_t *tempXlibSurface, IntSize size, gfxImageFormat format) { - nsRefPtr result = new gfxImageSurface(size, format); + RefPtr result = new gfxImageSurface(size, format); cairo_t* copyCtx = cairo_create(result->CairoSurface()); cairo_set_source_surface(copyCtx, tempXlibSurface, 0, 0); @@ -582,7 +582,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size, Rect(0, 0, size.width, size.height)); } } else { - nsRefPtr tmpSurf = gfxASurface::Wrap(tempXlibSurface); + RefPtr tmpSurf = gfxASurface::Wrap(tempXlibSurface); ctx->SetSource(tmpSurf, offset); ctx->Paint(); } @@ -590,7 +590,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size, return; } - nsRefPtr blackImage = + RefPtr blackImage = CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::ARGB32); cairo_t* tmpCtx = cairo_create(tempXlibSurface); @@ -599,7 +599,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size, cairo_paint(tmpCtx); cairo_destroy(tmpCtx); DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft()); - nsRefPtr whiteImage = + RefPtr whiteImage = CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::RGB24); if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS && diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index 9a5a7b651a..5132a22829 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -195,7 +195,7 @@ gfxXlibSurface::Create(Screen *screen, Visual *visual, if (!drawable) return nullptr; - nsRefPtr result = + RefPtr result = new gfxXlibSurface(DisplayOfScreen(screen), drawable, visual, size); result->TakePixmap(); @@ -215,7 +215,7 @@ gfxXlibSurface::Create(Screen *screen, XRenderPictFormat *format, if (!drawable) return nullptr; - nsRefPtr result = + RefPtr result = new gfxXlibSurface(screen, drawable, format, size); result->TakePixmap(); @@ -254,7 +254,7 @@ gfxXlibSurface::CreateSimilarSurface(gfxContentType aContent, // itself, so we use cairo_surface_create_similar with a // temporary reference surface to indicate the format. Screen* screen = cairo_xlib_surface_get_screen(CairoSurface()); - nsRefPtr depth24reference = + RefPtr depth24reference = gfxXlibSurface::Create(screen, format, gfx::IntSize(1, 1), mDrawable); if (depth24reference) diff --git a/gfx/vr/gfxVR.cpp b/gfx/vr/gfxVR.cpp index 552d580a72..f06068fb97 100644 --- a/gfx/vr/gfxVR.cpp +++ b/gfx/vr/gfxVR.cpp @@ -106,7 +106,7 @@ VRHMDManager::ManagerInit() sManagers = new VRHMDManagerArray(); - nsRefPtr mgr; + RefPtr mgr; // we'll only load the 0.5.0 oculus runtime if // the >= 0.6.0 one failed to load; otherwise @@ -150,7 +150,7 @@ VRHMDManager::ManagerDestroy() } /* static */ void -VRHMDManager::GetAllHMDs(nsTArray>& aHMDResult) +VRHMDManager::GetAllHMDs(nsTArray>& aHMDResult) { if (!sManagers) return; diff --git a/gfx/vr/gfxVR.h b/gfx/vr/gfxVR.h index 9097d01f3e..e53df53b1e 100644 --- a/gfx/vr/gfxVR.h +++ b/gfx/vr/gfxVR.h @@ -10,7 +10,7 @@ #include "nsIScreen.h" #include "nsString.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "mozilla/gfx/2D.h" #include "mozilla/EnumeratedArray.h" @@ -140,9 +140,9 @@ public: NS_INLINE_DECL_REFCOUNTING(RenderTargetSet) - nsRefPtr compositor; + RefPtr compositor; IntSize size; - nsTArray> renderTargets; + nsTArray> renderTargets; int32_t currentRenderTarget; virtual already_AddRefed GetNextRenderTarget() = 0; @@ -245,12 +245,12 @@ class VRHMDManager { public: static void ManagerInit(); static void ManagerDestroy(); - static void GetAllHMDs(nsTArray>& aHMDResult); + static void GetAllHMDs(nsTArray>& aHMDResult); static uint32_t AllocateDeviceIndex(); static already_AddRefed MakeFakeScreen(int32_t x, int32_t y, uint32_t width, uint32_t height); protected: - typedef nsTArray> VRHMDManagerArray; + typedef nsTArray> VRHMDManagerArray; static VRHMDManagerArray *sManagers; static Atomic sDeviceBase; @@ -260,7 +260,7 @@ public: virtual bool PlatformInit() = 0; virtual bool Init() = 0; virtual void Destroy() = 0; - virtual void GetHMDs(nsTArray>& aHMDResult) = 0; + virtual void GetHMDs(nsTArray>& aHMDResult) = 0; protected: VRHMDManager() { } diff --git a/gfx/vr/gfxVRCardboard.cpp b/gfx/vr/gfxVRCardboard.cpp index 3dec94e0d0..614beac51c 100644 --- a/gfx/vr/gfxVRCardboard.cpp +++ b/gfx/vr/gfxVRCardboard.cpp @@ -342,7 +342,7 @@ VRHMDManagerCardboard::Init() if (mCardboardInitialized) return true; - nsRefPtr hmd = new HMDInfoCardboard(); + RefPtr hmd = new HMDInfoCardboard(); mCardboardHMDs.AppendElement(hmd); mCardboardInitialized = true; @@ -364,7 +364,7 @@ VRHMDManagerCardboard::Destroy() } void -VRHMDManagerCardboard::GetHMDs(nsTArray>& aHMDResult) +VRHMDManagerCardboard::GetHMDs(nsTArray>& aHMDResult) { Init(); for (size_t i = 0; i < mCardboardHMDs.Length(); ++i) { diff --git a/gfx/vr/gfxVRCardboard.h b/gfx/vr/gfxVRCardboard.h index fd6ecd98ac..76065a8d80 100644 --- a/gfx/vr/gfxVRCardboard.h +++ b/gfx/vr/gfxVRCardboard.h @@ -85,9 +85,9 @@ public: virtual bool PlatformInit() override; virtual bool Init() override; virtual void Destroy() override; - virtual void GetHMDs(nsTArray >& aHMDResult) override; + virtual void GetHMDs(nsTArray >& aHMDResult) override; protected: - nsTArray> mCardboardHMDs; + nsTArray> mCardboardHMDs; bool mCardboardInitialized; }; diff --git a/gfx/vr/gfxVROculus.cpp b/gfx/vr/gfxVROculus.cpp index 5618cc5863..e8b596d7e5 100644 --- a/gfx/vr/gfxVROculus.cpp +++ b/gfx/vr/gfxVROculus.cpp @@ -441,7 +441,7 @@ struct RenderTargetSetOculus : public VRHMDRenderingSupport::RenderTargetSet currentRenderTarget = (currentRenderTarget + 1) % renderTargets.Length(); textureSet->CurrentIndex = currentRenderTarget; renderTargets[currentRenderTarget]->ClearOnBind(); - nsRefPtr rt = renderTargets[currentRenderTarget]; + RefPtr rt = renderTargets[currentRenderTarget]; return rt.forget(); } @@ -462,7 +462,7 @@ struct RenderTargetSetOculus : public VRHMDRenderingSupport::RenderTargetSet Destroy(); } - nsRefPtr hmd; + RefPtr hmd; ovrSwapTextureSet *textureSet; }; @@ -492,7 +492,7 @@ struct RenderTargetSetD3D11 : public RenderTargetSetOculus for (int i = 0; i < aTS->TextureCount; ++i) { ovrD3D11Texture *tex11; - nsRefPtr rt; + RefPtr rt; tex11 = (ovrD3D11Texture*)&aTS->Textures[i]; rt = new layers::CompositingRenderTargetD3D11(tex11->D3D11.pTexture, IntPoint(0, 0)); @@ -520,7 +520,7 @@ HMDInfoOculus::CreateRenderTargetSet(layers::Compositor *aCompositor, const IntS return nullptr; } - nsRefPtr rts = new RenderTargetSetD3D11(comp11, aSize, this, ts); + RefPtr rts = new RenderTargetSetD3D11(comp11, aSize, this, ts); return rts.forget(); } #endif @@ -621,7 +621,7 @@ VRHMDManagerOculus::Init() ovrHmd hmd; orv = ovrHmd_Create(i, &hmd); if (orv == ovrSuccess) { - nsRefPtr oc = new HMDInfoOculus(hmd); + RefPtr oc = new HMDInfoOculus(hmd); mOculusHMDs.AppendElement(oc); } } @@ -634,7 +634,7 @@ VRHMDManagerOculus::Init() ovrHmd hmd; orv = ovrHmd_CreateDebug(ovrHmd_DK2, &hmd); if (orv == ovrSuccess) { - nsRefPtr oc = new HMDInfoOculus(hmd); + RefPtr oc = new HMDInfoOculus(hmd); mOculusHMDs.AppendElement(oc); } } @@ -660,7 +660,7 @@ VRHMDManagerOculus::Destroy() } void -VRHMDManagerOculus::GetHMDs(nsTArray>& aHMDResult) +VRHMDManagerOculus::GetHMDs(nsTArray>& aHMDResult) { Init(); for (size_t i = 0; i < mOculusHMDs.Length(); ++i) { diff --git a/gfx/vr/gfxVROculus.h b/gfx/vr/gfxVROculus.h index e5ad10b266..a472e7e5c0 100644 --- a/gfx/vr/gfxVROculus.h +++ b/gfx/vr/gfxVROculus.h @@ -9,7 +9,7 @@ #include "nsTArray.h" #include "nsIScreen.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "mozilla/gfx/2D.h" #include "mozilla/EnumeratedArray.h" @@ -84,9 +84,9 @@ public: virtual bool PlatformInit() override; virtual bool Init() override; virtual void Destroy() override; - virtual void GetHMDs(nsTArray >& aHMDResult) override; + virtual void GetHMDs(nsTArray >& aHMDResult) override; protected: - nsTArray> mOculusHMDs; + nsTArray> mOculusHMDs; bool mOculusInitialized; bool mOculusPlatformInitialized; }; diff --git a/gfx/vr/gfxVROculus050.cpp b/gfx/vr/gfxVROculus050.cpp index 6853720d55..9f64458a63 100644 --- a/gfx/vr/gfxVROculus050.cpp +++ b/gfx/vr/gfxVROculus050.cpp @@ -518,7 +518,7 @@ VRHMDManagerOculus050::Init() for (int i = 0; i < count; ++i) { ovrHmd hmd = ovrHmd_Create(i); if (hmd) { - nsRefPtr oc = new HMDInfoOculus050(hmd); + RefPtr oc = new HMDInfoOculus050(hmd); mOculusHMDs.AppendElement(oc); } } @@ -530,7 +530,7 @@ VRHMDManagerOculus050::Init() { ovrHmd hmd = ovrHmd_CreateDebug(ovrHmd_DK2); if (hmd) { - nsRefPtr oc = new HMDInfoOculus050(hmd); + RefPtr oc = new HMDInfoOculus050(hmd); mOculusHMDs.AppendElement(oc); } } @@ -556,7 +556,7 @@ VRHMDManagerOculus050::Destroy() } void -VRHMDManagerOculus050::GetHMDs(nsTArray>& aHMDResult) +VRHMDManagerOculus050::GetHMDs(nsTArray>& aHMDResult) { Init(); for (size_t i = 0; i < mOculusHMDs.Length(); ++i) { diff --git a/gfx/vr/gfxVROculus050.h b/gfx/vr/gfxVROculus050.h index d4081ca0c3..06d28b6dd6 100644 --- a/gfx/vr/gfxVROculus050.h +++ b/gfx/vr/gfxVROculus050.h @@ -9,7 +9,7 @@ #include "nsTArray.h" #include "nsIScreen.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "mozilla/gfx/2D.h" #include "mozilla/EnumeratedArray.h" @@ -72,9 +72,9 @@ public: virtual bool PlatformInit() override; virtual bool Init() override; virtual void Destroy() override; - virtual void GetHMDs(nsTArray >& aHMDResult) override; + virtual void GetHMDs(nsTArray >& aHMDResult) override; protected: - nsTArray> mOculusHMDs; + nsTArray> mOculusHMDs; bool mOculusInitialized; bool mOculusPlatformInitialized; }; diff --git a/hal/gonk/GonkHal.cpp b/hal/gonk/GonkHal.cpp index 43bb5a15ca..52d17e560d 100644 --- a/hal/gonk/GonkHal.cpp +++ b/hal/gonk/GonkHal.cpp @@ -496,7 +496,7 @@ public: } private: - nsRefPtr mUpdater; + RefPtr mUpdater; }; // sBatteryObserver is owned by the IO thread. Only the IO thread may @@ -936,7 +936,7 @@ DisableScreenConfigurationNotifications() void GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration) { - nsRefPtr screen = nsScreenManagerGonk::GetPrimaryScreen(); + RefPtr screen = nsScreenManagerGonk::GetPrimaryScreen(); *aScreenConfiguration = screen->GetConfiguration(); } @@ -1036,7 +1036,7 @@ WaitForAlarm(void* aData) // *on time* (the system won't sleep during the process in any way), // we need to acquire a CPU wake lock before firing the alarm event. InternalLockCpu(); - nsRefPtr event = + RefPtr event = new AlarmFiredEvent(alarmData->mGeneration); NS_DispatchToMainThread(event); } @@ -1729,7 +1729,7 @@ EnsureKernelLowMemKillerParamsSet() } // Ensure OOM events appear in logcat - nsRefPtr oomLogger = new OomVictimLogger(); + RefPtr oomLogger = new OomVictimLogger(); nsCOMPtr os = services::GetObserverService(); if (os) { os->AddObserver(oomLogger, "ipc:content-shutdown", false); diff --git a/hal/windows/WindowsSensor.cpp b/hal/windows/WindowsSensor.cpp index e8e81d8086..302ad7c484 100644 --- a/hal/windows/WindowsSensor.cpp +++ b/hal/windows/WindowsSensor.cpp @@ -16,7 +16,7 @@ using namespace mozilla::hal; namespace mozilla { namespace hal_impl { -static nsRefPtr sAccelerometer; +static RefPtr sAccelerometer; class SensorEvent final : public ISensorEvents { public: @@ -114,7 +114,7 @@ EnableSensorNotifications(SensorType aSensor) return; } - nsRefPtr manager; + RefPtr manager; if (FAILED(CoCreateInstance(CLSID_SensorManager, nullptr, CLSCTX_INPROC_SERVER, IID_ISensorManager, @@ -124,7 +124,7 @@ EnableSensorNotifications(SensorType aSensor) // accelerometer event - nsRefPtr collection; + RefPtr collection; if (FAILED(manager->GetSensorsByType(SENSOR_TYPE_ACCELEROMETER_3D, getter_AddRefs(collection)))) { return; @@ -136,7 +136,7 @@ EnableSensorNotifications(SensorType aSensor) return; } - nsRefPtr sensor; + RefPtr sensor; collection->GetAt(0, getter_AddRefs(sensor)); if (!sensor) { return; @@ -144,7 +144,7 @@ EnableSensorNotifications(SensorType aSensor) // Set report interval to 100ms if possible. // Default value depends on drivers. - nsRefPtr values; + RefPtr values; if (SUCCEEDED(CoCreateInstance(CLSID_PortableDeviceValues, nullptr, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValues, @@ -152,13 +152,13 @@ EnableSensorNotifications(SensorType aSensor) if (SUCCEEDED(values->SetUnsignedIntegerValue( SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, DEFAULT_SENSOR_POLL))) { - nsRefPtr returns; + RefPtr returns; sensor->SetProperties(values, getter_AddRefs(returns)); } } - nsRefPtr event = new SensorEvent(); - nsRefPtr sensorEvents; + RefPtr event = new SensorEvent(); + RefPtr sensorEvents; if (FAILED(event->QueryInterface(IID_ISensorEvents, getter_AddRefs(sensorEvents)))) { return; diff --git a/image/ClippedImage.cpp b/image/ClippedImage.cpp index a6aa9c68cf..daa0d5cdef 100644 --- a/image/ClippedImage.cpp +++ b/image/ClippedImage.cpp @@ -108,7 +108,7 @@ public: } private: - nsRefPtr mImage; + RefPtr mImage; const nsIntSize mSize; const Maybe& mSVGContext; const uint32_t mWhichFrame; @@ -135,7 +135,7 @@ ClippedImage::ShouldClip() // aren't available yet, in which case we'll try again later. if (mShouldClip.isNothing()) { int32_t width, height; - nsRefPtr progressTracker = + RefPtr progressTracker = InnerImage()->GetProgressTracker(); if (InnerImage()->HasError()) { // If there's a problem with the inner image we'll let it handle @@ -254,12 +254,12 @@ ClippedImage::GetFrameInternal(const nsIntSize& aSize, return nullptr; } - nsRefPtr ctx = new gfxContext(target); + RefPtr ctx = new gfxContext(target); // Create our callback. - nsRefPtr drawTileCallback = + RefPtr drawTileCallback = new DrawSingleTileCallback(this, aSize, aSVGContext, aWhichFrame, aFlags); - nsRefPtr drawable = + RefPtr drawable = new gfxCallbackDrawable(drawTileCallback, aSize); // Actually draw. The callback will end up invoking DrawSingleTile. @@ -344,7 +344,7 @@ ClippedImage::Draw(gfxContext* aContext, } // Create a drawable from that surface. - nsRefPtr drawable = + RefPtr drawable = new gfxSurfaceDrawable(surface, aSize); // Draw. diff --git a/image/CopyOnWrite.h b/image/CopyOnWrite.h index 5f9c88bb94..21db5c3bc3 100644 --- a/image/CopyOnWrite.h +++ b/image/CopyOnWrite.h @@ -11,7 +11,7 @@ #ifndef mozilla_image_CopyOnWrite_h #define mozilla_image_CopyOnWrite_h -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "MainThreadUtils.h" #include "nsISupportsImpl.h" @@ -33,8 +33,8 @@ public: explicit CopyOnWriteValue(T* aValue) : mValue(aValue) { } explicit CopyOnWriteValue(already_AddRefed& aValue) : mValue(aValue) { } explicit CopyOnWriteValue(already_AddRefed&& aValue) : mValue(aValue) { } - explicit CopyOnWriteValue(const nsRefPtr& aValue) : mValue(aValue) { } - explicit CopyOnWriteValue(nsRefPtr&& aValue) : mValue(aValue) { } + explicit CopyOnWriteValue(const RefPtr& aValue) : mValue(aValue) { } + explicit CopyOnWriteValue(RefPtr&& aValue) : mValue(aValue) { } T* get() { return mValue.get(); } const T* get() const { return mValue.get(); } @@ -77,7 +77,7 @@ private: ~CopyOnWriteValue() { } - nsRefPtr mValue; + RefPtr mValue; uint64_t mReaders = 0; bool mWriter = false; }; @@ -122,11 +122,11 @@ public: : mValue(new CopyOnWriteValue(aValue)) { } - explicit CopyOnWrite(const nsRefPtr& aValue) + explicit CopyOnWrite(const RefPtr& aValue) : mValue(new CopyOnWriteValue(aValue)) { } - explicit CopyOnWrite(nsRefPtr&& aValue) + explicit CopyOnWrite(RefPtr&& aValue) : mValue(new CopyOnWriteValue(aValue)) { } @@ -149,7 +149,7 @@ public: MOZ_ASSERT(CanRead()); // Run the provided function while holding a read lock. - nsRefPtr cowValue = mValue; + RefPtr cowValue = mValue; typename CopyOnWriteValue::AutoReadLock lock(cowValue); return aReader(cowValue->get()); } @@ -205,7 +205,7 @@ public: } // Run the provided function while holding a write lock. - nsRefPtr cowValue = mValue; + RefPtr cowValue = mValue; typename CopyOnWriteValue::AutoWriteLock lock(cowValue); return aWriter(cowValue->get()); } @@ -241,7 +241,7 @@ private: CopyOnWrite(const CopyOnWrite&) = delete; CopyOnWrite(CopyOnWrite&&) = delete; - nsRefPtr mValue; + RefPtr mValue; }; } // namespace image diff --git a/image/DecodePool.cpp b/image/DecodePool.cpp index 52dbe20255..0834826380 100644 --- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -74,7 +74,7 @@ private: , mSurfaceFlags(aSurfaceFlags) { } - nsRefPtr mImage; + RefPtr mImage; const Progress mProgress; const nsIntRect mInvalidRect; const SurfaceFlags mSurfaceFlags; @@ -107,7 +107,7 @@ private: : mDecoder(aDecoder) { } - nsRefPtr mDecoder; + RefPtr mDecoder; }; #ifdef MOZ_NUWA_PROCESS @@ -141,7 +141,7 @@ struct Work SHUTDOWN } mType; - nsRefPtr mDecoder; + RefPtr mDecoder; }; class DecodePoolImpl @@ -195,7 +195,7 @@ public: void PushWork(Decoder* aDecoder) { MOZ_ASSERT(aDecoder); - nsRefPtr decoder(aDecoder); + RefPtr decoder(aDecoder); MonitorAutoLock lock(mMonitor); @@ -242,7 +242,7 @@ public: private: ~DecodePoolImpl() { } - Work PopWorkFromQueue(nsTArray>& aQueue) + Work PopWorkFromQueue(nsTArray>& aQueue) { Work work; work.mType = Work::Type::DECODE; @@ -256,8 +256,8 @@ private: // mMonitor guards the queues and mShuttingDown. Monitor mMonitor; - nsTArray> mMetadataDecodeQueue; - nsTArray> mFullDecodeQueue; + nsTArray> mMetadataDecodeQueue; + nsTArray> mFullDecodeQueue; bool mShuttingDown; }; @@ -296,7 +296,7 @@ public: } private: - nsRefPtr mImpl; + RefPtr mImpl; }; /* static */ void diff --git a/image/DecodePool.h b/image/DecodePool.h index 702903a14b..cf04d3f8c4 100644 --- a/image/DecodePool.h +++ b/image/DecodePool.h @@ -92,7 +92,7 @@ private: static StaticRefPtr sSingleton; static uint32_t sNumCores; - nsRefPtr mImpl; + RefPtr mImpl; // mMutex protects mThreads and mIOThread. Mutex mMutex; diff --git a/image/Decoder.cpp b/image/Decoder.cpp index 437672b1fd..cbe7ce9fb2 100644 --- a/image/Decoder.cpp +++ b/image/Decoder.cpp @@ -319,7 +319,7 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum, return RawAccessFrameRef(); } - nsRefPtr frame = new imgFrame(); + RefPtr frame = new imgFrame(); bool nonPremult = bool(mSurfaceFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA); if (NS_FAILED(frame->InitForDecoder(aTargetSize, aFrameRect, aFormat, aPaletteDepth, nonPremult))) { diff --git a/image/Decoder.h b/image/Decoder.h index c9b68d24ec..5a08de8a9d 100644 --- a/image/Decoder.h +++ b/image/Decoder.h @@ -407,7 +407,7 @@ protected: uint32_t mColormapSize; private: - nsRefPtr mImage; + RefPtr mImage; Maybe mIterator; RawAccessFrameRef mCurrentFrame; ImageMetadata mImageMetadata; diff --git a/image/DecoderFactory.cpp b/image/DecoderFactory.cpp index bad977cb02..fd9b0c1257 100644 --- a/image/DecoderFactory.cpp +++ b/image/DecoderFactory.cpp @@ -89,7 +89,7 @@ DecoderFactory::GetDecoder(DecoderType aType, RasterImage* aImage, bool aIsRedecode) { - nsRefPtr decoder; + RefPtr decoder; switch (aType) { case DecoderType::PNG: @@ -143,7 +143,7 @@ DecoderFactory::CreateDecoder(DecoderType aType, return nullptr; } - nsRefPtr decoder = + RefPtr decoder = GetDecoder(aType, aImage, bool(aDecoderFlags & DecoderFlags::IS_REDECODE)); MOZ_ASSERT(decoder, "Should have a decoder now"); @@ -184,7 +184,7 @@ DecoderFactory::CreateAnimationDecoder(DecoderType aType, MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG, "Calling CreateAnimationDecoder for non-animating DecoderType"); - nsRefPtr decoder = + RefPtr decoder = GetDecoder(aType, aImage, /* aIsRedecode = */ true); MOZ_ASSERT(decoder, "Should have a decoder now"); @@ -214,7 +214,7 @@ DecoderFactory::CreateMetadataDecoder(DecoderType aType, return nullptr; } - nsRefPtr decoder = + RefPtr decoder = GetDecoder(aType, aImage, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); @@ -241,7 +241,7 @@ DecoderFactory::CreateAnonymousDecoder(DecoderType aType, return nullptr; } - nsRefPtr decoder = + RefPtr decoder = GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); @@ -279,7 +279,7 @@ DecoderFactory::CreateAnonymousMetadataDecoder(DecoderType aType, return nullptr; } - nsRefPtr decoder = + RefPtr decoder = GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); diff --git a/image/DynamicImage.cpp b/image/DynamicImage.cpp index dd7c89015a..cf8d555565 100644 --- a/image/DynamicImage.cpp +++ b/image/DynamicImage.cpp @@ -185,7 +185,7 @@ DynamicImage::GetFrameAtSize(const IntSize& aSize, "DynamicImage::GetFrame failed in CreateOffscreenContentDrawTarget"; return nullptr; } - nsRefPtr context = new gfxContext(dt); + RefPtr context = new gfxContext(dt); auto result = Draw(context, aSize, ImageRegion::Create(aSize), aWhichFrame, Filter::POINT, Nothing(), aFlags); diff --git a/image/DynamicImage.h b/image/DynamicImage.h index 2ba75120bb..751bed82a1 100644 --- a/image/DynamicImage.h +++ b/image/DynamicImage.h @@ -66,7 +66,7 @@ public: private: virtual ~DynamicImage() { } - nsRefPtr mDrawable; + RefPtr mDrawable; }; } // namespace image diff --git a/image/FrameAnimator.cpp b/image/FrameAnimator.cpp index a77a9b667c..f87ce242e0 100644 --- a/image/FrameAnimator.cpp +++ b/image/FrameAnimator.cpp @@ -479,7 +479,7 @@ FrameAnimator::DoBlend(nsIntRect* aDirtyRect, // Create the Compositing Frame if (!mCompositingFrame) { - nsRefPtr newFrame = new imgFrame; + RefPtr newFrame = new imgFrame; nsresult rv = newFrame->InitForDecoder(mSize, SurfaceFormat::B8G8R8A8); if (NS_FAILED(rv)) { @@ -622,7 +622,7 @@ FrameAnimator::DoBlend(nsIntRect* aDirtyRect, // It would be better if we just stored the area that nextFrame is going to // overwrite. if (!mCompositingPrevFrame) { - nsRefPtr newFrame = new imgFrame; + RefPtr newFrame = new imgFrame; nsresult rv = newFrame->InitForDecoder(mSize, SurfaceFormat::B8G8R8A8); if (NS_FAILED(rv)) { diff --git a/image/Image.cpp b/image/Image.cpp index 3f8fa1dc94..b757a60f71 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -22,7 +22,7 @@ ImageMemoryCounter::ImageMemoryCounter(Image* aImage, MOZ_ASSERT(aImage); // Extract metadata about the image. - nsRefPtr imageURL(aImage->GetURI()); + RefPtr imageURL(aImage->GetURI()); if (imageURL) { imageURL->GetSpec(mURI); } diff --git a/image/Image.h b/image/Image.h index 5e5c325e67..ed81f8217e 100644 --- a/image/Image.h +++ b/image/Image.h @@ -232,7 +232,7 @@ class ImageResource : public Image public: already_AddRefed GetProgressTracker() override { - nsRefPtr progressTracker = mProgressTracker; + RefPtr progressTracker = mProgressTracker; MOZ_ASSERT(progressTracker); return progressTracker.forget(); } @@ -309,8 +309,8 @@ protected: virtual nsresult StopAnimation() = 0; // Member data shared by all implementations of this abstract class - nsRefPtr mProgressTracker; - nsRefPtr mURI; + RefPtr mProgressTracker; + RefPtr mURI; TimeStamp mLastRefreshTime; uint64_t mInnerWindowId; uint32_t mAnimationConsumers; diff --git a/image/ImageCacheKey.cpp b/image/ImageCacheKey.cpp index 861c11d3e6..f47b3fafe5 100644 --- a/image/ImageCacheKey.cpp +++ b/image/ImageCacheKey.cpp @@ -33,7 +33,7 @@ BlobSerial(ImageURL* aURI) nsAutoCString spec; aURI->GetSpec(spec); - nsRefPtr blob; + RefPtr blob; if (NS_SUCCEEDED(NS_GetBlobForBlobURISpec(spec, getter_AddRefs(blob))) && blob) { return Some(blob->GetSerialNumber()); diff --git a/image/ImageCacheKey.h b/image/ImageCacheKey.h index fb6b8b8271..e2dc36c99c 100644 --- a/image/ImageCacheKey.h +++ b/image/ImageCacheKey.h @@ -47,7 +47,7 @@ private: static uint32_t ComputeHash(ImageURL* aURI, const Maybe& aBlobSerial); - nsRefPtr mURI; + RefPtr mURI; Maybe mBlobSerial; uint32_t mHash; bool mIsChrome; diff --git a/image/ImageFactory.cpp b/image/ImageFactory.cpp index fd053383b4..a4fb1b76ee 100644 --- a/image/ImageFactory.cpp +++ b/image/ImageFactory.cpp @@ -104,7 +104,7 @@ ImageFactory::CreateImage(nsIRequest* aRequest, // Marks an image as having an error before returning it. template static already_AddRefed -BadImage(const char* aMessage, nsRefPtr& aImage) +BadImage(const char* aMessage, RefPtr& aImage) { NS_WARNING(aMessage); aImage->SetHasError(); @@ -116,9 +116,9 @@ ImageFactory::CreateAnonymousImage(const nsCString& aMimeType) { nsresult rv; - nsRefPtr newImage = new RasterImage(); + RefPtr newImage = new RasterImage(); - nsRefPtr newTracker = new ProgressTracker(); + RefPtr newTracker = new ProgressTracker(); newTracker->SetImage(newImage); newImage->SetProgressTracker(newTracker); @@ -137,7 +137,7 @@ ImageFactory::CreateMultipartImage(Image* aFirstPart, MOZ_ASSERT(aFirstPart); MOZ_ASSERT(aProgressTracker); - nsRefPtr newImage = new MultipartImage(aFirstPart); + RefPtr newImage = new MultipartImage(aFirstPart); aProgressTracker->SetImage(newImage); newImage->SetProgressTracker(aProgressTracker); @@ -201,7 +201,7 @@ ImageFactory::CreateRasterImage(nsIRequest* aRequest, nsresult rv; - nsRefPtr newImage = new RasterImage(aURI); + RefPtr newImage = new RasterImage(aURI); aProgressTracker->SetImage(newImage); newImage->SetProgressTracker(aProgressTracker); @@ -269,7 +269,7 @@ ImageFactory::CreateVectorImage(nsIRequest* aRequest, nsresult rv; - nsRefPtr newImage = new VectorImage(aURI); + RefPtr newImage = new VectorImage(aURI); aProgressTracker->SetImage(newImage); newImage->SetProgressTracker(aProgressTracker); diff --git a/image/ImageOps.cpp b/image/ImageOps.cpp index 0e7833e258..76a7bb968b 100644 --- a/image/ImageOps.cpp +++ b/image/ImageOps.cpp @@ -27,7 +27,7 @@ namespace image { /* static */ already_AddRefed ImageOps::Freeze(Image* aImage) { - nsRefPtr frozenImage = new FrozenImage(aImage); + RefPtr frozenImage = new FrozenImage(aImage); return frozenImage.forget(); } @@ -42,7 +42,7 @@ ImageOps::Freeze(imgIContainer* aImage) /* static */ already_AddRefed ImageOps::Clip(Image* aImage, nsIntRect aClip) { - nsRefPtr clippedImage = new ClippedImage(aImage, aClip); + RefPtr clippedImage = new ClippedImage(aImage, aClip); return clippedImage.forget(); } @@ -57,7 +57,7 @@ ImageOps::Clip(imgIContainer* aImage, nsIntRect aClip) /* static */ already_AddRefed ImageOps::Orient(Image* aImage, Orientation aOrientation) { - nsRefPtr orientedImage = new OrientedImage(aImage, aOrientation); + RefPtr orientedImage = new OrientedImage(aImage, aOrientation); return orientedImage.forget(); } @@ -104,7 +104,7 @@ ImageOps::DecodeToSurface(nsIInputStream* aInputStream, } // Write the data into a SourceBuffer. - nsRefPtr sourceBuffer = new SourceBuffer(); + RefPtr sourceBuffer = new SourceBuffer(); sourceBuffer->ExpectLength(length); rv = sourceBuffer->AppendFromInputStream(inputStream, length); if (NS_FAILED(rv)) { @@ -115,7 +115,7 @@ ImageOps::DecodeToSurface(nsIInputStream* aInputStream, // Create a decoder. DecoderType decoderType = DecoderFactory::GetDecoderType(PromiseFlatCString(aMimeType).get()); - nsRefPtr decoder = + RefPtr decoder = DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, ToSurfaceFlags(aFlags)); diff --git a/image/ImageWrapper.h b/image/ImageWrapper.h index 9975954418..f60a1c09c3 100644 --- a/image/ImageWrapper.h +++ b/image/ImageWrapper.h @@ -76,7 +76,7 @@ protected: } private: - nsRefPtr mInnerImage; + RefPtr mInnerImage; }; } // namespace image diff --git a/image/MultipartImage.cpp b/image/MultipartImage.cpp index 1778e629f0..4950e7699c 100644 --- a/image/MultipartImage.cpp +++ b/image/MultipartImage.cpp @@ -31,14 +31,14 @@ public: MOZ_ASSERT(aImage); mImage = aImage; - nsRefPtr tracker = mImage->GetProgressTracker(); + RefPtr tracker = mImage->GetProgressTracker(); tracker->AddObserver(this); } void BlockUntilDecodedAndFinishObserving() { // Use GetFrame() to block until our image finishes decoding. - nsRefPtr surface = + RefPtr surface = mImage->GetFrame(imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE); @@ -72,7 +72,7 @@ public: // If there's already an error, we may never get a FRAME_COMPLETE // notification, so go ahead and notify our owner right away. - nsRefPtr tracker = mImage->GetProgressTracker(); + RefPtr tracker = mImage->GetProgressTracker(); if (tracker->GetProgress() & FLAG_HAS_ERROR) { FinishObserving(); } @@ -92,7 +92,7 @@ private: { MOZ_ASSERT(mImage); - nsRefPtr tracker = mImage->GetProgressTracker(); + RefPtr tracker = mImage->GetProgressTracker(); tracker->RemoveObserver(this); mImage = nullptr; @@ -100,7 +100,7 @@ private: } MultipartImage* mOwner; - nsRefPtr mImage; + RefPtr mImage; }; @@ -122,7 +122,7 @@ MultipartImage::Init() MOZ_ASSERT(mTracker, "Should've called SetProgressTracker() by now"); // Start observing the first part. - nsRefPtr firstPartTracker = + RefPtr firstPartTracker = InnerImage()->GetProgressTracker(); firstPartTracker->AddObserver(this); InnerImage()->RequestDecode(); @@ -172,7 +172,7 @@ MultipartImage::FinishTransition() MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mNextPart, "Should have a next part here"); - nsRefPtr newCurrentPartTracker = + RefPtr newCurrentPartTracker = mNextPart->GetProgressTracker(); if (newCurrentPartTracker->GetProgress() & FLAG_HAS_ERROR) { // This frame has an error; drop it. @@ -180,7 +180,7 @@ MultipartImage::FinishTransition() // We still need to notify, though. mTracker->ResetForNewRequest(); - nsRefPtr currentPartTracker = + RefPtr currentPartTracker = InnerImage()->GetProgressTracker(); mTracker ->SyncNotifyProgress(FilterProgress(currentPartTracker->GetProgress())); @@ -190,7 +190,7 @@ MultipartImage::FinishTransition() // Stop observing the current part. { - nsRefPtr currentPartTracker = + RefPtr currentPartTracker = InnerImage()->GetProgressTracker(); currentPartTracker->RemoveObserver(this); } @@ -221,7 +221,7 @@ already_AddRefed MultipartImage::GetProgressTracker() { MOZ_ASSERT(mTracker); - nsRefPtr tracker = mTracker; + RefPtr tracker = mTracker; return tracker.forget(); } @@ -244,7 +244,7 @@ MultipartImage::OnImageDataAvailable(nsIRequest* aRequest, // one exists, and *not* the current part. // We may trigger notifications that will free mNextPart, so keep it alive. - nsRefPtr nextPart = mNextPart; + RefPtr nextPart = mNextPart; if (nextPart) { nextPart->OnImageDataAvailable(aRequest, aContext, aInStr, aSourceOffset, aCount); @@ -266,7 +266,7 @@ MultipartImage::OnImageDataComplete(nsIRequest* aRequest, // one exists, and *not* the current part. // We may trigger notifications that will free mNextPart, so keep it alive. - nsRefPtr nextPart = mNextPart; + RefPtr nextPart = mNextPart; if (nextPart) { nextPart->OnImageDataComplete(aRequest, aContext, aStatus, aLastPart); } else { diff --git a/image/MultipartImage.h b/image/MultipartImage.h index b041e72135..089ec993be 100644 --- a/image/MultipartImage.h +++ b/image/MultipartImage.h @@ -78,9 +78,9 @@ private: void FinishTransition(); - nsRefPtr mTracker; - nsRefPtr mNextPartObserver; - nsRefPtr mNextPart; + RefPtr mTracker; + RefPtr mNextPartObserver; + RefPtr mNextPart; bool mDeferNotifications : 1; }; diff --git a/image/OrientedImage.cpp b/image/OrientedImage.cpp index 08e5e5887c..7e0bc15418 100644 --- a/image/OrientedImage.cpp +++ b/image/OrientedImage.cpp @@ -109,11 +109,11 @@ OrientedImage::GetFrame(uint32_t aWhichFrame, RefPtr innerSurface = InnerImage()->GetFrame(aWhichFrame, aFlags); NS_ENSURE_TRUE(innerSurface, nullptr); - nsRefPtr drawable = + RefPtr drawable = new gfxSurfaceDrawable(innerSurface, size); // Draw. - nsRefPtr ctx = new gfxContext(target); + RefPtr ctx = new gfxContext(target); ctx->Multiply(OrientationMatrix(size)); gfxUtils::DrawPixelSnapped(ctx, drawable, size, ImageRegion::Create(size), surfaceFormat, Filter::LINEAR); diff --git a/image/ProgressTracker.cpp b/image/ProgressTracker.cpp index 65e8d39435..a129a4531d 100644 --- a/image/ProgressTracker.cpp +++ b/image/ProgressTracker.cpp @@ -148,8 +148,8 @@ class AsyncNotifyRunnable : public nsRunnable private: friend class ProgressTracker; - nsRefPtr mTracker; - nsTArray> mObservers; + RefPtr mTracker; + nsTArray> mObservers; }; void @@ -158,9 +158,9 @@ ProgressTracker::Notify(IProgressObserver* aObserver) MOZ_ASSERT(NS_IsMainThread()); if (MOZ_LOG_TEST(GetImgLog(), LogLevel::Debug)) { - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image && image->GetURI()) { - nsRefPtr uri(image->GetURI()); + RefPtr uri(image->GetURI()); nsAutoCString spec; uri->GetSpec(spec); LOG_FUNC_WITH_PARAM(GetImgLog(), @@ -213,12 +213,12 @@ class AsyncNotifyCurrentStateRunnable : public nsRunnable } private: - nsRefPtr mProgressTracker; - nsRefPtr mObserver; + RefPtr mProgressTracker; + RefPtr mObserver; // We have to hold on to a reference to the tracker's image, just in case // it goes away while we're in the event queue. - nsRefPtr mImage; + RefPtr mImage; }; void @@ -227,7 +227,7 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver) MOZ_ASSERT(NS_IsMainThread()); if (MOZ_LOG_TEST(GetImgLog(), LogLevel::Debug)) { - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); nsAutoCString spec; if (image && image->GetURI()) { image->GetURI()->GetSpec(spec); @@ -264,7 +264,7 @@ struct MOZ_STACK_CLASS ImageObserverNotifier void operator()(Lambda aFunc) { for (auto iter = mObservers->ConstIter(); !iter.Done(); iter.Next()) { - nsRefPtr observer = iter.Data().get(); + RefPtr observer = iter.Data().get(); if (observer && (mIgnoreDeferral || !observer->NotificationsDeferred())) { aFunc(observer); @@ -400,7 +400,7 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver) { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); nsAutoCString spec; if (image && image->GetURI()) { @@ -426,7 +426,7 @@ ProgressTracker::EmulateRequestFinished(IProgressObserver* aObserver) { MOZ_ASSERT(NS_IsMainThread(), "SyncNotifyState and mObservers are not threadsafe"); - nsRefPtr kungFuDeathGrip(aObserver); + RefPtr kungFuDeathGrip(aObserver); if (mProgress & FLAG_ONLOAD_BLOCKED && !(mProgress & FLAG_ONLOAD_UNBLOCKED)) { aObserver->UnblockOnload(); @@ -441,7 +441,7 @@ void ProgressTracker::AddObserver(IProgressObserver* aObserver) { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr observer = aObserver; + RefPtr observer = aObserver; mObservers.Write([=](ObserverTable* aTable) { MOZ_ASSERT(!aTable->Get(observer, nullptr), @@ -456,7 +456,7 @@ bool ProgressTracker::RemoveObserver(IProgressObserver* aObserver) { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr observer = aObserver; + RefPtr observer = aObserver; // Remove the observer from the list. bool removed = mObservers.Write([=](ObserverTable* aTable) { @@ -546,12 +546,12 @@ ProgressTracker::FireFailureNotification() // Some kind of problem has happened with image decoding. // Report the URI to net:failed-to-process-uri-conent observers. - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { // Should be on main thread, so ok to create a new nsIURI. nsCOMPtr uri; { - nsRefPtr threadsafeUriData = image->GetURI(); + RefPtr threadsafeUriData = image->GetURI(); uri = threadsafeUriData ? threadsafeUriData->ToIURI() : nullptr; } if (uri) { diff --git a/image/ProgressTracker.h b/image/ProgressTracker.h index 1cb0c116d8..021d8df52f 100644 --- a/image/ProgressTracker.h +++ b/image/ProgressTracker.h @@ -119,7 +119,7 @@ public: already_AddRefed GetImage() const { MutexAutoLock lock(mImageMutex); - nsRefPtr image = mImage; + RefPtr image = mImage; return image.forget(); } diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index 58c0f3dc76..5751fb899f 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -626,7 +626,7 @@ RasterImage::GetFrameInternal(const IntSize& aSize, return MakePair(DrawResult::SUCCESS, Move(frameSurf)); } -Pair> +Pair> RasterImage::GetCurrentImage(ImageContainer* aContainer, uint32_t aFlags) { MOZ_ASSERT(NS_IsMainThread()); @@ -639,7 +639,7 @@ RasterImage::GetCurrentImage(ImageContainer* aContainer, uint32_t aFlags) if (!surface) { // The OS threw out some or all of our buffer. We'll need to wait for the // redecode (which was automatically triggered by GetFrame) to complete. - return MakePair(drawResult, nsRefPtr()); + return MakePair(drawResult, RefPtr()); } CairoImage::Data cairoData; @@ -647,7 +647,7 @@ RasterImage::GetCurrentImage(ImageContainer* aContainer, uint32_t aFlags) GetHeight(&cairoData.mSize.height); cairoData.mSourceSurface = surface; - nsRefPtr image = + RefPtr image = aContainer->CreateImage(ImageFormat::CAIRO_SURFACE); MOZ_ASSERT(image); @@ -691,7 +691,7 @@ RasterImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags) mProgressTracker->OnUnlockedDraw(); } - nsRefPtr container = mImageContainer.get(); + RefPtr container = mImageContainer.get(); bool mustRedecode = (aFlags & (FLAG_SYNC_DECODE | FLAG_SYNC_DECODE_IF_FAST)) && @@ -706,7 +706,7 @@ RasterImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags) container = LayerManager::CreateImageContainer(); DrawResult drawResult; - nsRefPtr image; + RefPtr image; Tie(drawResult, image) = GetCurrentImage(container, aFlags); if (!image) { return nullptr; @@ -728,13 +728,13 @@ RasterImage::UpdateImageContainer() { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr container = mImageContainer.get(); + RefPtr container = mImageContainer.get(); if (!container) { return; } DrawResult drawResult; - nsRefPtr image; + RefPtr image; Tie(drawResult, image) = GetCurrentImage(container, FLAG_NONE); if (!image) { return; @@ -782,7 +782,7 @@ public: } private: - nsRefPtr mImage; + RefPtr mImage; uint32_t mNewFrameCount; IntRect mNewRefreshArea; }; @@ -1294,7 +1294,7 @@ RasterImage::Decode(const IntSize& aSize, uint32_t aFlags) } // Create a decoder. - nsRefPtr decoder; + RefPtr decoder; if (mAnim) { decoder = DecoderFactory::CreateAnimationDecoder(mDecoderType, this, mSourceBuffer, decoderFlags, @@ -1349,7 +1349,7 @@ RasterImage::DecodeMetadata(uint32_t aFlags) MOZ_ASSERT(!mHasSize, "Should not do unnecessary metadata decodes"); // Create a decoder. - nsRefPtr decoder = + RefPtr decoder = DecoderFactory::CreateMetadataDecoder(mDecoderType, this, mSourceBuffer, mRequestedSampleSize, mRequestedResolution); @@ -1647,7 +1647,7 @@ RasterImage::DoError() /* static */ void RasterImage::HandleErrorWorker::DispatchIfNeeded(RasterImage* aImage) { - nsRefPtr worker = new HandleErrorWorker(aImage); + RefPtr worker = new HandleErrorWorker(aImage); NS_DispatchToMainThread(worker); } @@ -1693,7 +1693,7 @@ RasterImage::NotifyProgress(Progress aProgress, MOZ_ASSERT(NS_IsMainThread()); // Ensure that we stay alive long enough to finish notifying. - nsRefPtr image(this); + RefPtr image(this); bool wasDefaultFlags = aSurfaceFlags == DefaultSurfaceFlags(); diff --git a/image/RasterImage.h b/image/RasterImage.h index 7c75b8b689..d9ad282625 100644 --- a/image/RasterImage.h +++ b/image/RasterImage.h @@ -280,7 +280,7 @@ private: nsIntRect GetFirstFrameRect(); - Pair> + Pair> GetCurrentImage(layers::ImageContainer* aContainer, uint32_t aFlags); void UpdateImageContainer(); @@ -382,7 +382,7 @@ private: // data #endif // The source data for this image. - nsRefPtr mSourceBuffer; + RefPtr mSourceBuffer; // The number of frames this image has. uint32_t mFrameCount; @@ -438,7 +438,7 @@ private: // data private: explicit HandleErrorWorker(RasterImage* aImage); - nsRefPtr mImage; + RefPtr mImage; }; // Helpers diff --git a/image/SourceBuffer.h b/image/SourceBuffer.h index 66458823ec..c4e826dc1e 100644 --- a/image/SourceBuffer.h +++ b/image/SourceBuffer.h @@ -19,7 +19,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/RefCounted.h" #include "mozilla/UniquePtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsTArray.h" class nsIInputStream; @@ -172,7 +172,7 @@ private: return mState = COMPLETE; } - nsRefPtr mOwner; + RefPtr mOwner; State mState; @@ -367,7 +367,7 @@ private: FallibleTArray mChunks; /// Consumers which are waiting to be notified when new data is available. - nsTArray> mWaitingConsumers; + nsTArray> mWaitingConsumers; /// If present, marks this SourceBuffer complete with the given final status. Maybe mStatus; diff --git a/image/SurfaceCache.cpp b/image/SurfaceCache.cpp index 6ffc76b3bf..ec18bc1849 100644 --- a/image/SurfaceCache.cpp +++ b/image/SurfaceCache.cpp @@ -221,7 +221,7 @@ public: private: nsExpirationState mExpirationState; - nsRefPtr mSurface; + RefPtr mSurface; DrawableFrameRef mDrawableRef; const Cost mCost; const ImageKey mImageKey; @@ -270,7 +270,7 @@ public: already_AddRefed Lookup(const SurfaceKey& aSurfaceKey) { - nsRefPtr surface; + RefPtr surface; mSurfaces.Get(aSurfaceKey, getter_AddRefs(surface)); return surface.forget(); } @@ -280,7 +280,7 @@ public: const Maybe& aAlternateFlags) { // Try for an exact match first. - nsRefPtr exactMatch; + RefPtr exactMatch; mSurfaces.Get(aSurfaceKey, getter_AddRefs(exactMatch)); if (exactMatch && exactMatch->IsDecoded()) { return MakePair(exactMatch.forget(), MatchType::EXACT); @@ -336,7 +336,7 @@ private: const SurfaceKey& mIdealKey; const Maybe mAlternateFlags; - nsRefPtr mBestMatch; + RefPtr mBestMatch; }; static PLDHashOperator TryToImproveMatch(const SurfaceKey& aSurfaceKey, @@ -499,13 +499,13 @@ public: // Locate the appropriate per-image cache. If there's not an existing cache // for this image, create it. - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { cache = new ImageSurfaceCache; mImageCaches.Put(aImageKey, cache); } - nsRefPtr surface = + RefPtr surface = new CachedSurface(aSurface, aCost, aImageKey, aSurfaceKey); // We require that locking succeed if the image is locked and we're not @@ -531,7 +531,7 @@ public: MOZ_ASSERT(aSurface, "Should have a surface"); ImageKey imageKey = aSurface->GetImageKey(); - nsRefPtr cache = GetImageCache(imageKey); + RefPtr cache = GetImageCache(imageKey); MOZ_ASSERT(cache, "Shouldn't try to remove a surface with no image cache"); // If the surface was not a placeholder, tell its image that we discarded it. @@ -602,13 +602,13 @@ public: const SurfaceKey& aSurfaceKey, bool aMarkUsed = true) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { // No cached surfaces for this image. return LookupResult(MatchType::NOT_FOUND); } - nsRefPtr surface = cache->Lookup(aSurfaceKey); + RefPtr surface = cache->Lookup(aSurfaceKey); if (!surface) { // Lookup in the per-image cache missed. return LookupResult(MatchType::NOT_FOUND); @@ -639,7 +639,7 @@ public: const SurfaceKey& aSurfaceKey, const Maybe& aAlternateFlags) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { // No cached surfaces for this image. return LookupResult(MatchType::NOT_FOUND); @@ -651,7 +651,7 @@ public: // XXX(seth): This is O(N^2), but N is expected to be very small. If we // encounter a performance problem here we can revisit this. - nsRefPtr surface; + RefPtr surface; DrawableFrameRef ref; MatchType matchType = MatchType::NOT_FOUND; while (true) { @@ -689,12 +689,12 @@ public: void RemoveSurface(const ImageKey aImageKey, const SurfaceKey& aSurfaceKey) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { return; // No cached surfaces for this image. } - nsRefPtr surface = cache->Lookup(aSurfaceKey); + RefPtr surface = cache->Lookup(aSurfaceKey); if (!surface) { return; // Lookup in the per-image cache missed. } @@ -709,7 +709,7 @@ public: void LockImage(const ImageKey aImageKey) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { cache = new ImageSurfaceCache; mImageCaches.Put(aImageKey, cache); @@ -723,7 +723,7 @@ public: void UnlockImage(const ImageKey aImageKey) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache || !cache->IsLocked()) { return; // Already unlocked. } @@ -736,7 +736,7 @@ public: void UnlockSurfaces(const ImageKey aImageKey) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache || !cache->IsLocked()) { return; // Already unlocked. } @@ -750,7 +750,7 @@ public: void RemoveImage(const ImageKey aImageKey) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { return; // No cached surfaces for this image, so nothing to do. } @@ -882,7 +882,7 @@ public: nsTArray& aCounters, MallocSizeOf aMallocSizeOf) { - nsRefPtr cache = GetImageCache(aImageKey); + RefPtr cache = GetImageCache(aImageKey); if (!cache) { return; // No surfaces for this image. } @@ -904,7 +904,7 @@ public: private: already_AddRefed GetImageCache(const ImageKey aImageKey) { - nsRefPtr imageCache; + RefPtr imageCache; mImageCaches.Get(aImageKey, getter_AddRefs(imageCache)); return imageCache.forget(); } @@ -968,7 +968,7 @@ private: nsRefPtrHashtable, ImageSurfaceCache> mImageCaches; SurfaceTracker mExpirationTracker; - nsRefPtr mMemoryPressureObserver; + RefPtr mMemoryPressureObserver; Mutex mMutex; const uint32_t mDiscardFactor; const Cost mMaxCost; diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index ca1699e6ae..898cc0c893 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -112,7 +112,7 @@ protected: } // Private data - const nsRefPtr mDocWrapper; + const RefPtr mDocWrapper; VectorImage* const mVectorImage; // Raw pointer because it owns me. bool mHonoringInvalidations; }; @@ -152,7 +152,7 @@ public: // OnSVGDocumentParsed will release our owner's reference to us, so ensure // we stick around long enough to complete our work. - nsRefPtr kungFuDeathGroup(this); + RefPtr kungFuDeathGroup(this); mImage->OnSVGDocumentParsed(); } @@ -211,7 +211,7 @@ public: // OnSVGDocumentLoaded/OnSVGDocumentError will release our owner's reference // to us, so ensure we stick around long enough to complete our work. - nsRefPtr kungFuDeathGroup(this); + RefPtr kungFuDeathGroup(this); nsAutoString eventType; aEvent->GetType(eventType); @@ -266,7 +266,7 @@ public: const Filter& aFilter, const gfxMatrix& aTransform); private: - nsRefPtr mSVGDocumentWrapper; + RefPtr mSVGDocumentWrapper; const IntRect mViewport; const IntSize mSize; uint32_t mImageFlags; @@ -715,7 +715,7 @@ VectorImage::GetFrameAtSize(const IntSize& aSize, return nullptr; } - nsRefPtr context = new gfxContext(dt); + RefPtr context = new gfxContext(dt); auto result = Draw(context, aSize, ImageRegion::Create(aSize), aWhichFrame, Filter::POINT, Nothing(), aFlags); @@ -844,7 +844,7 @@ VectorImage::Draw(gfxContext* aContext, if (result) { RefPtr surface = result.DrawableRef()->GetSurface(); if (surface) { - nsRefPtr svgDrawable = + RefPtr svgDrawable = new gfxSurfaceDrawable(surface, result.DrawableRef()->GetSize()); Show(svgDrawable, params); return DrawResult::SUCCESS; @@ -865,13 +865,13 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) mSVGDocumentWrapper->UpdateViewportBounds(aParams.viewportSize); mSVGDocumentWrapper->FlushImageTransformInvalidation(); - nsRefPtr cb = + RefPtr cb = new SVGDrawingCallback(mSVGDocumentWrapper, IntRect(IntPoint(0, 0), aParams.viewportSize), aParams.size, aParams.flags); - nsRefPtr svgDrawable = + RefPtr svgDrawable = new gfxCallbackDrawable(cb, aParams.size); bool bypassCache = bool(aParams.flags & FLAG_BYPASS_SURFACE_CACHE) || @@ -894,7 +894,7 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) // Try to create an imgFrame, initializing the surface it contains by drawing // our gfxDrawable into it. (We use FILTER_NEAREST since we never scale here.) - nsRefPtr frame = new imgFrame; + RefPtr frame = new imgFrame; nsresult rv = frame->InitWithDrawable(svgDrawable, aParams.size, SurfaceFormat::B8G8R8A8, @@ -921,7 +921,7 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) aParams.animationTime)); // Draw. - nsRefPtr drawable = + RefPtr drawable = new gfxSurfaceDrawable(surface, aParams.size); Show(drawable, aParams); diff --git a/image/VectorImage.h b/image/VectorImage.h index 8d918f67a4..3bbe4a813b 100644 --- a/image/VectorImage.h +++ b/image/VectorImage.h @@ -94,10 +94,10 @@ private: void CancelAllListeners(); void SendInvalidationNotifications(); - nsRefPtr mSVGDocumentWrapper; - nsRefPtr mRenderingObserver; - nsRefPtr mLoadEventListener; - nsRefPtr mParseCompleteListener; + RefPtr mSVGDocumentWrapper; + RefPtr mRenderingObserver; + RefPtr mLoadEventListener; + RefPtr mParseCompleteListener; /// Count of locks on this image (roughly correlated to visible instances). uint32_t mLockCount; diff --git a/image/decoders/nsICODecoder.cpp b/image/decoders/nsICODecoder.cpp index b35351efc9..3ad8ab0a38 100644 --- a/image/decoders/nsICODecoder.cpp +++ b/image/decoders/nsICODecoder.cpp @@ -472,7 +472,7 @@ nsICODecoder::ReadBIH(const char* aData) // contained resource over our own information. // XXX(seth): Is this ever different than the value we obtained from // ReadBPP() above? - nsRefPtr bmpDecoder = + RefPtr bmpDecoder = static_cast(mContainedDecoder.get()); mBPP = bmpDecoder->GetBitsPerPixel(); @@ -508,7 +508,7 @@ nsICODecoder::ReadBMP(const char* aData, uint32_t aLen) LexerTransition nsICODecoder::PrepareForMask() { - nsRefPtr bmpDecoder = + RefPtr bmpDecoder = static_cast(mContainedDecoder.get()); uint16_t numColors = GetNumColors(); @@ -582,7 +582,7 @@ nsICODecoder::ReadMaskRow(const char* aData) decoded = reinterpret_cast(mDownscaler->RowBuffer()); } else { - nsRefPtr bmpDecoder = + RefPtr bmpDecoder = static_cast(mContainedDecoder.get()); uint32_t* imageData = bmpDecoder->GetImageData(); if (!imageData) { @@ -632,7 +632,7 @@ nsICODecoder::FinishMask() // mMaskBuffer. We just need to transfer them to the image. if (mDownscaler) { // Retrieve the image data. - nsRefPtr bmpDecoder = + RefPtr bmpDecoder = static_cast(mContainedDecoder.get()); uint8_t* imageData = reinterpret_cast(bmpDecoder->GetImageData()); if (!imageData) { @@ -651,7 +651,7 @@ nsICODecoder::FinishMask() if (mHasMaskAlpha) { PostHasTransparency(); - nsRefPtr bmpDecoder = + RefPtr bmpDecoder = static_cast(mContainedDecoder.get()); bmpDecoder->SetHasAlphaData(); } diff --git a/image/decoders/nsICODecoder.h b/image/decoders/nsICODecoder.h index ad7f63b5d7..80c57d56cd 100644 --- a/image/decoders/nsICODecoder.h +++ b/image/decoders/nsICODecoder.h @@ -120,7 +120,7 @@ private: LexerTransition FinishResource(); StreamingLexer mLexer; // The lexer. - nsRefPtr mContainedDecoder; // Either a BMP or PNG decoder. + RefPtr mContainedDecoder; // Either a BMP or PNG decoder. UniquePtr mMaskBuffer; // A temporary buffer for the alpha mask. char mBIHraw[40]; // The bitmap information header. IconDirEntry mDirEntry; // The dir entry for the selected resource. diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index f6c90ecfa9..03782426a8 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -302,7 +302,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, // Draw using the drawable the caller provided. nsIntRect imageRect(0, 0, mSize.width, mSize.height); - nsRefPtr ctx = new gfxContext(target); + RefPtr ctx = new gfxContext(target); gfxUtils::DrawPixelSnapped(ctx, aDrawable, mSize, ImageRegion::Create(imageRect), mFormat, aFilter, aImageFlags); @@ -820,7 +820,7 @@ public: NS_IMETHOD Run() { return mTarget->UnlockImageData(); } private: - nsRefPtr mTarget; + RefPtr mTarget; }; nsresult diff --git a/image/imgFrame.h b/image/imgFrame.h index 228a25e654..5f114fd5b0 100644 --- a/image/imgFrame.h +++ b/image/imgFrame.h @@ -293,7 +293,7 @@ private: // methods } struct SurfaceWithFormat { - nsRefPtr mDrawable; + RefPtr mDrawable; SurfaceFormat mFormat; SurfaceWithFormat() { } SurfaceWithFormat(gfxDrawable* aDrawable, SurfaceFormat aFormat) @@ -433,7 +433,7 @@ public: private: DrawableFrameRef(const DrawableFrameRef& aOther) = delete; - nsRefPtr mFrame; + RefPtr mFrame; VolatileBufferPtr mRef; }; @@ -520,7 +520,7 @@ public: private: RawAccessFrameRef(const RawAccessFrameRef& aOther) = delete; - nsRefPtr mFrame; + RefPtr mFrame; }; } // namespace image diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index cd9d4c338a..439ec9687b 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -82,7 +82,7 @@ public: !iter.Done(); iter.Next()) { nsPtrHashKey* entry = iter.Get(); - nsRefPtr req = entry->GetKey(); + RefPtr req = entry->GetKey(); RecordCounterForRequest(req, &uncached, req->HasConsumers()); } } @@ -409,7 +409,7 @@ private: imgCacheEntry* aEntry, void* aUserArg) { - nsRefPtr req = aEntry->GetRequest(); + RefPtr req = aEntry->GetRequest(); RecordCounterForRequest(req, static_cast*>(aUserArg), !aEntry->HasNoProxies()); @@ -420,7 +420,7 @@ private: nsTArray* aArray, bool aIsUsed) { - nsRefPtr image = aRequest->GetImage(); + RefPtr image = aRequest->GetImage(); if (!image) { return; } @@ -438,8 +438,8 @@ private: return PL_DHASH_NEXT; } - nsRefPtr req = aEntry->GetRequest(); - nsRefPtr image = req->GetImage(); + RefPtr req = aEntry->GetRequest(); + RefPtr image = req->GetImage(); if (!image) { return PL_DHASH_NEXT; } @@ -554,8 +554,8 @@ NewRequestAndEntry(bool aForcePrincipalCheckForCacheEntry, imgLoader* aLoader, const ImageCacheKey& aKey, imgRequest** aRequest, imgCacheEntry** aEntry) { - nsRefPtr request = new imgRequest(aLoader, aKey); - nsRefPtr entry = + RefPtr request = new imgRequest(aLoader, aKey); + RefPtr entry = new imgCacheEntry(aLoader, request, aForcePrincipalCheckForCacheEntry); aLoader->AddToUncachedImages(request); request.forget(aRequest); @@ -976,7 +976,7 @@ imgCacheQueue::Push(imgCacheEntry* entry) { mSize += entry->GetDataSize(); - nsRefPtr refptr(entry); + RefPtr refptr(entry); mQueue.push_back(refptr); // If we're not dirty already, then we can efficiently add this to the // binary heap immediately. This is only O(log n). @@ -995,7 +995,7 @@ imgCacheQueue::Pop() Refresh(); } - nsRefPtr entry = mQueue[0]; + RefPtr entry = mQueue[0]; std::pop_heap(mQueue.begin(), mQueue.end(), imgLoader::CompareCacheEntries); mQueue.pop_back(); @@ -1077,14 +1077,14 @@ imgLoader::CreateNewProxyForRequest(imgRequest* aRequest, proxy calls to |aObserver|. */ - nsRefPtr proxyRequest = new imgRequestProxy(); + RefPtr proxyRequest = new imgRequestProxy(); /* It is important to call |SetLoadFlags()| before calling |Init()| because |Init()| adds the request to the loadgroup. */ proxyRequest->SetLoadFlags(aLoadFlags); - nsRefPtr uri; + RefPtr uri; aRequest->GetURI(getter_AddRefs(uri)); // init adds itself to imgRequest's list of observers @@ -1118,10 +1118,10 @@ imgCacheExpirationTracker::NotifyExpired(imgCacheEntry* entry) { // Hold on to a reference to this entry, because the expiration tracker // mechanism doesn't. - nsRefPtr kungFuDeathGrip(entry); + RefPtr kungFuDeathGrip(entry); if (MOZ_LOG_TEST(GetImgLog(), LogLevel::Debug)) { - nsRefPtr req = entry->GetRequest(); + RefPtr req = entry->GetRequest(); if (req) { LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheExpirationTracker::NotifyExpired", @@ -1182,7 +1182,7 @@ imgLoader::imgLoader() already_AddRefed imgLoader::GetInstance() { - static nsRefPtr singleton; + static RefPtr singleton; if (!singleton) { singleton = imgLoader::Create(); if (!singleton) { @@ -1190,7 +1190,7 @@ imgLoader::GetInstance() } ClearOnShutdown(&singleton); } - nsRefPtr loader = singleton.get(); + RefPtr loader = singleton.get(); return loader.forget(); } @@ -1204,7 +1204,7 @@ imgLoader::~imgLoader() MutexAutoLock lock(mUncachedImagesMutex); for (auto iter = mUncachedImages.Iter(); !iter.Done(); iter.Next()) { nsPtrHashKey* entry = iter.Get(); - nsRefPtr req = entry->GetKey(); + RefPtr req = entry->GetKey(); req->ClearLoader(); } } @@ -1420,13 +1420,13 @@ imgLoader::FindEntryProperties(nsIURI* uri, nsIProperties** _retval) ImageCacheKey key(uri); imgCacheTable& cache = GetCache(key); - nsRefPtr entry; + RefPtr entry; if (cache.Get(key, getter_AddRefs(entry)) && entry) { if (mCacheTracker && entry->HasNoProxies()) { mCacheTracker->MarkUsed(entry); } - nsRefPtr request = entry->GetRequest(); + RefPtr request = entry->GetRequest(); if (request) { nsCOMPtr properties = request->Properties(); properties.forget(_retval); @@ -1472,12 +1472,12 @@ imgLoader::PutIntoCache(const ImageCacheKey& aKey, imgCacheEntry* entry) // Check to see if this request already exists in the cache. If so, we'll // replace the old version. - nsRefPtr tmpCacheEntry; + RefPtr tmpCacheEntry; if (cache.Get(aKey, getter_AddRefs(tmpCacheEntry)) && tmpCacheEntry) { MOZ_LOG(GetImgLog(), LogLevel::Debug, ("[this=%p] imgLoader::PutIntoCache -- Element already in the cache", nullptr)); - nsRefPtr tmpRequest = tmpCacheEntry->GetRequest(); + RefPtr tmpRequest = tmpCacheEntry->GetRequest(); // If it already exists, and we're putting the same key into the cache, we // should remove the old version. @@ -1514,7 +1514,7 @@ imgLoader::PutIntoCache(const ImageCacheKey& aKey, imgCacheEntry* entry) } } - nsRefPtr request = entry->GetRequest(); + RefPtr request = entry->GetRequest(); request->SetIsInCache(true); RemoveFromUncachedImages(request); @@ -1563,10 +1563,10 @@ imgLoader::SetHasProxies(imgRequest* aRequest) LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::SetHasProxies", "uri", key.Spec()); - nsRefPtr entry; + RefPtr entry; if (cache.Get(key, getter_AddRefs(entry)) && entry) { // Make sure the cache entry is for the right request - nsRefPtr entryRequest = entry->GetRequest(); + RefPtr entryRequest = entry->GetRequest(); if (entryRequest == aRequest && entry->HasNoProxies()) { imgCacheQueue& queue = GetCacheQueue(key); queue.Remove(entry); @@ -1608,12 +1608,12 @@ imgLoader::CheckCacheLimits(imgCacheTable& cache, imgCacheQueue& queue) // Remove entries from the cache until we're back at our desired max size. while (queue.GetSize() > sCacheMaxSize) { // Remove the first entry in the queue. - nsRefPtr entry(queue.Pop()); + RefPtr entry(queue.Pop()); NS_ASSERTION(entry, "imgLoader::CheckCacheLimits -- NULL entry pointer"); if (MOZ_LOG_TEST(GetImgLog(), LogLevel::Debug)) { - nsRefPtr req = entry->GetRequest(); + RefPtr req = entry->GetRequest(); if (req) { LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::CheckCacheLimits", @@ -1696,7 +1696,7 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request, return false; } - nsRefPtr req; + RefPtr req; rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, aLoadFlags, getter_AddRefs(req)); if (NS_FAILED(rv)) { @@ -1704,13 +1704,13 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request, } // Make sure that OnStatus/OnProgress calls have the right request set... - nsRefPtr progressproxy = + RefPtr progressproxy = new nsProgressNotificationProxy(newChannel, req); if (!progressproxy) { return false; } - nsRefPtr hvc = + RefPtr hvc = new imgCacheValidator(progressproxy, this, request, aCX, forcePrincipalCheck); @@ -1726,7 +1726,7 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request, if (aCORSMode != imgIRequest::CORS_NONE) { bool withCredentials = aCORSMode == imgIRequest::CORS_USE_CREDENTIALS; - nsRefPtr corsproxy = + RefPtr corsproxy = new nsCORSListenerProxy(listener, aLoadingPrincipal, withCredentials); rv = corsproxy->Init(newChannel, DataURIHandling::Allow); if (NS_FAILED(rv)) { @@ -1806,7 +1806,7 @@ imgLoader::ValidateEntry(imgCacheEntry* aEntry, } } - nsRefPtr request(aEntry->GetRequest()); + RefPtr request(aEntry->GetRequest()); if (!request) { return false; @@ -1903,7 +1903,7 @@ imgLoader::RemoveFromCache(const ImageCacheKey& aKey) imgCacheTable& cache = GetCache(aKey); imgCacheQueue& queue = GetCacheQueue(aKey); - nsRefPtr entry; + RefPtr entry; if (cache.Get(aKey, getter_AddRefs(entry)) && entry) { cache.Remove(aKey); @@ -1919,7 +1919,7 @@ imgLoader::RemoveFromCache(const ImageCacheKey& aKey) entry->SetEvicted(true); - nsRefPtr request = entry->GetRequest(); + RefPtr request = entry->GetRequest(); request->SetIsInCache(false); AddToUncachedImages(request); @@ -1934,7 +1934,7 @@ imgLoader::RemoveFromCache(imgCacheEntry* entry, QueueState aQueueState) { LOG_STATIC_FUNC(GetImgLog(), "imgLoader::RemoveFromCache entry"); - nsRefPtr request = entry->GetRequest(); + RefPtr request = entry->GetRequest(); if (request) { const ImageCacheKey& key = request->CacheKey(); imgCacheTable& cache = GetCache(key); @@ -1974,11 +1974,11 @@ imgLoader::RemoveFromCache(imgCacheEntry* entry, QueueState aQueueState) static PLDHashOperator EnumEvictEntries(const ImageCacheKey&, - nsRefPtr& aData, + RefPtr& aData, void* data) { - nsTArray >* entries = - reinterpret_cast > *>(data); + nsTArray >* entries = + reinterpret_cast > *>(data); entries->AppendElement(aData); @@ -1992,7 +1992,7 @@ imgLoader::EvictEntries(imgCacheTable& aCacheToClear) // We have to make a temporary, since RemoveFromCache removes the element // from the queue, invalidating iterators. - nsTArray > entries; + nsTArray > entries; aCacheToClear.Enumerate(EnumEvictEntries, &entries); for (uint32_t i = 0; i < entries.Length(); ++i) { @@ -2013,7 +2013,7 @@ imgLoader::EvictEntries(imgCacheQueue& aQueueToClear) // We have to make a temporary, since RemoveFromCache removes the element // from the queue, invalidating iterators. - nsTArray > entries(aQueueToClear.GetNumElements()); + nsTArray > entries(aQueueToClear.GetNumElements()); for (imgCacheQueue::const_iterator i = aQueueToClear.begin(); i != aQueueToClear.end(); ++i) { entries.AppendElement(*i); @@ -2129,7 +2129,7 @@ imgLoader::LoadImage(nsIURI* aURI, *_retval = nullptr; - nsRefPtr request; + RefPtr request; nsresult rv; nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL; @@ -2181,7 +2181,7 @@ imgLoader::LoadImage(nsIURI* aURI, corsmode = imgIRequest::CORS_USE_CREDENTIALS; } - nsRefPtr entry; + RefPtr entry; // Look in the cache for our URI, and then validate it. // XXX For now ignore aCacheKey. We will need it in the future @@ -2282,7 +2282,7 @@ imgLoader::LoadImage(nsIURI* aURI, this)); bool withCredentials = corsmode == imgIRequest::CORS_USE_CREDENTIALS; - nsRefPtr corsproxy = + RefPtr corsproxy = new nsCORSListenerProxy(pl, aLoadingPrincipal, withCredentials); rv = corsproxy->Init(newChannel, DataURIHandling::Allow); if (NS_FAILED(rv)) { @@ -2412,7 +2412,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel, MOZ_ASSERT(NS_UsePrivateBrowsing(channel) == mRespectPrivacy); - nsRefPtr request; + RefPtr request; nsCOMPtr uri; channel->GetURI(getter_AddRefs(uri)); @@ -2421,7 +2421,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel, nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL; channel->GetLoadFlags(&requestFlags); - nsRefPtr entry; + RefPtr entry; if (requestFlags & nsIRequest::LOAD_BYPASS_CACHE) { RemoveFromCache(key); @@ -2532,7 +2532,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel, channel, channel, entry, aCX, nullptr, imgIRequest::CORS_NONE, RP_Default); - nsRefPtr pl = + RefPtr pl = new ProxyListener(static_cast(request.get())); pl.forget(listener); @@ -3066,7 +3066,7 @@ imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt) // data that's coming in off the channel. nsCOMPtr uri; { - nsRefPtr imageURL; + RefPtr imageURL; mRequest->GetURI(getter_AddRefs(imageURL)); uri = imageURL->ToIURI(); } diff --git a/image/imgLoader.h b/image/imgLoader.h index 3e19b82ef0..eef2f83798 100644 --- a/image/imgLoader.h +++ b/image/imgLoader.h @@ -113,7 +113,7 @@ public: already_AddRefed GetRequest() const { - nsRefPtr req = mRequest; + RefPtr req = mRequest; return req.forget(); } @@ -161,7 +161,7 @@ private: // data NS_DECL_OWNINGTHREAD imgLoader* mLoader; - nsRefPtr mRequest; + RefPtr mRequest; uint32_t mDataSize; int32_t mTouchedTime; int32_t mExpiryTime; @@ -196,7 +196,7 @@ public: void UpdateSize(int32_t diff); uint32_t GetNumElements() const; bool Contains(imgCacheEntry* aEntry) const; - typedef std::vector > queueContainer; + typedef std::vector > queueContainer; typedef queueContainer::iterator iterator; typedef queueContainer::const_iterator const_iterator; @@ -333,8 +333,8 @@ public: // Returns true if we should prefer evicting cache entry |two| over cache // entry |one|. // This mixes units in the worst way, but provides reasonable results. - inline static bool CompareCacheEntries(const nsRefPtr& one, - const nsRefPtr& two) + inline static bool CompareCacheEntries(const RefPtr& one, + const RefPtr& two) { if (!one) { return false; @@ -545,15 +545,15 @@ private: virtual ~imgCacheValidator(); nsCOMPtr mDestListener; - nsRefPtr mProgressProxy; + RefPtr mProgressProxy; nsCOMPtr mRedirectCallback; nsCOMPtr mRedirectChannel; - nsRefPtr mRequest; + RefPtr mRequest; nsCOMArray mProxies; - nsRefPtr mNewRequest; - nsRefPtr mNewEntry; + RefPtr mNewRequest; + RefPtr mNewEntry; nsCOMPtr mContext; diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index 273d9fc5e0..916d8d30f8 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -188,7 +188,7 @@ imgRequest::GetProgressTracker() const } else { MOZ_ASSERT(mProgressTracker, "Should have mProgressTracker until we create mImage"); - nsRefPtr progressTracker = mProgressTracker; + RefPtr progressTracker = mProgressTracker; MOZ_ASSERT(progressTracker); return progressTracker.forget(); } @@ -227,7 +227,7 @@ imgRequest::AddProxy(imgRequestProxy* proxy) // If we're empty before adding, we have to tell the loader we now have // proxies. - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); if (progressTracker->ObserverCount() == 0) { MOZ_ASSERT(mURI, "Trying to SetHasProxies without key uri."); if (mLoader) { @@ -252,7 +252,7 @@ imgRequest::RemoveProxy(imgRequestProxy* proxy, nsresult aStatus) // below, because Cancel() may result in OnStopRequest being called back // before Cancel() returns, leaving the image in a different state then the // one it was in at this point. - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); if (!progressTracker->RemoveObserver(proxy)) { return NS_OK; } @@ -336,7 +336,7 @@ public: return NS_OK; } private: - nsRefPtr mImgRequest; + RefPtr mImgRequest; nsresult mStatus; }; @@ -358,7 +358,7 @@ imgRequest::ContinueCancel(nsresult aStatus) { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); progressTracker->SyncNotifyProgress(FLAG_HAS_ERROR | FLAG_ONLOAD_UNBLOCKED); RemoveFromCache(); @@ -385,7 +385,7 @@ public: return NS_OK; } private: - nsRefPtr mImgRequest; + RefPtr mImgRequest; }; // EvictFromCache() is written to allowed to get called from any thread @@ -510,7 +510,7 @@ imgRequest::RemoveFromCache() bool imgRequest::HasConsumers() const { - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); return progressTracker && progressTracker->ObserverCount() > 0; } @@ -518,7 +518,7 @@ already_AddRefed imgRequest::GetImage() const { MutexAutoLock lock(mMutex); - nsRefPtr image = mImage; + RefPtr image = mImage; return image.forget(); } @@ -575,7 +575,7 @@ imgRequest::UpdateCacheEntrySize() return; } - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); size_t size = image->SizeOfSourceWithComputedFallback(moz_malloc_size_of); mCacheEntry->SetDataSize(size); } @@ -721,7 +721,7 @@ imgRequest::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt) { LOG_SCOPE(GetImgLog(), "imgRequest::OnStartRequest"); - nsRefPtr image; + RefPtr image; // Figure out if we're multipart. nsCOMPtr multiPartChannel = do_QueryInterface(aRequest); @@ -776,7 +776,7 @@ imgRequest::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt) // Shouldn't we be dead already if this gets hit? // Probably multipart/x-mixed-replace... - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); if (progressTracker->ObserverCount() == 0) { this->Cancel(NS_IMAGELIB_ERROR_FAILURE); } @@ -812,7 +812,7 @@ imgRequest::OnStopRequest(nsIRequest* aRequest, LOG_FUNC(GetImgLog(), "imgRequest::OnStopRequest"); MOZ_ASSERT(NS_IsMainThread(), "Can't send notifications off-main-thread"); - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); // XXXldb What if this is a non-last part of a multipart request? // xxx before we release our reference to mRequest, lets @@ -881,7 +881,7 @@ imgRequest::OnStopRequest(nsIRequest* aRequest, Progress progress = LoadCompleteProgress(lastPart, /* aError = */ false, status); - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); progressTracker->SyncNotifyProgress(progress); } @@ -922,7 +922,7 @@ struct NewPartResult final nsAutoCString mContentType; nsAutoCString mContentDisposition; - nsRefPtr mImage; + RefPtr mImage; const bool mIsFirstPart; bool mSucceeded; bool mShouldResetCacheEntry; @@ -970,8 +970,8 @@ PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount, // Create the new image and give it ownership of our ProgressTracker. if (aIsMultipart) { // Create the ProgressTracker and image for this part. - nsRefPtr progressTracker = new ProgressTracker(); - nsRefPtr partImage = + RefPtr progressTracker = new ProgressTracker(); + RefPtr partImage = ImageFactory::CreateImage(aRequest, progressTracker, result.mContentType, aURI, /* aIsMultipart = */ true, aInnerWindowId); @@ -1029,7 +1029,7 @@ public: } private: - nsRefPtr mImgRequest; + RefPtr mImgRequest; NewPartResult mResult; }; @@ -1044,7 +1044,7 @@ imgRequest::FinishPreparingForNewPart(const NewPartResult& aResult) if (aResult.mIsFirstPart) { // Notify listeners that we have an image. - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); progressTracker->OnImageAvailable(); MOZ_ASSERT(progressTracker->HasImage()); } @@ -1068,8 +1068,8 @@ imgRequest::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext, NS_ASSERTION(aRequest, "imgRequest::OnDataAvailable -- no request!"); - nsRefPtr image; - nsRefPtr progressTracker; + RefPtr image; + RefPtr progressTracker; bool isMultipart = false; bool newPartPending = false; diff --git a/image/imgRequest.h b/image/imgRequest.h index 01cce77e21..b8ab52e237 100644 --- a/image/imgRequest.h +++ b/image/imgRequest.h @@ -230,7 +230,7 @@ private: // The original URI we were loaded with. This is the same as the URI we are // keyed on in the cache. We store a string here to avoid off main thread // refcounting issues with nsStandardURL. - nsRefPtr mURI; + RefPtr mURI; // The URI of the resource we ended up loading after all redirects, etc. nsCOMPtr mCurrentURI; // The principal of the document which loaded this image. Used when @@ -249,7 +249,7 @@ private: nsCString mContentType; /* we hold on to this to this so long as we have observers */ - nsRefPtr mCacheEntry; + RefPtr mCacheEntry; /// The key under which this imgRequest is stored in the image cache. ImageCacheKey mCacheKey; @@ -281,8 +281,8 @@ private: // Member variables protected by mMutex. Note that *all* flags in our bitfield // are protected by mMutex; if you're adding a new flag that isn'protected, it // must not be a part of this bitfield. - nsRefPtr mProgressTracker; - nsRefPtr mImage; + RefPtr mProgressTracker; + RefPtr mImage; bool mIsMultiPartChannel : 1; bool mGotData : 1; bool mIsInCache : 1; diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp index 9d616ab067..48dad14ca1 100644 --- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -49,7 +49,7 @@ class RequestBehaviour : public ProxyBehaviour mOwner = aOwner; if (mOwner) { - nsRefPtr ownerProgressTracker = GetProgressTracker(); + RefPtr ownerProgressTracker = GetProgressTracker(); mOwnerHasImage = ownerProgressTracker && ownerProgressTracker->HasImage(); } else { mOwnerHasImage = false; @@ -63,7 +63,7 @@ class RequestBehaviour : public ProxyBehaviour // imgRequestProxy::~imgRequestProxy unregisters the proxy as an observer // from whatever request it was registered with (if any). This, in turn, // means that imgRequest::mObservers will not have any stale pointers in it. - nsRefPtr mOwner; + RefPtr mOwner; bool mOwnerHasImage; }; @@ -74,7 +74,7 @@ RequestBehaviour::GetImage() const if (!mOwnerHasImage) { return nullptr; } - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); return progressTracker->GetImage(); } @@ -210,7 +210,7 @@ imgRequestProxy::ChangeOwner(imgRequest* aNewOwner) // Were we decoded before? bool wasDecoded = false; - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); if (progressTracker->HasImage() && progressTracker->GetImageStatus() & imgIRequest::STATUS_FRAME_COMPLETE) { @@ -379,7 +379,7 @@ imgRequestProxy::StartDecoding() // Flag this, so we know to transfer the request if our owner changes mDecodeRequested = true; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { return image->StartDecoding(); } @@ -397,7 +397,7 @@ imgRequestProxy::RequestDecode() // Flag this, so we know to transfer the request if our owner changes mDecodeRequested = true; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { return image->RequestDecode(); } @@ -414,7 +414,7 @@ NS_IMETHODIMP imgRequestProxy::LockImage() { mLockCount++; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { return image->LockImage(); } @@ -427,7 +427,7 @@ imgRequestProxy::UnlockImage() MOZ_ASSERT(mLockCount > 0, "calling unlock but no locks!"); mLockCount--; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { return image->UnlockImage(); } @@ -437,7 +437,7 @@ imgRequestProxy::UnlockImage() NS_IMETHODIMP imgRequestProxy::RequestDiscard() { - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { return image->RequestDiscard(); } @@ -448,7 +448,7 @@ NS_IMETHODIMP imgRequestProxy::IncrementAnimationConsumers() { mAnimationConsumers++; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { image->IncrementAnimationConsumers(); } @@ -466,7 +466,7 @@ imgRequestProxy::DecrementAnimationConsumers() // early, but not the observer.) if (mAnimationConsumers > 0) { mAnimationConsumers--; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); if (image) { image->DecrementAnimationConsumers(); } @@ -530,7 +530,7 @@ imgRequestProxy::GetImage(imgIContainer** aImage) // that'll happen if we get Canceled before the owner instantiates its image // (because Canceling unregisters us as a listener on mOwner). If we're // in that situation, just grab the image off of mOwner. - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); nsCOMPtr imageToReturn; if (image) { imageToReturn = do_QueryInterface(image); @@ -550,7 +550,7 @@ imgRequestProxy::GetImage(imgIContainer** aImage) NS_IMETHODIMP imgRequestProxy::GetImageStatus(uint32_t* aStatus) { - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); *aStatus = progressTracker->GetImageStatus(); return NS_OK; @@ -633,7 +633,7 @@ imgRequestProxy* NewStaticProxy(imgRequestProxy* aThis) { nsCOMPtr currentPrincipal; aThis->GetImagePrincipal(getter_AddRefs(currentPrincipal)); - nsRefPtr image = aThis->GetImage(); + RefPtr image = aThis->GetImage(); return new imgRequestProxyStatic(image, currentPrincipal); } @@ -664,7 +664,7 @@ imgRequestProxy::PerformClone(imgINotificationObserver* aObserver, LOG_SCOPE(GetImgLog(), "imgRequestProxy::Clone"); *aClone = nullptr; - nsRefPtr clone = aAllocFn(this); + RefPtr clone = aAllocFn(this); // It is important to call |SetLoadFlags()| before calling |Init()| because // |Init()| adds the request to the loadgroup. @@ -933,7 +933,7 @@ nsresult imgRequestProxy::GetStaticRequest(imgRequestProxy** aReturn) { *aReturn = nullptr; - nsRefPtr image = GetImage(); + RefPtr image = GetImage(); bool animated; if (!image || (NS_SUCCEEDED(image->GetAnimated(&animated)) && !animated)) { @@ -950,12 +950,12 @@ imgRequestProxy::GetStaticRequest(imgRequestProxy** aReturn) } // We are animated. We need to create a frozen version of this image. - nsRefPtr frozenImage = ImageOps::Freeze(image); + RefPtr frozenImage = ImageOps::Freeze(image); // Create a static imgRequestProxy with our new extracted frame. nsCOMPtr currentPrincipal; GetImagePrincipal(getter_AddRefs(currentPrincipal)); - nsRefPtr req = new imgRequestProxyStatic(frozenImage, + RefPtr req = new imgRequestProxyStatic(frozenImage, currentPrincipal); req->Init(nullptr, nullptr, mURI, nullptr); @@ -972,7 +972,7 @@ imgRequestProxy::NotifyListener() // processing when we receive notifications (like OnStopRequest()), and we // need to check mCanceled everywhere too. - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); if (GetOwner()) { // Send the notifications to our listener asynchronously. progressTracker->Notify(this); @@ -993,16 +993,16 @@ imgRequestProxy::SyncNotifyListener() // processing when we receive notifications (like OnStopRequest()), and we // need to check mCanceled everywhere too. - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); progressTracker->SyncNotify(this); } void imgRequestProxy::SetHasImage() { - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); MOZ_ASSERT(progressTracker); - nsRefPtr image = progressTracker->GetImage(); + RefPtr image = progressTracker->GetImage(); MOZ_ASSERT(image); // Force any private status related to the owner to reflect @@ -1038,7 +1038,7 @@ RequestBehaviour::HasImage() const if (!mOwnerHasImage) { return false; } - nsRefPtr progressTracker = GetProgressTracker(); + RefPtr progressTracker = GetProgressTracker(); return progressTracker ? progressTracker->HasImage() : false; } @@ -1063,7 +1063,7 @@ public: virtual already_AddRefed GetImage() const override { - nsRefPtr image = mImage; + RefPtr image = mImage; return image.forget(); } @@ -1088,7 +1088,7 @@ public: private: // Our image. We have to hold a strong reference here, because that's normally // the job of the underlying request. - nsRefPtr mImage; + RefPtr mImage; }; imgRequestProxyStatic::imgRequestProxyStatic(mozilla::image::Image* aImage, diff --git a/image/imgRequestProxy.h b/image/imgRequestProxy.h index f63cafb3f5..473938706a 100644 --- a/image/imgRequestProxy.h +++ b/image/imgRequestProxy.h @@ -151,7 +151,7 @@ protected: } private: - nsRefPtr mOwner; + RefPtr mOwner; nsresult mStatus; }; @@ -198,7 +198,7 @@ private: friend imgRequestProxy* NewStaticProxy(imgRequestProxy* aThis); // The URI of our request. - nsRefPtr mURI; + RefPtr mURI; // mListener is only promised to be a weak ref (see imgILoader.idl), // but we actually keep a strong ref to it until we've seen our diff --git a/image/imgTools.cpp b/image/imgTools.cpp index 6cbe950fc3..29905c1ab3 100644 --- a/image/imgTools.cpp +++ b/image/imgTools.cpp @@ -69,8 +69,8 @@ imgTools::DecodeImage(nsIInputStream* aInStr, // Create a new image container to hold the decoded data. nsAutoCString mimeType(aMimeType); - nsRefPtr image = ImageFactory::CreateAnonymousImage(mimeType); - nsRefPtr tracker = image->GetProgressTracker(); + RefPtr image = ImageFactory::CreateAnonymousImage(mimeType); + RefPtr tracker = image->GetProgressTracker(); if (image->HasError()) { return NS_ERROR_FAILURE; diff --git a/image/test/gtest/Common.cpp b/image/test/gtest/Common.cpp index 40946a9815..812513dd1a 100644 --- a/image/test/gtest/Common.cpp +++ b/image/test/gtest/Common.cpp @@ -14,7 +14,7 @@ #include "nsIInputStream.h" #include "nsIProperties.h" #include "nsNetUtil.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsStreamUtils.h" #include "nsString.h" @@ -87,7 +87,7 @@ LoadFile(const char* aRelativePath) bool IsSolidColor(SourceSurface* aSurface, BGRAColor aColor, bool aFuzzy) { - nsRefPtr dataSurface = aSurface->GetDataSurface(); + RefPtr dataSurface = aSurface->GetDataSurface(); ASSERT_TRUE_OR_RETURN(dataSurface != nullptr, false); ASSERT_EQ_OR_RETURN(dataSurface->Stride(), aSurface->GetSize().width * 4, diff --git a/image/test/gtest/TestDecodeToSurface.cpp b/image/test/gtest/TestDecodeToSurface.cpp index f48cff6906..70fee36b76 100644 --- a/image/test/gtest/TestDecodeToSurface.cpp +++ b/image/test/gtest/TestDecodeToSurface.cpp @@ -14,7 +14,7 @@ #include "nsIInputStream.h" #include "nsIRunnable.h" #include "nsIThread.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsString.h" #include "nsThreadUtils.h" @@ -50,7 +50,7 @@ public: void Go() { - nsRefPtr surface = + RefPtr surface = ImageOps::DecodeToSurface(mInputStream, nsAutoCString(mTestCase.mMimeType), imgIContainer::DECODE_FLAGS_DEFAULT); @@ -112,7 +112,7 @@ TEST(ImageDecodeToSurface, Corrupt) nsCOMPtr inputStream = LoadFile(testCase.mPath); ASSERT_TRUE(inputStream != nullptr); - nsRefPtr surface = + RefPtr surface = ImageOps::DecodeToSurface(inputStream, nsAutoCString(testCase.mMimeType), imgIContainer::DECODE_FLAGS_DEFAULT); diff --git a/image/test/gtest/TestDecoders.cpp b/image/test/gtest/TestDecoders.cpp index d70738f548..e2cf677b18 100644 --- a/image/test/gtest/TestDecoders.cpp +++ b/image/test/gtest/TestDecoders.cpp @@ -17,7 +17,7 @@ #include "nsIInputStream.h" #include "nsIRunnable.h" #include "nsIThread.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsStreamUtils.h" #include "nsString.h" #include "nsThreadUtils.h" @@ -71,7 +71,7 @@ CheckDecoderResults(const ImageTestCase& aTestCase, Decoder* aDecoder) // Get the current frame, which is always the first frame of the image // because CreateAnonymousDecoder() forces a first-frame-only decode. RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef(); - nsRefPtr surface = currentFrame->GetSurface(); + RefPtr surface = currentFrame->GetSurface(); // Verify that the resulting surfaces matches our expectations. EXPECT_EQ(SurfaceType::DATA, surface->GetType()); @@ -94,7 +94,7 @@ CheckDecoderSingleChunk(const ImageTestCase& aTestCase) ASSERT_TRUE(NS_SUCCEEDED(rv)); // Write the data into a SourceBuffer. - nsRefPtr sourceBuffer = new SourceBuffer(); + RefPtr sourceBuffer = new SourceBuffer(); sourceBuffer->ExpectLength(length); rv = sourceBuffer->AppendFromInputStream(inputStream, length); ASSERT_TRUE(NS_SUCCEEDED(rv)); @@ -103,7 +103,7 @@ CheckDecoderSingleChunk(const ImageTestCase& aTestCase) // Create a decoder. DecoderType decoderType = DecoderFactory::GetDecoderType(aTestCase.mMimeType); - nsRefPtr decoder = + RefPtr decoder = DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, DefaultSurfaceFlags()); ASSERT_TRUE(decoder != nullptr); @@ -136,11 +136,11 @@ CheckDecoderMultiChunk(const ImageTestCase& aTestCase) ASSERT_TRUE(NS_SUCCEEDED(rv)); // Create a SourceBuffer and a decoder. - nsRefPtr sourceBuffer = new SourceBuffer(); + RefPtr sourceBuffer = new SourceBuffer(); sourceBuffer->ExpectLength(length); DecoderType decoderType = DecoderFactory::GetDecoderType(aTestCase.mMimeType); - nsRefPtr decoder = + RefPtr decoder = DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, DefaultSurfaceFlags()); ASSERT_TRUE(decoder != nullptr); @@ -148,7 +148,7 @@ CheckDecoderMultiChunk(const ImageTestCase& aTestCase) // Decode synchronously, using a |NoResume| IResumable so the Decoder doesn't // attempt to schedule itself on a nonexistent DecodePool when we write more // data into the SourceBuffer. - nsRefPtr noResume = new NoResume(); + RefPtr noResume = new NoResume(); for (uint64_t read = 0; read < length ; ++read) { uint64_t available = 0; rv = inputStream->Available(&available); diff --git a/image/test/gtest/TestMetadata.cpp b/image/test/gtest/TestMetadata.cpp index 5c79f60dc6..7f20d27950 100644 --- a/image/test/gtest/TestMetadata.cpp +++ b/image/test/gtest/TestMetadata.cpp @@ -17,7 +17,7 @@ #include "nsIInputStream.h" #include "nsIRunnable.h" #include "nsIThread.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsStreamUtils.h" #include "nsString.h" #include "nsThreadUtils.h" @@ -57,7 +57,7 @@ CheckMetadata(const ImageTestCase& aTestCase, ASSERT_TRUE(NS_SUCCEEDED(rv)); // Write the data into a SourceBuffer. - nsRefPtr sourceBuffer = new SourceBuffer(); + RefPtr sourceBuffer = new SourceBuffer(); sourceBuffer->ExpectLength(length); rv = sourceBuffer->AppendFromInputStream(inputStream, length); ASSERT_TRUE(NS_SUCCEEDED(rv)); @@ -66,7 +66,7 @@ CheckMetadata(const ImageTestCase& aTestCase, // Create a metadata decoder. DecoderType decoderType = DecoderFactory::GetDecoderType(aTestCase.mMimeType); - nsRefPtr decoder = + RefPtr decoder = DecoderFactory::CreateAnonymousMetadataDecoder(decoderType, sourceBuffer); ASSERT_TRUE(decoder != nullptr); @@ -193,7 +193,7 @@ TEST(ImageMetadata, NoFrameDelayGIFFullDecode) // animation at that point and successfully decode all the frames. // Create an image. - nsRefPtr image = + RefPtr image = ImageFactory::CreateAnonymousImage(nsAutoCString(testCase.mMimeType)); ASSERT_TRUE(!image->HasError()); @@ -214,11 +214,11 @@ TEST(ImageMetadata, NoFrameDelayGIFFullDecode) rv = image->OnImageDataComplete(nullptr, nullptr, NS_OK, true); ASSERT_TRUE(NS_SUCCEEDED(rv)); - nsRefPtr tracker = image->GetProgressTracker(); + RefPtr tracker = image->GetProgressTracker(); tracker->SyncNotifyProgress(FLAG_LOAD_COMPLETE); // Use GetFrame() to force a sync decode of the image. - nsRefPtr surface = + RefPtr surface = image->GetFrame(imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE); diff --git a/intl/hyphenation/nsHyphenationManager.cpp b/intl/hyphenation/nsHyphenationManager.cpp index 836a1d3842..3651750cd8 100644 --- a/intl/hyphenation/nsHyphenationManager.cpp +++ b/intl/hyphenation/nsHyphenationManager.cpp @@ -83,7 +83,7 @@ nsHyphenationManager::~nsHyphenationManager() already_AddRefed nsHyphenationManager::GetHyphenator(nsIAtom *aLocale) { - nsRefPtr hyph; + RefPtr hyph; mHyphenators.Get(aLocale, getter_AddRefs(hyph)); if (hyph) { return hyph.forget(); @@ -179,7 +179,7 @@ nsHyphenationManager::LoadPatternListFromOmnijar(Omnijar::Type aType) return; } - nsRefPtr zip = Omnijar::GetReader(aType); + RefPtr zip = Omnijar::GetReader(aType); if (!zip) { return; } diff --git a/intl/locale/nsLocaleService.cpp b/intl/locale/nsLocaleService.cpp index cb571e33ca..079e626894 100644 --- a/intl/locale/nsLocaleService.cpp +++ b/intl/locale/nsLocaleService.cpp @@ -119,7 +119,7 @@ nsLocaleService::nsLocaleService(void) NS_ENSURE_SUCCESS_VOID(rv); #endif #if defined(XP_UNIX) && !defined(XP_MACOSX) - nsRefPtr resultLocale(new nsLocale()); + RefPtr resultLocale(new nsLocale()); NS_ENSURE_TRUE_VOID(resultLocale); #ifdef MOZ_WIDGET_QT @@ -213,7 +213,7 @@ nsLocaleService::NewLocale(const nsAString &aLocale, nsILocale **_retval) *_retval = nullptr; - nsRefPtr resultLocale(new nsLocale()); + RefPtr resultLocale(new nsLocale()); if (!resultLocale) return NS_ERROR_OUT_OF_MEMORY; for (int32_t i = 0; i < LocaleListLength; i++) { diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp index d4774c29c3..8002beca55 100644 --- a/intl/strres/nsStringBundle.cpp +++ b/intl/strres/nsStringBundle.cpp @@ -593,7 +593,7 @@ nsStringBundleService::getStringBundle(const char *aURLSpec, } else { // hasn't been cached, so insert it into the hash table - nsRefPtr bundle = new nsStringBundle(aURLSpec, mOverrideStrings); + RefPtr bundle = new nsStringBundle(aURLSpec, mOverrideStrings); cacheEntry = insertIntoCache(bundle.forget(), key); } @@ -655,7 +655,7 @@ nsStringBundleService::CreateExtensibleBundle(const char* aCategory, NS_ENSURE_ARG_POINTER(aResult); *aResult = nullptr; - nsRefPtr bundle = new nsExtensibleStringBundle(); + RefPtr bundle = new nsExtensibleStringBundle(); nsresult res = bundle->Init(aCategory, this); if (NS_FAILED(res)) { diff --git a/ipc/chromium/src/base/message_loop.cc b/ipc/chromium/src/base/message_loop.cc index 3c9316155a..7f724120f2 100644 --- a/ipc/chromium/src/base/message_loop.cc +++ b/ipc/chromium/src/base/message_loop.cc @@ -321,7 +321,7 @@ void MessageLoop::PostTask_Helper( // directly, as it could starve handling of foreign threads. Put every task // into this queue. - nsRefPtr pump; + RefPtr pump; { AutoLock locked(incoming_queue_lock_); incoming_queue_.push(pending_task); diff --git a/ipc/chromium/src/base/message_loop.h b/ipc/chromium/src/base/message_loop.h index 5bb2b4f989..1ec889d3a9 100644 --- a/ipc/chromium/src/base/message_loop.h +++ b/ipc/chromium/src/base/message_loop.h @@ -415,7 +415,7 @@ public: // once we're out of nested message loops. TaskQueue deferred_non_nestable_work_queue_; - nsRefPtr pump_; + RefPtr pump_; base::ObserverList destruction_observers_; diff --git a/ipc/chromium/src/base/revocable_store.h b/ipc/chromium/src/base/revocable_store.h index eda0838685..17516c92ba 100644 --- a/ipc/chromium/src/base/revocable_store.h +++ b/ipc/chromium/src/base/revocable_store.h @@ -46,7 +46,7 @@ class RevocableStore { private: // We hold a reference to the store through this ref pointer. We release // this reference on destruction. - nsRefPtr store_reference_; + RefPtr store_reference_; DISALLOW_EVIL_CONSTRUCTORS(Revocable); }; @@ -68,7 +68,7 @@ class RevocableStore { void Add(Revocable* item); // This is the reference the unrevoked items in the store hold. - nsRefPtr owning_reference_; + RefPtr owning_reference_; // The number of unrevoked items in the store. int count_; diff --git a/ipc/chromium/src/base/waitable_event.h b/ipc/chromium/src/base/waitable_event.h index 87292662ce..27932fd19c 100644 --- a/ipc/chromium/src/base/waitable_event.h +++ b/ipc/chromium/src/base/waitable_event.h @@ -159,7 +159,7 @@ class WaitableEvent { ~WaitableEventKernel() {} }; - nsRefPtr kernel_; + RefPtr kernel_; bool SignalAll(); bool SignalOne(); diff --git a/ipc/chromium/src/base/waitable_event_watcher.h b/ipc/chromium/src/base/waitable_event_watcher.h index 5414bbfa2b..c295795b7c 100644 --- a/ipc/chromium/src/base/waitable_event_watcher.h +++ b/ipc/chromium/src/base/waitable_event_watcher.h @@ -142,10 +142,10 @@ class WaitableEventWatcher void WillDestroyCurrentMessageLoop(); MessageLoop* message_loop_; - nsRefPtr cancel_flag_; + RefPtr cancel_flag_; AsyncWaiter* waiter_; AsyncCallbackTask* callback_task_; - nsRefPtr kernel_; + RefPtr kernel_; #endif }; diff --git a/ipc/chromium/src/base/waitable_event_watcher_posix.cc b/ipc/chromium/src/base/waitable_event_watcher_posix.cc index 484c9b6091..74ada90c58 100644 --- a/ipc/chromium/src/base/waitable_event_watcher_posix.cc +++ b/ipc/chromium/src/base/waitable_event_watcher_posix.cc @@ -90,7 +90,7 @@ class AsyncWaiter final : public WaitableEvent::Waiter { private: MessageLoop *const message_loop_; Task *const cb_task_; - nsRefPtr flag_; + RefPtr flag_; }; // ----------------------------------------------------------------------------- @@ -120,7 +120,7 @@ class AsyncCallbackTask : public Task { } private: - nsRefPtr flag_; + RefPtr flag_; WaitableEventWatcher::Delegate *const delegate_; WaitableEvent *const event_; }; diff --git a/ipc/chromium/src/chrome/common/ipc_channel_posix.h b/ipc/chromium/src/chrome/common/ipc_channel_posix.h index 25ce390708..f769de10df 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_posix.h +++ b/ipc/chromium/src/chrome/common/ipc_channel_posix.h @@ -150,7 +150,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher { #if defined(OS_MACOSX) struct PendingDescriptors { uint32_t id; - nsRefPtr fds; + RefPtr fds; PendingDescriptors() : id(0) { } PendingDescriptors(uint32_t id, FileDescriptorSet *fds) diff --git a/ipc/chromium/src/chrome/common/ipc_channel_proxy.h b/ipc/chromium/src/chrome/common/ipc_channel_proxy.h index 06fdc9ebcd..bb312d9295 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_proxy.h +++ b/ipc/chromium/src/chrome/common/ipc_channel_proxy.h @@ -188,7 +188,7 @@ class ChannelProxy : public Message::Sender { Channel::Listener* listener_; // List of filters. This is only accessed on the IPC thread. - std::vector > filters_; + std::vector > filters_; MessageLoop* ipc_message_loop_; Channel* channel_; std::wstring channel_id_; @@ -205,7 +205,7 @@ class ChannelProxy : public Message::Sender { // By maintaining this indirection (ref-counted) to our internal state, we // can safely be destroyed while the background thread continues to do stuff // that involves this data. - nsRefPtr context_; + RefPtr context_; }; } // namespace IPC diff --git a/ipc/chromium/src/chrome/common/ipc_message.h b/ipc/chromium/src/chrome/common/ipc_message.h index b95a2d8861..bb75389422 100644 --- a/ipc/chromium/src/chrome/common/ipc_message.h +++ b/ipc/chromium/src/chrome/common/ipc_message.h @@ -332,7 +332,7 @@ class Message : public Pickle { #if defined(OS_POSIX) // The set of file descriptors associated with this message. - nsRefPtr file_descriptor_set_; + RefPtr file_descriptor_set_; // Ensure that a FileDescriptorSet is allocated void EnsureFileDescriptorSet(); diff --git a/ipc/chromium/src/chrome/common/ipc_sync_channel.cc b/ipc/chromium/src/chrome/common/ipc_sync_channel.cc index bb52b825f1..02920b3474 100644 --- a/ipc/chromium/src/chrome/common/ipc_sync_channel.cc +++ b/ipc/chromium/src/chrome/common/ipc_sync_channel.cc @@ -95,7 +95,7 @@ class SyncChannel::ReceivedSyncMsgQueue { void DispatchMessages() { while (true) { Message* message; - nsRefPtr context; + RefPtr context; { AutoLock auto_lock(message_lock_); if (message_queue_.empty()) @@ -164,7 +164,7 @@ class SyncChannel::ReceivedSyncMsgQueue { struct QueuedMessage { QueuedMessage(Message* m, SyncContext* c) : message(m), context(c) { } Message* message; - nsRefPtr context; + RefPtr context; }; typedef std::deque SyncMessageQueue; @@ -367,7 +367,7 @@ bool SyncChannel::SendWithTimeout(Message* message, int timeout_ms) { } // *this* might get deleted in WaitForReply. - nsRefPtr context(sync_context()); + RefPtr context(sync_context()); if (context->shutdown_event()->IsSignaled()) { delete message; return false; diff --git a/ipc/chromium/src/chrome/common/ipc_sync_channel.h b/ipc/chromium/src/chrome/common/ipc_sync_channel.h index f12aaeab9e..498375d465 100644 --- a/ipc/chromium/src/chrome/common/ipc_sync_channel.h +++ b/ipc/chromium/src/chrome/common/ipc_sync_channel.h @@ -124,7 +124,7 @@ class SyncChannel : public ChannelProxy, PendingSyncMessageQueue deserializers_; Lock deserializers_lock_; - nsRefPtr received_sync_msgs_; + RefPtr received_sync_msgs_; base::WaitableEvent* shutdown_event_; base::WaitableEventWatcher shutdown_watcher_; diff --git a/ipc/dbus/DBusUtils.cpp b/ipc/dbus/DBusUtils.cpp index 76b9b7cf76..ca226cd4c2 100644 --- a/ipc/dbus/DBusUtils.cpp +++ b/ipc/dbus/DBusUtils.cpp @@ -58,7 +58,7 @@ void DBusReplyHandler::Callback(DBusMessage* aReply, void* aData) { MOZ_ASSERT(aData); - nsRefPtr handler = + RefPtr handler = already_AddRefed(static_cast(aData)); handler->Handle(aReply); diff --git a/ipc/glue/BackgroundChildImpl.cpp b/ipc/glue/BackgroundChildImpl.cpp index fc2d5925b6..81f96c3844 100644 --- a/ipc/glue/BackgroundChildImpl.cpp +++ b/ipc/glue/BackgroundChildImpl.cpp @@ -211,7 +211,7 @@ BackgroundChildImpl::DeallocPFileDescriptorSetChild( BackgroundChildImpl::PVsyncChild* BackgroundChildImpl::AllocPVsyncChild() { - nsRefPtr actor = new mozilla::layout::VsyncChild(); + RefPtr actor = new mozilla::layout::VsyncChild(); // There still has one ref-count after return, and it will be released in // DeallocPVsyncChild(). return actor.forget().take(); @@ -223,7 +223,7 @@ BackgroundChildImpl::DeallocPVsyncChild(PVsyncChild* aActor) MOZ_ASSERT(aActor); // This actor already has one ref-count. Please check AllocPVsyncChild(). - nsRefPtr actor = + RefPtr actor = dont_AddRef(static_cast(aActor)); return true; } @@ -255,7 +255,7 @@ BackgroundChildImpl::AllocPBroadcastChannelChild(const PrincipalInfo& aPrincipal const nsString& aChannel, const bool& aPrivateBrowsing) { - nsRefPtr agent = + RefPtr agent = new dom::BroadcastChannelChild(aOrigin); return agent.forget().take(); } @@ -264,7 +264,7 @@ bool BackgroundChildImpl::DeallocPBroadcastChannelChild( PBroadcastChannelChild* aActor) { - nsRefPtr child = + RefPtr child = dont_AddRef(static_cast(aActor)); MOZ_ASSERT(child); return true; @@ -274,7 +274,7 @@ camera::PCamerasChild* BackgroundChildImpl::AllocPCamerasChild() { #ifdef MOZ_WEBRTC - nsRefPtr agent = + RefPtr agent = new camera::CamerasChild(); return agent.forget().take(); #else @@ -286,7 +286,7 @@ bool BackgroundChildImpl::DeallocPCamerasChild(camera::PCamerasChild *aActor) { #ifdef MOZ_WEBRTC - nsRefPtr child = + RefPtr child = dont_AddRef(static_cast(aActor)); MOZ_ASSERT(aActor); #endif @@ -300,7 +300,7 @@ BackgroundChildImpl::DeallocPCamerasChild(camera::PCamerasChild *aActor) dom::PServiceWorkerManagerChild* BackgroundChildImpl::AllocPServiceWorkerManagerChild() { - nsRefPtr agent = + RefPtr agent = new dom::workers::ServiceWorkerManagerChild(); return agent.forget().take(); } @@ -309,7 +309,7 @@ bool BackgroundChildImpl::DeallocPServiceWorkerManagerChild( PServiceWorkerManagerChild* aActor) { - nsRefPtr child = + RefPtr child = dont_AddRef(static_cast(aActor)); MOZ_ASSERT(child); return true; @@ -369,14 +369,14 @@ BackgroundChildImpl::AllocPMessagePortChild(const nsID& aUUID, const nsID& aDestinationUUID, const uint32_t& aSequenceID) { - nsRefPtr agent = new dom::MessagePortChild(); + RefPtr agent = new dom::MessagePortChild(); return agent.forget().take(); } bool BackgroundChildImpl::DeallocPMessagePortChild(PMessagePortChild* aActor) { - nsRefPtr child = + RefPtr child = dont_AddRef(static_cast(aActor)); MOZ_ASSERT(child); return true; diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 1817aad0d2..8bacd870c7 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -160,10 +160,10 @@ private: // This is only modified on the main thread. It is a FIFO queue for callbacks // waiting for the background thread to be created. - static StaticAutoPtr>> sPendingCallbacks; + static StaticAutoPtr>> sPendingCallbacks; // Only touched on the main thread, null if this is a same-process actor. - nsRefPtr mContent; + RefPtr mContent; // mTransport is "owned" by this object but it must only be released on the // IPC thread. It's left as a raw pointer here to prevent accidentally @@ -323,7 +323,7 @@ class ChildImpl final : public BackgroundChildImpl mCallbacks.AppendElement(aCallback); } - nsRefPtr mActor; + RefPtr mActor; nsTArray> mCallbacks; nsAutoPtr mConsumerThreadLocal; DebugOnly mClosed; @@ -551,7 +551,7 @@ private: class ParentImpl::CreateCallbackRunnable final : public nsRunnable { - nsRefPtr mCallback; + RefPtr mCallback; public: explicit CreateCallbackRunnable(CreateCallback* aCallback) @@ -573,7 +573,7 @@ private: class ParentImpl::ConnectActorRunnable final : public nsRunnable { - nsRefPtr mActor; + RefPtr mActor; Transport* mTransport; ProcessId mOtherPid; nsTArray* mLiveActorArray; @@ -727,7 +727,7 @@ protected: class ChildImpl::OpenChildProcessActorRunnable final : public nsRunnable { - nsRefPtr mActor; + RefPtr mActor; nsAutoPtr mTransport; ProcessId mOtherPid; @@ -759,8 +759,8 @@ private: class ChildImpl::OpenMainProcessActorRunnable final : public nsRunnable { - nsRefPtr mActor; - nsRefPtr mParentActor; + RefPtr mActor; + RefPtr mParentActor; MessageLoop* mParentMessageLoop; public: @@ -901,7 +901,7 @@ BackgroundChild::GetOrCreateActorForBlob(PBackgroundChild* aBackgroundActor, { MOZ_ASSERT(aBlob); - nsRefPtr blobImpl = static_cast(aBlob)->Impl(); + RefPtr blobImpl = static_cast(aBlob)->Impl(); MOZ_ASSERT(blobImpl); return GetOrCreateActorForBlobImpl(aBackgroundActor, blobImpl); @@ -965,7 +965,7 @@ bool ParentImpl::sShutdownObserverRegistered = false; bool ParentImpl::sShutdownHasStarted = false; -StaticAutoPtr>> +StaticAutoPtr>> ParentImpl::sPendingCallbacks; // ----------------------------------------------------------------------------- @@ -1060,7 +1060,7 @@ ParentImpl::Alloc(ContentParent* aContent, sLiveActorCount++; - nsRefPtr actor = new ParentImpl(aContent, aTransport); + RefPtr actor = new ParentImpl(aContent, aTransport); nsCOMPtr connectRunnable = new ConnectActorRunnable(actor, aTransport, aOtherPid, @@ -1104,7 +1104,7 @@ ParentImpl::CreateActorForSameProcess(CreateCallback* aCallback) } if (!sPendingCallbacks) { - sPendingCallbacks = new nsTArray>(); + sPendingCallbacks = new nsTArray>(); } sPendingCallbacks->AppendElement(aCallback); @@ -1190,11 +1190,11 @@ ParentImpl::ShutdownBackgroundThread() if (sPendingCallbacks) { if (!sPendingCallbacks->IsEmpty()) { - nsTArray> callbacks; + nsTArray> callbacks; sPendingCallbacks->SwapElements(callbacks); for (uint32_t index = 0; index < callbacks.Length(); index++) { - nsRefPtr callback; + RefPtr callback; callbacks[index].swap(callback); MOZ_ASSERT(callback); @@ -1426,7 +1426,7 @@ ParentImpl::RequestMessageLoopRunnable::Run() sBackgroundThreadMessageLoop = mMessageLoop; if (sPendingCallbacks && !sPendingCallbacks->IsEmpty()) { - nsTArray> callbacks; + nsTArray> callbacks; sPendingCallbacks->SwapElements(callbacks); for (uint32_t index = 0; index < callbacks.Length(); index++) { @@ -1531,10 +1531,10 @@ ParentImpl::CreateCallbackRunnable::Run() MOZ_ASSERT(sBackgroundThreadMessageLoop); MOZ_ASSERT(mCallback); - nsRefPtr callback; + RefPtr callback; mCallback.swap(callback); - nsRefPtr actor = new ParentImpl(); + RefPtr actor = new ParentImpl(); callback->Success(actor.forget(), sBackgroundThreadMessageLoop); @@ -1639,7 +1639,7 @@ ChildImpl::Alloc(Transport* aTransport, ProcessId aOtherPid) sPendingTargets->RemoveElementAt(0); - nsRefPtr actor = new ChildImpl(); + RefPtr actor = new ChildImpl(); ChildImpl* weakActor = actor; @@ -1723,7 +1723,7 @@ ChildImpl::GetOrCreateForCurrentThread( return true; } - nsRefPtr runnable = new CreateActorRunnable(); + RefPtr runnable = new CreateActorRunnable(); if (NS_FAILED(NS_DispatchToMainThread(runnable))) { CRASH_IN_CHILD_PROCESS("Failed to dispatch to main thread!"); return false; @@ -1875,7 +1875,7 @@ ChildImpl::OpenChildProcessActorRunnable::Run() "There should be at least one callback when first creating the " "actor!"); - nsRefPtr strongActor; + RefPtr strongActor; mActor.swap(strongActor); if (!strongActor->Open(mTransport.forget(), mOtherPid, @@ -1897,7 +1897,7 @@ ChildImpl::OpenChildProcessActorRunnable::Run() MOZ_ASSERT(threadLocalInfo); MOZ_ASSERT(!threadLocalInfo->mActor); - nsRefPtr& actor = threadLocalInfo->mActor; + RefPtr& actor = threadLocalInfo->mActor; strongActor.swap(actor); actor->SetBoundThread(); @@ -1929,10 +1929,10 @@ ChildImpl::OpenMainProcessActorRunnable::Run() "There should be at least one callback when first creating the " "actor!"); - nsRefPtr strongChildActor; + RefPtr strongChildActor; mActor.swap(strongChildActor); - nsRefPtr parentActor; + RefPtr parentActor; mParentActor.swap(parentActor); MessageChannel* parentChannel = parentActor->GetIPCChannel(); @@ -1963,7 +1963,7 @@ ChildImpl::OpenMainProcessActorRunnable::Run() MOZ_ASSERT(threadLocalInfo); MOZ_ASSERT(!threadLocalInfo->mActor); - nsRefPtr& childActor = threadLocalInfo->mActor; + RefPtr& childActor = threadLocalInfo->mActor; strongChildActor.swap(childActor); childActor->SetBoundThread(); @@ -1999,12 +1999,12 @@ ChildImpl::ParentCreateCallback::Success( AssertIsInMainProcess(); AssertIsOnMainThread(); - nsRefPtr parentActor = aParentActor; + RefPtr parentActor = aParentActor; MOZ_ASSERT(parentActor); MOZ_ASSERT(aParentMessageLoop); MOZ_ASSERT(mEventTarget); - nsRefPtr childActor = new ChildImpl(); + RefPtr childActor = new ChildImpl(); nsCOMPtr target; mEventTarget.swap(target); @@ -2043,7 +2043,7 @@ ChildImpl::OpenProtocolOnMainThread(nsIEventTarget* aEventTarget) } if (XRE_IsParentProcess()) { - nsRefPtr parentCallback = + RefPtr parentCallback = new ParentCreateCallback(aEventTarget); if (!ParentImpl::CreateActorForSameProcess(parentCallback)) { diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 80f5425b9c..77160ff935 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -30,7 +30,7 @@ #include "nsIAppsService.h" #include "nsNetUtil.h" #include "nsIScriptSecurityManager.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsThreadUtils.h" #include "nsTraceRefcnt.h" #include "nsXULAppAPI.h" @@ -266,7 +266,7 @@ BackgroundParentImpl::AllocPVsyncParent() AssertIsInMainProcess(); AssertIsOnBackgroundThread(); - nsRefPtr actor = + RefPtr actor = mozilla::layout::VsyncParent::Create(); // There still has one ref-count after return, and it will be released in // DeallocPVsyncParent(). @@ -281,7 +281,7 @@ BackgroundParentImpl::DeallocPVsyncParent(PVsyncParent* aActor) MOZ_ASSERT(aActor); // This actor already has one ref-count. Please check AllocPVsyncParent(). - nsRefPtr actor = + RefPtr actor = dont_AddRef(static_cast(aActor)); return true; } @@ -293,7 +293,7 @@ BackgroundParentImpl::AllocPCamerasParent() AssertIsOnBackgroundThread(); #ifdef MOZ_WEBRTC - nsRefPtr actor = + RefPtr actor = mozilla::camera::CamerasParent::Create(); return actor.forget().take(); #else @@ -309,7 +309,7 @@ BackgroundParentImpl::DeallocPCamerasParent(camera::PCamerasParent *aActor) MOZ_ASSERT(aActor); #ifdef MOZ_WEBRTC - nsRefPtr actor = + RefPtr actor = dont_AddRef(static_cast(aActor)); #endif return true; @@ -344,7 +344,7 @@ public: private: ~InitUDPSocketParentCallback() {}; - nsRefPtr mActor; + RefPtr mActor; nsCString mFilter; }; @@ -355,7 +355,7 @@ BackgroundParentImpl::AllocPUDPSocketParent(const OptionalPrincipalInfo& /* unus const nsCString& /* unused */) -> PUDPSocketParent* { - nsRefPtr p = new UDPSocketParent(this); + RefPtr p = new UDPSocketParent(this); return p.forget().take(); } @@ -440,7 +440,7 @@ public: struct MOZ_STACK_CLASS RunRAII { - explicit RunRAII(nsRefPtr& aContentParent) + explicit RunRAII(RefPtr& aContentParent) : mContentParent(aContentParent) {} @@ -449,7 +449,7 @@ public: mContentParent = nullptr; } - nsRefPtr& mContentParent; + RefPtr& mContentParent; }; RunRAII raii(mContentParent); @@ -480,7 +480,7 @@ public: } private: - nsRefPtr mContentParent; + RefPtr mContentParent; PrincipalInfo mPrincipalInfo; nsCString mOrigin; nsCOMPtr mBackgroundThread; @@ -499,7 +499,7 @@ BackgroundParentImpl::RecvPBroadcastChannelConstructor( AssertIsInMainProcess(); AssertIsOnBackgroundThread(); - nsRefPtr parent = BackgroundParent::GetContentParent(this); + RefPtr parent = BackgroundParent::GetContentParent(this); // If the ContentParent is null we are dealing with a same-process actor. if (!parent) { @@ -507,7 +507,7 @@ BackgroundParentImpl::RecvPBroadcastChannelConstructor( return true; } - nsRefPtr runnable = + RefPtr runnable = new CheckPrincipalRunnable(parent.forget(), aPrincipalInfo, aOrigin); nsresult rv = NS_DispatchToMainThread(runnable); MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv)); @@ -558,7 +558,7 @@ BackgroundParentImpl::RecvShutdownServiceWorkerRegistrar() return false; } - nsRefPtr service = + RefPtr service = dom::ServiceWorkerRegistrar::Get(); MOZ_ASSERT(service); diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index 434248d50c..9aa9f957ba 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -104,7 +104,7 @@ PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo, whitelist.AppendElement(wlPrincipal); } - nsRefPtr expandedPrincipal = new nsExpandedPrincipal(whitelist); + RefPtr expandedPrincipal = new nsExpandedPrincipal(whitelist); if (!expandedPrincipal) { NS_WARNING("could not instantiate expanded principal"); return nullptr; @@ -224,6 +224,12 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo, rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(), &triggeringPrincipalInfo); + nsTArray redirectChainIncludingInternalRedirects; + for (const nsCOMPtr& principal : aLoadInfo->RedirectChainIncludingInternalRedirects()) { + rv = PrincipalToPrincipalInfo(principal, redirectChainIncludingInternalRedirects.AppendElement()); + NS_ENSURE_SUCCESS(rv, rv); + } + nsTArray redirectChain; for (const nsCOMPtr& principal : aLoadInfo->RedirectChain()) { rv = PrincipalToPrincipalInfo(principal, redirectChain.AppendElement()); @@ -242,6 +248,8 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo, aLoadInfo->GetParentOuterWindowID(), aLoadInfo->GetEnforceSecurity(), aLoadInfo->GetInitialSecurityCheckDone(), + aLoadInfo->GetOriginAttributes(), + redirectChainIncludingInternalRedirects, redirectChain); return NS_OK; @@ -267,6 +275,14 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo(), &rv); NS_ENSURE_SUCCESS(rv, rv); + nsTArray> redirectChainIncludingInternalRedirects; + for (const PrincipalInfo& principalInfo : loadInfoArgs.redirectChainIncludingInternalRedirects()) { + nsCOMPtr redirectedPrincipal = + PrincipalInfoToPrincipal(principalInfo, &rv); + NS_ENSURE_SUCCESS(rv, rv); + redirectChainIncludingInternalRedirects.AppendElement(redirectedPrincipal.forget()); + } + nsTArray> redirectChain; for (const PrincipalInfo& principalInfo : loadInfoArgs.redirectChain()) { nsCOMPtr redirectedPrincipal = @@ -286,6 +302,8 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, loadInfoArgs.parentOuterWindowID(), loadInfoArgs.enforceSecurity(), loadInfoArgs.initialSecurityCheckDone(), + loadInfoArgs.originAttributes(), + redirectChainIncludingInternalRedirects, redirectChain); loadInfo.forget(outLoadInfo); diff --git a/ipc/glue/CrossProcessMutex.h b/ipc/glue/CrossProcessMutex.h index 9167df4bda..2d6bb2ad0d 100644 --- a/ipc/glue/CrossProcessMutex.h +++ b/ipc/glue/CrossProcessMutex.h @@ -101,7 +101,7 @@ private: #if defined(OS_WIN) HANDLE mMutex; #elif defined(OS_LINUX) || defined(OS_MACOSX) - nsRefPtr mSharedBuffer; + RefPtr mSharedBuffer; pthread_mutex_t* mMutex; mozilla::Atomic* mCount; #endif diff --git a/ipc/glue/InputStreamUtils.cpp b/ipc/glue/InputStreamUtils.cpp index 9e66cf723e..82ff92c264 100644 --- a/ipc/glue/InputStreamUtils.cpp +++ b/ipc/glue/InputStreamUtils.cpp @@ -112,7 +112,7 @@ DeserializeInputStream(const InputStreamParams& aParams, const nsID& id = aParams.get_RemoteInputStreamParams().id(); - nsRefPtr blobImpl = BlobParent::GetBlobImplForID(id); + RefPtr blobImpl = BlobParent::GetBlobImplForID(id); MOZ_ASSERT(blobImpl, "Invalid blob contents"); diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index a6708f8367..a8ffd1f183 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -481,13 +481,13 @@ class MessageChannel : HasResultCodes void Run() override { mTask->Run(); } private: - nsRefPtr mTask; + RefPtr mTask; }; private: mozilla::WeakPtr mListener; ChannelState mChannelState; - nsRefPtr mMonitor; + RefPtr mMonitor; Side mSide; MessageLink* mLink; MessageLoop* mWorkerLoop; // thread where work is done @@ -498,7 +498,7 @@ class MessageChannel : HasResultCodes int mWorkerLoopID; // A task encapsulating dequeuing one pending message. - nsRefPtr mDequeueOneTask; + RefPtr mDequeueOneTask; // Timeout periods are broken up in two to prevent system suspension from // triggering an abort. This method (called by WaitForEvent with a 'did @@ -740,7 +740,7 @@ class MessageChannel : HasResultCodes // Task and state used to asynchronously notify channel has been connected // safely. This is necessary to be able to cancel notification if we are // closed at the same time. - nsRefPtr mOnChannelConnectedTask; + RefPtr mOnChannelConnectedTask; DebugOnly mPeerPidSet; int32_t mPeerPid; }; diff --git a/ipc/glue/MessagePump.h b/ipc/glue/MessagePump.h index 02d296e375..3ba2eae9bb 100644 --- a/ipc/glue/MessagePump.h +++ b/ipc/glue/MessagePump.h @@ -63,7 +63,7 @@ protected: private: // Only accessed by this class. - nsRefPtr mDoWorkEvent; + RefPtr mDoWorkEvent; }; class MessagePumpForChildProcess final: public MessagePump diff --git a/ipc/glue/Shmem.cpp b/ipc/glue/Shmem.cpp index b3dbb073a1..97dc099ecb 100644 --- a/ipc/glue/Shmem.cpp +++ b/ipc/glue/Shmem.cpp @@ -113,7 +113,7 @@ public: static already_AddRefed CreateSegment(size_t aNBytes, SharedMemorySysV::Handle aHandle) { - nsRefPtr segment; + RefPtr segment; if (SharedMemorySysV::IsHandleValid(aHandle)) { segment = new SharedMemorySysV(aHandle); @@ -134,7 +134,7 @@ CreateSegment(size_t aNBytes, SharedMemorySysV::Handle aHandle) static already_AddRefed CreateSegment(size_t aNBytes, SharedMemoryBasic::Handle aHandle) { - nsRefPtr segment; + RefPtr segment; if (SharedMemoryBasic::IsHandleValid(aHandle)) { segment = new SharedMemoryBasic(aHandle); @@ -357,7 +357,7 @@ Shmem::Alloc(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead, MOZ_ASSERT(!aProtect || !aUnsafe, "protect => !unsafe"); size_t pageSize = SharedMemory::SystemPageSize(); - nsRefPtr segment; + RefPtr segment; // |2*pageSize| is for the front and back sentinel size_t segmentSize = SharedMemory::PageAlignedSize(aNBytes + 2*pageSize); @@ -416,7 +416,7 @@ Shmem::OpenExisting(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead, if (!ShmemCreated::ReadInfo(&aDescriptor, &iter, aId, &size, &type)) return nullptr; - nsRefPtr segment; + RefPtr segment; size_t pageSize = SharedMemory::SystemPageSize(); // |2*pageSize| is for the front and back sentinels size_t segmentSize = SharedMemory::PageAlignedSize(size + 2*pageSize); @@ -502,7 +502,7 @@ Shmem::Alloc(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead, bool /*unused*/, bool /*unused*/) { - nsRefPtr segment; + RefPtr segment; if (aType == SharedMemory::TYPE_BASIC) segment = CreateSegment(SharedMemory::PageAlignedSize(aNBytes + sizeof(uint32_t)), @@ -541,7 +541,7 @@ Shmem::OpenExisting(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead, if (!ShmemCreated::ReadInfo(&aDescriptor, &iter, aId, &size, &type)) return nullptr; - nsRefPtr segment; + RefPtr segment; size_t segmentSize = SharedMemory::PageAlignedSize(size + sizeof(uint32_t)); if (SharedMemory::TYPE_BASIC == type) { diff --git a/ipc/hal/DaemonRunnables.h b/ipc/hal/DaemonRunnables.h index 855b8bf484..70d651ad1a 100644 --- a/ipc/hal/DaemonRunnables.h +++ b/ipc/hal/DaemonRunnables.h @@ -39,7 +39,7 @@ public: static already_AddRefed Create(Obj* aObj, Res (Obj::*aMethod)(), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aObj, aMethod)); + RefPtr runnable(new SelfType(aObj, aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -53,7 +53,7 @@ public: if (!aObj) { return; // silently return if no result runnable has been given } - nsRefPtr runnable = Create(aObj, aMethod, aInitOp); + RefPtr runnable = Create(aObj, aMethod, aInitOp); if (!runnable) { return; } @@ -81,7 +81,7 @@ private: return aInitOp(); } - nsRefPtr mObj; + RefPtr mObj; void (Obj::*mMethod)(); }; @@ -95,7 +95,7 @@ public: static already_AddRefed Create(Obj* aObj, Res (Obj::*aMethod)(Arg1), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aObj, aMethod)); + RefPtr runnable(new SelfType(aObj, aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -109,7 +109,7 @@ public: if (!aObj) { return; // silently return if no result runnable has been given } - nsRefPtr runnable = Create(aObj, aMethod, aInitOp); + RefPtr runnable = Create(aObj, aMethod, aInitOp); if (!runnable) { return; } @@ -137,7 +137,7 @@ private: return aInitOp(mArg1); } - nsRefPtr mObj; + RefPtr mObj; Res (Obj::*mMethod)(Arg1); Tin1 mArg1; }; @@ -157,7 +157,7 @@ public: Create(Obj* aObj, Res (Obj::*aMethod)(Arg1, Arg2, Arg3), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aObj, aMethod)); + RefPtr runnable(new SelfType(aObj, aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -172,7 +172,7 @@ public: if (!aObj) { return; // silently return if no result runnable has been given } - nsRefPtr runnable = Create(aObj, aMethod, aInitOp); + RefPtr runnable = Create(aObj, aMethod, aInitOp); if (!runnable) { return; } @@ -201,7 +201,7 @@ private: return aInitOp(mArg1, mArg2, mArg3); } - nsRefPtr mObj; + RefPtr mObj; Res (Obj::*mMethod)(Arg1, Arg2, Arg3); Tin1 mArg1; Tin2 mArg2; @@ -236,7 +236,7 @@ public: static already_AddRefed Create(Res (ObjectType::*aMethod)(), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -247,7 +247,7 @@ public: static void Dispatch(Res (ObjectType::*aMethod)(), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -296,7 +296,7 @@ public: static already_AddRefed Create(Res (ObjectType::*aMethod)(Arg1), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -307,7 +307,7 @@ public: static void Dispatch(Res (ObjectType::*aMethod)(Arg1), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -363,7 +363,7 @@ public: static already_AddRefed Create(Res (ObjectType::*aMethod)(Arg1, Arg2), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -374,7 +374,7 @@ public: static void Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -432,7 +432,7 @@ public: static already_AddRefed Create(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -444,7 +444,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -504,7 +504,7 @@ public: Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -516,7 +516,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -578,7 +578,7 @@ public: Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -590,7 +590,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -654,7 +654,7 @@ public: Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -666,7 +666,7 @@ public: Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } @@ -734,7 +734,7 @@ public: Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9), const InitOp& aInitOp) { - nsRefPtr runnable(new SelfType(aMethod)); + RefPtr runnable(new SelfType(aMethod)); if (NS_FAILED(runnable->Init(aInitOp))) { return nullptr; } @@ -748,7 +748,7 @@ public: Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9), const InitOp& aInitOp) { - nsRefPtr runnable = Create(aMethod, aInitOp); + RefPtr runnable = Create(aMethod, aInitOp); if (!runnable) { return; } diff --git a/ipc/hal/DaemonSocketPDU.h b/ipc/hal/DaemonSocketPDU.h index 03419fa988..2f0c9b152c 100644 --- a/ipc/hal/DaemonSocketPDU.h +++ b/ipc/hal/DaemonSocketPDU.h @@ -81,7 +81,7 @@ private: void OnError(const char* aFunction, int aErrno); DaemonSocketIOConsumer* mConsumer; - nsRefPtr mRes; + RefPtr mRes; ScopedClose mReceivedFd; }; diff --git a/ipc/ipdl/ipdl/builtin.py b/ipc/ipdl/ipdl/builtin.py index b141df9fb5..b505d27688 100644 --- a/ipc/ipdl/ipdl/builtin.py +++ b/ipc/ipdl/ipdl/builtin.py @@ -46,7 +46,7 @@ HeaderIncludes = ( 'prtime.h', 'IPCMessageStart.h', 'ipc/IPCMessageUtils.h', - 'mozilla/nsRefPtr.h', + 'mozilla/RefPtr.h', 'nsStringGlue.h', 'nsTArray.h', 'mozilla/ipc/ProtocolUtils.h', diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index b7fb045247..0495fe44f8 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -321,7 +321,7 @@ def _runtimeAbort(msg): ExprCall(ExprVar('NS_RUNTIMEABORT'), args=[ msg ])) def _refptr(T): - return Type('nsRefPtr', T=T) + return Type('RefPtr', T=T) def _refptrGet(expr): return ExprCall(ExprSelect(expr, '.', 'get')) @@ -3667,7 +3667,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): [ idvar ]))) # SharedMemory* CreateSharedMemory(size_t aSize, Type aType, bool aUnsafe, id_t* aId): - # nsRefPtr segment(Shmem::Alloc(aSize, aType, aUnsafe)); + # RefPtr segment(Shmem::Alloc(aSize, aType, aUnsafe)); # if (!segment) # return nullptr; # Shmem shmem(segment.get(), [nextshmemid]); diff --git a/ipc/keystore/KeyStore.h b/ipc/keystore/KeyStore.h index 5c3c94623b..d0df690afb 100644 --- a/ipc/keystore/KeyStore.h +++ b/ipc/keystore/KeyStore.h @@ -131,8 +131,8 @@ private: bool mShutdown; - nsRefPtr mListenSocket; - nsRefPtr mStreamSocket; + RefPtr mListenSocket; + RefPtr mStreamSocket; }; } // namespace ipc diff --git a/ipc/netd/Netd.cpp b/ipc/netd/Netd.cpp index 8eeb7307bd..8ae279767b 100644 --- a/ipc/netd/Netd.cpp +++ b/ipc/netd/Netd.cpp @@ -26,8 +26,8 @@ namespace { -mozilla::RefPtr gNetdClient; -mozilla::RefPtr gNetdConsumer; +RefPtr gNetdClient; +RefPtr gNetdConsumer; class StopNetdConsumer : public nsRunnable { public: diff --git a/ipc/ril/Ril.cpp b/ipc/ril/Ril.cpp index a0bb99e880..9f5d6aa67c 100644 --- a/ipc/ril/Ril.cpp +++ b/ipc/ril/Ril.cpp @@ -122,7 +122,7 @@ PostToRIL(JSContext* aCx, unsigned aArgc, JS::Value* aVp) return false; } - nsRefPtr task = new SendRilSocketDataTask(clientId, + RefPtr task = new SendRilSocketDataTask(clientId, raw); NS_DispatchToMainThread(task); return true; @@ -231,7 +231,7 @@ RilConsumer::Register(unsigned int aClientId, return NS_ERROR_FAILURE; } - nsRefPtr connection = new ConnectWorkerToRIL(); + RefPtr connection = new ConnectWorkerToRIL(); if (!aDispatcher->PostTask(connection)) { NS_WARNING("Failed to connect worker to ril"); return NS_ERROR_UNEXPECTED; @@ -285,7 +285,7 @@ RilConsumer::ReceiveSocketData(int aIndex, { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr dre(new DispatchRILEvent(aIndex, aBuffer.forget())); + RefPtr dre(new DispatchRILEvent(aIndex, aBuffer.forget())); mDispatcher->PostTask(dre); } diff --git a/ipc/ril/Ril.h b/ipc/ril/Ril.h index 5d0ae62eff..8eaeafcefb 100644 --- a/ipc/ril/Ril.h +++ b/ipc/ril/Ril.h @@ -39,8 +39,8 @@ private: void OnConnectError(int aIndex) override; void OnDisconnect(int aIndex) override; - nsRefPtr mSocket; - nsRefPtr mDispatcher; + RefPtr mSocket; + RefPtr mDispatcher; nsCString mAddress; bool mShutdown; }; diff --git a/ipc/ril/RilSocket.cpp b/ipc/ril/RilSocket.cpp index 017a0905e8..6056a97236 100644 --- a/ipc/ril/RilSocket.cpp +++ b/ipc/ril/RilSocket.cpp @@ -70,7 +70,7 @@ private: /** * Cross-thread dispatcher for the RIL worker */ - nsRefPtr mDispatcher; + RefPtr mDispatcher; /** * Consumer pointer. Non-thread safe RefPtr, so should only be manipulated @@ -218,7 +218,7 @@ private: void RilSocketIO::ConsumeBuffer() { - nsRefPtr task = new ReceiveTask(this, mBuffer.forget()); + RefPtr task = new ReceiveTask(this, mBuffer.forget()); NS_WARN_IF(!mDispatcher->PostTask(task)); } diff --git a/ipc/ril/RilSocket.h b/ipc/ril/RilSocket.h index e1ca8f75cd..9a1f4d7f95 100644 --- a/ipc/ril/RilSocket.h +++ b/ipc/ril/RilSocket.h @@ -99,7 +99,7 @@ protected: private: RilSocketIO* mIO; - nsRefPtr mDispatcher; + RefPtr mDispatcher; RilSocketConsumer* mConsumer; int mIndex; }; diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index 1580c4197d..221bb3fb06 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -506,7 +506,7 @@ XPCShellEnvironment::Init() fprintf(stderr, "+++ Failed to get ScriptSecurityManager service, running without principals"); } - nsRefPtr backstagePass; + RefPtr backstagePass; rv = NS_NewBackstagePass(getter_AddRefs(backstagePass)); if (NS_FAILED(rv)) { NS_ERROR("Failed to create backstage pass!"); diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index d584e98aea..d007c20c66 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -243,7 +243,7 @@ class JS_FRIEND_API(BaseStackFrame) { // Get a unique identifier for this StackFrame. The identifier is not valid // across garbage collections. - virtual uint64_t identifier() const { return reinterpret_cast(ptr); } + virtual uint64_t identifier() const { return uint64_t(uintptr_t(ptr)); } // Get this frame's parent frame. virtual StackFrame parent() const = 0; @@ -418,7 +418,11 @@ class JS_FRIEND_API(StackFrame) : public JS::Traceable { // Methods that forward to virtual calls through BaseStackFrame. void trace(JSTracer* trc) { base()->trace(trc); } - uint64_t identifier() const { return base()->identifier(); } + uint64_t identifier() const { + auto id = base()->identifier(); + MOZ_ASSERT(JS::Value::isNumberRepresentable(id)); + return id; + } uint32_t line() const { return base()->line(); } uint32_t column() const { return base()->column(); } AtomOrTwoByteChars source() const { return base()->source(); } @@ -564,7 +568,7 @@ class JS_FRIEND_API(Base) { // caveats about multiple objects allocated at the same address for // 'ubi::Node::operator=='.) using Id = uint64_t; - virtual Id identifier() const { return reinterpret_cast(ptr); } + virtual Id identifier() const { return Id(uintptr_t(ptr)); } // Returns true if this node is pointing to something on the live heap, as // opposed to something from a deserialized core dump. Returns false, @@ -635,6 +639,12 @@ class JS_FRIEND_API(Base) { return true; } + // Methods for CoarseType::Script referents + + // Return the script's source's filename if available. If unavailable, + // return nullptr. + virtual const char* scriptFilename() const { return nullptr; } + private: Base(const Base& rhs) = delete; Base& operator=(const Base& rhs) = delete; @@ -775,6 +785,8 @@ class JS_FRIEND_API(Node) { return base()->jsObjectConstructorName(cx, outName); } + const char* scriptFilename() const { return base()->scriptFilename(); } + using Size = Base::Size; Size size(mozilla::MallocSizeOf mallocSizeof) const { return base()->size(mallocSizeof); @@ -790,7 +802,11 @@ class JS_FRIEND_API(Node) { } using Id = Base::Id; - Id identifier() const { return base()->identifier(); } + Id identifier() const { + auto id = base()->identifier(); + MOZ_ASSERT(JS::Value::isNumberRepresentable(id)); + return id; + } // A hash policy for ubi::Nodes. // This simply uses the stock PointerHasher on the ubi::Node's pointer. @@ -1044,6 +1060,7 @@ struct Concrete : TracerConcrete { template<> struct Concrete : TracerConcreteWithCompartment { CoarseType coarseType() const final { return CoarseType::Script; } Size size(mozilla::MallocSizeOf mallocSizeOf) const override; + const char* scriptFilename() const final; protected: explicit Concrete(JSScript *ptr) : TracerConcreteWithCompartment(ptr) { } diff --git a/js/public/Value.h b/js/public/Value.h index 0bbaf3d11c..4fc2afb85c 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -1010,6 +1010,15 @@ class Value Value(const Value& v) = default; #endif + /** + * Returns false if creating a NumberValue containing the given type would + * be lossy, true otherwise. + */ + template + static bool isNumberRepresentable(const T t) { + return T(double(t)) == t; + } + /*** Mutators ***/ void setNull() { @@ -1611,7 +1620,7 @@ template static inline Value NumberValue(const T t) { - MOZ_ASSERT(T(double(t)) == t, "value creation would be lossy"); + MOZ_ASSERT(Value::isNumberRepresentable(t), "value creation would be lossy"); return detail::MakeNumberValue::is_signed>::create(t); } diff --git a/js/src/doc/Debugger/Debugger.Source.md b/js/src/doc/Debugger/Debugger.Source.md index 7b89c2edc5..d9946a543c 100644 --- a/js/src/doc/Debugger/Debugger.Source.md +++ b/js/src/doc/Debugger/Debugger.Source.md @@ -40,6 +40,17 @@ to store metadata about particular pieces of source code. A `Debugger.Source` instance inherits the following accessor properties from its prototype: +`canonicalId` +: A stable, unique identifier for the source referent. This identifier is + suitable for checking if two `Debugger.Source` instances originating from + different `Debugger` instances refer to the same source that was compiled by + SpiderMonkey. The `canonicalId` is reliable even when the source does not + have a URL, or shares the same URL as another source but has different + source text. It is more efficient to compare `canonicalId`s than to compare + source text character-by-character. The `canonicalId` is not suitable for + ordering comparisons such as "greater than" or "less than". It is not + suitable for checking the equality of sources across worker threads. + `text` : The JavaScript source code, as a string. The value satisfies the `Program`, `FunctionDeclaration`, or `FunctionExpression` productions in diff --git a/js/src/jit-test/tests/debug/Source-canonicalId.js b/js/src/jit-test/tests/debug/Source-canonicalId.js new file mode 100644 index 0000000000..2d9b46bf96 --- /dev/null +++ b/js/src/jit-test/tests/debug/Source-canonicalId.js @@ -0,0 +1,32 @@ +// Test Debugger.Source.prototype.canonicalId + +const g = newGlobal(); + +const dbg1 = new Debugger; +const dbg2 = new Debugger; + +const gw1 = dbg1.addDebuggee(g); +const gw2 = dbg2.addDebuggee(g); + +g.eval("function f(x) { return 2*x; }"); +g.eval("function g(x) { return 2+x; }"); + +const fw1 = gw1.getOwnPropertyDescriptor('f').value; +const fw2 = gw2.getOwnPropertyDescriptor('f').value; +const hw1 = gw1.getOwnPropertyDescriptor('g').value; +const hw2 = gw2.getOwnPropertyDescriptor('g').value; + +const fs1 = fw1.script.source; +const fs2 = fw2.script.source; +const gs1 = hw1.script.source; +const gs2 = hw2.script.source; + +assertEq(!!fs1, true); +assertEq(!!fs2, true); +assertEq(fs1.canonicalId, fs2.canonicalId); + +assertEq(!!gs1, true); +assertEq(!!gs2, true); +assertEq(gs1.canonicalId, gs2.canonicalId); + +assertEq(fs1.canonicalId !== gs1.canonicalId, true); diff --git a/js/src/jit/IonCode.h b/js/src/jit/IonCode.h index f182332a3c..2995c883bb 100644 --- a/js/src/jit/IonCode.h +++ b/js/src/jit/IonCode.h @@ -782,6 +782,7 @@ namespace ubi { template<> struct Concrete : TracerConcrete { CoarseType coarseType() const final { return CoarseType::Script; } + Size size(mozilla::MallocSizeOf mallocSizeOf) const override { Size size = js::gc::Arena::thingSize(get().asTenured().getAllocKind()); size += get().bufferSize(); diff --git a/js/src/jsapi-tests/testUbiNode.cpp b/js/src/jsapi-tests/testUbiNode.cpp index 9457fcc9cb..586bd94a67 100644 --- a/js/src/jsapi-tests/testUbiNode.cpp +++ b/js/src/jsapi-tests/testUbiNode.cpp @@ -346,3 +346,37 @@ BEGIN_TEST(test_ubiPostOrder) return true; } END_TEST(test_ubiPostOrder) + +BEGIN_TEST(test_JS_ubi_Node_scriptFilename) +{ + JS::RootedValue val(cx); + CHECK(evaluate("(function one() { \n" // 1 + " return (function two() { \n" // 2 + " return (function three() { \n" // 3 + " return function four() {}; \n" // 4 + " }()); \n" // 5 + " }()); \n" // 6 + "}()); \n", // 7 + "my-cool-filename.js", + 1, + &val)); + + CHECK(val.isObject()); + JS::RootedObject obj(cx, &val.toObject()); + + CHECK(obj->is()); + JS::RootedFunction func(cx, &obj->as()); + + JS::RootedScript script(cx, func->getOrCreateScript(cx)); + CHECK(script); + CHECK(script->filename()); + + JS::ubi::Node node(script); + const char* filename = node.scriptFilename(); + CHECK(filename); + CHECK(strcmp(filename, script->filename()) == 0); + CHECK(strcmp(filename, "my-cool-filename.js") == 0); + + return true; +} +END_TEST(test_JS_ubi_Node_scriptFilename) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 84bf9d79bd..591c861c0a 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -332,7 +332,7 @@ IterPerformanceStats(JSContext* cx, continue; } js::AutoCompartment autoCompartment(cx, compartment); - mozilla::RefPtr group = compartment->performanceMonitoring.getSharedGroup(cx); + RefPtr group = compartment->performanceMonitoring.getSharedGroup(cx); if (group->data.ticks == 0) { // Don't report compartments that have never been used. continue; @@ -369,12 +369,12 @@ IterPerformanceStats(JSContext* cx, continue; } js::AutoCompartment autoCompartment(cx, compartment); - mozilla::RefPtr ownGroup = compartment->performanceMonitoring.getOwnGroup(); + RefPtr ownGroup = compartment->performanceMonitoring.getOwnGroup(); if (ownGroup->data.ticks == 0) { // Don't report compartments that have never been used. continue; } - mozilla::RefPtr sharedGroup = compartment->performanceMonitoring.getSharedGroup(cx); + RefPtr sharedGroup = compartment->performanceMonitoring.getSharedGroup(cx); if (!(*walker)(cx, ownGroup->data, ownGroup->uid, &sharedGroup->uid, closure)) { @@ -666,11 +666,9 @@ JS_NewRuntime(uint32_t maxbytes, uint32_t maxNurseryBytes, JSRuntime* parentRunt MOZ_ASSERT(jsInitState == Running, "must call JS_Init prior to creating any JSRuntimes"); - // Any parent runtime should be the topmost parent. This assert - // isn't required for correctness, but ensuring that the parent - // runtime is not destroyed before this one is more easily done - // for the main runtime in the process. - MOZ_ASSERT_IF(parentRuntime, !parentRuntime->parentRuntime); + // Make sure that all parent runtimes are the topmost parent. + while (parentRuntime && parentRuntime->parentRuntime) + parentRuntime = parentRuntime->parentRuntime; JSRuntime* rt = js_new(parentRuntime); if (!rt) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 334f3d7855..fa41b45f54 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -5579,7 +5579,7 @@ struct PerformanceGroup { recentCPOW = 0; } - // Refcounting. For use with mozilla::RefPtr. + // Refcounting. For use with RefPtr. void AddRef(); void Release(); @@ -5663,8 +5663,8 @@ struct PerformanceGroupHolder { // The PerformanceGroups held by this object. // Initially set to `nullptr` until the first call to `getGroup`. // May be reset to `nullptr` by a call to `unlink`. - mozilla::RefPtr sharedGroup_; - mozilla::RefPtr ownGroup_; + RefPtr sharedGroup_; + RefPtr ownGroup_; }; /** diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index e6f8143d8d..281c241ec8 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -4414,3 +4414,31 @@ JS::ubi::Concrete::size(mozilla::MallocSizeOf mallocSizeOf) const MOZ_ASSERT(size > 0); return size; } + +const char* +JS::ubi::Concrete::scriptFilename() const +{ + return get().filename(); +} + +JS::ubi::Node::Size +JS::ubi::Concrete::size(mozilla::MallocSizeOf mallocSizeOf) const +{ + Size size = js::gc::Arena::thingSize(get().asTenured().getAllocKind()); + size += get().sizeOfExcludingThis(mallocSizeOf); + return size; +} + +const char* +JS::ubi::Concrete::scriptFilename() const +{ + auto sourceObject = get().sourceObject(); + if (!sourceObject) + return nullptr; + + auto source = sourceObject->source(); + if (!source) + return nullptr; + + return source->filename(); +} diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 461fe29e5c..0511e89ce8 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -2497,6 +2497,8 @@ namespace ubi { template<> struct Concrete : TracerConcrete { CoarseType coarseType() const final { return CoarseType::Script; } + Size size(mozilla::MallocSizeOf mallocSizeOf) const override; + const char* scriptFilename() const final; protected: explicit Concrete(js::LazyScript *ptr) : TracerConcrete(ptr) { } diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 2c13062843..8512004b44 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -8,6 +8,7 @@ #include "mozilla/DebugOnly.h" #include "mozilla/ScopeExit.h" +#include "mozilla/TypeTraits.h" #include "jscntxt.h" #include "jscompartment.h" @@ -5946,6 +5947,31 @@ DebuggerSource_getSourceMapUrl(JSContext* cx, unsigned argc, Value* vp) return true; } +static bool +DebuggerSource_getCanonicalId(JSContext* cx, unsigned argc, Value* vp) +{ + THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get sourceMapURL)", args, obj, sourceObject); + + ScriptSource* ss = sourceObject->source(); + MOZ_ASSERT(ss); + + static_assert(!mozilla::IsBaseOf::value, + "We rely on ScriptSource* pointers to be stable, and not move in memory. " + "Currently, this holds true because ScriptSource is not managed by the GC. If " + "that changes, it doesn't necessarily mean that it will start moving, but we " + "will need a new assertion here. If we do start moving ScriptSources in memory, " + "then DebuggerSource_getCanonicalId will need to be reworked!"); + auto id = uintptr_t(ss); + + // IEEE 754 doubles can precisely store integers of up 53 bits. On 32 bit + // platforms, pointers trivially fit. On 64 bit platforms, pointers only use + // 48 bits so we are still good. + MOZ_ASSERT(Value::isNumberRepresentable(id)); + + args.rval().set(NumberValue(id)); + return true; +} + static const JSPropertySpec DebuggerSource_properties[] = { JS_PSG("text", DebuggerSource_getText, 0), JS_PSG("url", DebuggerSource_getUrl, 0), @@ -5956,6 +5982,7 @@ static const JSPropertySpec DebuggerSource_properties[] = { JS_PSG("introductionType", DebuggerSource_getIntroductionType, 0), JS_PSG("elementAttributeName", DebuggerSource_getElementProperty, 0), JS_PSGS("sourceMapURL", DebuggerSource_getSourceMapUrl, DebuggerSource_setSourceMapUrl, 0), + JS_PSG("canonicalId", DebuggerSource_getCanonicalId, 0), JS_PS_END }; diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 3bf6fbd067..bf4102a2c6 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -417,16 +417,16 @@ class MOZ_RAII AutoStopwatch final // The performance group shared by this compartment and possibly // others, or `nullptr` if another AutoStopwatch is already in // charge of monitoring that group. - mozilla::RefPtr sharedGroup_; + RefPtr sharedGroup_; // The toplevel group, representing the entire process, or `nullptr` // if another AutoStopwatch is already in charge of monitoring that group. - mozilla::RefPtr topGroup_; + RefPtr topGroup_; // The performance group specific to this compartment, or // `nullptr` if another AutoStopwatch is already in charge of // monitoring that group. - mozilla::RefPtr ownGroup_; + RefPtr ownGroup_; public: // If the stopwatch is active, constructing an instance of diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 517ac56954..4f77eec947 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -1018,16 +1018,16 @@ JSRuntime::Stopwatch::commit() if (systemTimeStop > systemTimeStart_) systemTimeDelta = systemTimeStop - systemTimeStart_; - mozilla::RefPtr group = performance.getOwnGroup(); + RefPtr group = performance.getOwnGroup(); const uint64_t totalRecentCycles = group->recentCycles; - mozilla::Vector> recentGroups; + mozilla::Vector> recentGroups; touchedGroups.swap(recentGroups); MOZ_ASSERT(recentGroups.length() > 0); // We should only reach this stage if `group` has had some activity. MOZ_ASSERT(group->recentTicks > 0); - for (mozilla::RefPtr* iter = recentGroups.begin(); iter != recentGroups.end(); ++iter) { + for (RefPtr* iter = recentGroups.begin(); iter != recentGroups.end(); ++iter) { transferDeltas(userTimeDelta, systemTimeDelta, totalRecentCycles, *iter); } diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 07ea46f570..433344b5a3 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -1787,7 +1787,7 @@ struct JSRuntime : public JS::shadow::Runtime, * * They are cleared by `commit()` and `reset()`. */ - mozilla::Vector> touchedGroups; + mozilla::Vector> touchedGroups; }; Stopwatch stopwatch; }; diff --git a/js/xpconnect/idl/nsIXPCScriptable.idl b/js/xpconnect/idl/nsIXPCScriptable.idl index 9362bcfbe8..967569630d 100644 --- a/js/xpconnect/idl/nsIXPCScriptable.idl +++ b/js/xpconnect/idl/nsIXPCScriptable.idl @@ -147,7 +147,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCClassInfo, NS_XPCCLASSINFO_IID) inline nsresult CallQueryInterface(nsISupports* aSourcePtr, - nsRefPtrGetterAddRefs aDestPtr) + RefPtrGetterAddRefs aDestPtr) { return CallQueryInterface(aSourcePtr, static_cast(aDestPtr)); diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 90d043c86e..747b89749f 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -536,7 +536,7 @@ mozJSComponentLoader::PrepareObjectForLocation(JSContext* aCx, bool createdNewGlobal = false; if (!mLoaderGlobal) { - nsRefPtr backstagePass; + RefPtr backstagePass; rv = NS_NewBackstagePass(getter_AddRefs(backstagePass)); NS_ENSURE_SUCCESS(rv, nullptr); diff --git a/js/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/xpconnect/loader/mozJSSubScriptLoader.cpp index 164da062d3..5c8ab3280b 100644 --- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp +++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp @@ -266,9 +266,9 @@ private: mozilla::DropJSObjects(this); } - nsRefPtr mChannel; + RefPtr mChannel; Heap mTargetObj; - nsRefPtr mPromise; + RefPtr mPromise; nsString mCharset; bool mReuseGlobal; bool mCache; @@ -321,7 +321,7 @@ class MOZ_STACK_CLASS AutoRejectPromise private: JSContext* mCx; - nsRefPtr mPromise; + RefPtr mPromise; nsCOMPtr mGlobalObject; }; @@ -395,7 +395,7 @@ mozJSSubScriptLoader::ReadScriptAsync(nsIURI* uri, JSObject* targetObjArg, return NS_ERROR_UNEXPECTED; } - nsRefPtr promise = Promise::Create(globalObject, result); + RefPtr promise = Promise::Create(globalObject, result); if (result.Failed()) { promise = nullptr; } @@ -423,7 +423,7 @@ mozJSSubScriptLoader::ReadScriptAsync(nsIURI* uri, JSObject* targetObjArg, channel->SetContentType(NS_LITERAL_CSTRING("application/javascript")); - nsRefPtr loadObserver = + RefPtr loadObserver = new AsyncScriptLoader(channel, reuseGlobal, target_obj, @@ -702,9 +702,9 @@ private: } } - nsRefPtr mObserver; - nsRefPtr mPrincipal; - nsRefPtr mChannel; + RefPtr mObserver; + RefPtr mPrincipal; + RefPtr mChannel; char16_t* mScriptBuf; size_t mScriptLength; }; @@ -727,7 +727,7 @@ public: } protected: - nsRefPtr mPrecompiler; + RefPtr mPrecompiler; void* mToken; }; @@ -820,7 +820,7 @@ ScriptPrecompiler::OnStreamComplete(nsIStreamLoader* aLoader, return NS_OK; } - nsRefPtr runnable = + RefPtr runnable = new NotifyPrecompilationCompleteRunnable(this); if (!JS::CompileOffThread(cx, options, @@ -841,7 +841,7 @@ ScriptPrecompiler::OnStreamComplete(nsIStreamLoader* aLoader, void ScriptPrecompiler::OffThreadCallback(void* aToken, void* aData) { - nsRefPtr runnable = + RefPtr runnable = dont_AddRef(static_cast(aData)); runnable->SetToken(aToken); @@ -873,7 +873,7 @@ mozJSSubScriptLoader::PrecompileScript(nsIURI* aURI, NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr loadObserver = + RefPtr loadObserver = new ScriptPrecompiler(aObserver, aPrincipal, channel); nsCOMPtr loader; diff --git a/js/xpconnect/src/ExportHelpers.cpp b/js/xpconnect/src/ExportHelpers.cpp index 0acaeb995b..6da951b48a 100644 --- a/js/xpconnect/src/ExportHelpers.cpp +++ b/js/xpconnect/src/ExportHelpers.cpp @@ -133,11 +133,11 @@ public: nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)); MOZ_ASSERT(global); - // nsRefPtr needs to go out of scope before toObjectOrNull() is called because + // RefPtr needs to go out of scope before toObjectOrNull() is called because // otherwise the static analysis thinks it can gc the JSObject via the stack. JS::Rooted val(aCx); { - nsRefPtr blob = Blob::Create(global, mBlobImpls[idx]); + RefPtr blob = Blob::Create(global, mBlobImpls[idx]); if (!ToJSValue(aCx, blob, &val)) { return nullptr; } @@ -156,7 +156,7 @@ public: // Prevent the return value from being trashed by a GC during ~nsRefPtr. JS::Rooted result(aCx); { - nsRefPtr ndefRecord = new MozNDEFRecord(global); + RefPtr ndefRecord = new MozNDEFRecord(global); result = ndefRecord->ReadStructuredClone(aCx, aReader) ? ndefRecord->WrapObject(aCx, nullptr) : nullptr; } @@ -230,7 +230,7 @@ public: StackScopedCloneOptions* mOptions; AutoObjectVector mReflectors; AutoObjectVector mFunctions; - nsTArray> mBlobImpls; + nsTArray> mBlobImpls; }; /* diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index a2cdd176b3..dc7a39c9b7 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -288,7 +288,7 @@ SandboxFetch(JSContext* cx, JS::HandleObject scope, const CallArgs& args) return false; } ErrorResult rv; - nsRefPtr response = + RefPtr response = FetchRequest(global, Constify(request), Constify(options), rv); rv.WouldReportJSException(); if (rv.Failed()) { @@ -980,7 +980,7 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin if (sop) { principal = sop->GetPrincipal(); } else { - nsRefPtr nullPrin = nsNullPrincipal::Create(); + RefPtr nullPrin = nsNullPrincipal::Create(); NS_ENSURE_TRUE(nullPrin, NS_ERROR_FAILURE); principal = nullPrin; } diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 3d21a5caf9..c4a347a095 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -1764,8 +1764,8 @@ private: JSContext* cx, HandleObject obj, const CallArgs& args, bool* _retval); private: - nsRefPtr mClassID; - nsRefPtr mInterfaceID; + RefPtr mClassID; + RefPtr mInterfaceID; char* mInitializer; }; @@ -1866,7 +1866,7 @@ nsXPCConstructor::~nsXPCConstructor() NS_IMETHODIMP nsXPCConstructor::GetClassID(nsIJSCID * *aClassID) { - nsRefPtr rval = mClassID; + RefPtr rval = mClassID; rval.forget(aClassID); return NS_OK; } @@ -1874,7 +1874,7 @@ nsXPCConstructor::GetClassID(nsIJSCID * *aClassID) NS_IMETHODIMP nsXPCConstructor::GetInterfaceID(nsIJSIID * *aInterfaceID) { - nsRefPtr rval = mInterfaceID; + RefPtr rval = mInterfaceID; rval.forget(aInterfaceID); return NS_OK; } @@ -2568,7 +2568,7 @@ NS_IMETHODIMP nsXPCComponents_Utils::GetWeakReference(HandleValue object, JSContext* cx, xpcIJSWeakReference** _retval) { - nsRefPtr ref = new xpcJSWeakReference(); + RefPtr ref = new xpcJSWeakReference(); nsresult rv = ref->Init(cx, object); NS_ENSURE_SUCCESS(rv, rv); ref.forget(_retval); @@ -2657,21 +2657,21 @@ class PreciseGCRunnable : public nsRunnable } private: - nsRefPtr mCallback; + RefPtr mCallback; bool mShrinking; }; NS_IMETHODIMP nsXPCComponents_Utils::SchedulePreciseGC(ScheduledGCCallback* aCallback) { - nsRefPtr event = new PreciseGCRunnable(aCallback, false); + RefPtr event = new PreciseGCRunnable(aCallback, false); return NS_DispatchToMainThread(event); } NS_IMETHODIMP nsXPCComponents_Utils::SchedulePreciseShrinkingGC(ScheduledGCCallback* aCallback) { - nsRefPtr event = new PreciseGCRunnable(aCallback, true); + RefPtr event = new PreciseGCRunnable(aCallback, true); return NS_DispatchToMainThread(event); } @@ -3204,7 +3204,7 @@ class WrappedJSHolder : public nsISupports NS_DECL_ISUPPORTS WrappedJSHolder() {} - nsRefPtr mWrappedJS; + RefPtr mWrappedJS; private: virtual ~WrappedJSHolder() {} @@ -3224,7 +3224,7 @@ nsXPCComponents_Utils::GenerateXPCWrappedJS(HandleValue aObj, HandleValue aScope if (!JS_WrapObject(aCx, &obj)) return NS_ERROR_FAILURE; - nsRefPtr holder = new WrappedJSHolder(); + RefPtr holder = new WrappedJSHolder(); nsresult rv = nsXPCWrappedJS::GetNewOrUsed(obj, NS_GET_IID(nsISupports), getter_AddRefs(holder->mWrappedJS)); holder.forget(aOut); @@ -3425,7 +3425,7 @@ NS_IMETHODIMP _class::Get##_n(nsIXPCComponents_##_n * *a##_n) { \ NS_ENSURE_ARG_POINTER(a##_n); \ if (!m##_n) \ m##_n = new nsXPCComponents_##_n(); \ - nsRefPtr ret = m##_n; \ + RefPtr ret = m##_n; \ ret.forget(a##_n); \ return NS_OK; \ } diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 4142a8eccc..37c9f666ea 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -726,7 +726,7 @@ CreateHolderIfNeeded(HandleObject obj, MutableHandleValue d, if (dest) { if (!obj) return false; - nsRefPtr objHolder = new XPCJSObjectHolder(obj); + RefPtr objHolder = new XPCJSObjectHolder(obj); objHolder.forget(dest); } @@ -820,7 +820,7 @@ XPCConvert::NativeInterface2JSObject(MutableHandleValue d, } } - nsRefPtr wrapper; + RefPtr wrapper; nsresult rv = XPCWrappedNative::GetNewOrUsed(aHelper, xpcscope, iface, getter_AddRefs(wrapper)); if (NS_FAILED(rv) && pErr) @@ -857,7 +857,7 @@ XPCConvert::NativeInterface2JSObject(MutableHandleValue d, } else { if (!flat) return false; - nsRefPtr objHolder = new XPCJSObjectHolder(flat); + RefPtr objHolder = new XPCJSObjectHolder(flat); objHolder.forget(dest); } } @@ -927,7 +927,7 @@ XPCConvert::JSObject2NativeInterface(void** dest, HandleObject src, } } - nsRefPtr wrapper; + RefPtr wrapper; nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, *iid, getter_AddRefs(wrapper)); if (pErr) *pErr = rv; @@ -986,7 +986,7 @@ XPCConvert::ConstructException(nsresult rv, const char* message, if (ifaceName && methodName) msgStr.AppendPrintf(format, msg, ifaceName, methodName); - nsRefPtr e = new Exception(msgStr, rv, EmptyCString(), nullptr, data); + RefPtr e = new Exception(msgStr, rv, EmptyCString(), nullptr, data); if (cx && jsExceptionPtr) { e->StowJSVal(*jsExceptionPtr); @@ -1195,7 +1195,7 @@ XPCConvert::JSErrorToXPCException(const char* message, { AutoJSContext cx; nsresult rv = NS_ERROR_FAILURE; - nsRefPtr data; + RefPtr data; if (report) { nsAutoString bestMessage; if (report && report->ucmessage) { diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp index 8c65daa212..99afdb256d 100644 --- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -176,7 +176,7 @@ nsJSID::NewID(const char* str) return nullptr; } - nsRefPtr idObj = new nsJSID(); + RefPtr idObj = new nsJSID(); NS_ENSURE_SUCCESS(idObj->Initialize(str), nullptr); return idObj.forget(); } @@ -185,7 +185,7 @@ nsJSID::NewID(const char* str) already_AddRefed nsJSID::NewID(const nsID& id) { - nsRefPtr idObj = new nsJSID(); + RefPtr idObj = new nsJSID(); idObj->mID = id; idObj->mName = nullptr; idObj->mNumber = nullptr; @@ -371,7 +371,7 @@ nsJSIID::NewID(nsIInterfaceInfo* aInfo) if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript) return nullptr; - nsRefPtr idObj = new nsJSIID(aInfo); + RefPtr idObj = new nsJSIID(aInfo); return idObj.forget(); } @@ -584,7 +584,7 @@ nsJSCID::NewID(const char* str) return nullptr; } - nsRefPtr idObj = new nsJSCID(); + RefPtr idObj = new nsJSCID(); if (str[0] == '{') { NS_ENSURE_SUCCESS(idObj->Initialize(str), nullptr); } else { diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 7f9cb2b475..118ae5d782 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1359,7 +1359,7 @@ XPCJSRuntime::InterruptCallback(JSContext* cx) // Get the DOM window associated with the running script. If the script is // running in a non-DOM scope, we have to just let it keep running. RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); - nsRefPtr win = WindowOrNull(global); + RefPtr win = WindowOrNull(global); if (!win && IsSandbox(global)) { // If this is a sandbox associated with a DOMWindow via a // sandboxPrototype, use that DOMWindow. This supports GreaseMonkey @@ -1488,6 +1488,8 @@ ReloadPrefsCallback(const char* pref, void* data) bool useBaseline = Preferences::GetBool(JS_OPTIONS_DOT_STR "baselinejit") && !safeMode; bool useIon = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion") && !safeMode; bool useAsmJS = Preferences::GetBool(JS_OPTIONS_DOT_STR "asmjs") && !safeMode; + bool throwOnAsmJSValidationFailure = Preferences::GetBool(JS_OPTIONS_DOT_STR + "throw_on_asmjs_validation_failure"); bool useNativeRegExp = Preferences::GetBool(JS_OPTIONS_DOT_STR "native_regexp") && !safeMode; bool parallelParsing = Preferences::GetBool(JS_OPTIONS_DOT_STR "parallel_parsing"); @@ -1511,6 +1513,7 @@ ReloadPrefsCallback(const char* pref, void* data) JS::RuntimeOptionsRef(rt).setBaseline(useBaseline) .setIon(useIon) .setAsmJS(useAsmJS) + .setThrowOnAsmJSValidationFailure(throwOnAsmJSValidationFailure) .setNativeRegExp(useNativeRegExp) .setAsyncStack(useAsyncStack) .setWerror(werror) @@ -3181,7 +3184,7 @@ GetCurrentPerfGroupCallback(JSContext* cx) { // If the compartment belongs to a webpage, use the address of the // topmost scriptable window, hence regrouping all frames of a // window. - nsRefPtr win = WindowOrNull(global); + RefPtr win = WindowOrNull(global); if (win) { nsCOMPtr top = win->GetScriptableTop(); if (!top) { diff --git a/js/xpconnect/src/XPCJSWeakReference.cpp b/js/xpconnect/src/XPCJSWeakReference.cpp index ffa63459ea..0f1d211376 100644 --- a/js/xpconnect/src/XPCJSWeakReference.cpp +++ b/js/xpconnect/src/XPCJSWeakReference.cpp @@ -41,7 +41,7 @@ nsresult xpcJSWeakReference::Init(JSContext* cx, const JS::Value& object) // support weak references, fall back to getting a weak ref to the object. // See if object is a wrapped JSObject. - nsRefPtr wrapped; + RefPtr wrapped; nsresult rv = nsXPCWrappedJS::GetNewOrUsed(obj, NS_GET_IID(nsISupports), getter_AddRefs(wrapped)); diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index 9d1ba84a51..02863f2e81 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -90,7 +90,7 @@ JSObject2WrappedJSMap::UpdateWeakPointersAfterGC(XPCJSRuntime* runtime) // Check all wrappers and update their JSObject pointer if it has been // moved. Release any wrappers whose weakly held JSObject has died. - nsTArray> dying; + nsTArray> dying; for (Map::Enum e(mTable); !e.empty(); e.popFront()) { nsXPCWrappedJS* wrapper = e.front().value(); diff --git a/js/xpconnect/src/XPCRuntimeService.cpp b/js/xpconnect/src/XPCRuntimeService.cpp index 2ae04dba82..7e6fbda9f4 100644 --- a/js/xpconnect/src/XPCRuntimeService.cpp +++ b/js/xpconnect/src/XPCRuntimeService.cpp @@ -184,7 +184,7 @@ BackstagePass::PreCreate(nsISupports* nativeObj, JSContext* cx, nsresult NS_NewBackstagePass(BackstagePass** ret) { - nsRefPtr bsp = new BackstagePass( + RefPtr bsp = new BackstagePass( nsContentUtils::GetSystemPrincipal()); bsp.forget(ret); return NS_OK; diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 788549e85d..b7ba2b9993 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -1430,7 +1430,7 @@ XRE_XPCShellMain(int argc, char** argv, char** envp) xpc->SetFunctionThisTranslator(NS_GET_IID(nsITestXPCFunctionCallback), translator); #endif - nsRefPtr backstagePass; + RefPtr backstagePass; rv = NS_NewBackstagePass(getter_AddRefs(backstagePass)); if (NS_FAILED(rv)) { fprintf(gErrFile, "+++ Failed to create BackstagePass: %8x\n", diff --git a/js/xpconnect/src/XPCVariant.cpp b/js/xpconnect/src/XPCVariant.cpp index 44f6eafa7a..cf9e3b0a41 100644 --- a/js/xpconnect/src/XPCVariant.cpp +++ b/js/xpconnect/src/XPCVariant.cpp @@ -98,7 +98,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END already_AddRefed XPCVariant::newVariant(JSContext* cx, Value aJSVal) { - nsRefPtr variant; + RefPtr variant; if (!aJSVal.isMarkable()) variant = new XPCVariant(cx, aJSVal); diff --git a/js/xpconnect/src/XPCWrappedJS.cpp b/js/xpconnect/src/XPCWrappedJS.cpp index c5c41fbc27..d5adf09384 100644 --- a/js/xpconnect/src/XPCWrappedJS.cpp +++ b/js/xpconnect/src/XPCWrappedJS.cpp @@ -331,7 +331,7 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj, } bool allowNonScriptable = mozilla::jsipc::IsWrappedCPOW(jsObj); - nsRefPtr clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID, + RefPtr clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID, allowNonScriptable); if (!clasp) return NS_ERROR_FAILURE; @@ -341,9 +341,9 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj, return NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE; - nsRefPtr root = map->Find(rootJSObj); + RefPtr root = map->Find(rootJSObj); if (root) { - nsRefPtr wrapper = root->FindOrFindInherited(aIID); + RefPtr wrapper = root->FindOrFindInherited(aIID); if (wrapper) { wrapper.forget(wrapperResult); return NS_OK; @@ -353,7 +353,7 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj, // Make a new root wrapper, because there is no existing // root wrapper, and the wrapper we are trying to make isn't // a root. - nsRefPtr rootClasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, NS_GET_IID(nsISupports)); + RefPtr rootClasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, NS_GET_IID(nsISupports)); if (!rootClasp) return NS_ERROR_FAILURE; @@ -363,7 +363,7 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj, } } - nsRefPtr wrapper = new nsXPCWrappedJS(cx, jsObj, clasp, root, &rv); + RefPtr wrapper = new nsXPCWrappedJS(cx, jsObj, clasp, root, &rv); if (NS_FAILED(rv)) { return rv; } diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index b8b05fa92d..01d5404be2 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -107,7 +107,7 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScr { XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap(); - nsRefPtr clasp = map->Find(aIID); + RefPtr clasp = map->Find(aIID); if (!clasp) { nsCOMPtr info; @@ -566,7 +566,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self, // Instead, simply do the nsXPCWrappedJS part of // XPConvert::JSObject2NativeInterface() here to make sure we // get a new (or used) nsXPCWrappedJS. - nsRefPtr wrapper; + RefPtr wrapper; nsresult rv = nsXPCWrappedJS::GetNewOrUsed(jsobj, aIID, getter_AddRefs(wrapper)); if (NS_SUCCEEDED(rv) && wrapper) { // We need to go through the QueryInterface logic to make diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 5af9d300e3..39f4be5548 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -213,7 +213,7 @@ XPCWrappedNative::WrapNewGlobal(xpcObjectHelper& nativeHelper, // Construct the wrapper, which takes over the strong reference to the // native object. - nsRefPtr wrapper = + RefPtr wrapper = new XPCWrappedNative(nativeHelper.forgetCanonical(), proto); // @@ -311,7 +311,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper, return NS_ERROR_FAILURE; } - nsRefPtr wrapper; + RefPtr wrapper; Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap(); // Some things are nsWrapperCache subclasses but never use the cache, so go @@ -474,7 +474,7 @@ FinishCreate(XPCWrappedNativeScope* Scope, Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap(); - nsRefPtr wrapper; + RefPtr wrapper; // Deal with the case where the wrapper got created as a side effect // of one of our calls out of this code. Add() returns the (possibly // pre-existing) wrapper that ultimately ends up in the map, which is @@ -510,7 +510,7 @@ XPCWrappedNative::GetUsedOnly(nsISupports* Object, MOZ_ASSERT(Object, "XPCWrappedNative::GetUsedOnly was called with a null Object"); MOZ_ASSERT(Interface); - nsRefPtr wrapper; + RefPtr wrapper; nsWrapperCache* cache = nullptr; CallQueryInterface(Object, &cache); if (cache) { @@ -910,7 +910,7 @@ XPCWrappedNative::FlatJSObjectFinalized() } // We also need to release any native pointers held... - nsRefPtr native = to->TakeNative(); + RefPtr native = to->TakeNative(); if (native && GetRuntime()) { DeferredFinalize(native.forget().take()); } @@ -1131,7 +1131,7 @@ XPCWrappedNative::InitTearOff(XPCWrappedNativeTearOff* aTearOff, // This is an nsRefPtr instead of an nsCOMPtr because it may not be the // canonical nsISupports for this object. - nsRefPtr qiResult; + RefPtr qiResult; // If the scriptable helper forbids us from reflecting additional // interfaces, then don't even try the QI, just fail. @@ -1209,7 +1209,7 @@ XPCWrappedNative::InitTearOff(XPCWrappedNativeTearOff* aTearOff, // nsIPropertyBag - xpconnect will do that work. if (iid->Equals(NS_GET_IID(nsIPropertyBag)) && jso) { - nsRefPtr clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, *iid); + RefPtr clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, *iid); if (clasp) { RootedObject answer(cx, clasp->CallQueryInterfaceOnJSObject(cx, jso, *iid)); diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index c2626dafcf..8598700c56 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -452,7 +452,7 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, // prototype. xpcObjectHelper helper(aCOMObj); MOZ_ASSERT(helper.GetScriptableFlags() & nsIXPCScriptable::IS_GLOBAL_OBJECT); - nsRefPtr wrappedGlobal; + RefPtr wrappedGlobal; nsresult rv = XPCWrappedNative::WrapNewGlobal(helper, aPrincipal, aFlags & nsIXPConnect::INIT_JS_STANDARD_CLASSES, @@ -584,7 +584,7 @@ nsXPConnect::JSValToVariant(JSContext* cx, { NS_PRECONDITION(aResult, "bad param"); - nsRefPtr variant = XPCVariant::newVariant(cx, aJSVal); + RefPtr variant = XPCVariant::newVariant(cx, aJSVal); variant.forget(aResult); NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY); @@ -629,7 +629,7 @@ nsXPConnect::GetWrappedNativeOfJSObject(JSContext * aJSContext, return NS_ERROR_FAILURE; } - nsRefPtr temp = XPCWrappedNative::Get(aJSObj); + RefPtr temp = XPCWrappedNative::Get(aJSObj); temp.forget(_retval); return NS_OK; } @@ -915,7 +915,7 @@ nsXPConnect::JSToVariant(JSContext* ctx, HandleValue value, nsIVariant** _retval NS_PRECONDITION(ctx, "bad param"); NS_PRECONDITION(_retval, "bad param"); - nsRefPtr variant = XPCVariant::newVariant(ctx, value); + RefPtr variant = XPCVariant::newVariant(ctx, value); variant.forget(_retval); if (!(*_retval)) return NS_ERROR_FAILURE; diff --git a/js/xpconnect/src/qsObjectHelper.h b/js/xpconnect/src/qsObjectHelper.h index 2fc2719431..6f87be7d41 100644 --- a/js/xpconnect/src/qsObjectHelper.h +++ b/js/xpconnect/src/qsObjectHelper.h @@ -39,7 +39,7 @@ public: template inline - qsObjectHelper(nsRefPtr& aObject, nsWrapperCache* aCache) + qsObjectHelper(RefPtr& aObject, nsWrapperCache* aCache) : xpcObjectHelper(ToSupports(aObject.get()), ToCanonicalSupports(aObject.get()), aCache) { diff --git a/js/xpconnect/src/xpcObjectHelper.h b/js/xpconnect/src/xpcObjectHelper.h index eb0a4033a8..237d0fe805 100644 --- a/js/xpconnect/src/xpcObjectHelper.h +++ b/js/xpconnect/src/xpcObjectHelper.h @@ -132,7 +132,7 @@ private: "(see bug 565742)") mObject; nsWrapperCache* mCache; nsCOMPtr mClassInfo; - nsRefPtr mXPCClassInfo; + RefPtr mXPCClassInfo; }; #endif diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 081a57983c..da63bb93eb 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -645,12 +645,12 @@ private: XPCRootSetElem* mWrappedJSRoots; XPCRootSetElem* mObjectHolderRoots; nsTArray extraGCCallbacks; - nsRefPtr mWatchdogManager; + RefPtr mWatchdogManager; JS::GCSliceCallback mPrevGCSliceCallback; JS::PersistentRootedObject mUnprivilegedJunkScope; JS::PersistentRootedObject mPrivilegedJunkScope; JS::PersistentRootedObject mCompilationScope; - nsRefPtr mAsyncSnowWhiteFreer; + RefPtr mAsyncSnowWhiteFreer; // If we spend too much time running JS code in an event handler, then we // want to show the slow script UI. The timeout T is controlled by prefs. We @@ -887,7 +887,7 @@ private: JSAutoRequest mAr; State mState; - nsRefPtr mXPC; + RefPtr mXPC; XPCContext* mXPCContext; JSContext* mJSContext; @@ -1208,7 +1208,7 @@ private: XPCJSRuntime* mRuntime; Native2WrappedNativeMap* mWrappedNativeMap; ClassInfo2WrappedNativeProtoMap* mWrappedNativeProtoMap; - nsRefPtr mComponents; + RefPtr mComponents; XPCWrappedNativeScope* mNext; // The JS global object for this scope. If non-null, this will be the // default parent for the XPCWrappedNatives that have us as the scope, @@ -1986,7 +1986,7 @@ private: XPCNativeInterface* mInterface; // mNative is an nsRefPtr not an nsCOMPtr because it may not be the canonical // nsISupports pointer. - nsRefPtr mNative; + RefPtr mNative; JS::TenuredHeap mJSObject; }; @@ -2508,7 +2508,7 @@ protected: private: JS::Heap mJSObj; - nsRefPtr mClass; + RefPtr mClass; nsXPCWrappedJS* mRoot; // If mRoot != this, it is an owning pointer. nsXPCWrappedJS* mNext; nsCOMPtr mOuter; // only set in root @@ -2818,7 +2818,7 @@ private: void ResolveName(); private: - nsRefPtr mDetails; + RefPtr mDetails; }; @@ -2916,9 +2916,9 @@ protected: XPCWrappedNativeScope* mScope; // Unprivileged members from nsIXPCComponentsBase. - nsRefPtr mInterfaces; - nsRefPtr mInterfacesByID; - nsRefPtr mResults; + RefPtr mInterfaces; + RefPtr mInterfacesByID; + RefPtr mResults; friend class XPCWrappedNativeScope; }; @@ -2937,12 +2937,12 @@ protected: virtual void ClearMembers() override; // Privileged members added by nsIXPCComponents. - nsRefPtr mClasses; - nsRefPtr mClassesByID; - nsRefPtr mID; - nsRefPtr mException; - nsRefPtr mConstructor; - nsRefPtr mUtils; + RefPtr mClasses; + RefPtr mClassesByID; + RefPtr mID; + RefPtr mException; + RefPtr mConstructor; + RefPtr mUtils; friend class XPCWrappedNativeScope; }; diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 92fabf2d6b..e68d23a8bb 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -1164,7 +1164,7 @@ void XPCWrappedNativeXrayTraits::preserveWrapper(JSObject* target) { XPCWrappedNative* wn = XPCWrappedNative::Get(target); - nsRefPtr ci; + RefPtr ci; CallQueryInterface(wn->Native(), getter_AddRefs(ci)); if (ci) ci->PreserveWrapper(wn->Native()); diff --git a/layout/base/AccessibleCaret.h b/layout/base/AccessibleCaret.h index 0b232cc81b..1e1058d720 100644 --- a/layout/base/AccessibleCaret.h +++ b/layout/base/AccessibleCaret.h @@ -15,7 +15,7 @@ #include "nsISupportsBase.h" #include "nsISupportsImpl.h" #include "nsRect.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsString.h" class nsIDocument; @@ -203,14 +203,14 @@ protected: // outlive mPresShell. nsIPresShell* MOZ_NON_OWNING_REF const mPresShell = nullptr; - nsRefPtr mCaretElementHolder; + RefPtr mCaretElementHolder; // mImaginaryCaretRect is relative to root frame. nsRect mImaginaryCaretRect; // A no-op touch-start listener which prevents APZ from panning when dragging // the caret. - nsRefPtr mDummyTouchListener{new DummyTouchListener()}; + RefPtr mDummyTouchListener{new DummyTouchListener()}; // Static class variables static float sWidth; diff --git a/layout/base/AccessibleCaretEventHub.cpp b/layout/base/AccessibleCaretEventHub.cpp index c2913b0805..f26d70f157 100644 --- a/layout/base/AccessibleCaretEventHub.cpp +++ b/layout/base/AccessibleCaretEventHub.cpp @@ -430,7 +430,7 @@ AccessibleCaretEventHub::Terminate() return; } - nsRefPtr docShell(mDocShell.get()); + RefPtr docShell(mDocShell.get()); if (docShell) { docShell->RemoveWeakReflowObserver(this); docShell->RemoveWeakScrollObserver(this); diff --git a/layout/base/AccessibleCaretEventHub.h b/layout/base/AccessibleCaretEventHub.h index 51661ab7b0..f901a266c3 100644 --- a/layout/base/AccessibleCaretEventHub.h +++ b/layout/base/AccessibleCaretEventHub.h @@ -16,7 +16,7 @@ #include "nsIScrollObserver.h" #include "nsISelectionListener.h" #include "nsPoint.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsWeakReference.h" class nsDocShell; diff --git a/layout/base/AccessibleCaretManager.cpp b/layout/base/AccessibleCaretManager.cpp index b5e550a958..a468968bf7 100644 --- a/layout/base/AccessibleCaretManager.cpp +++ b/layout/base/AccessibleCaretManager.cpp @@ -144,7 +144,7 @@ bool AccessibleCaretManager::IsCaretDisplayableInCursorMode(nsIFrame** aOutFrame, int32_t* aOutOffset) const { - nsRefPtr caret = mPresShell->GetCaret(); + RefPtr caret = mPresShell->GetCaret(); if (!caret || !caret->IsVisible()) { return false; } @@ -505,7 +505,7 @@ AccessibleCaretManager::OnKeyboardEvent() Selection* AccessibleCaretManager::GetSelection() const { - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { return nullptr; } @@ -531,7 +531,7 @@ AccessibleCaretManager::GetFrameSelection() const // Prevent us from touching the nsFrameSelection associated with other // PresShell. - nsRefPtr fs = focusFrame->GetFrameSelection(); + RefPtr fs = focusFrame->GetFrameSelection(); if (!fs || fs->GetShell() != mPresShell) { return nullptr; } @@ -631,7 +631,7 @@ AccessibleCaretManager::SelectWord(nsIFrame* aFrame, const nsPoint& aPoint) cons void AccessibleCaretManager::SetSelectionDragState(bool aState) const { - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (fs) { fs->SetDragState(aState); } @@ -651,7 +651,7 @@ AccessibleCaretManager::ClearMaintainedSelection() const { // Selection made by double-clicking for example will maintain the original // word selection. We should clear it so that we can drag caret freely. - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (fs) { fs->MaintainSelection(eSelectNoAmount); } @@ -673,12 +673,12 @@ AccessibleCaretManager::FindFirstNodeWithFrame(bool aBackward, return nullptr; } - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { return nullptr; } - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { return nullptr; } @@ -689,9 +689,9 @@ AccessibleCaretManager::FindFirstNodeWithFrame(bool aBackward, } nsRange* range = selection->GetRangeAt(aBackward ? rangeCount - 1 : 0); - nsRefPtr startNode = + RefPtr startNode = aBackward ? range->GetEndParent() : range->GetStartParent(); - nsRefPtr endNode = + RefPtr endNode = aBackward ? range->GetStartParent() : range->GetEndParent(); int32_t offset = aBackward ? range->EndOffset() : range->StartOffset(); nsCOMPtr startContent = do_QueryInterface(startNode); @@ -705,7 +705,7 @@ AccessibleCaretManager::FindFirstNodeWithFrame(bool aBackward, } ErrorResult err; - nsRefPtr walker = mPresShell->GetDocument()->CreateTreeWalker( + RefPtr walker = mPresShell->GetDocument()->CreateTreeWalker( *startNode, nsIDOMNodeFilter::SHOW_ALL, nullptr, err); if (!walker) { @@ -738,7 +738,7 @@ AccessibleCaretManager::CompareRangeWithContentOffset(nsIFrame::ContentOffsets& MOZ_ASSERT(rangeCount > 0); int32_t rangeIndex = (mActiveCaret == mFirstCaret.get() ? rangeCount - 1 : 0); - nsRefPtr range = selection->GetRangeAt(rangeIndex); + RefPtr range = selection->GetRangeAt(rangeIndex); nsINode* node = nullptr; int32_t nodeOffset = 0; @@ -760,7 +760,7 @@ AccessibleCaretManager::CompareRangeWithContentOffset(nsIFrame::ContentOffsets& } nsCOMPtr content = do_QueryInterface(node); - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { return false; } @@ -834,7 +834,7 @@ AccessibleCaretManager::DragCaretInternal(const nsPoint& aPoint) return NS_ERROR_FAILURE; } - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { return NS_ERROR_NULL_POINTER; } @@ -999,7 +999,7 @@ AccessibleCaretManager::DispatchCaretStateChangedEvent(CaretChangedReason aReaso commonAncestorNode = sel->GetFrameSelection()->GetAncestorLimiter(); } - nsRefPtr domRect = new DOMRect(ToSupports(doc)); + RefPtr domRect = new DOMRect(ToSupports(doc)); nsRect rect = nsContentUtils::GetSelectionBoundingRect(sel); nsIFrame* commonAncestorFrame = nullptr; @@ -1032,7 +1032,7 @@ AccessibleCaretManager::DispatchCaretStateChangedEvent(CaretChangedReason aReaso init.mCaretVisible = mFirstCaret->IsLogicallyVisible() || mSecondCaret->IsLogicallyVisible(); - nsRefPtr event = + RefPtr event = CaretStateChangedEvent::Constructor(doc, NS_LITERAL_STRING("mozcaretstatechanged"), init); event->SetTrusted(true); diff --git a/layout/base/AccessibleCaretManager.h b/layout/base/AccessibleCaretManager.h index 69a0acac82..042f393263 100644 --- a/layout/base/AccessibleCaretManager.h +++ b/layout/base/AccessibleCaretManager.h @@ -11,7 +11,7 @@ #include "nsCoord.h" #include "nsIFrame.h" #include "nsISelectionListener.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsWeakReference.h" #include "mozilla/dom/CaretStateChangedEvent.h" #include "mozilla/EventForwards.h" diff --git a/layout/base/ArenaRefPtr.h b/layout/base/ArenaRefPtr.h index 983f8d4a82..bc8ecaa70d 100644 --- a/layout/base/ArenaRefPtr.h +++ b/layout/base/ArenaRefPtr.h @@ -9,7 +9,7 @@ that might be held onto until the arena's destruction */ #include "mozilla/Assertions.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #ifndef mozilla_ArenaRefPtr_h #define mozilla_ArenaRefPtr_h @@ -128,14 +128,14 @@ private: template void assign(already_AddRefed& aSmartPtr) { - nsRefPtr newPtr(aSmartPtr); + RefPtr newPtr(aSmartPtr); assignFrom(newPtr); } template void assign(already_AddRefed&& aSmartPtr) { - nsRefPtr newPtr(aSmartPtr); + RefPtr newPtr(aSmartPtr); assignFrom(newPtr); } @@ -159,7 +159,7 @@ private: } } - nsRefPtr mPtr; + RefPtr mPtr; }; } // namespace mozilla diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index b89a7df5f3..cc3244437c 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -659,7 +659,7 @@ struct NewLayerEntry { {} // mLayer is null if the previous entry is for a PaintedLayer that hasn't // been optimized to some other form (yet). - nsRefPtr mLayer; + RefPtr mLayer; const nsIFrame* mAnimatedGeometryRoot; // For fixed background layers, mAnimatedGeometryRoot is the animated geometry // root of the viewport frame it's fixed to, but we need to annotate it with @@ -1406,7 +1406,7 @@ protected: Maybe mAncestorIndex; }; - nsDataHashtable, nsRefPtr> + nsDataHashtable, RefPtr> mRecycledMaskImageLayers; }; @@ -1489,8 +1489,8 @@ public: // See the comment in ComputeAndSetIgnoreInvalidationRect for more information. Maybe mIgnoreInvalidationsOutsideRect; - nsRefPtr mColorLayer; - nsRefPtr mImageLayer; + RefPtr mColorLayer; + RefPtr mImageLayer; // The region for which display item visibility for this layer has already // been calculated. Used to reduce the number of calls to @@ -1716,7 +1716,7 @@ FrameLayerBuilder::RemoveFrameFromLayerManager(nsIFrame* aFrame, // Hold a reference to all the items so that they don't get // deleted from under us. - nsTArray > arrayCopy; + nsTArray > arrayCopy; for (uint32_t i = 0; i < array->Length(); ++i) { arrayCopy.AppendElement(array->ElementAt(i)); } @@ -1975,7 +1975,7 @@ ContainerState::CreateOrRecycleColorLayer(PaintedLayer *aPainted) { PaintedDisplayItemLayerUserData* data = static_cast(aPainted->GetUserData(&gPaintedDisplayItemLayerUserData)); - nsRefPtr layer = data->mColorLayer; + RefPtr layer = data->mColorLayer; if (layer) { layer->SetMaskLayer(nullptr); layer->ClearExtraDumpInfo(); @@ -1999,7 +1999,7 @@ ContainerState::CreateOrRecycleImageLayer(PaintedLayer *aPainted) { PaintedDisplayItemLayerUserData* data = static_cast(aPainted->GetUserData(&gPaintedDisplayItemLayerUserData)); - nsRefPtr layer = data->mImageLayer; + RefPtr layer = data->mImageLayer; if (layer) { layer->SetMaskLayer(nullptr); layer->ClearExtraDumpInfo(); @@ -2021,7 +2021,7 @@ ContainerState::CreateOrRecycleImageLayer(PaintedLayer *aPainted) already_AddRefed ContainerState::CreateOrRecycleMaskImageLayerFor(const MaskLayerKey& aKey) { - nsRefPtr result = mRecycledMaskImageLayers.Get(aKey); + RefPtr result = mRecycledMaskImageLayers.Get(aKey); if (result) { mRecycledMaskImageLayers.Remove(aKey); aKey.mLayer->ClearExtraDumpInfo(); @@ -2134,7 +2134,7 @@ ContainerState::AttemptToRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRo } // Try to recycle a layer - nsRefPtr layer = oldLayer->AsPaintedLayer(); + RefPtr layer = oldLayer->AsPaintedLayer(); mPaintedLayersAvailableForRecycling.RemoveEntry(layer); // Check if the layer hint has changed and whether or not the layer should @@ -2161,7 +2161,7 @@ ContainerState::CreatePaintedLayer(PaintedLayerData* aData) GetLayerCreationHint(aData->mAnimatedGeometryRoot); // Create a new painted layer - nsRefPtr layer = mManager->CreatePaintedLayerWithHint(creationHint); + RefPtr layer = mManager->CreatePaintedLayerWithHint(creationHint); if (!layer) { return nullptr; } @@ -3065,13 +3065,13 @@ static int32_t FindIndexOfLayerIn(nsTArray& aArray, already_AddRefed ContainerState::PrepareImageLayer(PaintedLayerData* aData) { - nsRefPtr imageContainer = + RefPtr imageContainer = aData->GetContainerForImageLayer(mBuilder); if (!imageContainer) { return nullptr; } - nsRefPtr imageLayer = CreateOrRecycleImageLayer(aData->mLayer); + RefPtr imageLayer = CreateOrRecycleImageLayer(aData->mLayer); imageLayer->SetContainer(imageContainer); aData->mImage->ConfigureLayer(imageLayer, mParameters); imageLayer->SetPostScale(mParameters.mXScale, @@ -3096,7 +3096,7 @@ ContainerState::PrepareImageLayer(PaintedLayerData* aData) already_AddRefed ContainerState::PrepareColorLayer(PaintedLayerData* aData) { - nsRefPtr colorLayer = CreateOrRecycleColorLayer(aData->mLayer); + RefPtr colorLayer = CreateOrRecycleColorLayer(aData->mLayer); colorLayer->SetColor(Color::FromABGR(aData->mSolidColor)); // Copy transform @@ -3134,7 +3134,7 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB if (!data->mLayer) { // No layer was recycled, so we create a new one. - nsRefPtr paintedLayer = CreatePaintedLayer(data); + RefPtr paintedLayer = CreatePaintedLayer(data); data->mLayer = paintedLayer; NS_ASSERTION(FindIndexOfLayerIn(mNewChildLayers, paintedLayer) < 0, @@ -3153,7 +3153,7 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB NewLayerEntry* newLayerEntry = &mNewChildLayers[data->mNewChildLayersIndex]; - nsRefPtr layer; + RefPtr layer; bool canOptimizeToImageLayer = data->CanOptimizeToImageLayer(mBuilder); FLB_LOG_PAINTED_LAYER_DECISION(data, "Selecting layer for pld=%p\n", data); @@ -3628,7 +3628,7 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder, // This item has an inactive layer. Render it to a PaintedLayer // using a temporary BasicLayerManager. BasicLayerManager* basic = static_cast(aManager); - nsRefPtr context = aContext; + RefPtr context = aContext; #ifdef MOZ_DUMP_PAINTING int32_t appUnitsPerDevPixel = AppUnitsPerDevPixel(aItem); nsIntRect itemVisibleRect = @@ -4064,7 +4064,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) // item->BuildLayer, this will be set to a proper rect. nsIntRect layerContentsVisibleRect(0, 0, -1, -1); mParameters.mLayerContentsVisibleRect = &layerContentsVisibleRect; - nsRefPtr ownLayer = item->BuildLayer(mBuilder, mManager, mParameters); + RefPtr ownLayer = item->BuildLayer(mBuilder, mManager, mParameters); if (!ownLayer) { continue; } @@ -4233,7 +4233,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) if (!paintedLayerData->mLayer) { // Try to recycle the old layer of this display item. - nsRefPtr layer = + RefPtr layer = AttemptToRecyclePaintedLayer(animatedGeometryRoot, item, topLeft); if (layer) { paintedLayerData->mLayer = layer; @@ -4405,7 +4405,7 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, PaintedDisplayItemLayerUserData* paintedData = static_cast (layer->GetUserData(&gPaintedDisplayItemLayerUserData)); - nsRefPtr tempManager; + RefPtr tempManager; nsIntRect intClip; bool hasClip = false; if (aLayerState != LAYER_NONE) { @@ -4451,7 +4451,7 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, } UniquePtr props(LayerProperties::CloneFrom(tempManager->GetRoot())); - nsRefPtr tmpLayer = + RefPtr tmpLayer = aItem->BuildLayer(mDisplayListBuilder, tempManager, ContainerLayerParameters()); // We have no easy way of detecting if this transaction will ever actually get finished. // For now, I've just silenced the warning with nested transactions in BasicLayers.cpp @@ -4539,7 +4539,7 @@ FrameLayerBuilder::StoreDataForFrame(nsDisplayItem* aItem, Layer* aLayer, LayerS LayerManagerData* lmd = static_cast (mRetainingManager->GetUserData(&gLayerManagerUserData)); - nsRefPtr data = + RefPtr data = new DisplayItemData(lmd, aItem->GetPerFrameKey(), aLayer); data->BeginUpdate(aLayer, aState, mContainerLayerGeneration, aItem); @@ -4563,7 +4563,7 @@ FrameLayerBuilder::StoreDataForFrame(nsIFrame* aFrame, LayerManagerData* lmd = static_cast (mRetainingManager->GetUserData(&gLayerManagerUserData)); - nsRefPtr data = + RefPtr data = new DisplayItemData(lmd, aDisplayItemKey, aLayer, aFrame); data->BeginUpdate(aLayer, aState, mContainerLayerGeneration); @@ -4702,7 +4702,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) uint32_t baseLength = metricsArray.Length(); // Any extra mask layers we need to attach to FrameMetrics. - nsTArray> maskLayers; + nsTArray> maskLayers; nsIFrame* fParent; for (const nsIFrame* f = aEntry->mAnimatedGeometryRootForScrollMetadata; @@ -4746,7 +4746,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) // the APZC associated with this FrameMetrics, we attach the mask // layer as an additional, separate clip. Maybe nextIndex = Some(maskLayers.Length()); - nsRefPtr maskLayer = + RefPtr maskLayer = CreateMaskLayer(aEntry->mLayer, *clip, aEntry->mVisibleRegion, nextIndex, clip->GetRoundedRectCount()); if (maskLayer) { metrics.SetMaskLayerIndex(nextIndex); @@ -5193,7 +5193,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, return nullptr; } - nsRefPtr containerLayer; + RefPtr containerLayer; if (aManager == mRetainingManager) { // Using GetOldLayerFor will search merged frames, as well as the underlying // frame. The underlying frame can change when a page scrolls, so this @@ -5261,7 +5261,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, uint32_t oldGeneration = mContainerLayerGeneration; mContainerLayerGeneration = ++mMaxContainerLayerGeneration; - nsRefPtr paintedLayerInvalidRegion = nullptr; + RefPtr paintedLayerInvalidRegion = nullptr; if (mRetainingManager) { if (aContainerItem) { StoreDataForFrame(aContainerItem, containerLayer, LAYER_ACTIVE); @@ -5533,7 +5533,7 @@ static void DebugPaintItem(DrawTarget& aDrawTarget, RefPtr tempDT = aDrawTarget.CreateSimilarDrawTarget(IntSize(bounds.width, bounds.height), SurfaceFormat::B8G8R8A8); - nsRefPtr context = new gfxContext(tempDT); + RefPtr context = new gfxContext(tempDT); context->SetMatrix(gfxMatrix::Translation(-bounds.x, -bounds.y)); nsRenderingContext ctx(context); @@ -5978,7 +5978,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, return; } - nsRefPtr maskLayer = + RefPtr maskLayer = CreateMaskLayer(aLayer, aClip, aLayerVisibleRegion, Nothing(), aRoundedRectClipCount); if (!maskLayer) { @@ -5999,7 +5999,7 @@ ContainerState::CreateMaskLayer(Layer *aLayer, { // check if we can re-use the mask layer MaskLayerKey recycleKey(aLayer, aForAncestorMaskLayer); - nsRefPtr maskLayer = CreateOrRecycleMaskImageLayerFor(recycleKey); + RefPtr maskLayer = CreateOrRecycleMaskImageLayerFor(recycleKey); MaskLayerUserData* userData = GetMaskLayerUserData(maskLayer); MaskLayerUserData newData; @@ -6050,7 +6050,7 @@ ContainerState::CreateMaskLayer(Layer *aLayer, const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey; // check to see if we can reuse a mask image - nsRefPtr container = + RefPtr container = GetMaskLayerImageCache()->FindImageFor(&lookupKey); if (!container) { @@ -6066,7 +6066,7 @@ ContainerState::CreateMaskLayer(Layer *aLayer, return nullptr; } - nsRefPtr context = new gfxContext(dt); + RefPtr context = new gfxContext(dt); context->Multiply(ThebesMatrix(imageTransform)); // paint the clipping rects with alpha to create the mask @@ -6081,7 +6081,7 @@ ContainerState::CreateMaskLayer(Layer *aLayer, // build the image and container container = aLayer->Manager()->CreateImageContainer(); NS_ASSERTION(container, "Could not create image container for mask layer."); - nsRefPtr image = container->CreateImage(ImageFormat::CAIRO_SURFACE); + RefPtr image = container->CreateImage(ImageFormat::CAIRO_SURFACE); NS_ASSERTION(image, "Could not create image container for mask layer."); CairoImage::Data data; data.mSize = surfaceSizeInt; diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 1b2c7475fb..b256468c75 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -492,9 +492,9 @@ public: void EndUpdate(); LayerManagerData* mParent; - nsRefPtr mLayer; - nsRefPtr mOptLayer; - nsRefPtr mInactiveManager; + RefPtr mLayer; + RefPtr mOptLayer; + RefPtr mInactiveManager; nsAutoTArray mFrameList; nsAutoPtr mGeometry; DisplayItemClip mClip; @@ -592,7 +592,7 @@ protected: * layer, then this stores the layer manager being * used for the inactive transaction. */ - nsRefPtr mInactiveLayerManager; + RefPtr mInactiveLayerManager; uint32_t mContainerLayerGeneration; @@ -699,7 +699,7 @@ protected: /** * The root prescontext for the display list builder reference frame */ - nsRefPtr mRootPresContext; + RefPtr mRootPresContext; /** * The display list builder being used. diff --git a/layout/base/GeometryUtils.cpp b/layout/base/GeometryUtils.cpp index eacd02247c..20b9363fbc 100644 --- a/layout/base/GeometryUtils.cpp +++ b/layout/base/GeometryUtils.cpp @@ -164,7 +164,7 @@ GetBoxRectForFrame(nsIFrame** aFrame, CSSBoxType aType) class AccumulateQuadCallback : public nsLayoutUtils::BoxCallback { public: AccumulateQuadCallback(nsISupports* aParentObject, - nsTArray >& aResult, + nsTArray >& aResult, nsIFrame* aRelativeToFrame, const nsPoint& aRelativeToBoxTopLeft, CSSBoxType aBoxType) @@ -202,7 +202,7 @@ public: } nsISupports* mParentObject; - nsTArray >& mResult; + nsTArray >& mResult; nsIFrame* mRelativeToFrame; nsPoint mRelativeToBoxTopLeft; CSSBoxType mBoxType; @@ -241,7 +241,7 @@ CheckFramesInSameTopLevelBrowsingContext(nsIFrame* aFrame1, nsIFrame* aFrame2) void GetBoxQuads(nsINode* aNode, const dom::BoxQuadOptions& aOptions, - nsTArray >& aResult, + nsTArray >& aResult, ErrorResult& aRv) { nsIFrame* frame = GetFrameForNode(aNode); @@ -341,7 +341,7 @@ ConvertQuadFromNode(nsINode* aTo, dom::DOMQuad& aQuad, if (aRv.Failed()) { return nullptr; } - nsRefPtr result = new DOMQuad(aTo->GetParentObject().mObject, points); + RefPtr result = new DOMQuad(aTo->GetParentObject().mObject, points); return result.forget(); } @@ -361,7 +361,7 @@ ConvertRectFromNode(nsINode* aTo, dom::DOMRectReadOnly& aRect, if (aRv.Failed()) { return nullptr; } - nsRefPtr result = new DOMQuad(aTo->GetParentObject().mObject, points); + RefPtr result = new DOMQuad(aTo->GetParentObject().mObject, points); return result.forget(); } @@ -380,7 +380,7 @@ ConvertPointFromNode(nsINode* aTo, const dom::DOMPointInit& aPoint, if (aRv.Failed()) { return nullptr; } - nsRefPtr result = new DOMPoint(aTo->GetParentObject().mObject, point.x, point.y); + RefPtr result = new DOMPoint(aTo->GetParentObject().mObject, point.x, point.y); return result.forget(); } diff --git a/layout/base/GeometryUtils.h b/layout/base/GeometryUtils.h index 5cefbafd17..d01e631692 100644 --- a/layout/base/GeometryUtils.h +++ b/layout/base/GeometryUtils.h @@ -39,7 +39,7 @@ typedef dom::OwningTextOrElementOrDocument OwningGeometryNode; */ void GetBoxQuads(nsINode* aNode, const dom::BoxQuadOptions& aOptions, - nsTArray >& aResult, + nsTArray >& aResult, ErrorResult& aRv); already_AddRefed diff --git a/layout/base/MaskLayerImageCache.h b/layout/base/MaskLayerImageCache.h index c0536571d3..74c5750c69 100644 --- a/layout/base/MaskLayerImageCache.h +++ b/layout/base/MaskLayerImageCache.h @@ -270,7 +270,7 @@ protected: } nsAutoPtr mKey; - nsRefPtr mContainer; + RefPtr mContainer; }; nsTHashtable mMaskImageContainers; diff --git a/layout/base/PositionedEventTargeting.cpp b/layout/base/PositionedEventTargeting.cpp index a280056724..40e1133c75 100644 --- a/layout/base/PositionedEventTargeting.cpp +++ b/layout/base/PositionedEventTargeting.cpp @@ -413,7 +413,7 @@ IsElementClickableAndReadable(nsIFrame* aFrame, WidgetGUIEvent* aEvent, const Ev (pc->AppUnitsToGfxUnits(frameSize.width) * cumulativeResolution) < limitReadableSize) { return false; } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(aFrame)); if (fm) { diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 0c43d8c199..74c4844760 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1014,7 +1014,7 @@ RestyleManager::RestyleElement(Element* aElement, !mInRebuildAllStyleData) { nsStyleContext *oldContext = aPrimaryFrame->StyleContext(); if (!oldContext->GetParent()) { // check that we're the root element - nsRefPtr newContext = mPresContext->StyleSet()-> + RefPtr newContext = mPresContext->StyleSet()-> ResolveStyleFor(aElement, nullptr /* == oldContext->GetParent() */); if (oldContext->StyleFont()->mFont.size != newContext->StyleFont()->mFont.size) { @@ -1100,7 +1100,7 @@ RestyleManager::AnimationsWithDestroyedFrame::StopAnimationsForElementsWithoutFr void RestyleManager::AnimationsWithDestroyedFrame::StopAnimationsWithoutFrame( - nsTArray>& aArray, + nsTArray>& aArray, nsCSSPseudoElements::Type aPseudoType) { nsAnimationManager* animationManager = @@ -1628,7 +1628,7 @@ RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint, } // Make sure that the viewmanager will outlive the presshell - nsRefPtr vm = presShell->GetViewManager(); + RefPtr vm = presShell->GetViewManager(); // We may reconstruct frames below and hence process anything that is in the // tree. We don't want to get notified to process those items again after. @@ -2116,7 +2116,7 @@ RestyleManager::DebugVerifyStyleTree(nsIFrame* aFrame) RestyleManager::TryStartingTransition(nsPresContext* aPresContext, nsIContent* aContent, nsStyleContext* aOldStyleContext, - nsRefPtr* + RefPtr* aNewStyleContext /* inout */) { if (!aContent || !aContent->IsElement()) { @@ -2125,7 +2125,7 @@ RestyleManager::TryStartingTransition(nsPresContext* aPresContext, // Notify the transition manager. If it starts a transition, // it might modify the new style context. - nsRefPtr sc = *aNewStyleContext; + RefPtr sc = *aNewStyleContext; aPresContext->TransitionManager()->StyleContextChanged( aContent->AsElement(), aOldStyleContext, aNewStyleContext); return *aNewStyleContext != sc; @@ -2351,7 +2351,7 @@ RestyleManager::ReparentStyleContext(nsIFrame* aFrame) // tree has already been changed, so this check would just fail. nsStyleContext* oldContext = aFrame->StyleContext(); - nsRefPtr newContext; + RefPtr newContext; nsIFrame* providerFrame; nsStyleContext* newParentContext = aFrame->GetParentStyleContext(&providerFrame); bool isChild = providerFrame && providerFrame->GetParent() == aFrame; @@ -2493,7 +2493,7 @@ RestyleManager::ReparentStyleContext(nsIFrame* aFrame) for (nsStyleContext* oldExtraContext; (oldExtraContext = aFrame->GetAdditionalStyleContext(contextIndex)); ++contextIndex) { - nsRefPtr newExtraContext; + RefPtr newExtraContext; newExtraContext = mPresContext->StyleSet()-> ReparentStyleContext(oldExtraContext, newContext, nullptr); @@ -2541,7 +2541,7 @@ ElementRestyler::ElementRestyler(nsPresContext* aPresContext, nsTArray& aVisibleKidsOfHiddenElement, nsTArray& aContextsToClear, - nsTArray>& + nsTArray>& aSwappedStructOwners) : mPresContext(aPresContext) , mFrame(aFrame) @@ -2665,7 +2665,7 @@ ElementRestyler::ElementRestyler(nsPresContext* aPresContext, nsTArray& aVisibleKidsOfHiddenElement, nsTArray& aContextsToClear, - nsTArray>& + nsTArray>& aSwappedStructOwners) : mPresContext(aPresContext) , mFrame(nullptr) @@ -3214,7 +3214,7 @@ ElementRestyler::Restyle(nsRestyleHint aRestyleHint) // restyle. Before we return from this function, we call // RestyleTracker::AddRestyleRootsIfAwaitingRestyle to ensure they get // restyled in RestyleTracker::DoProcessRestyles. - nsTArray> descendants; + nsTArray> descendants; nsRestyleHint hintToRestore = nsRestyleHint(0); RestyleHintData hintDataToRestore; @@ -3256,7 +3256,7 @@ ElementRestyler::Restyle(nsRestyleHint aRestyleHint) eRestyle_Subtree | eRestyle_ForceDescendants)); - nsRefPtr oldContext = mFrame->StyleContext(); + RefPtr oldContext = mFrame->StyleContext(); nsTArray swaps; @@ -3755,7 +3755,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, ComputeRestyleResultFromFrame(aSelf, result, canStopWithStyleChange); nsChangeHint assumeDifferenceHint = NS_STYLE_HINT_NONE; - nsRefPtr oldContext = aSelf->StyleContext(); + RefPtr oldContext = aSelf->StyleContext(); nsStyleSet* styleSet = mPresContext->StyleSet(); #ifdef ACCESSIBILITY @@ -3814,7 +3814,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, LOG_RESTYLE("parentContext = %p", parentContext); // do primary context - nsRefPtr newContext; + RefPtr newContext; nsIFrame *prevContinuation = GetPrevContinuationWithPossiblySameStyle(aSelf); nsStyleContext *prevContinuationContext; @@ -4154,7 +4154,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, ++contextIndex) { LOG_RESTYLE("extra context %d", contextIndex); LOG_RESTYLE_INDENT(); - nsRefPtr newExtraContext; + RefPtr newExtraContext; nsIAtom* const extraPseudoTag = oldExtraContext->GetPseudo(); const nsCSSPseudoElements::Type extraPseudoType = oldExtraContext->GetPseudoType(); @@ -4342,7 +4342,7 @@ ElementRestyler::ComputeStyleChangeFor(nsIFrame* aFrame, const RestyleHintData& aRestyleHintData, nsTArray& aContextsToClear, - nsTArray>& + nsTArray>& aSwappedStructOwners) { nsIContent* content = aFrame->GetContent(); @@ -4503,7 +4503,7 @@ ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint, thisChildHint = nsRestyleHint(thisChildHint | undisplayedRestyleData->mRestyleHint); } - nsRefPtr undisplayedContext; + RefPtr undisplayedContext; nsStyleSet* styleSet = mPresContext->StyleSet(); if (MustRestyleSelf(thisChildHint, element)) { undisplayedContext = @@ -4826,7 +4826,7 @@ RestyleManager::ComputeAndProcessStyleChange(nsIFrame* aFrame, // swappedStructOwners needs to be kept alive until after // ProcessRestyledFrames and ClearCachedInheritedStyleDataOnDescendants // calls; see comment in ElementRestyler::Restyle. - nsTArray> swappedStructOwners; + nsTArray> swappedStructOwners; ElementRestyler::ComputeStyleChangeFor(aFrame, &changeList, aMinChange, aRestyleTracker, aRestyleHint, aRestyleHintData, @@ -4863,7 +4863,7 @@ RestyleManager::ComputeAndProcessStyleChange(nsStyleContext* aNewContext, // swappedStructOwners needs to be kept alive until after // ProcessRestyledFrames and ClearCachedInheritedStyleDataOnDescendants // calls; see comment in ElementRestyler::Restyle. - nsTArray> swappedStructOwners; + nsTArray> swappedStructOwners; nsStyleChangeList changeList; ElementRestyler r(frame->PresContext(), aElement, &changeList, aMinChange, aRestyleTracker, selectorsForDescendants, treeMatchContext, diff --git a/layout/base/RestyleManager.h b/layout/base/RestyleManager.h index 96d64427a6..21dbb85462 100644 --- a/layout/base/RestyleManager.h +++ b/layout/base/RestyleManager.h @@ -251,7 +251,7 @@ public: static bool TryStartingTransition(nsPresContext* aPresContext, nsIContent* aContent, nsStyleContext* aOldStyleContext, - nsRefPtr* aNewStyleContext /* inout */); + RefPtr* aNewStyleContext /* inout */); // AnimationsWithDestroyedFrame is used to stop animations on elements that // have no frame at the end of the restyling process. @@ -287,7 +287,7 @@ public: void StopAnimationsForElementsWithoutFrames(); private: - void StopAnimationsWithoutFrame(nsTArray>& aArray, + void StopAnimationsWithoutFrame(nsTArray>& aArray, nsCSSPseudoElements::Type aPseudoType); RestyleManager* mRestyleManager; @@ -299,9 +299,9 @@ public: // mBeforeContents and mAfterContents hold the real element rather than // the content node for the generated content (which might change during // a reframe) - nsTArray> mContents; - nsTArray> mBeforeContents; - nsTArray> mAfterContents; + nsTArray> mContents; + nsTArray> mBeforeContents; + nsTArray> mAfterContents; }; /** @@ -586,7 +586,7 @@ public: typedef mozilla::dom::Element Element; struct ContextToClear { - nsRefPtr mStyleContext; + RefPtr mStyleContext; uint32_t mStructs; }; @@ -600,7 +600,7 @@ public: TreeMatchContext& aTreeMatchContext, nsTArray& aVisibleKidsOfHiddenElement, nsTArray& aContextsToClear, - nsTArray>& aSwappedStructOwners); + nsTArray>& aSwappedStructOwners); // Construct for an element whose parent is being restyled. enum ConstructorFlags { @@ -631,7 +631,7 @@ public: TreeMatchContext& aTreeMatchContext, nsTArray& aVisibleKidsOfHiddenElement, nsTArray& aContextsToClear, - nsTArray>& aSwappedStructOwners); + nsTArray>& aSwappedStructOwners); /** * Restyle our frame's element and its subtree. @@ -676,7 +676,7 @@ public: nsRestyleHint aRestyleHint, const RestyleHintData& aRestyleHintData, nsTArray& aContextsToClear, - nsTArray>& + nsTArray>& aSwappedStructOwners); #ifdef RESTYLE_LOGGING @@ -709,8 +709,8 @@ private: struct SwapInstruction { - nsRefPtr mOldContext; - nsRefPtr mNewContext; + RefPtr mOldContext; + RefPtr mNewContext; uint32_t mStructsToSwap; }; @@ -890,7 +890,7 @@ private: // Style contexts that had old structs swapped into it and which should // stay alive until the end of the restyle. (See comment in // ElementRestyler::Restyle.) - nsTArray>& mSwappedStructOwners; + nsTArray>& mSwappedStructOwners; // Whether this is the root of the restyle. bool mIsRootOfRestyle; diff --git a/layout/base/RestyleTracker.cpp b/layout/base/RestyleTracker.cpp index 9dffeba33e..ed1bbe1d0a 100644 --- a/layout/base/RestyleTracker.cpp +++ b/layout/base/RestyleTracker.cpp @@ -58,7 +58,7 @@ RestyleTracker::Document() const { struct LaterSiblingCollector { RestyleTracker* tracker; - nsTArray< nsRefPtr >* elements; + nsTArray< RefPtr >* elements; }; static PLDHashOperator @@ -84,7 +84,7 @@ CollectLaterSiblings(nsISupports* aElement, } struct RestyleEnumerateData : RestyleTracker::Hints { - nsRefPtr mElement; + RefPtr mElement; #if defined(MOZ_ENABLE_PROFILER_SPS) && !defined(MOZILLA_XPCOMRT_API) UniquePtr mBacktrace; #endif @@ -267,7 +267,7 @@ RestyleTracker::DoProcessRestyles() while (mPendingRestyles.Count()) { if (mHaveLaterSiblingRestyles) { // Convert them to individual restyles on all the later siblings - nsAutoTArray, RESTYLE_ARRAY_STACKSIZE> laterSiblingArr; + nsAutoTArray, RESTYLE_ARRAY_STACKSIZE> laterSiblingArr; LaterSiblingCollector siblingCollector = { this, &laterSiblingArr }; mPendingRestyles.Enumerate(CollectLaterSiblings, &siblingCollector); for (uint32_t i = 0; i < laterSiblingArr.Length(); ++i) { @@ -315,7 +315,7 @@ RestyleTracker::DoProcessRestyles() // Make sure to pop the element off our restyle root array, so // that we can freely append to the array as we process this // element. - nsRefPtr element; + RefPtr element; element.swap(mRestyleRoots[rootCount - 1]); mRestyleRoots.RemoveElementAt(rootCount - 1); @@ -464,7 +464,7 @@ RestyleTracker::GetRestyleData(Element* aElement, nsAutoPtr& aData) void RestyleTracker::AddRestyleRootsIfAwaitingRestyle( - const nsTArray>& aElements) + const nsTArray>& aElements) { // The RestyleData for a given element has stored in mDescendants // the list of descendants we need to end up restyling. Since we diff --git a/layout/base/RestyleTracker.h b/layout/base/RestyleTracker.h index bb7bcd2bdc..fa56cf9dfe 100644 --- a/layout/base/RestyleTracker.h +++ b/layout/base/RestyleTracker.h @@ -318,7 +318,7 @@ public: // with the same invariant as mRestyleRoots. The elements here are those // that we called AddPendingRestyle for and found the element this is // the RestyleData for as its nearest restyle root. - nsTArray> mDescendants; + nsTArray> mDescendants; #if defined(MOZ_ENABLE_PROFILER_SPS) && !defined(MOZILLA_XPCOMRT_API) UniquePtr mBacktrace; #endif @@ -357,7 +357,7 @@ public: * ancestors appear after descendants. */ void AddRestyleRootsIfAwaitingRestyle( - const nsTArray>& aElements); + const nsTArray>& aElements); /** * Converts any eRestyle_SomeDescendants restyle hints in the pending restyle @@ -394,7 +394,7 @@ private: const RestyleHintData& aRestyleHintData); typedef nsClassHashtable PendingRestyleTable; - typedef nsAutoTArray< nsRefPtr, 32> RestyleRootArray; + typedef nsAutoTArray< RefPtr, 32> RestyleRootArray; // Our restyle bits. These will be a subset of ELEMENT_ALL_RESTYLE_FLAGS, and // will include one flag from ELEMENT_PENDING_RESTYLE_FLAGS, one flag // from ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS, and might also include diff --git a/layout/base/SelectionCarets.cpp b/layout/base/SelectionCarets.cpp index 956bbd7300..0293cefa6f 100644 --- a/layout/base/SelectionCarets.cpp +++ b/layout/base/SelectionCarets.cpp @@ -136,7 +136,7 @@ SelectionCarets::~SelectionCarets() void SelectionCarets::Terminate() { - nsRefPtr docShell(mDocShell.get()); + RefPtr docShell(mDocShell.get()); if (docShell) { docShell->RemoveWeakReflowObserver(this); docShell->RemoveWeakScrollObserver(this); @@ -413,7 +413,7 @@ FindFirstNodeWithFrame(nsIDocument* aDocument, } ErrorResult err; - nsRefPtr walker = + RefPtr walker = aDocument->CreateTreeWalker(*startNode, nsIDOMNodeFilter::SHOW_ALL, nullptr, @@ -448,7 +448,7 @@ SelectionCarets::UpdateSelectionCarets() return; } - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { SELECTIONCARETS_LOG("Cannot get selection!"); SetVisibility(false); @@ -462,8 +462,8 @@ SelectionCarets::UpdateSelectionCarets() } int32_t rangeCount = selection->RangeCount(); - nsRefPtr firstRange = selection->GetRangeAt(0); - nsRefPtr lastRange = selection->GetRangeAt(rangeCount - 1); + RefPtr firstRange = selection->GetRangeAt(0); + RefPtr lastRange = selection->GetRangeAt(rangeCount - 1); nsIFrame* rootFrame = mPresShell->GetRootFrame(); @@ -473,7 +473,7 @@ SelectionCarets::UpdateSelectionCarets() } // Check start and end frame is rtl or ltr text - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { SetVisibility(false); return; @@ -642,7 +642,7 @@ SelectionCarets::SelectWord() SetSelectionDragState(false); // Clear maintain selection otherwise we cannot select less than a word - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (fs) { fs->MaintainSelection(); } @@ -735,7 +735,7 @@ SelectionCarets::DragSelection(const nsPoint &movePoint) return nsEventStatus_eConsumeNoDefault; } - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { return nsEventStatus_eConsumeNoDefault; } @@ -762,7 +762,7 @@ SelectionCarets::DragSelection(const nsPoint &movePoint) return nsEventStatus_eConsumeNoDefault; } - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { return nsEventStatus_eConsumeNoDefault; } @@ -774,7 +774,7 @@ SelectionCarets::DragSelection(const nsPoint &movePoint) // Limit the drag behavior not to cross the end of last selection range // when drag the start frame and vice versa - nsRefPtr range = mDragMode == START_FRAME ? + RefPtr range = mDragMode == START_FRAME ? selection->GetRangeAt(rangeCount - 1) : selection->GetRangeAt(0); if (!CompareRangeWithContentOffset(range, fs, offsets, mDragMode)) { return nsEventStatus_eConsumeNoDefault; @@ -821,7 +821,7 @@ SelectionCarets::GetCaretYCenterPosition() return 0; } - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (!selection) { return 0; } @@ -831,7 +831,7 @@ SelectionCarets::GetCaretYCenterPosition() return 0; } - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (!fs) { return 0; } @@ -840,11 +840,11 @@ SelectionCarets::GetCaretYCenterPosition() nsCOMPtr node; uint32_t nodeOffset; if (mDragMode == START_FRAME) { - nsRefPtr range = selection->GetRangeAt(0); + RefPtr range = selection->GetRangeAt(0); node = do_QueryInterface(range->GetStartParent()); nodeOffset = range->StartOffset(); } else { - nsRefPtr range = selection->GetRangeAt(rangeCount - 1); + RefPtr range = selection->GetRangeAt(rangeCount - 1); node = do_QueryInterface(range->GetEndParent()); nodeOffset = range->EndOffset(); } @@ -866,7 +866,7 @@ SelectionCarets::GetCaretYCenterPosition() void SelectionCarets::SetSelectionDragState(bool aState) { - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (fs) { fs->SetDragState(aState); } @@ -875,7 +875,7 @@ SelectionCarets::SetSelectionDragState(bool aState) void SelectionCarets::SetSelectionDirection(nsDirection aDir) { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (selection) { selection->AdjustAnchorFocusForMultiRange(aDir); } @@ -979,7 +979,7 @@ SelectionCarets::GetFocusedContent() Selection* SelectionCarets::GetSelection() { - nsRefPtr fs = GetFrameSelection(); + RefPtr fs = GetFrameSelection(); if (fs) { return fs->GetSelection(nsISelectionController::SELECTION_NORMAL); } @@ -998,7 +998,7 @@ SelectionCarets::GetFrameSelection() // Prevent us from touching the nsFrameSelection associated to other // PresShell. - nsRefPtr fs = focusFrame->GetFrameSelection(); + RefPtr fs = focusFrame->GetFrameSelection(); if (!fs || fs->GetShell() != mPresShell) { return nullptr; } @@ -1076,7 +1076,7 @@ SelectionCarets::DispatchSelectionStateChangedEvent(Selection* aSelection, // XXX: Do we need to flush layout? mPresShell->FlushPendingNotifications(Flush_Layout); nsRect rect = nsContentUtils::GetSelectionBoundingRect(aSelection); - nsRefPtrdomRect = new DOMRect(ToSupports(doc)); + RefPtrdomRect = new DOMRect(ToSupports(doc)); domRect->SetLayoutRect(rect); init.mBoundingClientRect = domRect; @@ -1086,7 +1086,7 @@ SelectionCarets::DispatchSelectionStateChangedEvent(Selection* aSelection, } init.mStates = aStates; - nsRefPtr event = + RefPtr event = SelectionStateChangedEvent::Constructor(doc, NS_LITERAL_STRING("mozselectionstatechanged"), init); event->SetTrusted(true); @@ -1177,7 +1177,7 @@ DispatchScrollViewChangeEvent(nsIPresShell *aPresShell, const dom::ScrollState a detail.mBubbles = true; detail.mCancelable = false; detail.mState = aState; - nsRefPtr event = + RefPtr event = ScrollViewChangeEvent::Constructor(doc, NS_LITERAL_STRING("scrollviewchange"), detail); event->SetTrusted(true); @@ -1199,7 +1199,7 @@ SelectionCarets::AsyncPanZoomStarted() SELECTIONCARETS_LOG("Dispatch scroll started"); DispatchScrollViewChangeEvent(mPresShell, dom::ScrollState::Started); } else { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (selection && selection->RangeCount() && selection->IsCollapsed()) { mInAsyncPanZoomGesture = true; DispatchScrollViewChangeEvent(mPresShell, dom::ScrollState::Started); @@ -1251,7 +1251,7 @@ SelectionCarets::ScrollPositionChanged() } } } else { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (selection && selection->RangeCount() && selection->IsCollapsed()) { DispatchSelectionStateChangedEvent(selection, SelectionState::Updateposition); @@ -1299,7 +1299,7 @@ SelectionCarets::CancelLongTapDetector() /* static */void SelectionCarets::FireLongTap(nsITimer* aTimer, void* aSelectionCarets) { - nsRefPtr self = static_cast(aSelectionCarets); + RefPtr self = static_cast(aSelectionCarets); NS_PRECONDITION(aTimer == self->mLongTapDetectorTimer, "Unexpected timer"); @@ -1343,7 +1343,7 @@ SelectionCarets::CancelScrollEndDetector() /* static */void SelectionCarets::FireScrollEnd(nsITimer* aTimer, void* aSelectionCarets) { - nsRefPtr self = static_cast(aSelectionCarets); + RefPtr self = static_cast(aSelectionCarets); NS_PRECONDITION(aTimer == self->mScrollEndDetectorTimer, "Unexpected timer"); @@ -1367,7 +1367,7 @@ SelectionCarets::Reflow(DOMHighResTimeStamp aStart, DOMHighResTimeStamp aEnd) SelectionState::Updateposition); } } else { - nsRefPtr selection = GetSelection(); + RefPtr selection = GetSelection(); if (selection && selection->RangeCount() && selection->IsCollapsed()) { DispatchSelectionStateChangedEvent(selection, SelectionState::Updateposition); diff --git a/layout/base/TouchCaret.cpp b/layout/base/TouchCaret.cpp index e9fa2500cc..73ed61dfb0 100644 --- a/layout/base/TouchCaret.cpp +++ b/layout/base/TouchCaret.cpp @@ -126,7 +126,7 @@ TouchCaret::Init() void TouchCaret::Terminate() { - nsRefPtr docShell(mDocShell.get()); + RefPtr docShell(mDocShell.get()); if (docShell) { docShell->RemoveWeakScrollObserver(this); } @@ -159,7 +159,7 @@ TouchCaret::GetCaretFocusFrame(nsRect* aOutRect) return nullptr; } - nsRefPtr caret = presShell->GetCaret(); + RefPtr caret = presShell->GetCaret(); if (!caret) { return nullptr; } @@ -337,7 +337,7 @@ TouchCaret::SetTouchFramePos(const nsPoint& aOrigin) } // Convert aOrigin to CSS pixels. - nsRefPtr presContext = presShell->GetPresContext(); + RefPtr presContext = presShell->GetPresContext(); int32_t x = presContext->AppUnitsToIntCSSPixels(aOrigin.x); int32_t y = presContext->AppUnitsToIntCSSPixels(aOrigin.y); @@ -376,7 +376,7 @@ TouchCaret::MoveCaret(const nsPoint& movePoint) // Move caret position. nsWeakFrame weakScrollable = scrollable; - nsRefPtr fs = scrollable->GetFrameSelection(); + RefPtr fs = scrollable->GetFrameSelection(); fs->HandleClick(offsets.content, offsets.StartOffset(), offsets.EndOffset(), false, @@ -415,7 +415,7 @@ TouchCaret::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* aSel, return NS_OK; } - nsRefPtr caret = presShell->GetCaret(); + RefPtr caret = presShell->GetCaret(); if (!caret) { SetVisibility(false); return NS_OK; @@ -529,7 +529,7 @@ TouchCaret::CancelScrollEndDetector() /* static */void TouchCaret::FireScrollEnd(nsITimer* aTimer, void* aTouchCaret) { - nsRefPtr self = static_cast(aTouchCaret); + RefPtr self = static_cast(aTouchCaret); NS_PRECONDITION(aTimer == self->mScrollEndDetectorTimer, "Unexpected timer"); self->UpdatePosition(); @@ -575,7 +575,7 @@ TouchCaret::IsDisplayable() return false; } - nsRefPtr caret = presShell->GetCaret(); + RefPtr caret = presShell->GetCaret(); if (!caret) { TOUCHCARET_LOG("Caret is nullptr!"); return false; @@ -706,7 +706,7 @@ TouchCaret::ClampPositionToScrollFrame(const nsPoint& aPosition) /* static */void TouchCaret::DisableTouchCaretCallback(nsITimer* aTimer, void* aTouchCaret) { - nsRefPtr self = static_cast(aTouchCaret); + RefPtr self = static_cast(aTouchCaret); NS_PRECONDITION(aTimer == self->mTouchCaretExpirationTimer, "Unexpected timer"); @@ -747,7 +747,7 @@ TouchCaret::SetSelectionDragState(bool aState) return; } - nsRefPtr fs = caretFocusFrame->GetFrameSelection(); + RefPtr fs = caretFocusFrame->GetFrameSelection(); fs->SetDragState(aState); } @@ -1122,7 +1122,7 @@ TouchCaret::DispatchTapEvent() return; } - nsRefPtr caret = presShell->GetCaret(); + RefPtr caret = presShell->GetCaret(); if (!caret) { return; } @@ -1142,7 +1142,7 @@ TouchCaret::DispatchTapEvent() // XXX: Do we need to flush layout? presShell->FlushPendingNotifications(Flush_Layout); nsRect rect = nsContentUtils::GetSelectionBoundingRect(sel); - nsRefPtrdomRect = new dom::DOMRect(ToSupports(doc)); + RefPtrdomRect = new dom::DOMRect(ToSupports(doc)); domRect->SetLayoutRect(rect); init.mBoundingClientRect = domRect; @@ -1154,7 +1154,7 @@ TouchCaret::DispatchTapEvent() state.AppendElement(dom::SelectionState::Taponcaret, fallible); init.mStates = state; - nsRefPtr event = + RefPtr event = dom::SelectionStateChangedEvent::Constructor(doc, NS_LITERAL_STRING("mozselectionstatechanged"), init); event->SetTrusted(true); diff --git a/layout/base/TouchManager.cpp b/layout/base/TouchManager.cpp index 4541cbf674..2f5d961c0f 100644 --- a/layout/base/TouchManager.cpp +++ b/layout/base/TouchManager.cpp @@ -42,7 +42,7 @@ TouchManager::Destroy() } static void -EvictTouchPoint(nsRefPtr& aTouch, +EvictTouchPoint(RefPtr& aTouch, nsIDocument* aLimitToDocument = nullptr) { nsCOMPtr node(do_QueryInterface(aTouch->mTarget)); @@ -75,7 +75,7 @@ EvictTouchPoint(nsRefPtr& aTouch, } static PLDHashOperator -AppendToTouchList(const uint32_t& aKey, nsRefPtr& aData, void *aTouchList) +AppendToTouchList(const uint32_t& aKey, RefPtr& aData, void *aTouchList) { WidgetTouchEvent::TouchArray* touches = static_cast(aTouchList); @@ -142,7 +142,7 @@ TouchManager::PreHandleEvent(WidgetEvent* aEvent, int32_t id = touch->Identifier(); touch->mMessage = aEvent->mMessage; - nsRefPtr oldTouch = gCaptureTouchList->GetWeak(id); + RefPtr oldTouch = gCaptureTouchList->GetWeak(id); if (!oldTouch) { touches.RemoveElementAt(i); continue; @@ -207,7 +207,7 @@ TouchManager::PreHandleEvent(WidgetEvent* aEvent, touch->mChanged = true; int32_t id = touch->Identifier(); - nsRefPtr oldTouch = gCaptureTouchList->GetWeak(id); + RefPtr oldTouch = gCaptureTouchList->GetWeak(id); if (!oldTouch) { continue; } diff --git a/layout/base/TouchManager.h b/layout/base/TouchManager.h index f4df96c3f2..389b379b42 100644 --- a/layout/base/TouchManager.h +++ b/layout/base/TouchManager.h @@ -36,7 +36,7 @@ public: private: void EvictTouches(); - nsRefPtr mPresShell; + RefPtr mPresShell; nsCOMPtr mDocument; }; diff --git a/layout/base/gtest/TestAccessibleCaretEventHub.cpp b/layout/base/gtest/TestAccessibleCaretEventHub.cpp index 4ccd753672..d2dcee143c 100644 --- a/layout/base/gtest/TestAccessibleCaretEventHub.cpp +++ b/layout/base/gtest/TestAccessibleCaretEventHub.cpp @@ -154,7 +154,7 @@ public: float rotationAngle = 0; float force = 1; - nsRefPtr touch( + RefPtr touch( new dom::Touch(identifier, point, radius, rotationAngle, force)); event->touches.AppendElement(touch); @@ -234,7 +234,7 @@ public: ReleaseEventCreator aReleaseEventCreator); // Member variables - nsRefPtr mHub{new MockAccessibleCaretEventHub()}; + RefPtr mHub{new MockAccessibleCaretEventHub()}; }; // class AccessibleCaretEventHubTester diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index cd116d2a65..ee1742bb50 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -726,7 +726,7 @@ struct PendingBinding : public LinkedListElement } #endif - nsRefPtr mBinding; + RefPtr mBinding; }; // Structure used for maintaining state information during the @@ -1546,10 +1546,10 @@ struct nsGenConInitializer { already_AddRefed nsCSSFrameConstructor::CreateGenConTextNode(nsFrameConstructorState& aState, const nsString& aString, - nsRefPtr* aText, + RefPtr* aText, nsGenConInitializer* aInitializer) { - nsRefPtr content = new nsTextNode(mDocument->NodeInfoManager()); + RefPtr content = new nsTextNode(mDocument->NodeInfoManager()); content->SetText(aString, false); if (aText) { *aText = content; @@ -1583,7 +1583,7 @@ nsCSSFrameConstructor::CreateGeneratedContent(nsFrameConstructorState& aState, // Create an image content object and pass it the image request. // XXX Check if it's an image type we can handle... - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = mDocument->NodeInfoManager()-> GetNodeInfo(nsGkAtoms::mozgeneratedcontentimage, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE); @@ -1751,7 +1751,7 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat nsStyleSet *styleSet = mPresShell->StyleSet(); // Probe for the existence of the pseudo-element - nsRefPtr pseudoStyleContext; + RefPtr pseudoStyleContext; pseudoStyleContext = styleSet->ProbePseudoElementStyle(aParentContent->AsElement(), aPseudoElement, @@ -1764,7 +1764,7 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat // |ProbePseudoStyleFor| checked the 'display' property and the // |ContentCount()| of the 'content' property for us. - nsRefPtr nodeInfo; + RefPtr nodeInfo; nsIAtom* elemName = isBefore ? nsGkAtoms::mozgeneratedcontentbefore : nsGkAtoms::mozgeneratedcontentafter; nodeInfo = mDocument->NodeInfoManager()->GetNodeInfo(elemName, nullptr, @@ -1984,7 +1984,7 @@ nsCSSFrameConstructor::ConstructTable(nsFrameConstructorState& aState, const uint32_t nameSpaceID = aItem.mNameSpaceID; // create the pseudo SC for the outer table as a child of the inner SC - nsRefPtr outerStyleContext; + RefPtr outerStyleContext; outerStyleContext = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::tableOuter, styleContext); @@ -2202,7 +2202,7 @@ nsCSSFrameConstructor::ConstructTableCell(nsFrameConstructorState& aState, InitAndRestoreFrame(aState, content, aParentFrame, newFrame); // Resolve pseudo style and initialize the body cell frame - nsRefPtr innerPseudoStyle; + RefPtr innerPseudoStyle; innerPseudoStyle = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::cellContent, styleContext); @@ -2309,7 +2309,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // by a new root element style (e.g. a propagated 'direction'). // @see nsStyleContext::ApplyStyleFixups { - nsRefPtr sc = mPresShell->StyleSet()-> + RefPtr sc = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::viewport, nullptr); GetRootFrame()->SetStyleContextWithoutNotification(sc); } @@ -2350,7 +2350,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // FIXME: Should this use ResolveStyleContext? (The calls in this // function are the only case in nsCSSFrameConstructor where we don't // do so for the construction of a style context for an element.) - nsRefPtr styleContext; + RefPtr styleContext; styleContext = mPresShell->StyleSet()->ResolveStyleFor(aDocElement, nullptr); @@ -2367,7 +2367,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle return nullptr; } - nsRefPtr binding; + RefPtr binding; rv = xblService->LoadBindings(aDocElement, display->mBinding->GetURI(), display->mBinding->mOriginPrincipal, getter_AddRefs(binding), &resolveStyle); @@ -2459,7 +2459,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // Use a null PendingBinding, since our binding is not in fact pending. static const FrameConstructionData rootSVGData = FCDATA_DECL(0, nullptr); already_AddRefed extraRef = - nsRefPtr(styleContext).forget(); + RefPtr(styleContext).forget(); FrameConstructionItem item(&rootSVGData, aDocElement, aDocElement->NodeInfo()->NameAtom(), kNameSpaceID_SVG, nullptr, extraRef, true, @@ -2495,7 +2495,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // Use a null PendingBinding, since our binding is not in fact pending. static const FrameConstructionData rootTableData = FCDATA_DECL(0, nullptr); already_AddRefed extraRef = - nsRefPtr(styleContext).forget(); + RefPtr(styleContext).forget(); FrameConstructionItem item(&rootTableData, aDocElement, aDocElement->NodeInfo()->NameAtom(), kNameSpaceID_None, nullptr, extraRef, true, @@ -2588,7 +2588,7 @@ nsCSSFrameConstructor::ConstructRootFrame() } // --------- BUILD VIEWPORT ----------- - nsRefPtr viewportPseudoStyle = + RefPtr viewportPseudoStyle = styleSet->ResolveAnonymousBoxStyle(nsCSSAnonBoxes::viewport, nullptr); ViewportFrame* viewportFrame = NS_NewViewportFrame(mPresShell, viewportPseudoStyle); @@ -2741,7 +2741,7 @@ nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement) "XUL documents should never be scrollable - see above"); nsContainerFrame* newFrame = rootFrame; - nsRefPtr rootPseudoStyle; + RefPtr rootPseudoStyle; // we must create a state because if the scrollbars are GFX it needs the // state to build the scrollbar frames. nsFrameConstructorState state(mPresShell, nullptr, nullptr, nullptr); @@ -2769,7 +2769,7 @@ nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement) // created. // resolve a context for the scrollframe - nsRefPtr styleContext; + RefPtr styleContext; styleContext = styleSet->ResolveAnonymousBoxStyle(nsCSSAnonBoxes::viewportScroll, viewportPseudoStyle); @@ -2854,7 +2854,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, nsStyleContext* parentStyleContext = aParentFrame->StyleContext(); nsStyleSet *styleSet = aPresShell->StyleSet(); - nsRefPtr pagePseudoStyle; + RefPtr pagePseudoStyle; pagePseudoStyle = styleSet->ResolveAnonymousBoxStyle(nsCSSAnonBoxes::page, parentStyleContext); @@ -2864,7 +2864,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, // the pages easier and faster. pageFrame->Init(nullptr, aParentFrame, aPrevPageFrame); - nsRefPtr pageContentPseudoStyle; + RefPtr pageContentPseudoStyle; pageContentPseudoStyle = styleSet->ResolveAnonymousBoxStyle(nsCSSAnonBoxes::pageContent, pagePseudoStyle); @@ -2885,7 +2885,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, pageContentFrame->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); pageContentFrame->MarkAsAbsoluteContainingBlock(); - nsRefPtr canvasPseudoStyle; + RefPtr canvasPseudoStyle; canvasPseudoStyle = styleSet->ResolveAnonymousBoxStyle(nsCSSAnonBoxes::canvas, pageContentPseudoStyle); @@ -2911,7 +2911,7 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, nsIFrame* aPrevInFlow, nsFrameState aTypeBit) { - nsRefPtr placeholderStyle = aPresShell->StyleSet()-> + RefPtr placeholderStyle = aPresShell->StyleSet()-> ResolveStyleForNonElement(aStyleContext->GetParent()); // The placeholder frame gets a pseudo style context @@ -2989,7 +2989,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState, "doesn't implement nsIComboboxControlFrame"); // Resolve pseudo element style for the dropdown list - nsRefPtr listStyle; + RefPtr listStyle; listStyle = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::dropDownList, styleContext); @@ -3133,7 +3133,7 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState, fieldsetFrame); // Resolve style and initialize the frame - nsRefPtr fieldsetContentStyle; + RefPtr fieldsetContentStyle; fieldsetContentStyle = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::fieldsetContent, styleContext); @@ -3723,7 +3723,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt nsIFrame* maybeAbsoluteContainingBlock = newFrame; nsIFrame* possiblyLeafFrame = newFrame; if (bits & FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS) { - nsRefPtr outerSC = + RefPtr outerSC = mPresShell->StyleSet()->ResolveAnonymousBoxStyle(*data->mAnonBoxPseudo, styleContext); #ifdef DEBUG @@ -3752,7 +3752,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt */ default: { nsContainerFrame* columnSetFrame = nullptr; - nsRefPtr innerSC = outerSC; + RefPtr innerSC = outerSC; const nsStyleColumn* columns = outerSC->StyleColumn(); if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO || columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) { @@ -4373,7 +4373,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsFrameConstructorState& aState, nsFrameItems anonymousItems; - nsRefPtr contentStyle = aContentStyle; + RefPtr contentStyle = aContentStyle; if (!gfxScrollFrame) { // Build a XULScrollFrame when the child is a box, otherwise an @@ -4404,7 +4404,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsFrameConstructorState& aState, // we used the style that was passed in. So resolve another one. nsStyleSet *styleSet = mPresShell->StyleSet(); - nsRefPtr scrolledChildStyle = + RefPtr scrolledChildStyle = styleSet->ResolveAnonymousBoxStyle(aScrolledPseudo, contentStyle); if (gfxScrollFrame) { @@ -4461,7 +4461,7 @@ nsCSSFrameConstructor::BuildScrollFrame(nsFrameConstructorState& aState, nsContainerFrame* aParentFrame, nsContainerFrame*& aNewFrame) { - nsRefPtr scrolledContentStyle = + RefPtr scrolledContentStyle = BeginBuildingScrollFrame(aState, aContent, aContentStyle, aParentFrame, nsCSSAnonBoxes::scrolledContent, false, aNewFrame); @@ -4669,7 +4669,7 @@ nsCSSFrameConstructor::ConstructScrollableBlockWithConstructor( nsStyleContext* const styleContext = aItem.mStyleContext; nsContainerFrame* newFrame = nullptr; - nsRefPtr scrolledContentStyle + RefPtr scrolledContentStyle = BeginBuildingScrollFrame(aState, content, styleContext, aState.GetGeometricParent(aDisplay, aParentFrame), nsCSSAnonBoxes::scrolledContent, @@ -4831,7 +4831,7 @@ nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext, nsStyleSet *styleSet = mPresShell->StyleSet(); aContent->OwnerDoc()->FlushPendingLinkUpdates(); - nsRefPtr result; + RefPtr result; if (aContent->IsElement()) { if (aState) { result = styleSet->ResolveStyleFor(aContent->AsElement(), @@ -4886,7 +4886,7 @@ nsCSSFrameConstructor::FlushAccumulatedBlock(nsFrameConstructorState& aState, nsFrame::CorrectStyleParentFrame(aParentFrame, anonPseudo)->StyleContext(); nsStyleSet* styleSet = mPresShell->StyleSet(); - nsRefPtr blockContext; + RefPtr blockContext; blockContext = styleSet-> ResolveAnonymousBoxStyle(anonPseudo, parentContext); @@ -5012,7 +5012,7 @@ nsCSSFrameConstructor::ConstructFrameWithAnonymousChild( newFrame); // Create the pseudo SC for the anonymous wrapper child as a child of the SC: - nsRefPtr scForAnon; + RefPtr scForAnon; scForAnon = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(aInnerPseudo, styleContext); @@ -5324,7 +5324,7 @@ nsCSSFrameConstructor::AddPageBreakItem(nsIContent* aContent, // that's easier to re-resolve and it doesn't matter in practice. // (Getting different parents can result in framechange hints, e.g., // for user-modify.) - nsRefPtr pseudoStyle = + RefPtr pseudoStyle = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::pageBreak, aMainStyleContext->GetParent()); @@ -5423,7 +5423,7 @@ nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState if (!ShouldCreateItemsForChild(aState, aContent, parentFrame)) { return; } - nsRefPtr styleContext = + RefPtr styleContext = ResolveStyleContext(aInsertion, aContent, &aState); DoAddFrameConstructionItems(aState, aContent, styleContext, aSuppressWhiteSpaceOptimizations, parentFrame, @@ -5475,7 +5475,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState // of an element using XBL. XUL and HTML objects (like boxes, menus, etc.) // can then be extended arbitrarily. const nsStyleDisplay* display = aStyleContext->StyleDisplay(); - nsRefPtr styleContext(aStyleContext); + RefPtr styleContext(aStyleContext); PendingBinding* pendingBinding = nullptr; if ((aFlags & ITEM_ALLOW_XBL_BASE) && display->mBinding) { @@ -5701,7 +5701,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState } } - nsRefPtr childContext = + RefPtr childContext = ResolveStyleContext(styleContext, child, &aState); DoAddFrameConstructionItems(aState, child, childContext, aSuppressWhiteSpaceOptimizations, @@ -6358,7 +6358,7 @@ nsCSSFrameConstructor::IsValidSibling(nsIFrame* aSibling, } // XXXbz when this code is killed, the state argument to // ResolveStyleContext can be made non-optional. - nsRefPtr styleContext = + RefPtr styleContext = ResolveStyleContext(styleParent, aContent, nullptr); const nsStyleDisplay* display = styleContext->StyleDisplay(); aDisplay = display->mDisplay; @@ -9037,7 +9037,7 @@ static bool EqualURIs(mozilla::css::URLValue *aURI1, nsStyleContext* nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement) { - nsRefPtr oldContext = GetUndisplayedContent(aElement); + RefPtr oldContext = GetUndisplayedContent(aElement); uint8_t oldDisplay = NS_STYLE_DISPLAY_NONE; if (!oldContext) { oldContext = GetDisplayContentsStyleFor(aElement); @@ -9048,7 +9048,7 @@ nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement) } // The parent has a frame, so try resolving a new context. - nsRefPtr newContext = mPresShell->StyleSet()-> + RefPtr newContext = mPresShell->StyleSet()-> ResolveStyleFor(aElement, oldContext->GetParent()); if (oldDisplay == NS_STYLE_DISPLAY_NONE) { @@ -10360,7 +10360,7 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent( !content->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION), "Why is someone creating garbage anonymous content"); - nsRefPtr styleContext; + RefPtr styleContext; TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper parentDisplayBasedStyleFixupSkipper(aState.mTreeMatchContext); if (aAnonymousItems[i].mStyleContext) { @@ -10570,7 +10570,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState, params, ArrayLength(params)); } - nsRefPtr blockSC = mPresShell->StyleSet()-> + RefPtr blockSC = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozXULAnonymousBlock, frameStyleContext); nsBlockFrame* blockFrame = NS_NewBlockFrame(mPresShell, blockSC); @@ -10633,7 +10633,7 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame( nsFrame::CorrectStyleParentFrame(aBlockFrame, nsCSSPseudoElements::firstLine)-> StyleContext(); - nsRefPtr firstLineStyle = GetFirstLineStyle(aBlockContent, + RefPtr firstLineStyle = GetFirstLineStyle(aBlockContent, parentStyle); aLineFrame = NS_NewFirstLineFrame(mPresShell, firstLineStyle); @@ -10753,7 +10753,7 @@ nsCSSFrameConstructor::InsertFirstLineFrames( nsFrame::CorrectStyleParentFrame(aBlockFrame, nsCSSPseudoElements::firstLine)-> StyleContext(); - nsRefPtr firstLineStyle = + RefPtr firstLineStyle = GetFirstLineStyle(aContent, parentStyle); // Initialize the line frame @@ -10932,7 +10932,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // get a proper style context for it (the one passed in is for the // letter frame and will have the float property set on it; the text // frame shouldn't have that set). - nsRefPtr textSC; + RefPtr textSC; nsStyleSet* styleSet = mPresShell->StyleSet(); textSC = styleSet->ResolveStyleForNonElement(aStyleContext); aTextFrame->SetStyleContextWithoutNotification(textSC); @@ -10952,7 +10952,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // Repair the continuations style context nsStyleContext* parentStyleContext = aStyleContext->GetParent(); if (parentStyleContext) { - nsRefPtr newSC; + RefPtr newSC; newSC = styleSet->ResolveStyleForNonElement(parentStyleContext); nextTextFrame->SetStyleContext(newSC); } @@ -11003,10 +11003,10 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame, nsIContent* blockContent = aBlockFrame->GetContent(); // Create first-letter style rule - nsRefPtr sc = GetFirstLetterStyle(blockContent, + RefPtr sc = GetFirstLetterStyle(blockContent, parentStyleContext); if (sc) { - nsRefPtr textSC; + RefPtr textSC; textSC = mPresShell->StyleSet()->ResolveStyleForNonElement(sc); // Create a new text frame (the original one will be discarded) @@ -11208,7 +11208,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( if (!textContent) { return NS_OK; } - nsRefPtr newSC; + RefPtr newSC; newSC = aPresShell->StyleSet()->ResolveStyleForNonElement(parentSC); nsIFrame* newTextFrame = NS_NewTextFrame(aPresShell, newSC); newTextFrame->Init(textContent, parentFrame, nullptr); @@ -11282,7 +11282,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext, if (!textContent) { break; } - nsRefPtr newSC; + RefPtr newSC; newSC = aPresShell->StyleSet()->ResolveStyleForNonElement(parentSC); textFrame = NS_NewTextFrame(aPresShell, newSC); textFrame->Init(textContent, aFrame, nullptr); @@ -11425,7 +11425,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext, // If we ever initialize the ancestor filter on |state|, make sure // to push the right parent! - nsRefPtr styleContext; + RefPtr styleContext; styleContext = ResolveStyleContext(aParentFrame, aChild, &state); // Pre-check for display "none" - only if we find that, do we create @@ -11497,7 +11497,7 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState, blockFrame->GetType() == nsGkAtoms::detailsFrame), "not a block frame nor a details frame?"); nsContainerFrame* parent = aParentFrame; - nsRefPtr blockStyle = aStyleContext; + RefPtr blockStyle = aStyleContext; const nsStyleColumn* columns = aStyleContext->StyleColumn(); if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO @@ -11695,7 +11695,7 @@ nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState, // When such an inline box is affected by relative positioning, any // resulting translation also affects the block-level box contained // in the inline box. - nsRefPtr blockSC = + RefPtr blockSC = mPresShell->StyleSet()-> ResolveAnonymousBoxStyle(aIsPositioned ? nsCSSAnonBoxes::mozAnonymousPositionedBlock : @@ -11834,7 +11834,7 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState, content->UnsetFlags(ELEMENT_ALL_RESTYLE_FLAGS); } - nsRefPtr childContext = + RefPtr childContext = ResolveStyleContext(parentStyleContext, content, &aState); AddFrameConstructionItemsInternal(aState, content, nullptr, diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 4b5388025d..f27abcad79 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -435,7 +435,7 @@ private: */ already_AddRefed CreateGenConTextNode(nsFrameConstructorState& aState, const nsString& aString, - nsRefPtr* aText, + RefPtr* aText, nsGenConInitializer* aInitializer); /** @@ -1024,7 +1024,7 @@ private: {} nsIContent * const mContent; - nsRefPtr mStyleContext; + RefPtr mStyleContext; }; // Adjust our various counts for aItem being added or removed. aDelta @@ -1150,7 +1150,7 @@ private: // insertion point before doing so and pop it afterward. PendingBinding* mPendingBinding; // The style context to use for creating the new frame. - nsRefPtr mStyleContext; + RefPtr mStyleContext; // The XBL-resolved namespace to use for frame construction. int32_t mNameSpaceID; // Whether optimizations to skip constructing textframes around diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 462c0293a7..1fe10f39cc 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -2633,7 +2633,7 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext, stopScale = 1.0/(stopEnd - stopOrigin); // Create the gradient pattern. - nsRefPtr gradientPattern; + RefPtr gradientPattern; bool forceRepeatToCoverTiles = false; gfxMatrix matrix; gfxPoint gradientStart; @@ -2741,7 +2741,7 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext, rawStops[i].color = stops[i].mColor; rawStops[i].offset = stopScale * (stops[i].mPosition - stopOrigin); } - mozilla::RefPtr gs = + RefPtr gs = gfxGradientCache::GetOrCreateGradientStops(ctx->GetDrawTarget(), rawStops, isRepeat ? gfx::ExtendMode::REPEAT : gfx::ExtendMode::CLAMP); @@ -5114,7 +5114,7 @@ nsImageRenderer::Draw(nsPresContext* aPresContext, } case eStyleImageType_Element: { - nsRefPtr drawable = DrawableForElement(aDest, + RefPtr drawable = DrawableForElement(aDest, aRenderingContext); if (!drawable) { NS_WARNING("Could not create drawable for element"); @@ -5158,7 +5158,7 @@ nsImageRenderer::DrawableForElement(const nsRect& aImageRect, nsRect destRect = aImageRect - aImageRect.TopLeft(); nsIntSize roundedOut = destRect.ToOutsidePixels(appUnitsPerDevPixel).Size(); IntSize imageSize(roundedOut.width, roundedOut.height); - nsRefPtr drawable = + RefPtr drawable = nsSVGIntegrationUtils::DrawableFromPaintServer( mPaintServerFrame, mForFrame, mSize, imageSize, aRenderingContext.GetDrawTarget(), @@ -5170,7 +5170,7 @@ nsImageRenderer::DrawableForElement(const nsRect& aImageRect, return drawable.forget(); } NS_ASSERTION(mImageElementSurface.mSourceSurface, "Surface should be ready."); - nsRefPtr drawable = new gfxSurfaceDrawable( + RefPtr drawable = new gfxSurfaceDrawable( mImageElementSurface.mSourceSurface, mImageElementSurface.mSize); return drawable.forget(); @@ -5310,7 +5310,7 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext, // invalidate that cache, and it's not clear that it's worth the trouble // since using border-image with -moz-element is rare. - nsRefPtr drawable = DrawableForElement(nsRect(nsPoint(), mSize), + RefPtr drawable = DrawableForElement(nsRect(nsPoint(), mSize), aRenderingContext); if (!drawable) { NS_WARNING("Could not create drawable for element"); diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index 5cfa40c427..8845c10d3a 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -285,7 +285,7 @@ private: const nsStyleImage* mImage; nsStyleImageType mType; nsCOMPtr mImageContainer; - nsRefPtr mGradientData; + RefPtr mGradientData; nsIFrame* mPaintServerFrame; nsLayoutUtils::SurfaceFromElementResult mImageElementSurface; bool mIsReady; @@ -1003,7 +1003,7 @@ protected: bool aConstrainSpreadRadius = true); gfxAlphaBoxBlur mAlphaBoxBlur; - nsRefPtr mContext; + RefPtr mContext; gfxContext* mDestinationCtx; /* This is true if the blur already has it's content transformed diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 0adbedcfde..2142ef9503 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -353,7 +353,7 @@ nsCaret::GetGeometryForFrame(nsIFrame* aFrame, "We should not be in the middle of reflow"); nscoord baseline = frame->GetCaretBaseline(); nscoord ascent = 0, descent = 0; - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(aFrame)); NS_ASSERTION(fm, "We should be able to get the font metrics"); diff --git a/layout/base/nsCounterManager.h b/layout/base/nsCounterManager.h index bd87dd4794..2eb0a8c03a 100644 --- a/layout/base/nsCounterManager.h +++ b/layout/base/nsCounterManager.h @@ -80,10 +80,10 @@ struct nsCounterUseNode : public nsCounterNode { // The same structure passed through the style system: an array // containing the values in the counter() or counters() in the order // given in the CSS spec. - nsRefPtr mCounterFunction; + RefPtr mCounterFunction; nsPresContext* mPresContext; - nsRefPtr mCounterStyle; + RefPtr mCounterStyle; // false for counter(), true for counters() bool mAllCounters; diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 2fac88435e..4a1eb3394b 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -818,7 +818,7 @@ nsDisplayListBuilder::SubtractFromVisibleRegion(nsRegion* aVisibleRegion, nsCaret * nsDisplayListBuilder::GetCaret() { - nsRefPtr caret = CurrentPresShellState()->mPresShell->GetCaret(); + RefPtr caret = CurrentPresShellState()->mPresShell->GetCaret(); return caret; } @@ -859,7 +859,7 @@ nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame, if (!buildCaret) return; - nsRefPtr caret = state->mPresShell->GetCaret(); + RefPtr caret = state->mPresShell->GetCaret(); state->mCaretFrame = caret->GetPaintGeometry(&state->mCaretRect); if (state->mCaretFrame) { mFramesMarkedForDisplay.AppendElement(state->mCaretFrame); @@ -1494,7 +1494,7 @@ already_AddRefed nsDisplayList::PaintRoot(nsDisplayListBuilder* aB PROFILER_LABEL("nsDisplayList", "PaintRoot", js::ProfileEntry::Category::GRAPHICS); - nsRefPtr layerManager; + RefPtr layerManager; bool widgetTransaction = false; bool allowRetaining = false; bool doBeginTransaction = true; @@ -1553,7 +1553,7 @@ already_AddRefed nsDisplayList::PaintRoot(nsDisplayListBuilder* aB ContainerLayerParameters containerParameters (presShell->GetResolution(), presShell->GetResolution()); - nsRefPtr root = layerBuilder-> + RefPtr root = layerBuilder-> BuildContainerLayerFor(aBuilder, layerManager, frame, nullptr, this, containerParameters, nullptr); @@ -2373,7 +2373,7 @@ bool nsDisplayBackgroundImage::ShouldFixToViewport(nsDisplayListBuilder* aBuilder) { // APZ needs background-attachment:fixed images layerized for correctness. - nsRefPtr layerManager = aBuilder->GetWidgetLayerManager(); + RefPtr layerManager = aBuilder->GetWidgetLayerManager(); if (!nsLayoutUtils::UsesAsyncScrolling(mFrame) && layerManager && layerManager->ShouldAvoidComponentAlphaLayers()) { return false; @@ -2458,7 +2458,7 @@ nsDisplayBackgroundImage::GetContainer(LayerManager* aManager, mImageContainer = mImage->GetImageContainer(aManager, flags); } - nsRefPtr container = mImageContainer; + RefPtr container = mImageContainer; return container.forget(); } @@ -2528,14 +2528,14 @@ nsDisplayBackgroundImage::BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) { - nsRefPtr layer = static_cast + RefPtr layer = static_cast (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this)); if (!layer) { layer = aManager->CreateImageLayer(); if (!layer) return nullptr; } - nsRefPtr imageContainer = GetContainer(aManager, aBuilder); + RefPtr imageContainer = GetContainer(aManager, aBuilder); layer->SetContainer(imageContainer); ConfigureLayer(layer, aParameters); return layer.forget(); @@ -3096,7 +3096,7 @@ nsDisplayClearBackground::BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) { - nsRefPtr layer = static_cast + RefPtr layer = static_cast (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this)); if (!layer) { layer = aManager->CreateColorLayer(); @@ -3860,7 +3860,7 @@ already_AddRefed nsDisplayOpacity::BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) { - nsRefPtr container = aManager->GetLayerBuilder()-> + RefPtr container = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, aContainerParameters, nullptr, FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR); @@ -4049,7 +4049,7 @@ nsDisplayMixBlendMode::BuildLayer(nsDisplayListBuilder* aBuilder, ContainerLayerParameters newContainerParameters = aContainerParameters; newContainerParameters.mDisableSubpixelAntialiasingInDescendants = true; - nsRefPtr container = aManager->GetLayerBuilder()-> + RefPtr container = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, newContainerParameters, nullptr); if (!container) { @@ -4122,7 +4122,7 @@ nsDisplayBlendContainer::BuildLayer(nsDisplayListBuilder* aBuilder, ContainerLayerParameters newContainerParameters = aContainerParameters; newContainerParameters.mDisableSubpixelAntialiasingInDescendants = true; - nsRefPtr container = aManager->GetLayerBuilder()-> + RefPtr container = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, newContainerParameters, nullptr); if (!container) { @@ -4171,7 +4171,7 @@ nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) { - nsRefPtr layer = aManager->GetLayerBuilder()-> + RefPtr layer = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, aContainerParameters, nullptr, FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR); @@ -4222,7 +4222,7 @@ nsDisplaySubDocument::BuildLayer(nsDisplayListBuilder* aBuilder, params.mInLowPrecisionDisplayPort = true; } - nsRefPtr layer = nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, params); + RefPtr layer = nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, params); layer->AsContainerLayer()->SetEventRegionsOverride(mForceDispatchToContentRegion ? EventRegionsOverride::ForceDispatchToContent : EventRegionsOverride::NoOverride); @@ -4368,7 +4368,7 @@ nsDisplayResolution::BuildLayer(nsDisplayListBuilder* aBuilder, presShell->GetResolution(), presShell->GetResolution(), nsIntPoint(), aContainerParameters); - nsRefPtr layer = nsDisplaySubDocument::BuildLayer( + RefPtr layer = nsDisplaySubDocument::BuildLayer( aBuilder, aManager, containerParameters); layer->SetPostScale(1.0f / presShell->GetResolution(), 1.0f / presShell->GetResolution()); @@ -4395,7 +4395,7 @@ already_AddRefed nsDisplayStickyPosition::BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) { - nsRefPtr layer = + RefPtr layer = nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, aContainerParameters); StickyScrollContainer* stickyScrollContainer = StickyScrollContainer:: @@ -5334,7 +5334,7 @@ already_AddRefed nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBu uint32_t flags = ShouldPrerender(aBuilder) ? FrameLayerBuilder::CONTAINER_NOT_CLIPPED_BY_ANCESTORS : 0; flags |= FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR; - nsRefPtr container = aManager->GetLayerBuilder()-> + RefPtr container = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mStoredList.GetChildren(), aContainerParameters, &newTransformMatrix, flags); @@ -5863,7 +5863,7 @@ nsDisplayVR::BuildLayer(nsDisplayListBuilder* aBuilder, ContainerLayerParameters newContainerParameters = aContainerParameters; uint32_t flags = FrameLayerBuilder::CONTAINER_NOT_CLIPPED_BY_ANCESTORS | FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR; - nsRefPtr container = aManager->GetLayerBuilder()-> + RefPtr container = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, newContainerParameters, nullptr, flags); @@ -5949,7 +5949,7 @@ nsDisplaySVGEffects::BuildLayer(nsDisplayListBuilder* aBuilder, newContainerParameters.mDisableSubpixelAntialiasingInDescendants = true; } - nsRefPtr container = aManager->GetLayerBuilder()-> + RefPtr container = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, newContainerParameters, nullptr); diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 37d5a281eb..83e20aa2f9 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -2363,7 +2363,7 @@ public: void SetNeedsCustomScrollClip() { mNeedsCustomScrollClip = true; } protected: - nsRefPtr mCaret; + RefPtr mCaret; nsRect mBounds; bool mNeedsCustomScrollClip; }; @@ -2582,7 +2582,7 @@ protected: // mIsThemed is true or if FindBackground returned false. const nsStyleBackground* mBackgroundStyle; nsCOMPtr mImage; - nsRefPtr mImageContainer; + RefPtr mImageContainer; LayoutDeviceRect mDestRect; /* Bounds of this display item */ nsRect mBounds; @@ -3789,7 +3789,7 @@ public: } const nsIFrame* mFrame; - nsRefPtr mTransformList; + RefPtr mTransformList; const Point3D mToTransformOrigin; nscoord mChildPerspective; @@ -3984,7 +3984,7 @@ public: const ContainerLayerParameters& aContainerParameters) override; protected: - nsRefPtr mHMD; + RefPtr mHMD; }; #endif /*NSDISPLAYLIST_H_*/ diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 9dbaa2fe7e..011e2084d3 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -347,18 +347,18 @@ protected: WeakPtr mContainer; // it owns me! nsWeakPtr mTopContainerWhilePrinting; - nsRefPtr mDeviceContext; // We create and own this baby + RefPtr mDeviceContext; // We create and own this baby // the following six items are explicitly in this order // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsRefPtr mViewManager; - nsRefPtr mPresContext; + RefPtr mViewManager; + RefPtr mPresContext; nsCOMPtr mPresShell; - nsRefPtr mSelectionListener; - nsRefPtr mFocusListener; + RefPtr mSelectionListener; + RefPtr mFocusListener; nsCOMPtr mPreviousViewer; nsCOMPtr mSHEntry; @@ -399,7 +399,7 @@ protected: nsCOMPtr mCachedPrintSettings; nsCOMPtr mCachedPrintWebProgressListner; - nsRefPtr mPrintEngine; + RefPtr mPrintEngine; float mOriginalPrintPreviewScale; float mPrintPreviewZoom; nsAutoPtr mBeforeAndAfterPrint; @@ -457,7 +457,7 @@ private: already_AddRefed NS_NewContentViewer() { - nsRefPtr viewer = new nsDocumentViewer(); + RefPtr viewer = new nsDocumentViewer(); return viewer.forget(); } @@ -725,7 +725,7 @@ nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) mSelectionListener = selectionListener; } - nsRefPtr selection = GetDocumentSelection(); + RefPtr selection = GetDocumentSelection(); if (!selection) { return NS_ERROR_FAILURE; } @@ -735,7 +735,7 @@ nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) return rv; // Save old listener so we can unregister it - nsRefPtr oldFocusListener = mFocusListener; + RefPtr oldFocusListener = mFocusListener; if (oldFocusListener) { oldFocusListener->Disconnect(); } @@ -953,7 +953,7 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) http://bugzilla.mozilla.org/show_bug.cgi?id=78445 for more explanation. */ - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); // Flush out layout so it's up-to-date by the time onload is called. // Note that this could destroy the window, so do this before @@ -1008,7 +1008,7 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) nsCOMPtr d = mDocument; mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE); - nsRefPtr timing(d->GetNavigationTiming()); + RefPtr timing(d->GetNavigationTiming()); if (timing) { timing->NotifyLoadEventStart(); } @@ -1147,7 +1147,7 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow, // In evil cases we might be destroyed while handling the // onbeforeunload event, don't let that happen. (see also bug#331040) - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); { // Never permit popups from the beforeunload handler, no matter @@ -1422,7 +1422,7 @@ AttachContainerRecurse(nsIDocShell* aShell) if (doc) { doc->SetContainer(static_cast(aShell)); } - nsRefPtr pc; + RefPtr pc; viewer->GetPresContext(getter_AddRefs(pc)); if (pc) { pc->SetContainer(static_cast(aShell)); @@ -1579,7 +1579,7 @@ DetachContainerRecurse(nsIDocShell *aShell) if (doc) { doc->SetContainer(nullptr); } - nsRefPtr pc; + RefPtr pc; viewer->GetPresContext(getter_AddRefs(pc)); if (pc) { pc->Detach(); @@ -2311,7 +2311,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument, nsCOMPtr ds(mContainer); nsCOMPtr chromeHandler; nsCOMPtr uri; - nsRefPtr csssheet; + RefPtr csssheet; if (ds) { ds->GetChromeEventHandler(getter_AddRefs(chromeHandler)); @@ -2325,7 +2325,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument, nsAutoString sheets; elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets); if (!sheets.IsEmpty() && baseURI) { - nsRefPtr cssLoader = new mozilla::css::Loader(); + RefPtr cssLoader = new mozilla::css::Loader(); char *str = ToNewCString(sheets); char *newStr = str; @@ -2653,7 +2653,7 @@ nsDocumentViewer::GetDocumentSelection() NS_IMETHODIMP nsDocumentViewer::ClearSelection() { // use nsCopySupport::GetSelectionForCopy() ? - nsRefPtr selection = GetDocumentSelection(); + RefPtr selection = GetDocumentSelection(); if (!selection) { return NS_ERROR_FAILURE; } @@ -2668,7 +2668,7 @@ NS_IMETHODIMP nsDocumentViewer::SelectAll() // functions to make this easier. // use nsCopySupport::GetSelectionForCopy() ? - nsRefPtr selection = GetDocumentSelection(); + RefPtr selection = GetDocumentSelection(); if (!selection) { return NS_ERROR_FAILURE; } @@ -3438,7 +3438,7 @@ nsDocumentViewer::GetContentSize(int32_t* aWidth, int32_t* aHeight) nsresult rv = presShell->ResizeReflow(prefWidth, NS_UNCONSTRAINEDSIZE); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr presContext; + RefPtr presContext; GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); @@ -3640,7 +3640,7 @@ NS_IMETHODIMP nsDocViewerSelectionListener::NotifySelectionChanged(nsIDOMDocumen } // get the selection state - nsRefPtr selection = mDocViewer->GetDocumentSelection(); + RefPtr selection = mDocViewer->GetDocumentSelection(); if (!selection) { return NS_ERROR_FAILURE; } @@ -4424,7 +4424,7 @@ nsDocumentViewer::OnDonePrinting() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) if (mPrintEngine) { - nsRefPtr pe = mPrintEngine; + RefPtr pe = mPrintEngine; if (GetIsPrintPreview()) { pe->DestroyPrintingData(); } else { @@ -4533,7 +4533,7 @@ nsDocumentViewer::DestroyPresShell() // Break circular reference (or something) mPresShell->EndObservingDocument(); - nsRefPtr selection = GetDocumentSelection(); + RefPtr selection = GetDocumentSelection(); if (selection && mSelectionListener) selection->RemoveSelectionListener(mSelectionListener); diff --git a/layout/base/nsFrameManager.h b/layout/base/nsFrameManager.h index 7d419f5eb2..1ee562cd38 100644 --- a/layout/base/nsFrameManager.h +++ b/layout/base/nsFrameManager.h @@ -58,7 +58,7 @@ struct UndisplayedNode { } nsCOMPtr mContent; - nsRefPtr mStyle; + RefPtr mStyle; UndisplayedNode* mNext; }; diff --git a/layout/base/nsGenConList.h b/layout/base/nsGenConList.h index 5fbd40912f..2d0ad9f3e7 100644 --- a/layout/base/nsGenConList.h +++ b/layout/base/nsGenConList.h @@ -30,7 +30,7 @@ struct nsGenConNode : public PRCList { // null for 'content:no-open-quote', 'content:no-close-quote' and for // counter nodes for increments and resets (rather than uses) - nsRefPtr mText; + RefPtr mText; explicit nsGenConNode(int32_t aContentIndex) : mPseudoFrame(nullptr) diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 311f9807f9..084a7fda28 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -1712,12 +1712,12 @@ protected: // These are the same Document and PresContext owned by the DocViewer. // we must share ownership. nsCOMPtr mDocument; - nsRefPtr mPresContext; + RefPtr mPresContext; nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to nsPresArena mFrameArena; - nsRefPtr mSelection; + RefPtr mSelection; // Pointer into mFrameConstructor - this is purely so that FrameManager() and // GetRootFrame() can be inlined: nsFrameManagerBase* mFrameManager; @@ -1802,7 +1802,7 @@ protected: // same update block we have already had other changes that require // the whole document to be restyled (i.e., mStylesHaveChanged is already // true), then we don't bother adding the scope root here. - nsAutoTArray,1> mChangedScopeStyleRoots; + nsAutoTArray,1> mChangedScopeStyleRoots; static nsIContent* gKeyDownTarget; diff --git a/layout/base/nsLayoutHistoryState.cpp b/layout/base/nsLayoutHistoryState.cpp index 686b2434b6..14c8ce21bf 100644 --- a/layout/base/nsLayoutHistoryState.cpp +++ b/layout/base/nsLayoutHistoryState.cpp @@ -49,7 +49,7 @@ private: already_AddRefed NS_NewLayoutHistoryState() { - nsRefPtr state = new nsLayoutHistoryState(); + RefPtr state = new nsLayoutHistoryState(); return state.forget(); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index f751d0f7a9..8459bdaf2b 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1961,7 +1961,7 @@ nsLayoutUtils::HasPseudoStyle(nsIContent* aContent, { NS_PRECONDITION(aPresContext, "Must have a prescontext"); - nsRefPtr pseudoContext; + RefPtr pseudoContext; if (aContent) { pseudoContext = aPresContext->StyleSet()-> ProbePseudoElementStyle(aContent->AsElement(), aPseudoElement, @@ -3341,7 +3341,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram } TimeStamp paintStart = TimeStamp::Now(); - nsRefPtr layerManager = + RefPtr layerManager = list.PaintRoot(&builder, aRenderingContext, flags); Telemetry::AccumulateTimeDelta(Telemetry::PAINT_RASTERIZE_TIME, paintStart); @@ -3631,7 +3631,7 @@ nsLayoutUtils::RectListBuilder::RectListBuilder(DOMRectList* aList) } void nsLayoutUtils::RectListBuilder::AddRect(const nsRect& aRect) { - nsRefPtr rect = new DOMRect(mRectList); + RefPtr rect = new DOMRect(mRectList); rect->SetLayoutRect(aRect); mRectList->Append(rect); @@ -6789,7 +6789,7 @@ nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow) win->EnsureSizeUpToDate(); - nsRefPtr presContext; + RefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); if (presContext) { nsDeviceContext* context = presContext->DeviceContext(); @@ -8249,7 +8249,7 @@ nsLayoutUtils::SetBSizeFromFontMetrics(const nsIFrame* aFrame, WritingMode aLineWM, WritingMode aFrameWM) { - nsRefPtr fm; + RefPtr fm; float inflation = nsLayoutUtils::FontSizeInflationFor(aFrame); nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), inflation); diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index d2d889ecf5..dafe2a5b33 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -2064,7 +2064,7 @@ public: SurfaceFromElementResult(); /* mSourceSurface will contain the resulting surface, or will be nullptr on error */ - mozilla::RefPtr mSourceSurface; + RefPtr mSourceSurface; /* Contains info for drawing when there is no mSourceSurface. */ DirectDrawInfo mDrawInfo; @@ -2090,28 +2090,28 @@ public: static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::Element *aElement, uint32_t aSurfaceFlags, - mozilla::RefPtr& aTarget); + RefPtr& aTarget); static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::Element *aElement, uint32_t aSurfaceFlags = 0) { - mozilla::RefPtr target = nullptr; + RefPtr target = nullptr; return SurfaceFromElement(aElement, aSurfaceFlags, target); } static SurfaceFromElementResult SurfaceFromElement(nsIImageLoadingContent *aElement, uint32_t aSurfaceFlags, - mozilla::RefPtr& aTarget); + RefPtr& aTarget); // Need an HTMLImageElement overload, because otherwise the // nsIImageLoadingContent and mozilla::dom::Element overloads are ambiguous // for HTMLImageElement. static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLImageElement *aElement, uint32_t aSurfaceFlags, - mozilla::RefPtr& aTarget); + RefPtr& aTarget); static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLCanvasElement *aElement, uint32_t aSurfaceFlags, - mozilla::RefPtr& aTarget); + RefPtr& aTarget); static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLVideoElement *aElement, uint32_t aSurfaceFlags, - mozilla::RefPtr& aTarget); + RefPtr& aTarget); /** * When the document is editable by contenteditable attribute of its root diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index ae99abf5b5..a9d4c8fb80 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -119,7 +119,7 @@ public: } private: - nsRefPtr mPresContext; + RefPtr mPresContext; nsCString mCharSet; }; @@ -162,7 +162,7 @@ nsPresContext::IsDOMPaintEventPending() void nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data) { - nsRefPtr presContext = + RefPtr presContext = static_cast(instance_data); NS_ASSERTION(nullptr != presContext, "bad instance data"); @@ -873,7 +873,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) // Re-fetch the view manager's window dimensions in case there's a deferred // resize which hasn't affected our mVisibleArea yet nscoord oldWidthAppUnits, oldHeightAppUnits; - nsRefPtr vm = shell->GetViewManager(); + RefPtr vm = shell->GetViewManager(); if (!vm) { return; } @@ -1236,7 +1236,7 @@ nsPresContext::Observe(nsISupports* aSubject, const char16_t* aData) { if (!nsCRT::strcmp(aTopic, "charset")) { - nsRefPtr runnable = + RefPtr runnable = new CharSetChangingRunnable(this, NS_LossyConvertUTF16toASCII(aData)); return NS_DispatchToCurrentThread(runnable); } @@ -1584,7 +1584,7 @@ GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext, // Check the style on the document root element nsStyleSet *styleSet = aPresContext->StyleSet(); - nsRefPtr rootStyle; + RefPtr rootStyle; rootStyle = styleSet->ResolveStyleFor(docElement, nullptr); if (CheckOverflow(rootStyle->StyleDisplay(), aStyles)) { // tell caller we stole the overflow style from the root element @@ -1612,7 +1612,7 @@ GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext, return nullptr; } - nsRefPtr bodyStyle; + RefPtr bodyStyle; bodyStyle = styleSet->ResolveStyleFor(bodyElement->AsElement(), rootStyle); if (CheckOverflow(bodyStyle->StyleDisplay(), aStyles)) { @@ -1947,7 +1947,7 @@ NotifyChildrenUIResolutionChanged(nsIDOMWindow* aWindow) return; } nsCOMPtr doc = piWin->GetExtantDoc(); - nsRefPtr topLevelWin = nsContentUtils::GetWindowRoot(doc); + RefPtr topLevelWin = nsContentUtils::GetWindowRoot(doc); if (!topLevelWin) { return; } @@ -2150,7 +2150,7 @@ nsPresContext::EnsureVisible() docShell->GetContentViewer(getter_AddRefs(cv)); // Make sure this is the content viewer we belong with if (cv) { - nsRefPtr currentPresContext; + RefPtr currentPresContext; cv->GetPresContext(getter_AddRefs(currentPresContext)); if (currentPresContext == this) { // OK, this is us. We want to call Show() on the content viewer. @@ -2326,7 +2326,7 @@ nsPresContext::FireDOMPaintEvent(nsInvalidateRequestList* aList) // This will empty our list in case dispatching the event causes more damage // (hopefully it won't, or we're likely to get an infinite loop! At least // it won't be blocking app execution though). - nsRefPtr event = + RefPtr event = NS_NewDOMNotifyPaintEvent(eventTarget, this, nullptr, eAfterPaint, aList); // Even if we're not telling the window about the event (so eventTarget is @@ -2554,7 +2554,7 @@ public: return NS_OK; } - nsRefPtr mPresContext; + RefPtr mPresContext; nsInvalidateRequestList mList; }; diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 12b5b699dd..c934025bfd 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -1219,17 +1219,17 @@ protected: nsPresContextType mType; nsIPresShell* mShell; // [WEAK] nsCOMPtr mDocument; - nsRefPtr mDeviceContext; // [STRONG] could be weak, but + RefPtr mDeviceContext; // [STRONG] could be weak, but // better safe than sorry. // Cannot reintroduce cycles // since there is no dependency // from gfx back to layout. - nsRefPtr mEventManager; - nsRefPtr mRefreshDriver; - nsRefPtr mTransitionManager; - nsRefPtr mAnimationManager; - nsRefPtr mRestyleManager; - nsRefPtr mCounterStyleManager; + RefPtr mEventManager; + RefPtr mRefreshDriver; + RefPtr mTransitionManager; + RefPtr mAnimationManager; + RefPtr mRestyleManager; + RefPtr mCounterStyleManager; nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom nsCOMPtr mMediaEmulated; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index de29831694..e6dace24ab 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -211,7 +211,7 @@ nsClassHashtable* nsIPresShell::gAct // RangePaintInfo is used to paint ranges to offscreen buffers struct RangePaintInfo { - nsRefPtr mRange; + RefPtr mRange; nsDisplayListBuilder mBuilder; nsDisplayList mList; @@ -484,7 +484,7 @@ public: // handles both D3E "wheel" event and legacy mouse scroll events. // We should dispatch legacy mouse events before dispatching the // "wheel" event into system group. - nsRefPtr esm = + RefPtr esm = aVisitor.mPresContext->EventStateManager(); esm->DispatchLegacyMouseScrollEvents(frame, aVisitor.mEvent->AsWheelEvent(), @@ -507,7 +507,7 @@ public: } } - nsRefPtr mPresShell; + RefPtr mPresShell; }; class nsBeforeFirstPaintDispatcher : public nsRunnable @@ -695,7 +695,7 @@ nsIPresShell::RemoveWeakFrameInternal(nsWeakFrame* aWeakFrame) already_AddRefed nsIPresShell::FrameSelection() { - nsRefPtr ret = mSelection; + RefPtr ret = mSelection; return ret.forget(); } @@ -1394,7 +1394,7 @@ PresShell::UpdatePreferenceStyles() // matter which pres context we pass in when it does need to be recreated. // (See nsPresContext::GetDocumentColorPreferences for how whether we // are a chrome origin image affects some pref styling information.) - nsRefPtr newPrefSheet = + RefPtr newPrefSheet = mPresContext->IsChromeOriginImage() ? nsLayoutStylesheetCache::ChromePreferenceSheet(mPresContext) : nsLayoutStylesheetCache::ContentPreferenceSheet(mPresContext); @@ -1787,7 +1787,7 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight) void PresShell::sPaintSuppressionCallback(nsITimer *aTimer, void* aPresShell) { - nsRefPtr self = static_cast(aPresShell); + RefPtr self = static_cast(aPresShell); if (self) self->UnsuppressPainting(); } @@ -1842,7 +1842,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_OK; } - nsRefPtr viewManagerDeathGrip = mViewManager; + RefPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first. nsCOMPtr kungFuDeathGrip(this); @@ -1897,7 +1897,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) nsITimer::TYPE_ONE_SHOT); } } else { - nsRefPtr > resizeEvent = + RefPtr > resizeEvent = NS_NewRunnableMethod(this, &PresShell::FireResizeEvent); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(resizeEvent))) { mResizeEvent = resizeEvent; @@ -1997,26 +1997,26 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) already_AddRefed PresShell::GetCaret() const { - nsRefPtr caret = mCaret; + RefPtr caret = mCaret; return caret.forget(); } // TouchCaret already_AddRefed PresShell::GetTouchCaret() const { - nsRefPtr touchCaret = mTouchCaret; + RefPtr touchCaret = mTouchCaret; return touchCaret.forget(); } already_AddRefed PresShell::GetSelectionCarets() const { - nsRefPtr selectionCaret = mSelectionCarets; + RefPtr selectionCaret = mSelectionCarets; return selectionCaret.forget(); } already_AddRefed PresShell::GetAccessibleCaretEventHub() const { - nsRefPtr eventHub = mAccessibleCaretEventHub; + RefPtr eventHub = mAccessibleCaretEventHub; return eventHub.forget(); } @@ -2459,7 +2459,7 @@ PresShell::RestoreRootScrollPosition() void PresShell::MaybeReleaseCapturingContent() { - nsRefPtr frameSelection = FrameSelection(); + RefPtr frameSelection = FrameSelection(); if (frameSelection) { frameSelection->SetDragState(false); } @@ -2938,7 +2938,7 @@ already_AddRefed PresShell::CreateReferenceRenderingContext() { nsDeviceContext* devCtx = mPresContext->DeviceContext(); - nsRefPtr rc; + RefPtr rc; if (mPresContext->IsScreen()) { rc = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()); } else { @@ -2972,7 +2972,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll, } // Hold a reference to the ESM in case event dispatch tears us down. - nsRefPtr esm = mPresContext->EventStateManager(); + RefPtr esm = mPresContext->EventStateManager(); if (aAnchorName.IsEmpty()) { NS_ASSERTION(!aScroll, "can't scroll to empty anchor name"); @@ -3080,7 +3080,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll, // Even if select anchor pref is false, we must still move the // caret there. That way tabbing will start from the new // location - nsRefPtr jumpToRange = new nsRange(mDocument); + RefPtr jumpToRange = new nsRange(mDocument); while (content && content->GetFirstChild()) { content = content->GetFirstChild(); } @@ -3648,7 +3648,7 @@ PresShell::ScheduleViewManagerFlush(PaintType aType) static const uint32_t kPaintDelayPeriod = 1000; if (!mDelayedPaintTimer) { mDelayedPaintTimer = do_CreateInstance(NS_TIMER_CONTRACTID); - nsRefPtr cb = new PaintTimerCallBack(this); + RefPtr cb = new PaintTimerCallBack(this); mDelayedPaintTimer->InitWithCallback(cb, kPaintDelayPeriod, nsITimer::TYPE_ONE_SHOT); } return; @@ -4020,7 +4020,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsRefPtr viewManagerDeathGrip = mViewManager; + RefPtr viewManagerDeathGrip = mViewManager; bool didStyleFlush = false; bool didLayoutFlush = false; nsCOMPtr kungFuDeathGrip; @@ -4458,7 +4458,7 @@ PresShell::ReconstructFrames(void) void nsIPresShell::ReconstructStyleDataInternal() { - nsAutoTArray,1> scopeRoots; + nsAutoTArray,1> scopeRoots; mChangedScopeStyleRoots.SwapElements(scopeRoots); if (mStylesHaveChanged) { @@ -4521,7 +4521,7 @@ PresShell::RecordStyleSheetChange(nsIStyleSheet* aStyleSheet) if (mStylesHaveChanged) return; - nsRefPtr cssStyleSheet = do_QueryObject(aStyleSheet); + RefPtr cssStyleSheet = do_QueryObject(aStyleSheet); if (cssStyleSheet) { Element* scopeElement = cssStyleSheet->GetScopeElement(); if (scopeElement) { @@ -5043,7 +5043,7 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, return nullptr; } - nsRefPtr ctx = new gfxContext(dt); + RefPtr ctx = new gfxContext(dt); if (aRegion) { // Convert aRegion from CSS pixels to dev pixels @@ -5072,7 +5072,7 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, // temporarily hide the selection so that text is drawn normally. If a // selection is being rendered, use that, otherwise use the presshell's // selection. - nsRefPtr frameSelection; + RefPtr frameSelection; if (aSelection) { frameSelection = static_cast(aSelection)->GetFrameSelection(); } @@ -5092,7 +5092,7 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, ctx->SetMatrix(gfxMatrix(initialTM).Translate(rootOffset)); aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y); nsRegion visible(aArea); - nsRefPtr layerManager = + RefPtr layerManager = rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, &rc, nsDisplayList::PAINT_DEFAULT); aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y); @@ -5120,7 +5120,7 @@ PresShell::RenderNode(nsIDOMNode* aNode, if (!node->IsInDoc()) return nullptr; - nsRefPtr range = new nsRange(node); + RefPtr range = new nsRange(node); if (NS_FAILED(range->SelectNode(aNode))) return nullptr; @@ -5440,7 +5440,7 @@ void PresShell::SynthesizeMouseMove(bool aFromScroll) return; if (!mSynthMouseMoveEvent.IsPending()) { - nsRefPtr ev = + RefPtr ev = new nsSynthMouseMoveEvent(this, aFromScroll); if (!GetPresContext()->RefreshDriver()->AddRefreshObserver(ev, @@ -5924,7 +5924,7 @@ PresShell::ScheduleImageVisibilityUpdate() if (mUpdateImageVisibilityEvent.IsPending()) return; - nsRefPtr > ev = + RefPtr > ev = NS_NewRunnableMethod(this, &PresShell::UpdateImageVisibility); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mUpdateImageVisibilityEvent = ev; @@ -6170,7 +6170,7 @@ PresShell::Paint(nsView* aViewToPaint, return; } - nsRefPtr root = layerManager->CreateColorLayer(); + RefPtr root = layerManager->CreateColorLayer(); if (root) { nsPresContext* pc = GetPresContext(); nsIntRect bounds = @@ -6259,7 +6259,7 @@ nsIPresShell::ReleasePointerCapturingContent(uint32_t aPointerId, nsIContent* aC if (gPointerCaptureList->Get(aPointerId, &pointerCaptureInfo) && pointerCaptureInfo) { // Set flag to asyncronously release capture for given pointer. pointerCaptureInfo->mReleaseContent = true; - nsRefPtr asyncCaller = + RefPtr asyncCaller = new AsyncCheckPointerCaptureStateCaller(aPointerId); NS_DispatchToCurrentThread(asyncCaller); } @@ -6619,7 +6619,7 @@ PresShell::RecordMouseLocation(WidgetGUIEvent* aEvent) } static PLDHashOperator -FindAnyTarget(const uint32_t& aKey, nsRefPtr& aData, +FindAnyTarget(const uint32_t& aKey, RefPtr& aData, void* aAnyTarget) { if (aData) { @@ -7075,7 +7075,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, // Bug 1057256: Touch caret should handle the event before selection carets. // Otherwise, a long tap on touch caret will be incorrectly handled by // selection carets which makes moving touch caret failed. - nsRefPtr touchCaret = presShell ? + RefPtr touchCaret = presShell ? presShell->GetTouchCaret() : nullptr; if (touchCaret) { @@ -7088,7 +7088,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, } } - nsRefPtr selectionCaret = presShell ? + RefPtr selectionCaret = presShell ? presShell->GetSelectionCarets() : nullptr; if (selectionCaret) { @@ -7111,7 +7111,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, nsCOMPtr presShell = retargetEventDoc ? retargetEventDoc->GetShell() : nullptr; - nsRefPtr eventHub = + RefPtr eventHub = presShell ? presShell->GetAccessibleCaretEventHub() : nullptr; if (eventHub) { *aEventStatus = eventHub->HandleEvent(aEvent); @@ -7402,7 +7402,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, touch->mChanged = false; int32_t id = touch->Identifier(); - nsRefPtr oldTouch = TouchManager::gCaptureTouchList->GetWeak(id); + RefPtr oldTouch = TouchManager::gCaptureTouchList->GetWeak(id); if (oldTouch) { touch->SetTarget(oldTouch->mTarget); } @@ -7506,7 +7506,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, break; } - nsRefPtr oldTouch = + RefPtr oldTouch = TouchManager::gCaptureTouchList->GetWeak(touch->Identifier()); if (!oldTouch) { break; @@ -7827,7 +7827,7 @@ PresShell::HandleEventWithTarget(WidgetEvent* aEvent, nsIFrame* aFrame, nsresult PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus) { - nsRefPtr manager = mPresContext->EventStateManager(); + RefPtr manager = mPresContext->EventStateManager(); nsresult rv = NS_OK; if (!NS_EVENT_NEEDS_FRAME(aEvent) || GetCurrentEventFrame() || GetCurrentEventContent()) { @@ -8021,7 +8021,7 @@ nsIPresShell::DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture, init.mBubbles = true; ConvertPointerTypeToString(aPointerType, init.mPointerType); init.mIsPrimary = aIsPrimary; - nsRefPtr event; + RefPtr event; event = PointerEvent::Constructor(aCaptureTarget, aIsGotCapture ? NS_LITERAL_STRING("gotpointercapture") @@ -8121,7 +8121,7 @@ PresShell::DispatchTouchEventToDOM(WidgetEvent* aEvent, newEvent.AssignTouchEventData(*touchEvent, false); newEvent.target = targetPtr; - nsRefPtr contentPresShell; + RefPtr contentPresShell; if (doc == mDocument) { contentPresShell = static_cast(doc->GetShell()); if (contentPresShell) { @@ -8328,7 +8328,7 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsresult rv; // check caret visibility - nsRefPtr caret = GetCaret(); + RefPtr caret = GetCaret(); NS_ENSURE_TRUE(caret, false); bool caretVisible = caret->IsVisible(); @@ -8930,7 +8930,7 @@ PresShell::GetPerformanceNow() void PresShell::sReflowContinueCallback(nsITimer* aTimer, void* aPresShell) { - nsRefPtr self = static_cast(aPresShell); + RefPtr self = static_cast(aPresShell); NS_PRECONDITION(aTimer == self->mReflowContinueTimer, "Unexpected timer"); self->mReflowContinueTimer = nullptr; @@ -9844,7 +9844,7 @@ PresShell::VerifyIncrementalReflow() } // Create a presentation context to view the new frame tree - nsRefPtr cx = + RefPtr cx = new nsRootPresContext(mDocument, mPresContext->IsPaginated() ? nsPresContext::eContext_PrintPreview : nsPresContext::eContext_Galley); @@ -9860,7 +9860,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsRefPtr vm = new nsViewManager(); + RefPtr vm = new nsViewManager(); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); @@ -10229,7 +10229,7 @@ void ReflowCountMgr::PaintCount(const char* aName, nsFont font(eFamily_serif, NS_FONT_STYLE_NORMAL, NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, nsPresContext::CSSPixelsToAppUnits(11)); - nsRefPtr fm; + RefPtr fm; aPresContext->DeviceContext()->GetMetricsFor(font, nsGkAtoms::x_western, false, gfxFont::eHorizontal, nullptr, aPresContext->GetTextPerfMetrics(), *getter_AddRefs(fm)); diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index f5ddc27bb7..8517541ec3 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -642,7 +642,7 @@ protected: } virtual void WillRefresh(mozilla::TimeStamp aTime) override { if (mPresShell) { - nsRefPtr shell = mPresShell; + RefPtr shell = mPresShell; shell->ProcessSynthMouseMoveEvent(mFromScroll); } } @@ -785,7 +785,7 @@ protected: nsPoint mMouseLocation; // mStyleSet owns it but we maintain a ref, may be null - nsRefPtr mPrefStyleSheet; + RefPtr mPrefStyleSheet; // Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after // we finish reflowing mCurrentReflowRoot. @@ -805,21 +805,21 @@ private: protected: nsRevocableEventPtr mSynthMouseMoveEvent; nsCOMPtr mLastAnchorScrolledTo; - nsRefPtr mCaret; - nsRefPtr mOriginalCaret; + RefPtr mCaret; + RefPtr mOriginalCaret; nsCallbackEventRequest* mFirstCallbackEventRequest; nsCallbackEventRequest* mLastCallbackEventRequest; // TouchManager TouchManager mTouchManager; - nsRefPtr mZoomConstraintsClient; - nsRefPtr mMobileViewportManager; + RefPtr mZoomConstraintsClient; + RefPtr mMobileViewportManager; // TouchCaret - nsRefPtr mTouchCaret; - nsRefPtr mSelectionCarets; - nsRefPtr mAccessibleCaretEventHub; + RefPtr mTouchCaret; + RefPtr mSelectionCarets; + RefPtr mAccessibleCaretEventHub; // This timer controls painting suppression. Until it fires // or all frames are constructed, we won't paint anything but diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index f2649ab950..e8957dab29 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -174,7 +174,7 @@ protected: mLastFireTime = now; LOG("[%p] ticking drivers...", this); - nsTArray > drivers(mRefreshDrivers); + nsTArray > drivers(mRefreshDrivers); // RD is short for RefreshDriver profiler_tracing("Paint", "RD", TRACING_INTERVAL_START); for (nsRefreshDriver* driver : drivers) { @@ -199,7 +199,7 @@ protected: TimeStamp mLastFireTime; TimeStamp mTargetTime; - nsTArray > mRefreshDrivers; + nsTArray > mRefreshDrivers; // useful callback for nsITimer-based derived classes, here // bacause of c++ protected shenanigans @@ -268,7 +268,7 @@ protected: double mRateMilliseconds; TimeDuration mRateDuration; - nsRefPtr mTimer; + RefPtr mTimer; }; /* @@ -285,7 +285,7 @@ public: MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); mVsyncObserver = new RefreshDriverVsyncObserver(this); - nsRefPtr vsyncSource = gfxPlatform::GetPlatform()->GetHardwareVsync(); + RefPtr vsyncSource = gfxPlatform::GetPlatform()->GetHardwareVsync(); MOZ_ALWAYS_TRUE(mVsyncDispatcher = vsyncSource->GetRefreshTimerVsyncDispatcher()); mVsyncDispatcher->SetParentRefreshTimer(mVsyncObserver); } @@ -342,7 +342,7 @@ private: aVsyncTimestamp); NS_DispatchToMainThread(vsyncEvent); } else { - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); TickRefreshDriver(aVsyncTimestamp); } @@ -441,13 +441,13 @@ private: Tick(vsyncJsNow, aTimeStamp); } - nsRefPtr mVsyncObserver; + RefPtr mVsyncObserver; // Used for parent process. - nsRefPtr mVsyncDispatcher; + RefPtr mVsyncDispatcher; // Used for child process. // The mVsyncChild will be always available before VsncChild::ActorDestroy(). // After ActorDestroy(), StartTimer() and StopTimer() calls will be non-op. - nsRefPtr mVsyncChild; + RefPtr mVsyncChild; }; // VsyncRefreshDriverTimer /* @@ -745,7 +745,7 @@ protected: mLastFireEpoch = jsnow; mLastFireTime = now; - nsTArray > drivers(mRefreshDrivers); + nsTArray > drivers(mRefreshDrivers); if (mNextDriverIndex < drivers.Length() && !drivers[mNextDriverIndex]->IsTestControllingRefreshesEnabled()) { @@ -839,7 +839,7 @@ CreateContentVsyncRefreshTimer(void*) return; } // Setup VsyncChildCreateCallback callback - nsRefPtr callback = new VsyncChildCreateCallback(); + RefPtr callback = new VsyncChildCreateCallback(); if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(callback))) { MOZ_CRASH("PVsync actor create failed!"); } @@ -1706,7 +1706,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) for (uint32_t i = 0; i < ArrayLength(mObservers); ++i) { ObserverArray::EndLimitedIterator etor(mObservers[i]); while (etor.HasMore()) { - nsRefPtr obs = etor.GetNext(); + RefPtr obs = etor.GetNext(); obs->WillRefresh(aNowTime); if (!mPresContext || !mPresContext->GetPresShell()) { @@ -1875,7 +1875,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsRefPtr vm = mPresContext->GetPresShell()->GetViewManager(); + RefPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef MOZ_DUMP_PAINTING if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { diff --git a/layout/base/nsRefreshDriver.h b/layout/base/nsRefreshDriver.h index ac0b4e3a07..521df8d7a1 100644 --- a/layout/base/nsRefreshDriver.h +++ b/layout/base/nsRefreshDriver.h @@ -354,7 +354,7 @@ private: nsPresContext *mPresContext; // weak; pres context passed in constructor // and unset in Disconnect - nsRefPtr mRootRefresh; + RefPtr mRootRefresh; // The most recently allocated transaction id. uint64_t mPendingTransaction; diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index f85227ee92..404ea74da5 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -185,9 +185,9 @@ nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI, aSheetType == AUTHOR_SHEET); NS_ENSURE_ARG_POINTER(aSheetURI); - nsRefPtr loader = new css::Loader(); + RefPtr loader = new css::Loader(); - nsRefPtr sheet; + RefPtr sheet; // Allow UA sheets, but not user sheets, to use unsafe rules nsresult rv = loader->LoadSheetSync(aSheetURI, aSheetType == AGENT_SHEET, true, getter_AddRefs(sheet)); @@ -225,10 +225,10 @@ nsStyleSheetService::PreloadSheet(nsIURI *aSheetURI, uint32_t aSheetType, NS_ENSURE_ARG_POINTER(aSheetURI); NS_PRECONDITION(aSheet, "Null out param"); - nsRefPtr loader = new css::Loader(); + RefPtr loader = new css::Loader(); // Allow UA sheets, but not user sheets, to use unsafe rules - nsRefPtr sheet; + RefPtr sheet; nsresult rv = loader->LoadSheetSync(aSheetURI, aSheetType == AGENT_SHEET, true, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp index 76ff9b61f9..ee74296c82 100644 --- a/layout/build/nsContentDLF.cpp +++ b/layout/build/nsContentDLF.cpp @@ -225,7 +225,7 @@ nsContentDLF::CreateInstance(const char* aCommand, aDocListener, aDocViewer); } - nsRefPtr pluginHost = nsPluginHost::GetInst(); + RefPtr pluginHost = nsPluginHost::GetInst(); // Don't exclude disabled plugins, which will still trigger the "this plugin // is disabled" placeholder. if (pluginHost && pluginHost->HavePluginForType(contentType, @@ -285,7 +285,7 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, nsNodeInfoManager *nim = blankDoc->NodeInfoManager(); - nsRefPtr htmlNodeInfo; + RefPtr htmlNodeInfo; // generate an html html element htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML, diff --git a/layout/forms/nsButtonFrameRenderer.h b/layout/forms/nsButtonFrameRenderer.h index 87480873c6..218d1b766d 100644 --- a/layout/forms/nsButtonFrameRenderer.h +++ b/layout/forms/nsButtonFrameRenderer.h @@ -77,8 +77,8 @@ protected: private: // cached styles for focus and outline. - nsRefPtr mInnerFocusStyle; - nsRefPtr mOuterFocusStyle; + RefPtr mInnerFocusStyle; + RefPtr mOuterFocusStyle; nsFrame* mFrame; }; diff --git a/layout/forms/nsColorControlFrame.cpp b/layout/forms/nsColorControlFrame.cpp index bf35fbd137..f2c6aa1683 100644 --- a/layout/forms/nsColorControlFrame.cpp +++ b/layout/forms/nsColorControlFrame.cpp @@ -73,7 +73,7 @@ nsColorControlFrame::CreateAnonymousContent(nsTArray& aElements) NS_ENSURE_SUCCESS(rv, rv); nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozColorSwatch; - nsRefPtr newStyleContext = PresContext()->StyleSet()-> + RefPtr newStyleContext = PresContext()->StyleSet()-> ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, StyleContext(), mColorContent->AsElement()); if (!aElements.AppendElement(ContentInfo(mColorContent, newStyleContext))) { diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 346e991faa..72ad2a1adf 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -695,7 +695,7 @@ nsComboboxControlFrame::NotifyGeometryChange() !mDelayedShowDropDown) { // Async because we're likely in a middle of a scroll here so // frame/view positions are in flux. - nsRefPtr resize = + RefPtr resize = new nsResizeDropdownAtFinalPosition(this); NS_DispatchToCurrentThread(resize); } @@ -838,7 +838,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, // First reflow our dropdown so that we know how tall we should be. ReflowDropdown(aPresContext, aReflowState); - nsRefPtr resize = + RefPtr resize = new nsResizeDropdownAtFinalPosition(this); if (NS_SUCCEEDED(aPresContext->PresShell()->PostReflowCallback(resize))) { // The reflow callback queue doesn't AddRef so we keep it alive until @@ -993,7 +993,7 @@ nsComboboxControlFrame::RedisplayText(int32_t aIndex) "If we happen to run our redisplay event now, we might kill " "ourselves!"); - nsRefPtr event = new RedisplayTextEvent(this); + RefPtr event = new RedisplayTextEvent(this); mRedisplayTextEvent = event; if (!nsContentUtils::AddScriptRunner(event)) mRedisplayTextEvent.Forget(); @@ -1344,13 +1344,13 @@ nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent) nsStyleSet *styleSet = shell->StyleSet(); // create the style contexts for the anonymous block frame and text frame - nsRefPtr styleContext; + RefPtr styleContext; styleContext = styleSet-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozDisplayComboboxControlFrame, mStyleContext, nsStyleSet::eSkipParentDisplayBasedStyleFixup); - nsRefPtr textStyleContext; + RefPtr textStyleContext; textStyleContext = styleSet->ResolveStyleForNonElement(mStyleContext); // Start by creating our anonymous block frame diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 23646c19d9..779274c4af 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -79,7 +79,7 @@ MakeAnonButton(nsIDocument* aDoc, const char* labelKey, HTMLInputElement* aInputElement, const nsAString& aAccessKey) { - nsRefPtr button = aDoc->CreateHTMLElement(nsGkAtoms::button); + RefPtr button = aDoc->CreateHTMLElement(nsGkAtoms::button); // NOTE: SetIsNativeAnonymousRoot() has to be called before setting any // attribute. button->SetIsNativeAnonymousRoot(); @@ -93,7 +93,7 @@ MakeAnonButton(nsIDocument* aDoc, const char* labelKey, // Set the browse button text. It's a bit of a pain to do because we want to // make sure we are not notifying. - nsRefPtr textContent = + RefPtr textContent = new nsTextNode(button->NodeInfo()->NodeInfoManager()); textContent->SetText(buttonTxt, false); @@ -105,7 +105,7 @@ MakeAnonButton(nsIDocument* aDoc, const char* labelKey, // Make sure access key and tab order for the element actually redirect to the // file picking button. - nsRefPtr buttonElement = + RefPtr buttonElement = HTMLButtonElement::FromContentOrNull(button); if (!aAccessKey.IsEmpty()) { @@ -131,7 +131,7 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) bool isDirPicker = Preferences::GetBool("dom.input.dirpicker", false) && content && content->HasAttr(kNameSpaceID_None, nsGkAtoms::directory); - nsRefPtr fileContent = HTMLInputElement::FromContentOrNull(mContent); + RefPtr fileContent = HTMLInputElement::FromContentOrNull(mContent); // The access key is transferred to the "Choose files..." button only. In // effect that access key allows access to the control via that button, then @@ -158,7 +158,7 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) } // Create and setup the text showing the selected files. - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::label, nullptr, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); @@ -286,7 +286,7 @@ nsFileControlFrame::DnDListener::IsValidDropData(nsIDOMDataTransfer* aDOMDataTra NS_ENSURE_TRUE(dataTransfer, false); // We only support dropping files onto a file upload control - nsRefPtr types = dataTransfer->Types(); + RefPtr types = dataTransfer->Types(); return types->Contains(NS_LITERAL_STRING("Files")); } diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 3de290d19d..864f33756c 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -146,7 +146,7 @@ protected: * Drag and drop mouse listener. * This makes sure we don't get used after destruction. */ - nsRefPtr mMouseListener; + RefPtr mMouseListener; protected: /** diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 186c1310d1..0c10b6b907 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -89,7 +89,7 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIContent* aContent) nsContainerFrame* parentFrame = do_QueryFrame(mFrames.FirstChild()); nsPresContext* presContext = PresContext(); - nsRefPtr textStyleContext; + RefPtr textStyleContext; textStyleContext = presContext->StyleSet()-> ResolveStyleForNonElement(mStyleContext); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 7ff37880d1..57a4fdc500 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -698,7 +698,7 @@ nsListControlFrame::InitSelectionRange(int32_t aClickedIndex) int32_t selectedIndex = GetSelectedIndex(); if (selectedIndex >= 0) { // Get the end of the contiguous selection - nsRefPtr options = GetOptions(); + RefPtr options = GetOptions(); NS_ASSERTION(options, "Collection of options is null!"); uint32_t numOptions = options->Length(); // Push i to one past the last selected index in the group. @@ -1108,7 +1108,7 @@ nsListControlFrame::GetCurrentOption() } // There is no selected item. Return the first non-disabled item. - nsRefPtr selectElement = + RefPtr selectElement = dom::HTMLSelectElement::FromContent(mContent); for (uint32_t i = 0, length = selectElement->Length(); i < length; ++i) { @@ -1258,7 +1258,7 @@ nsListControlFrame::SetOptionsSelectedFromFrame(int32_t aStartIndex, bool aValue, bool aClearAll) { - nsRefPtr selectElement = + RefPtr selectElement = dom::HTMLSelectElement::FromContent(mContent); uint32_t mask = dom::HTMLSelectElement::NOTIFY; @@ -1278,11 +1278,11 @@ nsListControlFrame::SetOptionsSelectedFromFrame(int32_t aStartIndex, bool nsListControlFrame::ToggleOptionSelectedFromFrame(int32_t aIndex) { - nsRefPtr option = + RefPtr option = GetOption(static_cast(aIndex)); NS_ENSURE_TRUE(option, false); - nsRefPtr selectElement = + RefPtr selectElement = dom::HTMLSelectElement::FromContent(mContent); uint32_t mask = dom::HTMLSelectElement::NOTIFY; @@ -1516,7 +1516,7 @@ nsListControlFrame::GetBSizeOfARow() nsresult nsListControlFrame::IsOptionDisabled(int32_t anIndex, bool &aIsDisabled) { - nsRefPtr sel = + RefPtr sel = dom::HTMLSelectElement::FromContent(mContent); if (sel) { sel->IsOptionDisabled(anIndex, &aIsDisabled); @@ -1547,7 +1547,7 @@ nsListControlFrame::CalcFallbackRowBSize(float aFontSizeInflation) { nscoord rowBSize = 0; - nsRefPtr fontMet; + RefPtr fontMet; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), aFontSizeInflation); if (fontMet) { @@ -1737,7 +1737,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, } } - nsRefPtr option; + RefPtr option; for (nsCOMPtr content = PresContext()->EventStateManager()->GetEventTargetContent(nullptr); content && !option; @@ -1759,7 +1759,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, // If the event coordinate is above the first option frame, then target the // first option frame - nsRefPtr firstOption = GetOption(0); + RefPtr firstOption = GetOption(0); NS_ASSERTION(firstOption, "Can't find first option that's supposed to be there"); nsIFrame* optionFrame = firstOption->GetPrimaryFrame(); if (optionFrame) { @@ -1771,7 +1771,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, } } - nsRefPtr lastOption = GetOption(numOptions - 1); + RefPtr lastOption = GetOption(numOptions - 1); // If the event coordinate is below the last option frame, then target the // last option frame NS_ASSERTION(lastOption, "Can't find last option that's supposed to be there"); @@ -1948,7 +1948,7 @@ nsListControlFrame::ScrollToIndex(int32_t aIndex) // kNothingSelected? ScrollTo(nsPoint(0, 0), nsIScrollableFrame::INSTANT); } else { - nsRefPtr option = + RefPtr option = GetOption(AssertedCast(aIndex)); if (option) { ScrollToFrame(*option); @@ -2137,7 +2137,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) } // now make sure there are options or we are wasting our time - nsRefPtr options = GetOptions(); + RefPtr options = GetOptions(); NS_ENSURE_TRUE(options, NS_ERROR_FAILURE); uint32_t numOptions = options->Length(); @@ -2386,7 +2386,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) } // now make sure there are options or we are wasting our time - nsRefPtr options = GetOptions(); + RefPtr options = GetOptions(); NS_ENSURE_TRUE(options, NS_ERROR_FAILURE); uint32_t numOptions = options->Length(); @@ -2394,7 +2394,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) nsWeakFrame weakFrame(this); for (uint32_t i = 0; i < numOptions; ++i) { uint32_t index = (i + startIndex) % numOptions; - nsRefPtr optionElement = + RefPtr optionElement = options->ItemAsOption(index); if (!optionElement || !optionElement->GetPrimaryFrame()) { continue; diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 4482be340c..c2afcb0c43 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -437,7 +437,7 @@ protected: // are translucent. nscolor mLastDropdownBackstopColor; - nsRefPtr mEventListener; + RefPtr mEventListener; static nsListControlFrame * mFocused; static nsString * sIncrementalString; diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index 6a26b85e49..475b2e346f 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -73,7 +73,7 @@ nsMeterFrame::CreateAnonymousContent(nsTArray& aElements) // Associate ::-moz-meter-bar pseudo-element to the anonymous child. nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozMeterBar; - nsRefPtr newStyleContext = PresContext()->StyleSet()-> + RefPtr newStyleContext = PresContext()->StyleSet()-> ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, StyleContext(), mBarDiv->AsElement()); @@ -227,7 +227,7 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, const LogicalSize& aPadding, bool aShrinkWrap) { - nsRefPtr fontMet; + RefPtr fontMet; NS_ENSURE_SUCCESS(nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), LogicalSize(aWM)); @@ -248,7 +248,7 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, nscoord nsMeterFrame::GetMinISize(nsRenderingContext *aRenderingContext) { - nsRefPtr fontMet; + RefPtr fontMet; NS_ENSURE_SUCCESS( nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), 0); diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index 67f8bd5d2a..a61291f1da 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -328,7 +328,7 @@ nsNumberControlFrame::MakeAnonymousElement(Element** aResult, { // Get the NodeInfoManager and tag necessary to create the anonymous divs. nsCOMPtr doc = mContent->GetComposedDoc(); - nsRefPtr resultElement = doc->CreateHTMLElement(aTagName); + RefPtr resultElement = doc->CreateHTMLElement(aTagName); // If we legitimately fail this assertion and need to allow // non-pseudo-element anonymous children, then we'll need to add a branch @@ -337,7 +337,7 @@ nsNumberControlFrame::MakeAnonymousElement(Element** aResult, NS_ASSERTION(aPseudoType != nsCSSPseudoElements::ePseudo_NotPseudoElement, "Expecting anonymous children to all be pseudo-elements"); // Associate the pseudo-element with the anonymous child - nsRefPtr newStyleContext = + RefPtr newStyleContext = PresContext()->StyleSet()->ResolvePseudoElementStyle(mContent->AsElement(), aPseudoType, aParentContext, @@ -424,7 +424,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray& aElements) if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) { // We don't want to focus the frame but the text field. - nsRefPtr focusJob = new FocusTextField(mContent, mTextField); + RefPtr focusJob = new FocusTextField(mContent, mTextField); nsContentUtils::AddScriptRunner(focusJob); } @@ -677,7 +677,7 @@ nsNumberControlFrame::HandleFocusEvent(WidgetEvent* aEvent) { if (aEvent->originalTarget != mTextField) { // Move focus to our text field - nsRefPtr textField = HTMLInputElement::FromContent(mTextField); + RefPtr textField = HTMLInputElement::FromContent(mTextField); textField->Focus(); } } @@ -685,7 +685,7 @@ nsNumberControlFrame::HandleFocusEvent(WidgetEvent* aEvent) nsresult nsNumberControlFrame::HandleSelectCall() { - nsRefPtr textField = HTMLInputElement::FromContent(mTextField); + RefPtr textField = HTMLInputElement::FromContent(mTextField); return textField->Select(); } diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index f41eeba5d1..d454d42cac 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -70,7 +70,7 @@ nsProgressFrame::CreateAnonymousContent(nsTArray& aElements) // Associate ::-moz-progress-bar pseudo-element to the anonymous child. nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozProgressBar; - nsRefPtr newStyleContext = PresContext()->StyleSet()-> + RefPtr newStyleContext = PresContext()->StyleSet()-> ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, StyleContext(), mBarDiv->AsElement()); @@ -254,7 +254,7 @@ nsProgressFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, nscoord nsProgressFrame::GetMinISize(nsRenderingContext *aRenderingContext) { - nsRefPtr fontMet; + RefPtr fontMet; NS_ENSURE_SUCCESS( nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), 0); diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index 570eb05175..89c1d01f01 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -113,10 +113,10 @@ nsRangeFrame::MakeAnonymousDiv(Element** aResult, nsTArray& aElements) { nsCOMPtr doc = mContent->GetComposedDoc(); - nsRefPtr resultElement = doc->CreateHTMLElement(nsGkAtoms::div); + RefPtr resultElement = doc->CreateHTMLElement(nsGkAtoms::div); // Associate the pseudo-element with the anonymous child. - nsRefPtr newStyleContext = + RefPtr newStyleContext = PresContext()->StyleSet()->ResolvePseudoElementStyle(mContent->AsElement(), aPseudoType, StyleContext(), diff --git a/layout/forms/nsRangeFrame.h b/layout/forms/nsRangeFrame.h index 32dba33df3..0c2d2b70b3 100644 --- a/layout/forms/nsRangeFrame.h +++ b/layout/forms/nsRangeFrame.h @@ -178,7 +178,7 @@ private: /** * Cached style context for -moz-focus-outer CSS pseudo-element style. */ - nsRefPtr mOuterFocusStyle; + RefPtr mOuterFocusStyle; class DummyTouchListener final : public nsIDOMEventListener { @@ -197,7 +197,7 @@ private: /** * A no-op touch-listener used for APZ purposes (see nsRangeFrame::Init). */ - nsRefPtr mDummyTouchListener; + RefPtr mDummyTouchListener; }; #endif diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 96f1137c1f..99216c4cb6 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -153,7 +153,7 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext, nscoord charWidth = 0; nscoord charMaxAdvance = 0; - nsRefPtr fontMet; + RefPtr fontMet; nsresult rv = nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), aFontSizeInflation); @@ -349,7 +349,7 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray& aElements) nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozPlaceholder; - nsRefPtr placeholderStyleContext = + RefPtr placeholderStyleContext = PresContext()->StyleSet()->ResolvePseudoElementStyle( mContent->AsElement(), pseudoType, StyleContext(), placeholderNode->AsElement()); @@ -522,7 +522,7 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext, lineHeight = nsHTMLReflowState::CalcLineHeight(GetContent(), StyleContext(), NS_AUTOHEIGHT, inflation); } - nsRefPtr fontMet; + RefPtr fontMet; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), inflation); // now adjust for our borders and padding @@ -654,7 +654,7 @@ void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint) if (!ourSel) return; nsIPresShell* presShell = PresContext()->GetPresShell(); - nsRefPtr caret = presShell->GetCaret(); + RefPtr caret = presShell->GetCaret(); if (!caret) return; // Scroll the current selection into view @@ -671,7 +671,7 @@ void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint) } } if (!(lastFocusMethod & nsIFocusManager::FLAG_BYMOUSE)) { - nsRefPtr event = new ScrollOnFocusEvent(this); + RefPtr event = new ScrollOnFocusEvent(this); nsresult rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv)) { mScrollEvent = event; @@ -750,7 +750,7 @@ nsTextControlFrame::SetSelectionInternal(nsIDOMNode *aStartNode, // Note that we use a new range to avoid having to do // isIncreasing checks to avoid possible errors. - nsRefPtr range = new nsRange(mContent); + RefPtr range = new nsRange(mContent); nsresult rv = range->SetStart(aStartNode, aStartOffset); NS_ENSURE_SUCCESS(rv, rv); @@ -1292,7 +1292,7 @@ nsTextControlFrame::UpdateValueDisplay(bool aNotify, nsIContent *textContent = rootNode->GetChildAt(0); if (!textContent) { // Set up a textnode with our value - nsRefPtr textNode = + RefPtr textNode = new nsTextNode(mContent->NodeInfo()->NodeInfoManager()); NS_ASSERTION(textNode, "Must have textcontent!\n"); diff --git a/layout/generic/DetailsFrame.cpp b/layout/generic/DetailsFrame.cpp index 4184d0078b..25a44e69d8 100644 --- a/layout/generic/DetailsFrame.cpp +++ b/layout/generic/DetailsFrame.cpp @@ -112,7 +112,7 @@ DetailsFrame::CreateAnonymousContent(nsTArray& aElements) nsXPIDLString defaultSummaryText; nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, "DefaultSummary", defaultSummaryText); - nsRefPtr description = new nsTextNode(nodeInfoManager); + RefPtr description = new nsTextNode(nodeInfoManager); description->SetText(defaultSummaryText, false); mDefaultSummary->AppendChildTo(description, false); diff --git a/layout/generic/MathMLTextRunFactory.cpp b/layout/generic/MathMLTextRunFactory.cpp index 70a09fe610..b87bd4ce5b 100644 --- a/layout/generic/MathMLTextRunFactory.cpp +++ b/layout/generic/MathMLTextRunFactory.cpp @@ -537,7 +537,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun, nsAutoString convertedString; nsAutoTArray charsToMergeArray; nsAutoTArray deletedCharsArray; - nsAutoTArray,50> styleArray; + nsAutoTArray,50> styleArray; nsAutoTArray canBreakBeforeArray; bool mergeNeeded = false; @@ -546,7 +546,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun, uint32_t length = aTextRun->GetLength(); const char16_t* str = aTextRun->mString.BeginReading(); - const nsTArray>& styles = aTextRun->mStyles; + const nsTArray>& styles = aTextRun->mStyles; nsFont font; if (length) { font = styles[0]->mFont; @@ -668,7 +668,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun, // Alphanumeric Symbols. Hence we check whether the transformed // character is actually available. uint8_t matchType; - nsRefPtr mathFont = fontGroup-> + RefPtr mathFont = fontGroup-> FindFontForChar(ch2, 0, 0, HB_SCRIPT_COMMON, nullptr, &matchType); if (mathFont) { // Don't apply the CSS style if there is a math font for at least one @@ -741,7 +741,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun, if (length) { font.size = NSToCoordRound(font.size * mFontInflation); nsPresContext* pc = styles[0]->mPresContext; - nsRefPtr metrics; + RefPtr metrics; pc->DeviceContext()->GetMetricsFor(font, styles[0]->mLanguage, styles[0]->mExplicitLanguage, diff --git a/layout/generic/ScrollbarActivity.h b/layout/generic/ScrollbarActivity.h index c3c94840f6..54f0a35776 100644 --- a/layout/generic/ScrollbarActivity.h +++ b/layout/generic/ScrollbarActivity.h @@ -86,7 +86,7 @@ public: virtual void WillRefresh(TimeStamp aTime) override; static void FadeBeginTimerFired(nsITimer* aTimer, void* aSelf) { - nsRefPtr scrollbarActivity( + RefPtr scrollbarActivity( reinterpret_cast(aSelf)); scrollbarActivity->BeginFade(); } diff --git a/layout/generic/Selection.h b/layout/generic/Selection.h index 3de441a3ca..2c8238edba 100644 --- a/layout/generic/Selection.h +++ b/layout/generic/Selection.h @@ -38,7 +38,7 @@ struct RangeData : mRange(aRange) {} - nsRefPtr mRange; + RefPtr mRange; mozilla::TextRangeStyle mTextRangeStyle; }; @@ -204,7 +204,7 @@ public: void GetRangesForInterval(nsINode& aBeginNode, int32_t aBeginOffset, nsINode& aEndNode, int32_t aEndOffset, bool aAllowAdjacent, - nsTArray>& aReturn, + nsTArray>& aReturn, mozilla::ErrorResult& aRv); void ScrollIntoView(int16_t aRegion, bool aIsSynchronous, @@ -299,7 +299,7 @@ private: int32_t* aStartIndex, int32_t* aEndIndex); RangeData* FindRangeData(nsIDOMRange* aRange); - void UserSelectRangesToAdd(nsRange* aItem, nsTArray >& rangesToAdd); + void UserSelectRangesToAdd(nsRange* aItem, nsTArray >& rangesToAdd); /** * Helper method for AddItem. @@ -321,9 +321,9 @@ private: // O(log n) time, though this would require rebalancing and other overhead. nsTArray mRanges; - nsRefPtr mAnchorFocusRange; - nsRefPtr mFrameSelection; - nsRefPtr mAutoScrollTimer; + RefPtr mAnchorFocusRange; + RefPtr mFrameSelection; + RefPtr mAutoScrollTimer; nsCOMArray mSelectionListeners; nsRevocableEventPtr mScrollEvent; CachedOffsetForFrame *mCachedOffsetForFrame; @@ -345,7 +345,7 @@ private: class MOZ_STACK_CLASS SelectionBatcher final { private: - nsRefPtr mSelection; + RefPtr mSelection; public: explicit SelectionBatcher(Selection* aSelection) { @@ -366,7 +366,7 @@ public: class MOZ_STACK_CLASS AutoHideSelectionChanges final { private: - nsRefPtr mSelection; + RefPtr mSelection; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER public: explicit AutoHideSelectionChanges(const nsFrameSelection* aFrame); diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 5ddb90086e..8111c6d781 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -44,7 +44,7 @@ private: static gfxTextRun* GetEllipsisTextRun(nsIFrame* aFrame) { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(aFrame)); LazyReferenceRenderingContextGetterFromFrame lazyRefContextGetter(aFrame); @@ -251,7 +251,7 @@ nsDisplayTextOverflowMarker::PaintTextToContext(nsRenderingContext* aCtx, 0, textRun->GetLength(), nullptr, nullptr, nullptr); } } else { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(mFrame, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(mFrame)); nsLayoutUtils::DrawString(mFrame, *fm, aCtx, mStyle->mString.get(), @@ -734,7 +734,7 @@ TextOverflow::CanHaveTextOverflow(nsDisplayListBuilder* aBuilder, } // Inhibit the markers if a descendant content owns the caret. - nsRefPtr caret = aBlockFrame->PresContext()->PresShell()->GetCaret(); + RefPtr caret = aBlockFrame->PresContext()->PresShell()->GetCaret(); if (caret && caret->IsVisible()) { nsCOMPtr domSelection = caret->GetSelection(); if (domSelection) { @@ -807,7 +807,7 @@ TextOverflow::Marker::SetupString(nsIFrame* aFrame) } else { nsRenderingContext rc( aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext()); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(aFrame)); mISize = nsLayoutUtils::AppUnitWidthOfStringBidi(mStyle->mString, aFrame, diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index 457976c7d7..ab5ffcb012 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -121,7 +121,7 @@ BRFrame::Reflow(nsPresContext* aPresContext, // We also do this in strict mode because BR should act like a // normal inline frame. That line-height is used is important // here for cases where the line-height is less than 1. - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(this)); if (fm) { diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 0cb2131943..a19d2f12f1 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -516,7 +516,7 @@ nsBlockFrame::GetCaretBaseline() const return bp.top + firstLine->mFirstChild->GetCaretBaseline(); } } - nsRefPtr fm; + RefPtr fm; float inflation = nsLayoutUtils::FontSizeInflationFor(this); nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation); nscoord lineHeight = @@ -2624,7 +2624,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) } } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(this)); @@ -6843,7 +6843,7 @@ nsBlockFrame::SetInitialChildList(ChildListID aListID, pseudo == nsCSSAnonBoxes::mozSVGText) && GetType() != nsGkAtoms::comboboxControlFrame && !IsFrameOfType(eMathML) && - nsRefPtr(GetFirstLetterStyle(PresContext())) != nullptr; + RefPtr(GetFirstLetterStyle(PresContext())) != nullptr; NS_ASSERTION(haveFirstLetterStyle == ((mState & NS_BLOCK_HAS_FIRST_LETTER_STYLE) != 0), "NS_BLOCK_HAS_FIRST_LETTER_STYLE state out of sync"); @@ -6899,7 +6899,7 @@ nsBlockFrame::CreateBulletFrameForListItem(bool aCreateBulletList, nsCSSPseudoElements::GetPseudoAtom(pseudoType))-> StyleContext(); - nsRefPtr kidSC = shell->StyleSet()-> + RefPtr kidSC = shell->StyleSet()-> ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, parentStyle, nullptr); diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index f1ceb316be..25c1f6dfcd 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -128,7 +128,7 @@ nsBulletFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) } if (needNewRequest) { - nsRefPtr newRequestClone; + RefPtr newRequestClone; newRequest->Clone(mListener, getter_AddRefs(newRequestClone)); // Deregister the old request. We wait until after Clone is done in case @@ -304,7 +304,7 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt, } } - nsRefPtr fm; + RefPtr fm; ColorPattern color(ToDeviceColor( nsLayoutUtils::GetColor(this, eCSSProperty_color))); @@ -535,7 +535,7 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX, const nsStyleList* myList = StyleList(); nscoord ascent; - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), aFontSizeInflation); @@ -893,7 +893,7 @@ nsBulletFrame::GetLogicalBaseline(WritingMode aWritingMode) const if (GetStateBits() & BULLET_FRAME_IMAGE_LOADING) { ascent = BSize(aWritingMode); } else { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), GetFontSizeInflation()); CounterStyle* listStyleType = StyleList()->GetCounterStyle(); diff --git a/layout/generic/nsBulletFrame.h b/layout/generic/nsBulletFrame.h index b050859b83..dba83fe26c 100644 --- a/layout/generic/nsBulletFrame.h +++ b/layout/generic/nsBulletFrame.h @@ -125,8 +125,8 @@ protected: nsIDocument* GetOurCurrentDoc() const; mozilla::LogicalMargin mPadding; - nsRefPtr mImageRequest; - nsRefPtr mListener; + RefPtr mImageRequest; + RefPtr mListener; mozilla::LogicalSize mIntrinsicSize; int32_t mOrdinal; diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index 5738091c28..d9a1da14ca 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -85,7 +85,7 @@ nsCanvasFrame::CreateAnonymousContent(nsTArray& aElements) ErrorResult er; // We won't create touch caret element if preference is not enabled. if (PresShell::TouchCaretPrefEnabled()) { - nsRefPtr nodeInfo; + RefPtr nodeInfo; // Create and append touch caret frame. nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div, nullptr, @@ -221,7 +221,7 @@ nsCanvasFrame::DestroyFrom(nsIFrame* aDestructRoot) nsCOMPtr doc = mContent->OwnerDoc(); ErrorResult rv; - nsTArray>& docAnonContents = + nsTArray>& docAnonContents = doc->GetAnonymousContents(); for (size_t i = 0, len = docAnonContents.Length(); i < len; ++i) { AnonymousContent* content = docAnonContents[i]; @@ -369,7 +369,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder, nsRect bgClipRect = frame->CanvasArea() + offset; nsRenderingContext context; - nsRefPtr dest = aCtx->ThebesContext(); + RefPtr dest = aCtx->ThebesContext(); RefPtr dt; gfxRect destRect; #ifndef MOZ_GFX_OPTIMIZE_MOBILE @@ -387,7 +387,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder, } dt = destDT->CreateSimilarDrawTarget(IntSize(ceil(destRect.width), ceil(destRect.height)), SurfaceFormat::B8G8R8A8); if (dt) { - nsRefPtr ctx = new gfxContext(dt); + RefPtr ctx = new gfxContext(dt); ctx->SetMatrix( ctx->CurrentMatrix().Translate(-destRect.x, -destRect.y)); context.Init(ctx); diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index 4e56b80af0..1e97bdd9a0 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -186,7 +186,7 @@ protected: /** * A no-op touch-listener used for APZ purposes. */ - nsRefPtr mDummyTouchListener; + RefPtr mDummyTouchListener; }; /** diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 2480f71a84..930345002a 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -656,7 +656,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, return; } - nsRefPtr kungFuDeathGrip(aPresContext); + RefPtr kungFuDeathGrip(aPresContext); nsWeakFrame weak(rootFrame); nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame, rootFrame); diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index 918647e887..bbd1869a0d 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -60,7 +60,7 @@ nsFirstLetterFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) { - nsRefPtr newSC; + RefPtr newSC; if (aPrevInFlow) { // Get proper style context for ourselves. We're creating the frame // that represents everything *except* the first letter, so just create @@ -326,7 +326,7 @@ nsFirstLetterFrame::CreateContinuationForFloatingParent(nsPresContext* aPresCont // doesn't have the first letter styling. nsStyleContext* parentSC = this->StyleContext()->GetParent(); if (parentSC) { - nsRefPtr newSC; + RefPtr newSC; newSC = presShell->StyleSet()->ResolveStyleForNonElement(parentSC); continuation->SetStyleContext(newSC); nsLayoutUtils::MarkDescendantsDirty(continuation); @@ -374,7 +374,7 @@ nsFirstLetterFrame::DrainOverflowFrames(nsPresContext* aPresContext) // are reflowed) nsIFrame* kid = mFrames.FirstChild(); if (kid) { - nsRefPtr sc; + RefPtr sc; nsIContent* kidContent = kid->GetContent(); if (kidContent) { NS_ASSERTION(kidContent->IsNodeOfType(nsINode::eTEXT), diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 2e2a739c0c..ea98a5d30e 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2605,7 +2605,7 @@ nsFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent) nsIContent* target = aContent ? aContent : mContent; if (target) { - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(target, aDOMEventName, true, false); DebugOnly rv = asyncDispatcher->PostDOMEvent(); NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncEventDispatcher failed to dispatch"); @@ -2949,7 +2949,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext, bool control = mouseEvent->IsControl(); #endif - nsRefPtr fc = const_cast(frameselection); + RefPtr fc = const_cast(frameselection); if (mouseEvent->clickCount > 1) { // These methods aren't const but can't actually delete anything, // so no need for nsWeakFrame. @@ -3231,7 +3231,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, return rv; // Keep frameSelection alive. - nsRefPtr frameSelection = GetFrameSelection(); + RefPtr frameSelection = GetFrameSelection(); rv = frameSelection->HandleClick(startpos.mResultContent, startpos.mContentOffset, startpos.mContentOffset, @@ -3271,7 +3271,7 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext, } nsIPresShell *presShell = aPresContext->PresShell(); - nsRefPtr frameselection = GetFrameSelection(); + RefPtr frameselection = GetFrameSelection(); bool mouseDown = frameselection->GetDragState(); if (!mouseDown) return NS_OK; @@ -3406,7 +3406,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext, bool selectionOff = (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF); - nsRefPtr frameselection; + RefPtr frameselection; ContentOffsets offsets; nsCOMPtr parentContent; int32_t contentOffsetForTableSel = 0; @@ -3437,7 +3437,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext, // We might be capturing in some other document and the event just happened to // trickle down here. Make sure that document's frame selection is notified. // Note, this may cause the current nsFrame object to be deleted, bug 336592. - nsRefPtr frameSelection; + RefPtr frameSelection; if (activeFrame != this && static_cast(activeFrame)->DisplaySelection(activeFrame->PresContext()) != nsISelectionController::SELECTION_OFF) { @@ -6054,7 +6054,7 @@ nsFrame::GetSelectionController(nsPresContext *aPresContext, nsISelectionControl already_AddRefed nsIFrame::GetFrameSelection() { - nsRefPtr fs = + RefPtr fs = const_cast(GetConstFrameSelection()); return fs.forget(); } diff --git a/layout/generic/nsFrameSelection.h b/layout/generic/nsFrameSelection.h index 83e98fca13..27890474b5 100644 --- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -683,7 +683,7 @@ private: // so remember to use nsCOMPtr when needed. nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc? - nsRefPtr mDomSelections[nsISelectionController::NUM_SELECTIONTYPES]; + RefPtr mDomSelections[nsISelectionController::NUM_SELECTIONTYPES]; // Table selection support. nsITableCellLayout* GetCellLayout(nsIContent *aCellContent) const; @@ -721,7 +721,7 @@ private: int32_t mSelectedCellIndex; // maintain selection - nsRefPtr mMaintainRange; + RefPtr mMaintainRange; nsSelectionAmount mMaintainedAmount; //batching diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 54fc338d79..33393992ee 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -312,7 +312,7 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent, continue; if (child->IsAnyOfHTMLElements(nsGkAtoms::frameset, nsGkAtoms::frame)) { - nsRefPtr kidSC; + RefPtr kidSC; kidSC = shell->StyleSet()->ResolveStyleFor(child->AsElement(), mStyleContext); @@ -345,7 +345,7 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent, mNonBlankChildCount = mChildCount; // add blank frames for frameset cells that had no content provided for (int blankX = mChildCount; blankX < numCells; blankX++) { - nsRefPtr pseudoStyleContext; + RefPtr pseudoStyleContext; pseudoStyleContext = shell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::framesetBlank, mStyleContext); @@ -920,7 +920,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext, offset.y += lastSize.height; if (firstTime) { // create horizontal border - nsRefPtr pseudoStyleContext; + RefPtr pseudoStyleContext; pseudoStyleContext = styleSet-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::horizontalFramesetBorder, mStyleContext); @@ -950,7 +950,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext, if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border - nsRefPtr pseudoStyleContext; + RefPtr pseudoStyleContext; pseudoStyleContext = styleSet-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::verticalFramesetBorder, mStyleContext); diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 53200474a7..1c6cead10e 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -3557,7 +3557,7 @@ ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination, nsSize ScrollFrameHelper::GetLineScrollAmount() const { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(mOuter, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(mOuter)); NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit"); @@ -3877,14 +3877,14 @@ ScrollFrameHelper::CreateAnonymousContent( nsNodeInfoManager *nodeInfoManager = presContext->Document()->NodeInfoManager(); - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::scrollbar, nullptr, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); if (canHaveHorizontal) { - nsRefPtr ni = nodeInfo; + RefPtr ni = nodeInfo; NS_TrustedNewXULElement(getter_AddRefs(mHScrollbarContent), ni.forget()); mHScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient, NS_LITERAL_STRING("horizontal"), false); @@ -3899,7 +3899,7 @@ ScrollFrameHelper::CreateAnonymousContent( } if (canHaveVertical) { - nsRefPtr ni = nodeInfo; + RefPtr ni = nodeInfo; NS_TrustedNewXULElement(getter_AddRefs(mVScrollbarContent), ni.forget()); mVScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient, NS_LITERAL_STRING("vertical"), false); @@ -3914,7 +3914,7 @@ ScrollFrameHelper::CreateAnonymousContent( } if (isResizable) { - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::resizer, nullptr, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); @@ -4084,7 +4084,7 @@ void ScrollFrameHelper::CurPosAttributeChanged(nsIContent* aContent) } if (mScrollbarActivity) { - nsRefPtr scrollbarActivity(mScrollbarActivity); + RefPtr scrollbarActivity(mScrollbarActivity); scrollbarActivity->ActivityOccurred(); } @@ -5086,7 +5086,7 @@ ScrollFrameHelper::SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom, } if (mScrollbarActivity) { - nsRefPtr scrollbarActivity(mScrollbarActivity); + RefPtr scrollbarActivity(mScrollbarActivity); scrollbarActivity->ActivityOccurred(); } } diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 48d518a7ea..db8ab7b93d 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -423,9 +423,9 @@ public: nsIFrame* mScrollCornerBox; nsIFrame* mResizerBox; nsContainerFrame* mOuter; - nsRefPtr mAsyncScroll; - nsRefPtr mAsyncSmoothMSDScroll; - nsRefPtr mScrollbarActivity; + RefPtr mAsyncScroll; + RefPtr mAsyncSmoothMSDScroll; + RefPtr mScrollbarActivity; nsTArray mListeners; nsIAtom* mLastScrollOrigin; nsIAtom* mLastSmoothScrollOrigin; diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 901a1b8eb7..5d16dc198e 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -338,7 +338,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder, CanvasLayer* oldLayer = static_cast (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)); - nsRefPtr layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager); + RefPtr layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager); if (!layer) return nullptr; diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 9c6923ebab..559951cae7 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -2624,7 +2624,7 @@ ComputeLineHeight(nsStyleContext* aStyleContext, } } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, getter_AddRefs(fm), aFontSizeInflation); diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h index 69d08867a8..e7d4399b6b 100644 --- a/layout/generic/nsIAnonymousContentCreator.h +++ b/layout/generic/nsIAnonymousContentCreator.h @@ -39,7 +39,7 @@ public: {} nsIContent* mContent; - nsRefPtr mStyleContext; + RefPtr mStyleContext; nsTArray mChildren; }; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 55c74f4c95..fe1fcd0225 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1145,7 +1145,7 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext, // Set font and color aRenderingContext.ThebesContext()-> SetColor(Color::FromABGR(StyleColor()->mColor)); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), nsLayoutUtils::FontSizeInflationFor(this)); @@ -1625,13 +1625,13 @@ nsDisplayImage::BuildLayer(nsDisplayListBuilder* aBuilder, ? imgIContainer::FLAG_SYNC_DECODE : imgIContainer::FLAG_NONE; - nsRefPtr container = + RefPtr container = mImage->GetImageContainer(aManager, flags); if (!container) { return nullptr; } - nsRefPtr layer = static_cast + RefPtr layer = static_cast (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this)); if (!layer) { layer = aManager->CreateImageLayer(); @@ -2049,7 +2049,7 @@ nsImageFrame::GetCursor(const nsPoint& aPoint, // technically correct, but it's probably the right thing to do // here, since it means that areas on which the cursor isn't // specified will inherit the style from the image. - nsRefPtr areaStyle = + RefPtr areaStyle = PresContext()->PresShell()->StyleSet()-> ResolveStyleFor(area->AsElement(), StyleContext()); FillCursorInformationFromStyle(areaStyle->StyleUserInterface(), @@ -2166,7 +2166,7 @@ nsImageFrame::LoadIcon(const nsAString& aSpec, nsCOMPtr realURI; SpecToURI(aSpec, sIOService, getter_AddRefs(realURI)); - nsRefPtr il = + RefPtr il = nsContentUtils::GetImgLoaderForDocument(aPresContext->Document()); nsCOMPtr loadGroup; diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 4a566ff1a7..44e640bb6b 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -375,8 +375,8 @@ private: public: - nsRefPtr mLoadingImage; - nsRefPtr mBrokenImage; + RefPtr mLoadingImage; + RefPtr mBrokenImage; bool mPrefForceInlineAltText; bool mPrefShowPlaceholders; }; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index f82ac09acf..b4322d3fbc 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -1058,7 +1058,7 @@ nsFirstLineFrame::Init(nsIContent* aContent, // we behave as if an anonymous (unstyled) span was the child // of the parent frame. nsStyleContext* parentContext = aParent->StyleContext(); - nsRefPtr newSC = PresContext()->StyleSet()-> + RefPtr newSC = PresContext()->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozLineFrame, parentContext); SetStyleContext(newSC); } else { diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 0be80d398a..e1c0352717 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -1717,7 +1717,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nsIFrame* spanFrame = spanFramePFD->mFrame; // Get the parent frame's font for all of the frames in this span - nsRefPtr fm; + RefPtr fm; float inflation = GetInflationForBlockDirAlignment(spanFrame, mInflationMinFontSize); nsLayoutUtils::GetFontMetricsForFrame(spanFrame, getter_AddRefs(fm), diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index 377c2ee1fd..59b920e249 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -629,7 +629,7 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext, gfxContextAutoDisableSubpixelAntialiasing disable(aRenderingContext.ThebesContext(), aDisableSubpixelAA); // Get the FontMetrics to determine width.height of strings - nsRefPtr fontMet; + RefPtr fontMet; pc->DeviceContext()->GetMetricsFor(mPD->mHeadFootFont, nullptr, false, gfxFont::eHorizontal, pc->GetUserFontSet(), diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 826312e661..b28953bc00 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -321,7 +321,7 @@ nsPluginFrame::PrepForDrawing(nsIWidget *aWidget) configuration->mBounds.height = NSAppUnitsToIntPixels(mRect.height, appUnitsPerDevPixel); parentWidget->ConfigureChildren(configurations); - nsRefPtr dx = viewMan->GetDeviceContext(); + RefPtr dx = viewMan->GetDeviceContext(); mInnerView->AttachWidgetEventHandler(mWidget); #ifdef XP_MACOSX @@ -593,7 +593,7 @@ nsPluginFrame::CallSetWindow(bool aCheckIsHidden) NPWindow *win = nullptr; nsresult rv = NS_ERROR_FAILURE; - nsRefPtr pi; + RefPtr pi; if (!mInstanceOwner || NS_FAILED(rv = mInstanceOwner->GetInstance(getter_AddRefs(pi))) || !pi || @@ -610,7 +610,7 @@ nsPluginFrame::CallSetWindow(bool aCheckIsHidden) // on OS X) or SetWindow() (below, on all platforms) can destroy this // frame. (FixUpPluginWindow() calls SetWindow()). So grab a safe // reference to mInstanceOwner which we can use below, if needed. - nsRefPtr instanceOwnerRef(mInstanceOwner); + RefPtr instanceOwnerRef(mInstanceOwner); // refresh the plugin port as well #ifdef XP_MACOSX @@ -1125,7 +1125,7 @@ nsPluginFrame::IsTransparentMode() const return false; nsresult rv; - nsRefPtr pi; + RefPtr pi; rv = mInstanceOwner->GetInstance(getter_AddRefs(pi)); if (NS_FAILED(rv) || !pi) return false; @@ -1247,7 +1247,7 @@ nsPluginFrame::PrintPlugin(nsRenderingContext& aRenderingContext, return; // finally we can get our plugin instance - nsRefPtr pi; + RefPtr pi; if (NS_FAILED(objectFrame->GetPluginInstance(getter_AddRefs(pi))) || !pi) return; @@ -1397,12 +1397,12 @@ nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder, gfxRect r = nsLayoutUtils::RectToGfxRect(area, PresContext()->AppUnitsPerDevPixel()); // to provide crisper and faster drawing. r.Round(); - nsRefPtr layer = + RefPtr layer = (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)); if (aItem->GetType() == nsDisplayItem::TYPE_PLUGIN) { // Create image - nsRefPtr container = mInstanceOwner->GetImageContainer(); + RefPtr container = mInstanceOwner->GetImageContainer(); if (!container) { // This can occur if our instance is gone. return nullptr; @@ -1441,7 +1441,7 @@ nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder, nsDisplayPluginVideo* videoItem = reinterpret_cast(aItem); nsNPAPIPluginInstance::VideoInfo* videoInfo = videoItem->VideoInfo(); - nsRefPtr container = mInstanceOwner->GetImageContainerForVideo(videoInfo); + RefPtr container = mInstanceOwner->GetImageContainerForVideo(videoInfo); if (!container) return nullptr; @@ -1569,7 +1569,7 @@ nsPluginFrame::PaintPlugin(nsDisplayListBuilder* aBuilder, return; } - nsRefPtr inst; + RefPtr inst; GetPluginInstance(getter_AddRefs(inst)); if (!inst) { NS_WARNING("null plugin instance during PaintPlugin"); @@ -1636,7 +1636,7 @@ nsPluginFrame::PaintPlugin(nsDisplayListBuilder* aBuilder, } } #elif defined(XP_WIN) - nsRefPtr inst; + RefPtr inst; GetPluginInstance(getter_AddRefs(inst)); if (inst) { gfxRect frameGfxRect = @@ -1836,7 +1836,7 @@ nsPluginFrame::GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor) return NS_ERROR_FAILURE; } - nsRefPtr inst; + RefPtr inst; mInstanceOwner->GetInstance(getter_AddRefs(inst)); if (!inst) { return NS_ERROR_FAILURE; @@ -1867,7 +1867,7 @@ nsPluginFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot) while (child) { nsIObjectFrame* outFrame = do_QueryFrame(child); if (outFrame) { - nsRefPtr pi; + RefPtr pi; outFrame->GetPluginInstance(getter_AddRefs(pi)); // make sure we have a REAL plugin if (pi) return outFrame; diff --git a/layout/generic/nsPluginFrame.h b/layout/generic/nsPluginFrame.h index 9cfe52a00e..d69d5fd9fc 100644 --- a/layout/generic/nsPluginFrame.h +++ b/layout/generic/nsPluginFrame.h @@ -302,7 +302,7 @@ private: // plugins we register on the root PresContext. // This is only non-null while we have a plugin registered for geometry // updates. - nsRefPtr mRootPresContextRegisteredWith; + RefPtr mRootPresContextRegisteredWith; }; class nsDisplayPlugin : public nsDisplayItem { diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index cd392398cf..d20741f73f 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -410,7 +410,7 @@ struct MOZ_RAII AutoPrepareFocusRange aSelection->mAnchorFocusRange = range; // Remove all generated ranges (including the old mAnchorFocusRange). - nsRefPtr presContext = aSelection->GetPresContext(); + RefPtr presContext = aSelection->GetPresContext(); size_t i = len; while (i--) { range = aSelection->mRanges[i].mRange; @@ -541,7 +541,7 @@ nsFrameSelection::FetchDesiredPos(nsPoint &aDesiredPos) return NS_OK; } - nsRefPtr caret = mShell->GetCaret(); + RefPtr caret = mShell->GetCaret(); if (!caret) { return NS_ERROR_NULL_POINTER; } @@ -720,7 +720,7 @@ nsFrameSelection::SetCaretBidiLevel(nsBidiLevel aLevel) // In this case, we don't want to reset the keyboard language mCaretBidiLevel = aLevel; - nsRefPtr caret; + RefPtr caret; if (mShell && (caret = mShell->GetCaret())) { caret->SchedulePaint(); } @@ -830,7 +830,7 @@ nsFrameSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) } // Set touch caret as selection listener - nsRefPtr touchCaret = mShell->GetTouchCaret(); + RefPtr touchCaret = mShell->GetTouchCaret(); if (touchCaret) { int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); if (mDomSelections[index]) { @@ -839,7 +839,7 @@ nsFrameSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) } // Set selection caret as selection listener - nsRefPtr selectionCarets = mShell->GetSelectionCarets(); + RefPtr selectionCarets = mShell->GetSelectionCarets(); if (selectionCarets) { int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); if (mDomSelections[index]) { @@ -855,12 +855,12 @@ nsFrameSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) if (mDomSelections[index]) { // The Selection instance will hold a strong reference to its selectionchangelistener // so we don't have to worry about that! - nsRefPtr listener = new SelectionChangeListener; + RefPtr listener = new SelectionChangeListener; mDomSelections[index]->AddSelectionListener(listener); } } - nsRefPtr eventHub = mShell->GetAccessibleCaretEventHub(); + RefPtr eventHub = mShell->GetAccessibleCaretEventHub(); if (eventHub) { int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); if (mDomSelections[index]) { @@ -900,7 +900,7 @@ nsFrameSelection::MoveCaret(nsDirection aDirection, nsPoint desiredPos(0, 0); //we must keep this around and revalidate it when its just UP/DOWN int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - nsRefPtr sel = mDomSelections[index]; + RefPtr sel = mDomSelections[index]; if (!sel) return NS_ERROR_NULL_POINTER; @@ -1704,7 +1704,7 @@ nsFrameSelection::TakeFocus(nsIContent* aNewFocus, // non-anchor/focus collapsed ranges. mDomSelections[index]->RemoveCollapsedRanges(); - nsRefPtr newRange = new nsRange(aNewFocus); + RefPtr newRange = new nsRange(aNewFocus); newRange->SetStart(aNewFocus, aContentOffset); newRange->SetEnd(aNewFocus, aContentOffset); @@ -1871,7 +1871,7 @@ nsFrameSelection::ScrollSelectionIntoView(SelectionType aType, // After ScrollSelectionIntoView(), the pending notifications might be // flushed and PresShell/PresContext/Frames may be dead. See bug 418470. - nsRefPtr sel = mDomSelections[index]; + RefPtr sel = mDomSelections[index]; return sel->ScrollIntoView(aRegion, verticalScroll, nsIPresShell::ScrollAxis(), flags); } @@ -2094,7 +2094,7 @@ nsFrameSelection::PhysicalMove(int16_t aDirection, int16_t aAmount, } int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - nsRefPtr sel = mDomSelections[index]; + RefPtr sel = mDomSelections[index]; if (!sel) { return NS_ERROR_NULL_POINTER; } @@ -2588,7 +2588,7 @@ printf("HandleTableSelection: Unselecting mUnselectCellOnMouseUp; rangeCount=%d\ { // Strong reference, because sometimes we want to remove // this range, and then we might be the only owner. - nsRefPtr range = mDomSelections[index]->GetRangeAt(i); + RefPtr range = mDomSelections[index]->GetRangeAt(i); if (!range) return NS_ERROR_NULL_POINTER; nsINode* parent = range->GetStartParent(); @@ -2699,7 +2699,7 @@ nsFrameSelection::UnselectCells(nsIContent *aTableContent, int32_t maxColIndex = std::max(aStartColumnIndex, aEndColumnIndex); // Strong reference because we sometimes remove the range - nsRefPtr range = GetFirstCellRange(); + RefPtr range = GetFirstCellRange(); nsIContent* cellNode = GetFirstSelectedContent(range); NS_PRECONDITION(!range || cellNode, "Must have cellNode if had a range"); @@ -3200,7 +3200,7 @@ nsFrameSelection::CreateAndAddRange(nsINode *aParentNode, int32_t aOffset) { if (!aParentNode) return NS_ERROR_NULL_POINTER; - nsRefPtr range = new nsRange(aParentNode); + RefPtr range = new nsRange(aParentNode); // Set range around child at given offset nsresult result = range->SetStart(aParentNode, aOffset); @@ -3261,9 +3261,9 @@ nsFrameSelection::DeleteFromDocument() return NS_OK; } - nsRefPtr selection = mDomSelections[index]; + RefPtr selection = mDomSelections[index]; for (uint32_t rangeIdx = 0; rangeIdx < selection->RangeCount(); ++rangeIdx) { - nsRefPtr range = selection->GetRangeAt(rangeIdx); + RefPtr range = selection->GetRangeAt(rangeIdx); res = range->DeleteContents(); if (NS_FAILED(res)) return res; @@ -3300,19 +3300,19 @@ void nsFrameSelection::DisconnectFromPresShell() { // Remove touch caret as selection listener - nsRefPtr touchCaret = mShell->GetTouchCaret(); + RefPtr touchCaret = mShell->GetTouchCaret(); if (touchCaret) { int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); mDomSelections[index]->RemoveSelectionListener(touchCaret); } - nsRefPtr selectionCarets = mShell->GetSelectionCarets(); + RefPtr selectionCarets = mShell->GetSelectionCarets(); if (selectionCarets) { int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); mDomSelections[index]->RemoveSelectionListener(selectionCarets); } - nsRefPtr eventHub = mShell->GetAccessibleCaretEventHub(); + RefPtr eventHub = mShell->GetAccessibleCaretEventHub(); if (eventHub) { int8_t index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); mDomSelections[index]->RemoveSelectionListener(eventHub); @@ -3645,7 +3645,7 @@ Selection::SubtractRange(RangeData* aRange, nsRange* aSubtract, if (cmp2 > 0) { // We need to add a new RangeData to the output, running from // the end of aSubtract to the end of range - nsRefPtr postOverlap = new nsRange(aSubtract->GetEndParent()); + RefPtr postOverlap = new nsRange(aSubtract->GetEndParent()); rv = postOverlap->SetStart(aSubtract->GetEndParent(), aSubtract->EndOffset()); @@ -3663,7 +3663,7 @@ Selection::SubtractRange(RangeData* aRange, nsRange* aSubtract, if (cmp < 0) { // We need to add a new RangeData to the output, running from // the start of the range to the start of aSubtract - nsRefPtr preOverlap = new nsRange(range->GetStartParent()); + RefPtr preOverlap = new nsRange(range->GetStartParent()); nsresult rv = preOverlap->SetStart(range->GetStartParent(), range->StartOffset()); @@ -3683,7 +3683,7 @@ Selection::SubtractRange(RangeData* aRange, nsRange* aSubtract, } void -Selection::UserSelectRangesToAdd(nsRange* aItem, nsTArray>& aRangesToAdd) +Selection::UserSelectRangesToAdd(nsRange* aItem, nsTArray>& aRangesToAdd) { aItem->ExcludeNonSelectableNodes(&aRangesToAdd); if (aRangesToAdd.IsEmpty()) { @@ -3719,7 +3719,7 @@ Selection::AddItem(nsRange* aItem, int32_t* aOutIndex, bool aNoStartSelect) */ #if 0 if (mUserInitiated) { - nsAutoTArray, 4> rangesToAdd; + nsAutoTArray, 4> rangesToAdd; *aOutIndex = -1; nsIDocument* doc = GetParentObject(); @@ -3734,7 +3734,7 @@ Selection::AddItem(nsRange* aItem, int32_t* aOutIndex, bool aNoStartSelect) // clone of the original range passed in. We do this seperately, because the // selectstart event could have caused the world to change, and required // ranges to be re-generated - nsRefPtr scratchRange = aItem->CloneRange(); + RefPtr scratchRange = aItem->CloneRange(); UserSelectRangesToAdd(scratchRange, rangesToAdd); bool newRangesNonEmpty = rangesToAdd.Length() > 1 || (rangesToAdd.Length() == 1 && !rangesToAdd[0]->Collapsed()); @@ -4042,7 +4042,7 @@ Selection::GetRangesForInterval(nsIDOMNode* aBeginNode, int32_t aBeginOffset, *aResultCount = 0; *aResults = nullptr; - nsTArray> results; + nsTArray> results; ErrorResult result; nsCOMPtr beginNode = do_QueryInterface(aBeginNode); nsCOMPtr endNode = do_QueryInterface(aEndNode); @@ -4072,7 +4072,7 @@ void Selection::GetRangesForInterval(nsINode& aBeginNode, int32_t aBeginOffset, nsINode& aEndNode, int32_t aEndOffset, bool aAllowAdjacent, - nsTArray>& aReturn, + nsTArray>& aReturn, mozilla::ErrorResult& aRv) { nsTArray results; @@ -4761,7 +4761,7 @@ Selection::RemoveAllRanges(ErrorResult& aRv) { if (!mFrameSelection) return; // nothing to do - nsRefPtr presContext = GetPresContext(); + RefPtr presContext = GetPresContext(); nsresult result = Clear(presContext); if (NS_FAILED(result)) { aRv.Throw(result); @@ -4841,7 +4841,7 @@ Selection::AddRangeInternal(nsRange& aRange, nsIDocument* aDocument, if (mType == nsISelectionController::SELECTION_NORMAL) SetInterlinePosition(true); - nsRefPtr presContext = GetPresContext(); + RefPtr presContext = GetPresContext(); selectFrames(presContext, &aRange, true); if (!mFrameSelection) @@ -4909,7 +4909,7 @@ Selection::RemoveRange(nsRange& aRange, ErrorResult& aRv) } // clear the selected bit from the removed range's frames - nsRefPtr presContext = GetPresContext(); + RefPtr presContext = GetPresContext(); selectFrames(presContext, &aRange, false); // add back the selected bit for each range touching our nodes @@ -4992,7 +4992,7 @@ Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv) } nsresult result; - nsRefPtr presContext = GetPresContext(); + RefPtr presContext = GetPresContext(); if (!presContext || presContext->Document() != aParentNode.OwnerDoc()) { aRv.Throw(NS_ERROR_FAILURE); return; @@ -5004,7 +5004,7 @@ Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv) // Turn off signal for table selection mFrameSelection->ClearTableCellSelection(); - nsRefPtr range = new nsRange(&aParentNode); + RefPtr range = new nsRange(&aParentNode); result = range->SetEnd(&aParentNode, aOffset); if (NS_FAILED(result)) { aRv.Throw(result); @@ -5218,7 +5218,7 @@ void Selection::ReplaceAnchorFocusRange(nsRange* aRange) { NS_ENSURE_TRUE_VOID(mAnchorFocusRange); - nsRefPtr presContext = GetPresContext(); + RefPtr presContext = GetPresContext(); if (presContext) { selectFrames(presContext, mAnchorFocusRange, false); SetAnchorFocusToRange(aRange); @@ -5325,7 +5325,7 @@ Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv) return; } - nsRefPtr presContext = GetPresContext(); + RefPtr presContext = GetPresContext(); if (!presContext || presContext->Document() != aParentNode.OwnerDoc()) { aRv.Throw(NS_ERROR_FAILURE); return; @@ -5339,7 +5339,7 @@ Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv) uint32_t anchorOffset = AnchorOffset(); uint32_t focusOffset = FocusOffset(); - nsRefPtr range = mAnchorFocusRange->CloneRange(); + RefPtr range = mAnchorFocusRange->CloneRange(); nsINode* startNode = range->GetStartParent(); nsINode* endNode = range->GetEndParent(); @@ -5378,7 +5378,7 @@ Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv) selectFrames(presContext, range, false); } - nsRefPtr difRange = new nsRange(&aParentNode); + RefPtr difRange = new nsRange(&aParentNode); if ((result1 == 0 && result3 < 0) || (result1 <= 0 && result2 < 0)){//a1,2 a,1,2 //select from 1 to 2 unless they are collapsed range->SetEnd(aParentNode, aOffset, aRv); @@ -5842,7 +5842,7 @@ Selection::ScrollSelectionIntoViewEvent::Run() Selection::SCROLL_SYNCHRONOUS; Selection* sel = mSelection; // workaround to satisfy static analysis - nsRefPtr kungFuDeathGrip(sel); + RefPtr kungFuDeathGrip(sel); mSelection->mScrollEvent.Forget(); mSelection->ScrollIntoView(mRegion, mVerticalScroll, mHorizontalScroll, mFlags | flags); @@ -5862,7 +5862,7 @@ Selection::PostScrollSelectionIntoViewEvent( // correct place on screen. mScrollEvent.Revoke(); - nsRefPtr ev = + RefPtr ev = new ScrollSelectionIntoViewEvent(this, aRegion, aVertical, aHorizontal, aFlags); nsresult rv = NS_DispatchToCurrentThread(ev); @@ -6247,7 +6247,7 @@ Selection::SelectionLanguageChange(bool aLangRTL) int32_t frameStart, frameEnd; focusFrame->GetOffsets(frameStart, frameEnd); - nsRefPtr context = GetPresContext(); + RefPtr context = GetPresContext(); nsBidiLevel levelBefore, levelAfter; if (!context) { return NS_ERROR_FAILURE; @@ -6446,7 +6446,7 @@ SelectionChangeListener::NotifySelectionChanged(nsIDOMDocument* aDoc, { // This cast is valid as nsISelection is a builtinclass which is only // implemented by Selection. - nsRefPtr sel = static_cast(aSel); + RefPtr sel = static_cast(aSel); nsIDocument* doc = sel->GetParentObject(); if (!(doc && nsContentUtils::IsSystemPrincipal(doc->NodePrincipal())) && @@ -6513,7 +6513,7 @@ SelectionChangeListener::NotifySelectionChanged(nsIDOMDocument* aDoc, } if (target) { - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(target, NS_LITERAL_STRING("selectionchange"), false); asyncDispatcher->PostDOMEvent(); } @@ -6528,7 +6528,7 @@ SelectionChangeListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsCOMPtr doc = do_QueryInterface(aDoc); if (doc) { - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(doc, NS_LITERAL_STRING("selectionchange"), false); asyncDispatcher->PostDOMEvent(); } diff --git a/layout/generic/nsSimplePageSequenceFrame.cpp b/layout/generic/nsSimplePageSequenceFrame.cpp index fac7318fbf..1d3d226d45 100644 --- a/layout/generic/nsSimplePageSequenceFrame.cpp +++ b/layout/generic/nsSimplePageSequenceFrame.cpp @@ -501,7 +501,7 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext, } void -GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray >* aArr) +GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray >* aArr) { if (!aFrame) { return; @@ -644,10 +644,10 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a mCalledBeginPage = true; - nsRefPtr renderingContext = dc->CreateRenderingContext(); + RefPtr renderingContext = dc->CreateRenderingContext(); NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY); - nsRefPtr renderingSurface = + RefPtr renderingSurface = renderingContext->CurrentSurface(); NS_ENSURE_TRUE(renderingSurface, NS_ERROR_OUT_OF_MEMORY); @@ -655,7 +655,7 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a HTMLCanvasElement* canvas = mCurrentCanvasList[i]; nsIntSize size = canvas->GetSize(); - nsRefPtr printSurface = renderingSurface-> + RefPtr printSurface = renderingSurface-> CreateSimilarSurface( gfxContentType::COLOR_ALPHA, size @@ -775,7 +775,7 @@ nsSimplePageSequenceFrame::PrintNextPage() PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum)); // CreateRenderingContext can fail - nsRefPtr gCtx = dc->CreateRenderingContext(); + RefPtr gCtx = dc->CreateRenderingContext(); NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY); nsRenderingContext renderingContext(gCtx); diff --git a/layout/generic/nsSimplePageSequenceFrame.h b/layout/generic/nsSimplePageSequenceFrame.h index 46afc7bffd..b1ccaf34d6 100644 --- a/layout/generic/nsSimplePageSequenceFrame.h +++ b/layout/generic/nsSimplePageSequenceFrame.h @@ -154,7 +154,7 @@ protected: int32_t mFromPageNum; int32_t mToPageNum; nsTArray mPageRanges; - nsTArray > mCurrentCanvasList; + nsTArray > mCurrentCanvasList; // Selection Printing Info nscoord mSelectionHeight; diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 34be242141..6aa403a977 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -130,7 +130,7 @@ nsSubDocumentFrame::Init(nsIContent* aContent, // it into the view tree. This happens when we've been reframed, and // ensures the presentation persists across reframes. If the frame element // has changed documents however, we blow away the presentation. - nsRefPtr frameloader = FrameLoader(); + RefPtr frameloader = FrameLoader(); if (frameloader) { nsCOMPtr oldContainerDoc; nsIFrame* detachedFrame = @@ -166,7 +166,7 @@ nsSubDocumentFrame::ShowViewer() // create the inner view for it to use. (void) EnsureInnerView(); } else { - nsRefPtr frameloader = FrameLoader(); + RefPtr frameloader = FrameLoader(); if (frameloader) { CSSIntSize margin = GetMarginAttributes(); nsWeakFrame weakThis(this); @@ -255,7 +255,7 @@ ScreenIntSize nsSubDocumentFrame::GetSubdocumentSize() { if (GetStateBits() & NS_FRAME_FIRST_REFLOW) { - nsRefPtr frameloader = FrameLoader(); + RefPtr frameloader = FrameLoader(); if (frameloader) { nsCOMPtr oldContainerDoc; nsIFrame* detachedFrame = @@ -899,12 +899,12 @@ nsSubDocumentFrame::AttributeChanged(int32_t aNameSpaceID, CSSIntSize margins = GetMarginAttributes(); // Notify the frameloader - nsRefPtr frameloader = FrameLoader(); + RefPtr frameloader = FrameLoader(); if (frameloader) frameloader->MarginsChanged(margins.width, margins.height); } else if (aAttribute == nsGkAtoms::mozpasspointerevents) { - nsRefPtr frameloader = FrameLoader(); + RefPtr frameloader = FrameLoader(); if (frameloader) { if (aModType == nsIDOMMutationEvent::ADDITION) { frameloader->ActivateUpdateHitRegion(); @@ -976,7 +976,7 @@ public: } private: nsCOMPtr mFrameElement; - nsRefPtr mFrameLoader; + RefPtr mFrameLoader; nsCOMPtr mPresShell; bool mHideViewerIfFrameless; }; @@ -995,7 +995,7 @@ nsSubDocumentFrame::DestroyFrom(nsIFrame* aDestructRoot) // Detach the subdocument's views and stash them in the frame loader. // We can then reattach them if we're being reframed (for example if // the frame has been made position:fixed). - nsRefPtr frameloader = FrameLoader(); + RefPtr frameloader = FrameLoader(); if (frameloader) { nsView* detachedViews = ::BeginSwapDocShellsForViews(mInnerView->GetFirstChild()); if (detachedViews && detachedViews->GetFrame()) { @@ -1176,7 +1176,7 @@ EndSwapDocShellsForDocument(nsIDocument* aDocument, void*) nsCOMPtr cv; ds->GetContentViewer(getter_AddRefs(cv)); while (cv) { - nsRefPtr pc; + RefPtr pc; cv->GetPresContext(getter_AddRefs(pc)); if (pc && pc->GetPresShell()) { pc->GetPresShell()->SetNeverPainting(ds->IsInvisible()); diff --git a/layout/generic/nsSubDocumentFrame.h b/layout/generic/nsSubDocumentFrame.h index 71debc3f6f..2251ba4dfb 100644 --- a/layout/generic/nsSubDocumentFrame.h +++ b/layout/generic/nsSubDocumentFrame.h @@ -158,7 +158,7 @@ protected: */ nsIFrame* ObtainIntrinsicSizeFrame(); - nsRefPtr mFrameLoader; + RefPtr mFrameLoader; nsView* mInnerView; bool mIsInline; bool mPostedReflowCallback; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 986bf5b3f3..0bb467148c 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -369,7 +369,7 @@ protected: int16_t mSelectionStatus; // see nsIDocument.h SetDisplaySelection() nscolor mSelectionTextColor; nscolor mSelectionBGColor; - nsRefPtr mSelectionShadow; + RefPtr mSelectionShadow; bool mHasSelectionShadow; // Common data @@ -1787,7 +1787,7 @@ GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation, if (aOutFontMetrics) *aOutFontMetrics = nullptr; - nsRefPtr metrics; + RefPtr metrics; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(metrics), aFontSizeInflation); @@ -1817,7 +1817,7 @@ CreateReferenceThebesContext(nsTextFrame* aTextFrame) static gfxTextRun* GetHyphenTextRun(gfxTextRun* aTextRun, gfxContext* aContext, nsTextFrame* aTextFrame) { - nsRefPtr ctx = aContext; + RefPtr ctx = aContext; if (!ctx) { ctx = CreateReferenceThebesContext(aTextFrame); } @@ -2158,14 +2158,14 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer) new MathMLTextRunFactory(transformingFactory.forget(), mathFlags, sstyScriptLevel, fontInflation); } - nsTArray> styles; + nsTArray> styles; if (transformingFactory) { iter.SetOriginalOffset(0); for (uint32_t i = 0; i < mMappedFlows.Length(); ++i) { MappedFlow* mappedFlow = &mMappedFlows[i]; nsTextFrame* f; nsStyleContext* sc = nullptr; - nsRefPtr charStyle; + RefPtr charStyle; for (f = mappedFlow->mStartFrame; f != mappedFlow->mEndFrame; f = static_cast(f->GetNextContinuation())) { uint32_t offset = iter.GetSkippedOffset(); @@ -2629,7 +2629,7 @@ nsTextFrame::EnsureTextRun(TextRunType aWhichTextRun, gTextRuns->MarkUsed(textRun); } } else { - nsRefPtr ctx = aReferenceContext; + RefPtr ctx = aReferenceContext; if (!ctx) { ctx = CreateReferenceThebesContext(this); } @@ -2989,7 +2989,7 @@ protected: gfxTextRun* mTextRun; gfxFontGroup* mFontGroup; - nsRefPtr mFontMetrics; + RefPtr mFontMetrics; const nsStyleText* mTextStyle; const nsTextFragment* mFrag; nsIFrame* mLineContainer; @@ -3728,7 +3728,7 @@ nsTextPaintStyle::InitSelectionColorsAndShadow() if (selectionElement && selectionStatus == nsISelectionController::SELECTION_ON) { - nsRefPtr sc = nullptr; + RefPtr sc = nullptr; sc = mPresContext->StyleSet()-> ProbePseudoElementStyle(selectionElement, nsCSSPseudoElements::ePseudo_mozSelection, @@ -6737,7 +6737,7 @@ nsTextFrame::CombineSelectionUnderlineRect(nsPresContext* aPresContext, nsRect givenRect = aRect; - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), GetFontSizeInflation()); gfxFontGroup* fontGroup = fm->GetThebesFontGroup(); diff --git a/layout/generic/nsTextRunTransformations.cpp b/layout/generic/nsTextRunTransformations.cpp index 0f124f26a7..ad7a0973ad 100644 --- a/layout/generic/nsTextRunTransformations.cpp +++ b/layout/generic/nsTextRunTransformations.cpp @@ -38,7 +38,7 @@ nsTransformedTextRun::Create(const gfxTextRunFactory::Parameters* aParams, gfxFontGroup* aFontGroup, const char16_t* aString, uint32_t aLength, const uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory) { NS_ASSERTION(!(aFlags & gfxTextRunFactory::TEXT_IS_8BIT), @@ -104,7 +104,7 @@ nsTransformedTextRun* nsTransformingTextRunFactory::MakeTextRun(const char16_t* aString, uint32_t aLength, const gfxTextRunFactory::Parameters* aParams, gfxFontGroup* aFontGroup, uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory) { return nsTransformedTextRun::Create(aParams, this, aFontGroup, @@ -116,7 +116,7 @@ nsTransformedTextRun* nsTransformingTextRunFactory::MakeTextRun(const uint8_t* aString, uint32_t aLength, const gfxTextRunFactory::Parameters* aParams, gfxFontGroup* aFontGroup, uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory) { // We'll only have a Unicode code path to minimize the amount of code needed @@ -283,7 +283,7 @@ nsCaseTransformTextRunFactory::TransformString( nsTArray& aDeletedCharsArray, nsTransformedTextRun* aTextRun, nsTArray* aCanBreakBeforeArray, - nsTArray>* aStyleArray) + nsTArray>* aStyleArray) { NS_PRECONDITION(!aTextRun || (aCanBreakBeforeArray && aStyleArray), "either none or all three optional parameters required"); @@ -315,7 +315,7 @@ nsCaseTransformTextRunFactory::TransformString( for (uint32_t i = 0; i < length; ++i) { uint32_t ch = str[i]; - nsRefPtr charStyle; + RefPtr charStyle; if (aTextRun) { charStyle = aTextRun->mStyles[i]; style = aAllUppercase ? NS_STYLE_TEXT_TRANSFORM_UPPERCASE : @@ -621,7 +621,7 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun, nsAutoTArray charsToMergeArray; nsAutoTArray deletedCharsArray; nsAutoTArray canBreakBeforeArray; - nsAutoTArray,50> styleArray; + nsAutoTArray,50> styleArray; bool mergeNeeded = TransformString(aTextRun->mString, convertedString, diff --git a/layout/generic/nsTextRunTransformations.h b/layout/generic/nsTextRunTransformations.h index 2dab9ef2a4..1fb938101e 100644 --- a/layout/generic/nsTextRunTransformations.h +++ b/layout/generic/nsTextRunTransformations.h @@ -27,7 +27,7 @@ struct nsTransformedCharStyle final { nsFont mFont; nsCOMPtr mLanguage; - nsRefPtr mPresContext; + RefPtr mPresContext; float mScriptSizeMultiplier; uint8_t mTextTransform; uint8_t mMathVariant; @@ -47,12 +47,12 @@ public: nsTransformedTextRun* MakeTextRun(const uint8_t* aString, uint32_t aLength, const gfxFontGroup::Parameters* aParams, gfxFontGroup* aFontGroup, uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory); nsTransformedTextRun* MakeTextRun(const char16_t* aString, uint32_t aLength, const gfxFontGroup::Parameters* aParams, gfxFontGroup* aFontGroup, uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory); virtual void RebuildTextRun(nsTransformedTextRun* aTextRun, @@ -100,7 +100,7 @@ public: nsTArray& aDeletedCharsArray, nsTransformedTextRun* aTextRun = nullptr, nsTArray* aCanBreakBeforeArray = nullptr, - nsTArray>* aStyleArray = nullptr); + nsTArray>* aStyleArray = nullptr); protected: nsAutoPtr mInnerTransformingTextRunFactory; @@ -119,7 +119,7 @@ public: gfxFontGroup* aFontGroup, const char16_t* aString, uint32_t aLength, const uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory); ~nsTransformedTextRun() { @@ -153,7 +153,7 @@ public: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) MOZ_MUST_OVERRIDE; nsTransformingTextRunFactory *mFactory; - nsTArray> mStyles; + nsTArray> mStyles; nsTArray mCapitalize; nsString mString; bool mOwnsFactory; @@ -165,7 +165,7 @@ private: gfxFontGroup* aFontGroup, const char16_t* aString, uint32_t aLength, const uint32_t aFlags, - nsTArray>&& aStyles, + nsTArray>&& aStyles, bool aOwnsFactory) : gfxTextRun(aParams, aLength, aFontGroup, aFlags), mFactory(aFactory), mStyles(aStyles), mString(aString, aLength), diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 6e032e1d4a..b15976e185 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -92,7 +92,7 @@ nsresult nsVideoFrame::CreateAnonymousContent(nsTArray& aElements) { nsNodeInfoManager *nodeInfoManager = GetContent()->GetComposedDoc()->NodeInfoManager(); - nsRefPtr nodeInfo; + RefPtr nodeInfo; Element *element; if (HasVideoElement()) { @@ -201,7 +201,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder, return nullptr; } - nsRefPtr container = element->GetImageContainer(); + RefPtr container = element->GetImageContainer(); if (!container) return nullptr; @@ -240,7 +240,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder, SwapScaleWidthHeightForRotation(scaleHint, rotationDeg); container->SetScaleHint(scaleHint); - nsRefPtr layer = static_cast + RefPtr layer = static_cast (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)); if (!layer) { layer = aManager->CreateImageLayer(); @@ -261,7 +261,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder, layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); layer->SetScaleToSize(scaleHint, ScaleMode::STRETCH); - nsRefPtr result = layer.forget(); + RefPtr result = layer.forget(); return result.forget(); } @@ -347,7 +347,7 @@ nsVideoFrame::Reflow(nsPresContext* aPresContext, aReflowState.ComputedWidth(), aReflowState.ComputedHeight())); if (child->GetSize() != size) { - nsRefPtr event = new DispatchResizeToControls(child->GetContent()); + RefPtr event = new DispatchResizeToControls(child->GetContent()); nsContentUtils::AddScriptRunner(event); } } else if (child->GetContent() == mCaptionDiv) { diff --git a/layout/inspector/inCSSValueSearch.cpp b/layout/inspector/inCSSValueSearch.cpp index 8b2f2d4d9a..d8a770519b 100644 --- a/layout/inspector/inCSSValueSearch.cpp +++ b/layout/inspector/inCSSValueSearch.cpp @@ -93,12 +93,12 @@ inCSSValueSearch::SearchSync() nsCOMPtr baseURI = document->GetBaseURI(); - nsRefPtr sheets = document->StyleSheets(); + RefPtr sheets = document->StyleSheets(); MOZ_ASSERT(sheets); uint32_t length = sheets->Length(); for (uint32_t i = 0; i < length; ++i) { - nsRefPtr sheet = sheets->Item(i); + RefPtr sheet = sheets->Item(i); SearchStyleSheet(sheet, baseURI); } diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index ae6a2b2fa5..9aa4a6f358 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -226,7 +226,7 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement, nsRuleNode* ruleNode = nullptr; nsCOMPtr element = do_QueryInterface(aElement); NS_ENSURE_STATE(element); - nsRefPtr styleContext; + RefPtr styleContext; GetRuleNodeForElement(element, pseudoElt, getter_AddRefs(styleContext), &ruleNode); if (!ruleNode) { // This can fail for elements that are not in the document or @@ -238,7 +238,7 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement, NS_NewISupportsArray(getter_AddRefs(rules)); if (!rules) return NS_ERROR_OUT_OF_MEMORY; - nsRefPtr cssRule; + RefPtr cssRule; for ( ; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) { cssRule = do_QueryObject(ruleNode->GetRule()); if (cssRule) { @@ -262,7 +262,7 @@ GetRuleFromDOMRule(nsIDOMCSSStyleRule *aRule, ErrorResult& rv) return nullptr; } - nsRefPtr cssrule; + RefPtr cssrule; rv = rule->GetCSSStyleRule(getter_AddRefs(cssrule)); if (rv.Failed()) { return nullptr; @@ -346,7 +346,7 @@ NS_IMETHODIMP inDOMUtils::GetSelectorCount(nsIDOMCSSStyleRule* aRule, uint32_t *aCount) { ErrorResult rv; - nsRefPtr rule = GetRuleFromDOMRule(aRule, rv); + RefPtr rule = GetRuleFromDOMRule(aRule, rv); if (rv.Failed()) { return rv.StealNSResult(); } @@ -362,7 +362,7 @@ inDOMUtils::GetSelectorCount(nsIDOMCSSStyleRule* aRule, uint32_t *aCount) static nsCSSSelectorList* GetSelectorAtIndex(nsIDOMCSSStyleRule* aRule, uint32_t aIndex, ErrorResult& rv) { - nsRefPtr rule = GetRuleFromDOMRule(aRule, rv); + RefPtr rule = GetRuleFromDOMRule(aRule, rv); if (rv.Failed()) { return nullptr; } @@ -390,7 +390,7 @@ inDOMUtils::GetSelectorText(nsIDOMCSSStyleRule* aRule, return rv.StealNSResult(); } - nsRefPtr rule = GetRuleFromDOMRule(aRule, rv); + RefPtr rule = GetRuleFromDOMRule(aRule, rv); MOZ_ASSERT(!rv.Failed(), "How could we get a selector but not a rule?"); sel->mSelectors->ToString(aText, rule->GetStyleSheet(), false); @@ -1086,7 +1086,7 @@ inDOMUtils::SetContentState(nsIDOMElement* aElement, { NS_ENSURE_ARG_POINTER(aElement); - nsRefPtr esm = + RefPtr esm = inLayoutUtils::GetEventStateManagerFor(aElement); if (esm) { nsCOMPtr content; @@ -1135,7 +1135,7 @@ inDOMUtils::GetRuleNodeForElement(dom::Element* aElement, presContext->EnsureSafeToHandOutCSSRules(); - nsRefPtr sContext = + RefPtr sContext = nsComputedDOMStyle::GetStyleContextForElement(aElement, aPseudo, presShell); if (sContext) { *aRuleNode = sContext->RuleNode(); @@ -1256,7 +1256,7 @@ NS_IMETHODIMP inDOMUtils::ParseStyleSheet(nsIDOMCSSStyleSheet *aSheet, const nsAString& aInput) { - nsRefPtr sheet = do_QueryObject(aSheet); + RefPtr sheet = do_QueryObject(aSheet); NS_ENSURE_ARG_POINTER(sheet); return sheet->ParseSheet(aInput); diff --git a/layout/inspector/nsFontFace.h b/layout/inspector/nsFontFace.h index 3da0d98be5..e7a092d6cb 100644 --- a/layout/inspector/nsFontFace.h +++ b/layout/inspector/nsFontFace.h @@ -30,8 +30,8 @@ public: protected: virtual ~nsFontFace(); - nsRefPtr mFontEntry; - nsRefPtr mFontGroup; + RefPtr mFontEntry; + RefPtr mFontGroup; uint8_t mMatchType; }; diff --git a/layout/inspector/nsFontFaceList.cpp b/layout/inspector/nsFontFaceList.cpp index 33806a9eff..1ee2db0dde 100644 --- a/layout/inspector/nsFontFaceList.cpp +++ b/layout/inspector/nsFontFaceList.cpp @@ -82,7 +82,7 @@ nsFontFaceList::AddFontsFromTextRun(gfxTextRun* aTextRun, existingFace->AddMatchType(iter.GetGlyphRun()->mMatchType); } else { // A new font entry we haven't seen before - nsRefPtr ff = + RefPtr ff = new nsFontFace(fe, aTextRun->GetFontGroup(), iter.GetGlyphRun()->mMatchType); mFontFaces.Put(fe, ff); diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 4a62ba4d11..b8829eba01 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -298,7 +298,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, return; } - nsRefPtr lm = GetFrom(mFrameLoader); + RefPtr lm = GetFrom(mFrameLoader); mAsyncPanZoomEnabled = lm && lm->AsyncPanZoomEnabled(); @@ -389,7 +389,7 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder, return nullptr; } - nsRefPtr layer = + RefPtr layer = (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)); if (!layer) { layer = aManager->CreateRefLayer(); @@ -420,7 +420,7 @@ RenderFrameParent::OwnerContentChanged(nsIContent* aContent) MOZ_ASSERT(!mFrameLoader || mFrameLoader->GetOwnerContent() == aContent, "Don't build new map if owner is same!"); - nsRefPtr lm = mFrameLoader ? GetFrom(mFrameLoader) : nullptr; + RefPtr lm = mFrameLoader ? GetFrom(mFrameLoader) : nullptr; // Perhaps the document containing this frame currently has no presentation? if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { ClientLayerManager *clientManager = @@ -607,7 +607,7 @@ RenderFrameParent::StartScrollbarDrag(const AsyncDragMetrics& aDragMetrics) void RenderFrameParent::GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier) { - nsRefPtr lm = mFrameLoader ? GetFrom(mFrameLoader) : nullptr; + RefPtr lm = mFrameLoader ? GetFrom(mFrameLoader) : nullptr; // Perhaps the document containing this frame currently has no presentation? if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { *aTextureFactoryIdentifier = @@ -666,7 +666,7 @@ nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder, int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel(); nsIntRect visibleRect = GetVisibleRect().ToNearestPixels(appUnitsPerDevPixel); visibleRect += aContainerParameters.mOffset; - nsRefPtr layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect, this, aContainerParameters); + RefPtr layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect, this, aContainerParameters); if (layer && layer->AsContainerLayer()) { layer->AsContainerLayer()->SetEventRegionsOverride(mEventRegionsOverride); } diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index 21f3b53347..cefc6422f1 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -121,13 +121,13 @@ private: // context. uint64_t mLayersId; - nsRefPtr mFrameLoader; - nsRefPtr mContainer; + RefPtr mFrameLoader; + RefPtr mContainer; // When our scrolling behavior is ASYNC_PAN_ZOOM, we have a nonnull // APZCTreeManager. It's used to manipulate the shadow layer tree // on the compositor thread. - nsRefPtr mApzcTreeManager; - nsRefPtr mContentController; + RefPtr mApzcTreeManager; + RefPtr mContentController; layers::APZCTreeManager* GetApzcTreeManager(); diff --git a/layout/ipc/VsyncChild.h b/layout/ipc/VsyncChild.h index 8eace84592..118f3620cd 100644 --- a/layout/ipc/VsyncChild.h +++ b/layout/ipc/VsyncChild.h @@ -8,7 +8,7 @@ #include "mozilla/layout/PVsyncChild.h" #include "nsISupportsImpl.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" namespace mozilla { @@ -50,7 +50,7 @@ private: bool mIsShutdown; // The content side vsync observer. - nsRefPtr mObserver; + RefPtr mObserver; }; } // namespace layout diff --git a/layout/ipc/VsyncParent.cpp b/layout/ipc/VsyncParent.cpp index 89364e568a..1252406996 100644 --- a/layout/ipc/VsyncParent.cpp +++ b/layout/ipc/VsyncParent.cpp @@ -23,8 +23,8 @@ namespace layout { VsyncParent::Create() { AssertIsOnBackgroundThread(); - nsRefPtr vsyncSource = gfxPlatform::GetPlatform()->GetHardwareVsync(); - nsRefPtr vsyncParent = new VsyncParent(); + RefPtr vsyncSource = gfxPlatform::GetPlatform()->GetHardwareVsync(); + RefPtr vsyncParent = new VsyncParent(); vsyncParent->mVsyncDispatcher = vsyncSource->GetRefreshTimerVsyncDispatcher(); return vsyncParent.forget(); } diff --git a/layout/ipc/VsyncParent.h b/layout/ipc/VsyncParent.h index 23ba5211b6..2456378f63 100644 --- a/layout/ipc/VsyncParent.h +++ b/layout/ipc/VsyncParent.h @@ -9,7 +9,7 @@ #include "mozilla/layout/PVsyncParent.h" #include "mozilla/VsyncDispatcher.h" #include "nsCOMPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" class nsIThread; @@ -46,7 +46,7 @@ private: bool mObservingVsync; bool mDestroyed; nsCOMPtr mBackgroundThread; - nsRefPtr mVsyncDispatcher; + RefPtr mVsyncDispatcher; }; } // namespace layout diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index 24df6a6de7..ad7ff87a2a 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -447,7 +447,7 @@ public: } private: - nsRefPtr mFontEntry; + RefPtr mFontEntry; FontFamilyName mFontFamilyName; uint32_t mGlyphID; @@ -723,7 +723,7 @@ InitGlobals(nsPresContext* aPresContext) // Allocate the placeholders for the preferred parts and variants nsresult rv = NS_ERROR_OUT_OF_MEMORY; - nsRefPtr glyphTableList = new nsGlyphTableList(); + RefPtr glyphTableList = new nsGlyphTableList(); if (glyphTableList) { rv = glyphTableList->Initialize(); } @@ -982,7 +982,7 @@ nsMathMLChar::SetFontFamily(nsPresContext* aPresContext, const nsGlyphCode& aGlyphCode, const FontFamilyList& aDefaultFamilyList, nsFont& aFont, - nsRefPtr* aFontGroup) + RefPtr* aFontGroup) { FontFamilyList glyphCodeFont; @@ -997,7 +997,7 @@ nsMathMLChar::SetFontFamily(nsPresContext* aPresContext, nsFont font = aFont; font.fontlist = familyList; const nsStyleFont* styleFont = mStyleContext->StyleFont(); - nsRefPtr fm; + RefPtr fm; aPresContext->DeviceContext()-> GetMetricsFor(font, styleFont->mLanguage, @@ -1071,10 +1071,10 @@ public: private: bool TryVariants(nsGlyphTable* aGlyphTable, - nsRefPtr* aFontGroup, + RefPtr* aFontGroup, const FontFamilyList& aFamilyList); bool TryParts(nsGlyphTable* aGlyphTable, - nsRefPtr* aFontGroup, + RefPtr* aFontGroup, const FontFamilyList& aFamilyList); nsMathMLChar* mChar; @@ -1104,7 +1104,7 @@ private: bool nsMathMLChar:: StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable, - nsRefPtr* aFontGroup, + RefPtr* aFontGroup, const FontFamilyList& aFamilyList) { // Use our stretchy style context now that stretching is in progress @@ -1255,7 +1255,7 @@ StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable, // Always updates the char if a better match is found. bool nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable* aGlyphTable, - nsRefPtr* aFontGroup, + RefPtr* aFontGroup, const FontFamilyList& aFamilyList) { // Use our stretchy style context now that stretching is in progress @@ -1439,7 +1439,7 @@ nsMathMLChar::StretchEnumContext::EnumCallback(const FontFamilyName& aFamily, nsStyleContext *sc = context->mChar->mStyleContext; nsFont font = sc->StyleFont()->mFont; NormalizeDefaultFont(font, context->mFontSizeInflation); - nsRefPtr fontGroup; + RefPtr fontGroup; FontFamilyList family; family.Append(unquotedFamilyName); if (!aGeneric && !context->mChar->SetFontFamily(context->mPresContext, @@ -1542,7 +1542,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext, NormalizeDefaultFont(font, aFontSizeInflation); const nsStyleFont* styleFont = mStyleContext->StyleFont(); - nsRefPtr fm; + RefPtr fm; aPresContext->DeviceContext()-> GetMetricsFor(font, styleFont->mLanguage, @@ -2125,7 +2125,7 @@ nsMathMLChar::PaintForeground(nsPresContext* aPresContext, styleContext = parentContext; } - nsRefPtr thebesContext = aRenderingContext.ThebesContext(); + RefPtr thebesContext = aRenderingContext.ThebesContext(); // Set color ... nscolor fgColor = styleContext->GetVisitedDependentColor(eCSSProperty_color); diff --git a/layout/mathml/nsMathMLChar.h b/layout/mathml/nsMathMLChar.h index f1216c3c9f..46bfc79625 100644 --- a/layout/mathml/nsMathMLChar.h +++ b/layout/mathml/nsMathMLChar.h @@ -243,7 +243,7 @@ private: const nsGlyphCode& aGlyphCode, const mozilla::FontFamilyList& aDefaultFamily, nsFont& aFont, - nsRefPtr* aFontGroup); + RefPtr* aFontGroup); nsresult StretchInternal(nsPresContext* aPresContext, diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp index a14a3a044f..f3570d4859 100644 --- a/layout/mathml/nsMathMLContainerFrame.cpp +++ b/layout/mathml/nsMathMLContainerFrame.cpp @@ -51,7 +51,7 @@ nsMathMLContainerFrame::ReflowError(nsRenderingContext& aRenderingContext, /////////////// // Set font - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), nsLayoutUtils:: FontSizeInflationFor(this)); @@ -96,7 +96,7 @@ void nsDisplayMathMLError::Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) { // Set color and font ... - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(mFrame, getter_AddRefs(fm)); nsPoint pt = ToReferenceFrame(); diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp index 66ad07d347..da595ebefa 100644 --- a/layout/mathml/nsMathMLFrame.cpp +++ b/layout/mathml/nsMathMLFrame.cpp @@ -100,7 +100,7 @@ nsMathMLFrame::ResolveMathMLCharStyle(nsPresContext* aPresContext, { nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozMathAnonymous; // savings - nsRefPtr newStyleContext; + RefPtr newStyleContext; newStyleContext = aPresContext->StyleSet()-> ResolvePseudoElementStyle(aContent->AsElement(), pseudoType, aParentStyleContext, nullptr); @@ -232,7 +232,7 @@ nsMathMLFrame::CalcLength(nsPresContext* aPresContext, } else if (eCSSUnit_XHeight == unit) { aPresContext->SetUsesExChUnits(true); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, getter_AddRefs(fm), aFontSizeInflation); diff --git a/layout/mathml/nsMathMLFrame.h b/layout/mathml/nsMathMLFrame.h index e8a95df737..f8c3997203 100644 --- a/layout/mathml/nsMathMLFrame.h +++ b/layout/mathml/nsMathMLFrame.h @@ -199,7 +199,7 @@ public: nscoord& aSubDrop, float aFontSizeInflation) { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aChild, getter_AddRefs(fm), aFontSizeInflation); GetSubDrop(fm, aSubDrop); @@ -210,7 +210,7 @@ public: nscoord& aSupDrop, float aFontSizeInflation) { - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aChild, getter_AddRefs(fm), aFontSizeInflation); GetSupDrop(fm, aSupDrop); diff --git a/layout/mathml/nsMathMLTokenFrame.cpp b/layout/mathml/nsMathMLTokenFrame.cpp index a87e5aaaa8..6980eef6c2 100644 --- a/layout/mathml/nsMathMLTokenFrame.cpp +++ b/layout/mathml/nsMathMLTokenFrame.cpp @@ -177,7 +177,7 @@ nsMathMLTokenFrame::Place(nsRenderingContext& aRenderingContext, mBoundingMetrics += childSize.mBoundingMetrics; } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), nsLayoutUtils:: FontSizeInflationFor(this)); diff --git a/layout/mathml/nsMathMLmactionFrame.h b/layout/mathml/nsMathMLmactionFrame.h index 5564be205f..9f2a149b82 100644 --- a/layout/mathml/nsMathMLmactionFrame.h +++ b/layout/mathml/nsMathMLmactionFrame.h @@ -66,7 +66,7 @@ private: int32_t mActionType; int32_t mChildCount; int32_t mSelection; - nsRefPtr mListener; + RefPtr mListener; // helper to return the frame for the attribute selection="number" nsIFrame* diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index e9633df04e..014d1df11d 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -344,7 +344,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext, nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); GetRuleThickness(aRenderingContext, fm, mRuleThickness); diff --git a/layout/mathml/nsMathMLmfencedFrame.cpp b/layout/mathml/nsMathMLmfencedFrame.cpp index 2eb3c9ad12..d6dcacb3f8 100644 --- a/layout/mathml/nsMathMLmfencedFrame.cpp +++ b/layout/mathml/nsMathMLmfencedFrame.cpp @@ -224,7 +224,7 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext, int32_t i; const nsStyleFont* font = StyleFont(); float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); nscoord axisHeight, em; @@ -612,7 +612,7 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon nsPresContext* presContext = PresContext(); const nsStyleFont* font = StyleFont(); float fontSizeInflation = nsLayoutUtils:: FontSizeInflationFor(this); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); nscoord em; diff --git a/layout/mathml/nsMathMLmfracFrame.cpp b/layout/mathml/nsMathMLmfracFrame.cpp index 92b6fc79f1..c666dcbf4c 100644 --- a/layout/mathml/nsMathMLmfracFrame.cpp +++ b/layout/mathml/nsMathMLmfracFrame.cpp @@ -224,7 +224,7 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext, nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp index 2ee6212f45..d0bd33d4cd 100644 --- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -185,7 +185,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // get x-height (an ex) const nsStyleFont* font = aFrame->StyleFont(); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm), aFontSizeInflation); diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp index 402116b244..d313020829 100644 --- a/layout/mathml/nsMathMLmoFrame.cpp +++ b/layout/mathml/nsMathMLmoFrame.cpp @@ -362,7 +362,7 @@ nsMathMLmoFrame::ProcessOperatorData() // Cache the default values of lspace and rspace. // since these values are relative to the 'em' unit, convert to twips now nscoord em; - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); GetEmHeight(fm, em); @@ -615,7 +615,7 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext, // get the axis height; float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); nscoord axisHeight, height; diff --git a/layout/mathml/nsMathMLmrootFrame.cpp b/layout/mathml/nsMathMLmrootFrame.cpp index e65253b1bb..c4a0de6285 100644 --- a/layout/mathml/nsMathMLmrootFrame.cpp +++ b/layout/mathml/nsMathMLmrootFrame.cpp @@ -225,7 +225,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext, //////////// // Prepare the radical symbol and the overline bar - nsRefPtr fm; + RefPtr fm; float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); @@ -381,7 +381,7 @@ nsMathMLmrootFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingConte fontSizeInflation); nscoord dxSqr; - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); GetRadicalXOffsets(indexWidth, sqrWidth, fm, nullptr, &dxSqr); diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index 73d84641f8..8eb4770db4 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -475,7 +475,7 @@ ParseSpacingAttribute(nsMathMLmtableFrame* aFrame, nsIAtom* aAttribute) nscoord value2; // Set defaults float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(aFrame); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), fontSizeInflation); if (nsGkAtoms::rowspacing_ == aAttribute) { @@ -854,7 +854,7 @@ nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext, case eAlign_axis: default: { // XXX should instead use style data from the row of reference here ? - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), nsLayoutUtils:: FontSizeInflationFor(this)); diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp index a465dc9dd4..e6f9d9b9ed 100644 --- a/layout/mathml/nsMathMLmunderoverFrame.cpp +++ b/layout/mathml/nsMathMLmunderoverFrame.cpp @@ -398,7 +398,7 @@ nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext, //////////////////// // Place Children - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); diff --git a/layout/printing/nsPrintData.h b/layout/printing/nsPrintData.h index 69e01bb712..39f5b7d24b 100644 --- a/layout/printing/nsPrintData.h +++ b/layout/printing/nsPrintData.h @@ -54,7 +54,7 @@ public: ePrintDataType mType; // the type of data this is (Printing or Print Preview) - nsRefPtr mPrintDC; + RefPtr mPrintDC; FILE *mDebugFilePtr; // a file where information can go to when printing nsPrintObject * mPrintObject; diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 9947ba90a3..5ddc995ec9 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -201,7 +201,7 @@ public: void Disconnect() { mPrintEngine = nullptr; } protected: - nsRefPtr mPrintEngine; + RefPtr mPrintEngine; bool mSuppressed; }; @@ -408,7 +408,7 @@ nsPrintEngine::CommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aWebProgressListener, nsIDOMDocument* aDoc) { - nsRefPtr kungfuDeathGrip = this; + RefPtr kungfuDeathGrip = this; nsresult rv = DoCommonPrint(aIsPrintPreview, aPrintSettings, aWebProgressListener, aDoc); if (NS_FAILED(rv)) { @@ -1986,7 +1986,7 @@ nsPrintEngine::UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO, { nsCOMPtr displayShell = aPO->mDocShell->GetPresShell(); // Transfer Selection Ranges to the new Print PresShell - nsRefPtr selection, selectionPS; + RefPtr selection, selectionPS; // It's okay if there is no display shell, just skip copying the selection if (displayShell) { selection = displayShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL); @@ -2249,7 +2249,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO) fprintf(fd, "Title: %s\n", docStr.get()); fprintf(fd, "URL: %s\n", urlStr.get()); fprintf(fd, "--------------- Frames ----------------\n"); - //nsRefPtr renderingContext = + //RefPtr renderingContext = // mPrt->mPrintDocDC->CreateRenderingContext(); RootFrameList(aPO->mPresContext, fd, 0); //DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0); @@ -2392,7 +2392,7 @@ CloneRangeToSelection(nsRange* aRange, nsIDocument* aDoc, nsCOMPtr newStartNode = do_QueryInterface(newStart); NS_ENSURE_TRUE_VOID(newStartNode); - nsRefPtr range = new nsRange(newStartNode); + RefPtr range = new nsRange(newStartNode); nsresult rv = range->SetStart(newStartNode, startOffset); NS_ENSURE_SUCCESS_VOID(rv); rv = range->SetEnd(newEnd, endOffset); @@ -2407,9 +2407,9 @@ static nsresult CloneSelection(nsIDocument* aOrigDoc, nsIDocument* aDoc) nsIPresShell* shell = aDoc->GetShell(); NS_ENSURE_STATE(origShell && shell); - nsRefPtr origSelection = + RefPtr origSelection = origShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL); - nsRefPtr selection = + RefPtr selection = shell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL); NS_ENSURE_STATE(origSelection && selection); @@ -2492,7 +2492,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO) // mPrintDC must have positive width and height for this call // CreateRenderingContext can fail for large dimensions - nsRefPtr gCtx = mPrt->mPrintDC->CreateRenderingContext(); + RefPtr gCtx = mPrt->mPrintDC->CreateRenderingContext(); NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY); nsRenderingContext rc(gCtx); @@ -2506,7 +2506,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO) nsRect startRect; nsRect endRect; - nsRefPtr selectionPS = + RefPtr selectionPS = poPresShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL); rv = GetPageRangeForSelection(poPresShell, poPresContext, rc, selectionPS, pageSequence, @@ -2632,7 +2632,7 @@ DocHasPrintCallbackCanvas(nsIDocument* aDoc, void* aData) if (!root) { return true; } - nsRefPtr canvases = NS_GetContentList(root, + RefPtr canvases = NS_GetContentList(root, kNameSpaceID_XHTML, NS_LITERAL_STRING("canvas")); uint32_t canvasCount = canvases->Length(true); @@ -3559,7 +3559,7 @@ nsPrintEngine::StartPagePrintTimer(nsPrintObject* aPO) int32_t printPageDelay = 50; mPrt->mPrintSettings->GetPrintPageDelay(&printPageDelay); - nsRefPtr timer = + RefPtr timer = new nsPagePrintTimer(this, mDocViewerPrint, printPageDelay); timer.forget(&mPagePrintTimer); } @@ -3800,7 +3800,7 @@ void DumpLayoutData(char* aTitleStr, fprintf(fd, "URL: %s\n", aURLStr?aURLStr:""); fprintf(fd, "--------------- Frames ----------------\n"); fprintf(fd, "--------------- Frames ----------------\n"); - //nsRefPtr renderingContext = + //RefPtr renderingContext = // aDC->CreateRenderingContext(); RootFrameList(aPresContext, fd, 0); //DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0); diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 7be2a6e8f5..f464968a1f 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -44,9 +44,9 @@ public: nsCOMPtr mTreeOwner; nsCOMPtr mDocument; - nsRefPtr mPresContext; + RefPtr mPresContext; nsCOMPtr mPresShell; - nsRefPtr mViewManager; + RefPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index 7fb453ab43..d183d37847 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -218,7 +218,7 @@ private: InfallibleTArray mPropertyValuePairs; }; -typedef InfallibleTArray> AnimationPtrArray; +typedef InfallibleTArray> AnimationPtrArray; struct AnimationCollection : public LinkedListElement { @@ -392,7 +392,7 @@ public: // afterwards with animation. // NOTE: If we don't need to apply any styles, mStyleRule will be // null, but mStyleRuleRefreshTime will still be valid. - nsRefPtr mStyleRule; + RefPtr mStyleRule; // RestyleManager keeps track of the number of animation // 'mini-flushes' (see nsTransitionManager::UpdateAllThrottledStyles()). diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index f7dc4dcc11..e213997ef2 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -647,7 +647,7 @@ nsMediaList::SetStyleSheet(CSSStyleSheet* aSheet) already_AddRefed nsMediaList::Clone() { - nsRefPtr result = new nsMediaList(); + RefPtr result = new nsMediaList(); result->mArray.AppendElements(mArray.Length()); for (uint32_t i = 0, i_end = mArray.Length(); i < i_end; ++i) { result->mArray[i] = mArray[i]->Clone(); @@ -844,7 +844,7 @@ static bool SetStyleSheetReference(css::Rule* aRule, void* aSheet) } struct ChildSheetListBuilder { - nsRefPtr* sheetSlot; + RefPtr* sheetSlot; CSSStyleSheet* parent; void SetParentLinks(CSSStyleSheet* aSheet) { @@ -890,7 +890,7 @@ CSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) // Have to do this QI to be safe, since XPConnect can fake // nsIDOMCSSStyleSheets - nsRefPtr cssSheet = do_QueryObject(childSheet); + RefPtr cssSheet = do_QueryObject(childSheet); if (!cssSheet) { return true; } @@ -1003,7 +1003,7 @@ AddNamespaceRuleToMap(css::Rule* aRule, nsXMLNameSpaceMap* aMap) { NS_ASSERTION(aRule->GetType() == css::Rule::NAMESPACE_RULE, "Bogus rule type"); - nsRefPtr nameSpaceRule = do_QueryObject(aRule); + RefPtr nameSpaceRule = do_QueryObject(aRule); nsAutoString urlSpec; nameSpaceRule->GetURLSpec(urlSpec); @@ -1201,13 +1201,13 @@ CSSStyleSheet::UnlinkInner() // don't want to do any addrefing in the process, just to make sure // we don't confuse the cycle collector (though on the face of it, // addref/release pairs during unlink should probably be ok). - nsRefPtr child; + RefPtr child; child.swap(mInner->mFirstChild); while (child) { MOZ_ASSERT(child->mParent == this, "We have a unique inner!"); child->mParent = nullptr; child->mDocument = nullptr; - nsRefPtr next; + RefPtr next; // Null out child->mNext, but don't let it die yet next.swap(child->mNext); // Switch to looking at the old value of child->mNext next iteration @@ -1226,7 +1226,7 @@ CSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb) return; } - nsRefPtr* childSheetSlot = &mInner->mFirstChild; + RefPtr* childSheetSlot = &mInner->mFirstChild; while (*childSheetSlot) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "child sheet"); cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIStyleSheet*, childSheetSlot->get())); @@ -1478,7 +1478,7 @@ CSSStyleSheet::FindOwningWindowInnerID() const if (windowID == 0 && mOwnerRule) { nsCOMPtr sheet = static_cast(mOwnerRule)->GetStyleSheet(); if (sheet) { - nsRefPtr cssSheet = do_QueryObject(sheet); + RefPtr cssSheet = do_QueryObject(sheet); if (cssSheet) { windowID = cssSheet->FindOwningWindowInnerID(); } @@ -1498,7 +1498,7 @@ CSSStyleSheet::AppendStyleSheet(CSSStyleSheet* aSheet) NS_PRECONDITION(nullptr != aSheet, "null arg"); WillDirty(); - nsRefPtr* tail = &mInner->mFirstChild; + RefPtr* tail = &mInner->mFirstChild; while (*tail) { tail = &(*tail)->mNext; } @@ -1517,7 +1517,7 @@ CSSStyleSheet::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex) NS_PRECONDITION(nullptr != aSheet, "null arg"); WillDirty(); - nsRefPtr* tail = &mInner->mFirstChild; + RefPtr* tail = &mInner->mFirstChild; while (*tail && aIndex) { --aIndex; tail = &(*tail)->mNext; @@ -1662,7 +1662,7 @@ CSSStyleSheet::Clone(CSSStyleSheet* aCloneParent, nsIDocument* aCloneDocument, nsINode* aCloneOwningNode) const { - nsRefPtr clone = new CSSStyleSheet(*this, + RefPtr clone = new CSSStyleSheet(*this, aCloneParent, aCloneOwnerRule, aCloneDocument, @@ -1974,7 +1974,7 @@ RuleHasPendingChildSheet(css::Rule *cssRule) NS_ASSERTION(importRule, "Rule which has type IMPORT_RULE and does not implement nsIDOMCSSImportRule!"); nsCOMPtr childSheet; importRule->GetStyleSheet(getter_AddRefs(childSheet)); - nsRefPtr cssSheet = do_QueryObject(childSheet); + RefPtr cssSheet = do_QueryObject(childSheet); return cssSheet != nullptr && !cssSheet->IsComplete(); } @@ -1998,7 +1998,7 @@ CSSStyleSheet::InsertRuleInternal(const nsAString& aRule, // Hold strong ref to the CSSLoader in case the document update // kills the document - nsRefPtr loader; + RefPtr loader; if (mDocument) { loader = mDocument->CSSLoader(); NS_ASSERTION(loader, "Document with no CSS loader!"); @@ -2008,7 +2008,7 @@ CSSStyleSheet::InsertRuleInternal(const nsAString& aRule, mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, true); - nsRefPtr rule; + RefPtr rule; nsresult result = css.ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI, mInner->mPrincipal, getter_AddRefs(rule)); if (NS_FAILED(result)) @@ -2113,7 +2113,7 @@ CSSStyleSheet::DeleteRule(uint32_t aIndex) "Too many style rules!"); // Hold a strong ref to the rule so it doesn't die when we RemoveObjectAt - nsRefPtr rule = mInner->mOrderedRules.ObjectAt(aIndex); + RefPtr rule = mInner->mOrderedRules.ObjectAt(aIndex); if (rule) { mInner->mOrderedRules.RemoveObjectAt(aIndex); if (mDocument && mDocument->StyleSheetChangeEventsEnabled()) { @@ -2137,7 +2137,7 @@ CSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex) { NS_ENSURE_ARG_POINTER(aGroup); NS_ASSERTION(mInner->mComplete, "No deleting from an incomplete sheet!"); - nsRefPtr rule = aGroup->GetStyleRuleAt(aIndex); + RefPtr rule = aGroup->GetStyleRuleAt(aIndex); NS_ENSURE_TRUE(rule, NS_ERROR_ILLEGAL_VALUE); // check that the rule actually belongs to this sheet! @@ -2177,7 +2177,7 @@ CSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, // Hold strong ref to the CSSLoader in case the document update // kills the document - nsRefPtr loader; + RefPtr loader; if (mDocument) { loader = mDocument->CSSLoader(); NS_ASSERTION(loader, "Document with no CSS loader!"); @@ -2190,7 +2190,7 @@ CSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, WillDirty(); - nsRefPtr rule; + RefPtr rule; nsresult result = css.ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI, mInner->mPrincipal, getter_AddRefs(rule)); if (NS_FAILED(result)) @@ -2276,7 +2276,7 @@ CSSStyleSheet::ParseSheet(const nsAString& aInput) // Hold strong ref to the CSSLoader in case the document update // kills the document - nsRefPtr loader; + RefPtr loader; if (mDocument) { loader = mDocument->CSSLoader(); NS_ASSERTION(loader, "Document with no CSS loader!"); @@ -2291,7 +2291,7 @@ CSSStyleSheet::ParseSheet(const nsAString& aInput) // detach existing rules (including child sheets via import rules) int ruleCount; while ((ruleCount = mInner->mOrderedRules.Count()) != 0) { - nsRefPtr rule = mInner->mOrderedRules.ObjectAt(ruleCount - 1); + RefPtr rule = mInner->mOrderedRules.ObjectAt(ruleCount - 1); mInner->mOrderedRules.RemoveObjectAt(ruleCount - 1); rule->SetStyleSheet(nullptr); if (mDocument) { @@ -2320,7 +2320,7 @@ CSSStyleSheet::ParseSheet(const nsAString& aInput) // notify document of all new rules if (mDocument) { for (int32_t index = 0; index < mInner->mOrderedRules.Count(); ++index) { - nsRefPtr rule = mInner->mOrderedRules.ObjectAt(index); + RefPtr rule = mInner->mOrderedRules.ObjectAt(index); if (rule->GetType() == css::Rule::IMPORT_RULE && RuleHasPendingChildSheet(rule)) { continue; // notify when loaded (see StyleSheetLoaded) diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index d07b762d14..7e1ba545c2 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -93,7 +93,7 @@ private: // currently this is the case) that any time page JS can get ts hands on a // child sheet that means we've already ensured unique inners throughout its // parent chain and things are good. - nsRefPtr mFirstChild; + RefPtr mFirstChild; CORSMode mCORSMode; // The Referrer Policy of a stylesheet is used for its child sheets, so it is // stored here. @@ -357,18 +357,18 @@ protected: protected: nsString mTitle; - nsRefPtr mMedia; - nsRefPtr mNext; + RefPtr mMedia; + RefPtr mNext; CSSStyleSheet* mParent; // weak ref css::ImportRule* mOwnerRule; // weak ref - nsRefPtr mRuleCollection; + RefPtr mRuleCollection; nsIDocument* mDocument; // weak ref; parents maintain this for their children nsINode* mOwningNode; // weak ref bool mDisabled; bool mDirty; // has been modified bool mInRuleProcessorCache; - nsRefPtr mScopeElement; + RefPtr mScopeElement; CSSStyleSheetInner* mInner; diff --git a/layout/style/CounterStyleManager.cpp b/layout/style/CounterStyleManager.cpp index 95c52c4675..eb833da2ef 100644 --- a/layout/style/CounterStyleManager.cpp +++ b/layout/style/CounterStyleManager.cpp @@ -1127,7 +1127,7 @@ private: // frames are released. CounterStyleManager* mManager; - nsRefPtr mRule; + RefPtr mRule; uint32_t mRuleGeneration; uint8_t mSystem; @@ -2062,13 +2062,13 @@ struct InvalidateOldStyleData } nsPresContext* mPresContext; - nsTArray> mToBeRemoved; + nsTArray> mToBeRemoved; bool mChanged; }; static PLDHashOperator InvalidateOldStyle(const nsSubstring& aKey, - nsRefPtr& aStyle, + RefPtr& aStyle, void* aArg) { InvalidateOldStyleData* data = static_cast(aArg); diff --git a/layout/style/FontFace.cpp b/layout/style/FontFace.cpp index 2ad6e5fe72..fa8b0639a0 100644 --- a/layout/style/FontFace.cpp +++ b/layout/style/FontFace.cpp @@ -33,7 +33,7 @@ public: virtual void TakeBuffer(uint8_t*& aBuffer, uint32_t& aLength); private: - nsRefPtr mFontFace; + RefPtr mFontFace; }; void @@ -156,7 +156,7 @@ FontFace::CreateForRule(nsISupports* aGlobal, { nsCOMPtr globalObject = do_QueryInterface(aGlobal); - nsRefPtr obj = new FontFace(aGlobal, aFontFaceSet); + RefPtr obj = new FontFace(aGlobal, aFontFaceSet); obj->mRule = aRule; obj->mSourceType = eSourceType_FontFaceRule; obj->mInFontFaceSet = true; @@ -178,7 +178,7 @@ FontFace::Constructor(const GlobalObject& aGlobal, return nullptr; } - nsRefPtr obj = new FontFace(global, doc->Fonts()); + RefPtr obj = new FontFace(global, doc->Fonts()); if (!obj->SetDescriptors(aFamily, aDescriptors)) { return obj.forget(); } @@ -391,7 +391,7 @@ FontFace::CreateUserFontEntry() "Rule backed FontFace objects should already have a user font " "entry by the time Load() can be called on them"); - nsRefPtr newEntry = + RefPtr newEntry = mFontFaceSet->FindOrCreateUserFontEntryFromFontFace(this); if (newEntry) { SetUserFontEntry(newEntry); @@ -683,7 +683,7 @@ FontFace::TakeBuffer(uint8_t*& aBuffer, uint32_t& aLength) already_AddRefed FontFace::CreateBufferSource() { - nsRefPtr bufferSource = new FontFaceBufferSource(this); + RefPtr bufferSource = new FontFaceBufferSource(this); return bufferSource.forget(); } diff --git a/layout/style/FontFace.h b/layout/style/FontFace.h index cc6600a0fb..09e5bc270a 100644 --- a/layout/style/FontFace.h +++ b/layout/style/FontFace.h @@ -209,15 +209,15 @@ private: // A Promise that is fulfilled once the font represented by this FontFace // is loaded, and is rejected if the load fails. - nsRefPtr mLoaded; + RefPtr mLoaded; // The @font-face rule this FontFace object is reflecting, if it is a // rule backed FontFace. - nsRefPtr mRule; + RefPtr mRule; // The FontFace object's user font entry. This is initially null, but is set // during FontFaceSet::UpdateRules and when a FontFace is explicitly loaded. - nsRefPtr mUserFontEntry; + RefPtr mUserFontEntry; // The current load status of the font represented by this FontFace. // Note that we can't just reflect the value of the gfxUserFontEntry's @@ -247,7 +247,7 @@ private: // The FontFaceSet this FontFace is associated with, regardless of whether // it is currently "in" the set. - nsRefPtr mFontFaceSet; + RefPtr mFontFaceSet; // Whether this FontFace appears in the FontFaceSet. bool mInFontFaceSet; diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 958d3dd921..c80410b640 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -166,7 +166,7 @@ FontFaceSet::RemoveDOMContentLoadedListener() void FontFaceSet::ParseFontShorthandForMatching( const nsAString& aFont, - nsRefPtr& aFamilyList, + RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, uint32_t& aItalicStyle, @@ -249,7 +249,7 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont, nsTArray& aFontFaces, ErrorResult& aRv) { - nsRefPtr familyList; + RefPtr familyList; uint32_t weight; int32_t stretch; uint32_t italicStyle; @@ -272,7 +272,7 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont, nsTHashtable> matchingFaces; for (const FontFamilyName& fontFamilyName : familyList->GetFontlist()) { - nsRefPtr family = + RefPtr family = mUserFontSet->LookupFamily(fontFamilyName.mName); if (!family) { @@ -313,7 +313,7 @@ FontFaceSet::Load(JSContext* aCx, { FlushUserFontSet(); - nsTArray> promises; + nsTArray> promises; nsTArray faces; FindMatchingFontFaces(aFont, aText, faces, aRv); @@ -322,7 +322,7 @@ FontFaceSet::Load(JSContext* aCx, } for (FontFace* f : faces) { - nsRefPtr promise = f->Load(aRv); + RefPtr promise = f->Load(aRv); if (aRv.Failed()) { return nullptr; } @@ -336,7 +336,7 @@ FontFaceSet::Load(JSContext* aCx, JS::Rooted jsGlobal(aCx, globalObject->GetGlobalJSObject()); GlobalObject global(aCx, jsGlobal); - nsRefPtr result = Promise::All(global, promises, aRv); + RefPtr result = Promise::All(global, promises, aRv); return result.forget(); } @@ -590,7 +590,7 @@ FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry, NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr fontLoader = + RefPtr fontLoader = new nsFontFaceLoader(aUserFontEntry, aFontFaceSrc->mURI, this, channel); if (LOG_ENABLED()) { @@ -641,7 +641,7 @@ FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry, // allow data, javascript, etc URI's rv = channel->AsyncOpen(streamLoader, nullptr); } else { - nsRefPtr listener = + RefPtr listener = new nsCORSListenerProxy(streamLoader, aUserFontEntry->GetPrincipal(), false); // Doesn't matter what data: URI handling we use here, since we // don't even use a CORS listener proxy for the data: case. @@ -665,7 +665,7 @@ FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry, } static PLDHashOperator DetachFontEntries(const nsAString& aKey, - nsRefPtr& aFamily, + RefPtr& aFamily, void* aUserArg) { aFamily->DetachFontEntries(); @@ -673,7 +673,7 @@ static PLDHashOperator DetachFontEntries(const nsAString& aKey, } static PLDHashOperator RemoveIfEmpty(const nsAString& aKey, - nsRefPtr& aFamily, + RefPtr& aFamily, void* aUserArg) { return aFamily->GetFontList().Length() ? PL_DHASH_NEXT : PL_DHASH_REMOVE; @@ -730,7 +730,7 @@ FontFaceSet::UpdateRules(const nsTArray& aRules) continue; } nsCSSFontFaceRule* rule = aRules[i].mRule; - nsRefPtr f = ruleFaceMap.Get(rule); + RefPtr f = ruleFaceMap.Get(rule); if (!f.get()) { f = FontFace::CreateForRule(GetParentObject(), this, rule); } @@ -763,7 +763,7 @@ FontFaceSet::UpdateRules(const nsTArray& aRules) // it when the FontFace is GCed, if we can detect that. size_t count = oldRecords.Length(); for (size_t i = 0; i < count; ++i) { - nsRefPtr f = oldRecords[i].mFontFace; + RefPtr f = oldRecords[i].mFontFace; gfxUserFontEntry* userFontEntry = f->GetUserFontEntry(); if (userFontEntry) { nsFontFaceLoader* loader = userFontEntry->GetLoader(); @@ -832,7 +832,7 @@ FontFaceSet::InsertNonRuleFontFace(FontFace* aFontFace, if (!aFontFace->GetUserFontEntry()) { // XXX Should we be checking mUserFontSet->mLocalRulesUsed like // InsertRuleFontFace does? - nsRefPtr entry = + RefPtr entry = FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace, nsStyleSet::eDocSheet); if (!entry) { @@ -904,7 +904,7 @@ FontFaceSet::InsertRuleFontFace(FontFace* aFontFace, uint8_t aSheetType, } // this is a new rule: - nsRefPtr entry = + RefPtr entry = FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace, aSheetType); if (!entry) { @@ -1154,7 +1154,7 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName, return nullptr; } - nsRefPtr entry = + RefPtr entry = set->mUserFontSet->FindOrCreateUserFontEntry(aFamilyName, srcArray, weight, stretch, italicStyle, featureSettings, @@ -1484,7 +1484,7 @@ FontFaceSet::CheckLoadingStarted() false))->PostDOMEvent(); if (PrefEnabled()) { - nsRefPtr ready; + RefPtr ready; if (GetParentObject()) { ErrorResult rv; ready = Promise::Create(GetParentObject(), rv); @@ -1633,7 +1633,7 @@ FontFaceSet::DispatchLoadingFinishedEvent( for (size_t i = 0; i < aFontFaces.Length(); i++) { elements[i] = aFontFaces[i]; } - nsRefPtr event = + RefPtr event = CSSFontFaceLoadEvent::Constructor(this, aType, init); (new AsyncEventDispatcher(this, event))->PostDOMEvent(); } @@ -1779,7 +1779,7 @@ FontFaceSet::UserFontSet::CreateUserFontEntry( uint32_t aLanguageOverride, gfxSparseBitSet* aUnicodeRanges) { - nsRefPtr entry = + RefPtr entry = new FontFace::Entry(this, aFontFaceSrcList, aWeight, aStretch, aItalicStyle, aFeatureSettings, aLanguageOverride, aUnicodeRanges); return entry.forget(); diff --git a/layout/style/FontFaceSet.h b/layout/style/FontFaceSet.h index 04d9d248c0..1d6c5ac1e2 100644 --- a/layout/style/FontFaceSet.h +++ b/layout/style/FontFaceSet.h @@ -89,7 +89,7 @@ public: gfxSparseBitSet* aUnicodeRanges) override; private: - nsRefPtr mFontFaceSet; + RefPtr mFontFaceSet; }; NS_DECL_ISUPPORTS_INHERITED @@ -225,7 +225,7 @@ private: // make sure to update FontFaceSet's cycle collection macros // accordingly. struct FontFaceRecord { - nsRefPtr mFontFace; + RefPtr mFontFace; uint8_t mSheetType; // only relevant for mRuleFaces entries // When true, indicates that when finished loading, the FontFace should be @@ -277,7 +277,7 @@ private: void ParseFontShorthandForMatching( const nsAString& aFont, - nsRefPtr& aFamilyList, + RefPtr& aFamilyList, uint32_t& aWeight, int32_t& aStretch, uint32_t& aItalicStyle, @@ -287,7 +287,7 @@ private: nsTArray& aFontFaces, mozilla::ErrorResult& aRv); - nsRefPtr mUserFontSet; + RefPtr mUserFontSet; // The document this is a FontFaceSet for. nsCOMPtr mDocument; @@ -298,7 +298,7 @@ private: // any of those fonts failed to load. mReady is replaced with // a new Promise object whenever mReady is settled and another // FontFace in mRuleFaces or mNonRuleFaces starts to load. - nsRefPtr mReady; + RefPtr mReady; // Set of all loaders pointing to us. These are not strong pointers, // but that's OK because nsFontFaceLoader always calls RemoveLoader on diff --git a/layout/style/FontFaceSetIterator.h b/layout/style/FontFaceSetIterator.h index 91ad787a7e..31a31f4e0e 100644 --- a/layout/style/FontFaceSetIterator.h +++ b/layout/style/FontFaceSetIterator.h @@ -28,7 +28,7 @@ public: mozilla::ErrorResult& aRv); private: - nsRefPtr mFontFaceSet; + RefPtr mFontFaceSet; uint32_t mNextIndex; bool mIsKeyAndValue; }; diff --git a/layout/style/GroupRule.h b/layout/style/GroupRule.h index 7cf00cb269..7de24066bf 100644 --- a/layout/style/GroupRule.h +++ b/layout/style/GroupRule.h @@ -79,7 +79,7 @@ public: static bool CloneRuleInto(Rule* aRule, void* aArray) { - nsRefPtr clone = aRule->Clone(); + RefPtr clone = aRule->Clone(); static_cast(aArray)->AppendObject(clone); return true; } @@ -96,7 +96,7 @@ protected: nsresult DeleteRule(uint32_t aIndex); IncrementalClearCOMRuleArray mRules; - nsRefPtr mRuleCollection; // lazily constructed + RefPtr mRuleCollection; // lazily constructed }; } // namespace css diff --git a/layout/style/ImageLoader.cpp b/layout/style/ImageLoader.cpp index cd14cf25aa..37e3709f4a 100644 --- a/layout/style/ImageLoader.cpp +++ b/layout/style/ImageLoader.cpp @@ -141,7 +141,7 @@ ImageLoader::MaybeRegisterCSSImage(ImageLoader::Image* aImage) return; } - nsRefPtr request; + RefPtr request; // Ignore errors here. If cloning fails for some reason we'll put a null // entry in the hash and we won't keep trying to clone. @@ -278,7 +278,7 @@ ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal, return; } - nsRefPtr request; + RefPtr request; nsContentUtils::LoadImage(aURI, mDocument, aOriginPrincipal, aReferrer, mDocument->GetReferrerPolicy(), nullptr, nsIRequest::LOAD_NORMAL, @@ -289,7 +289,7 @@ ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal, return; } - nsRefPtr clonedRequest; + RefPtr clonedRequest; mInClone = true; nsresult rv = request->Clone(this, getter_AddRefs(clonedRequest)); mInClone = false; diff --git a/layout/style/ImportRule.h b/layout/style/ImportRule.h index 87cd6ebbb4..2efbf43a09 100644 --- a/layout/style/ImportRule.h +++ b/layout/style/ImportRule.h @@ -64,8 +64,8 @@ public: private: nsString mURLSpec; - nsRefPtr mMedia; - nsRefPtr mChildSheet; + RefPtr mMedia; + RefPtr mChildSheet; }; } // namespace css diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index e9242c4053..24b253f779 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -155,7 +155,7 @@ public: // Hold a ref to the CSSLoader so we can call back to it to let it // know the load finished - nsRefPtr mLoader; + RefPtr mLoader; // Title needed to pull datas out of the pending datas table when // the preferred title is changed @@ -171,14 +171,14 @@ public: uint32_t mLineNumber; // The sheet we're loading data for - nsRefPtr mSheet; + RefPtr mSheet; // Linked list of datas for the same URI as us SheetLoadData* mNext; // strong ref // Load data for the sheet that @import-ed us if we were @import-ed // during the parse - nsRefPtr mParentData; + RefPtr mParentData; // Number of sheets we @import-ed that are still loading uint32_t mPendingChildren; @@ -468,7 +468,7 @@ SheetLoadData::FireLoadEvent(nsIThreadInternal* aThread) // First remove ourselves as a thread observer. But we need to keep // ourselves alive while doing that! - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); aThread->RemoveObserver(this); // Now fire the event @@ -986,7 +986,7 @@ Loader::IsAlternate(const nsAString& aTitle, bool aHasAlternateRel) /* static */ PLDHashOperator Loader::RemoveEntriesWithURI(URIPrincipalReferrerPolicyAndCORSModeHashKey* aKey, - nsRefPtr& aSheet, + RefPtr& aSheet, void* aUserData) { nsIURI* obsoleteURI = static_cast(aUserData); @@ -1108,7 +1108,7 @@ Loader::CreateSheet(nsIURI* aURI, if (aURI) { aSheetState = eSheetComplete; - nsRefPtr sheet; + RefPtr sheet; // First, the XUL cache #ifdef MOZ_XUL @@ -1240,7 +1240,7 @@ Loader::CreateSheet(nsIURI* aURI, SRICheck::IntegrityMetadata(aIntegrity, mDocument, &sriMetadata); } - nsRefPtr sheet = new CSSStyleSheet(aCORSMode, + RefPtr sheet = new CSSStyleSheet(aCORSMode, aReferrerPolicy, sriMetadata); sheet->SetURIs(sheetURI, originalURI, baseURI); @@ -1269,7 +1269,7 @@ Loader::PrepareSheet(CSSStyleSheet* aSheet, { NS_PRECONDITION(aSheet, "Must have a sheet!"); - nsRefPtr mediaList(aMediaList); + RefPtr mediaList(aMediaList); if (!aMediaString.IsEmpty()) { NS_ASSERTION(!aMediaList, @@ -1688,7 +1688,7 @@ Loader::LoadSheet(SheetLoadData* aLoadData, if (ourCORSMode != CORS_NONE) { bool withCredentials = (ourCORSMode == CORS_USE_CREDENTIALS); LOG((" Doing CORS-enabled load; credentials %d", withCredentials)); - nsRefPtr corsListener = + RefPtr corsListener = new nsCORSListenerProxy(streamLoader, aLoadData->mLoaderPrincipal, withCredentials); rv = corsListener->Init(channel, DataURIHandling::Allow); @@ -1794,7 +1794,7 @@ Loader::SheetComplete(SheetLoadData* aLoadData, nsresult aStatus) // 8 is probably big enough for all our common cases. It's not likely that // imports will nest more than 8 deep, and multiple sheets with the same URI // are rare. - nsAutoTArray, 8> datasToNotify; + nsAutoTArray, 8> datasToNotify; DoSheetComplete(aLoadData, aStatus, datasToNotify); // Now it's safe to go ahead and notify observers @@ -1976,7 +1976,7 @@ Loader::LoadInlineStyle(nsIContent* aElement, // load data or to CreateSheet(). Also, OK to use CORS_NONE for the CORS // mode and mDocument's ReferrerPolicy. StyleSheetState state; - nsRefPtr sheet; + RefPtr sheet; nsresult rv = CreateSheet(nullptr, aElement, nullptr, CORS_NONE, mDocument->GetReferrerPolicy(), EmptyString(), // no inline integrity checks @@ -2060,7 +2060,7 @@ Loader::LoadStyleLink(nsIContent* aElement, LOG((" Passed load check")); StyleSheetState state; - nsRefPtr sheet; + RefPtr sheet; rv = CreateSheet(aURL, aElement, principal, aCORSMode, aReferrerPolicy, aIntegrity, false, aHasAlternateRel, aTitle, state, aIsAlternate, @@ -2219,7 +2219,7 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet, // Now that we know it's safe to load this (passes security check and not a // loop) do so. - nsRefPtr sheet; + RefPtr sheet; bool isAlternate; StyleSheetState state; const nsSubstring& empty = EmptyString(); @@ -2341,7 +2341,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, StyleSheetState state; bool isAlternate; - nsRefPtr sheet; + RefPtr sheet; bool syncLoad = (aObserver == nullptr); const nsSubstring& empty = EmptyString(); @@ -2394,7 +2394,7 @@ Loader::PostLoadEvent(nsIURI* aURI, NS_PRECONDITION(aObserver || !mObservers.IsEmpty() || aElement, "Must have observer or element"); - nsRefPtr evt = + RefPtr evt = new SheetLoadData(this, EmptyString(), // title doesn't matter here aURI, aSheet, @@ -2614,7 +2614,7 @@ Loader::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const // If aSheet has a parent, then its parent will report it so we don't // have to worry about it here. Likewise, if aSheet has an owning node, // then the document that node is in will report it. - const nsRefPtr& aSheet = iter.Data(); + const RefPtr& aSheet = iter.Data(); n += (aSheet->GetOwnerNode() || aSheet->GetParentSheet()) ? 0 : aSheet->SizeOfIncludingThis(aMallocSizeOf); diff --git a/layout/style/Loader.h b/layout/style/Loader.h index 13d322b06a..6c86097120 100644 --- a/layout/style/Loader.h +++ b/layout/style/Loader.h @@ -387,7 +387,7 @@ public: // is selected and aHasAlternateRel is false. bool IsAlternate(const nsAString& aTitle, bool aHasAlternateRel); - typedef nsTArray > LoadDataArray; + typedef nsTArray > LoadDataArray; // Measure our size. size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; @@ -401,7 +401,7 @@ private: static PLDHashOperator RemoveEntriesWithURI(URIPrincipalReferrerPolicyAndCORSModeHashKey* aKey, - nsRefPtr& aSheet, + RefPtr& aSheet, void* aUserData); // Note: null aSourcePrincipal indicates that the content policy and diff --git a/layout/style/MediaQueryList.h b/layout/style/MediaQueryList.h index e0587a0a5b..cd7cb7d34a 100644 --- a/layout/style/MediaQueryList.h +++ b/layout/style/MediaQueryList.h @@ -44,8 +44,8 @@ public: nsISupports* GetParentObject() const; struct HandleChangeData { - nsRefPtr mql; - nsRefPtr callback; + RefPtr mql; + RefPtr callback; }; // Appends listeners that need notification to aListenersToNotify @@ -82,10 +82,10 @@ private: // linked list. nsCOMPtr mDocument; - nsRefPtr mMediaList; + RefPtr mMediaList; bool mMatches; bool mMatchesValid; - nsTArray> mCallbacks; + nsTArray> mCallbacks; }; } // namespace dom diff --git a/layout/style/RuleProcessorCache.h b/layout/style/RuleProcessorCache.h index 5caf696f61..844a281f33 100644 --- a/layout/style/RuleProcessorCache.h +++ b/layout/style/RuleProcessorCache.h @@ -111,7 +111,7 @@ private: struct DocumentEntry { nsDocumentRuleResultCacheKey mCacheKey; - nsRefPtr mRuleProcessor; + RefPtr mRuleProcessor; }; struct Entry { diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 91e001d3a0..4d4bda7ab1 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -153,7 +153,7 @@ AppendFunction(nsCSSKeyword aTransformFunction) break; } - nsRefPtr arr = nsCSSValue::Array::Create(nargs + 1); + RefPtr arr = nsCSSValue::Array::Create(nargs + 1); arr->Item(0).SetIntValue(aTransformFunction, eCSSUnit_Enumerated); return arr.forget(); @@ -164,7 +164,7 @@ ToPrimitive(nsCSSValue::Array* aArray) { nsCSSKeyword tfunc = nsStyleTransformMatrix::TransformFunctionOf(aArray); nsCSSKeyword primitive = ToPrimitive(tfunc); - nsRefPtr arr = AppendFunction(primitive); + RefPtr arr = AppendFunction(primitive); // FIXME: This would produce fewer calc() expressions if the // zero were of compatible type (length vs. percent) when @@ -259,7 +259,7 @@ AppendCSSShadowValue(const nsCSSShadowItem *aShadow, MOZ_ASSERT(aShadow, "shadow expected"); // X, Y, Radius, Spread, Color, Inset - nsRefPtr arr = nsCSSValue::Array::Create(6); + RefPtr arr = nsCSSValue::Array::Create(6); nscoordToCSSValue(aShadow->mXOffset, arr->Item(0)); nscoordToCSSValue(aShadow->mYOffset, arr->Item(1)); nscoordToCSSValue(aShadow->mRadius, arr->Item(2)); @@ -363,7 +363,7 @@ ExtractCalcValue(const nsCSSValue& aValue) static void SetCalcValue(const nsStyleCoord::CalcValue* aCalc, nsCSSValue& aValue) { - nsRefPtr arr = nsCSSValue::Array::Create(1); + RefPtr arr = nsCSSValue::Array::Create(1); if (!aCalc->mHasPercent) { nscoordToCSSValue(aCalc->mLength, arr->Item(0)); } else { @@ -379,7 +379,7 @@ SetCalcValue(const nsStyleCoord::CalcValue* aCalc, nsCSSValue& aValue) static void SetCalcValue(const PixelCalcValue& aCalc, nsCSSValue& aValue) { - nsRefPtr arr = nsCSSValue::Array::Create(1); + RefPtr arr = nsCSSValue::Array::Create(1); if (!aCalc.mHasPercent) { arr->Item(0).SetFloatValue(aCalc.mLength, eCSSUnit_Pixel); } else { @@ -1128,7 +1128,7 @@ AddShadowItems(double aCoeff1, const nsCSSValue &aValue1, "wrong unit"); nsCSSValue::Array *array1 = aValue1.GetArrayValue(); nsCSSValue::Array *array2 = aValue2.GetArrayValue(); - nsRefPtr resultArray = nsCSSValue::Array::Create(6); + RefPtr resultArray = nsCSSValue::Array::Create(6); for (size_t i = 0; i < 4; ++i) { AddCSSValuePixel(aCoeff1, array1->Item(i), aCoeff2, array2->Item(i), @@ -1223,7 +1223,7 @@ AddTransformScale(double aCoeff1, const nsCSSValue &aValue1, StyleAnimationValue::AppendTransformFunction(nsCSSKeyword aTransformFunction, nsCSSValueList**& aListTail) { - nsRefPtr arr = AppendFunction(aTransformFunction); + RefPtr arr = AppendFunction(aTransformFunction); nsCSSValueList *item = new nsCSSValueList; item->mValue.SetArrayValue(arr, eCSSUnit_Function); @@ -1606,7 +1606,7 @@ AddDifferentTransformLists(double aCoeff1, const nsCSSValueList* aList1, nsAutoPtr result; nsCSSValueList **resultTail = getter_Transfers(result); - nsRefPtr arr; + RefPtr arr; arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_interpolatematrix, resultTail); @@ -1645,7 +1645,7 @@ AddFilterFunctionImpl(double aCoeff1, const nsCSSValueList* aList1, "expected function"); MOZ_ASSERT(aList2->mValue.GetUnit() == eCSSUnit_Function, "expected function"); - nsRefPtr a1 = aList1->mValue.GetArrayValue(), + RefPtr a1 = aList1->mValue.GetArrayValue(), a2 = aList2->mValue.GetArrayValue(); nsCSSKeyword filterFunction = a1->Item(0).GetKeywordValue(); if (filterFunction != a2->Item(0).GetKeywordValue()) @@ -1755,7 +1755,7 @@ AddTransformLists(double aCoeff1, const nsCSSValueList* aList1, nsCSSValueList **resultTail = getter_Transfers(result); do { - nsRefPtr a1 = ToPrimitive(aList1->mValue.GetArrayValue()), + RefPtr a1 = ToPrimitive(aList1->mValue.GetArrayValue()), a2 = ToPrimitive(aList2->mValue.GetArrayValue()); MOZ_ASSERT( TransformFunctionsMatch(nsStyleTransformMatrix::TransformFunctionOf(a1), @@ -1765,7 +1765,7 @@ AddTransformLists(double aCoeff1, const nsCSSValueList* aList1, "resultTail isn't pointing to the tail (may leak)"); nsCSSKeyword tfunc = nsStyleTransformMatrix::TransformFunctionOf(a1); - nsRefPtr arr; + RefPtr arr; if (tfunc != eCSSKeyword_matrix && tfunc != eCSSKeyword_matrix3d && tfunc != eCSSKeyword_interpolatematrix && @@ -2514,7 +2514,7 @@ BuildStyleRule(nsCSSProperty aProperty, return nullptr; } - nsRefPtr rule = new css::StyleRule(nullptr, + RefPtr rule = new css::StyleRule(nullptr, declaration.forget(), 0, 0); return rule.forget(); @@ -2546,7 +2546,7 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty, "are in a document"); // Parse specified value into a temporary css::StyleRule - nsRefPtr styleRule = + RefPtr styleRule = BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode); if (!styleRule) { return false; @@ -2565,13 +2565,13 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty, } // Look up style context for our target element - nsRefPtr styleContext = LookupStyleContext(aTargetElement); + RefPtr styleContext = LookupStyleContext(aTargetElement); if (!styleContext) { return false; } nsStyleSet* styleSet = styleContext->PresContext()->StyleSet(); - nsRefPtr tmpStyleContext; + RefPtr tmpStyleContext; if (aIsContextSensitive) { nsCOMArray ruleArray; ruleArray.AppendObject(styleSet->InitialStyleRule()); @@ -2844,7 +2844,7 @@ StyleCoordToCSSValue(const nsStyleCoord& aCoord, nsCSSValue& aCSSValue) static void SetPositionValue(const nsStyleBackground::Position& aPos, nsCSSValue& aCSSValue) { - nsRefPtr posArray = nsCSSValue::Array::Create(4); + RefPtr posArray = nsCSSValue::Array::Create(4); aCSSValue.SetArrayValue(posArray.get(), eCSSUnit_Array); // NOTE: Array entries #0 and #2 here are intentionally left untouched, with @@ -2881,7 +2881,7 @@ SubstitutePixelValues(nsStyleContext* aStyleContext, SetCalcValue(&c2, aOutput); } else if (aInput.UnitHasArrayValue()) { const nsCSSValue::Array *inputArray = aInput.GetArrayValue(); - nsRefPtr outputArray = + RefPtr outputArray = nsCSSValue::Array::Create(inputArray->Count()); for (size_t i = 0, i_end = inputArray->Count(); i < i_end; ++i) { SubstitutePixelValues(aStyleContext, @@ -3302,9 +3302,9 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, int32_t type = filter.GetType(); if (type == NS_STYLE_FILTER_URL) { nsIDocument* doc = aStyleContext->PresContext()->Document(); - nsRefPtr uriAsStringBuffer = + RefPtr uriAsStringBuffer = GetURIAsUtf16StringBuffer(filter.GetURL()); - nsRefPtr url = + RefPtr url = new mozilla::css::URLValue(filter.GetURL(), uriAsStringBuffer, doc->GetDocumentURI(), @@ -3473,11 +3473,11 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, return false; } nsAutoPtr pair(new nsCSSValuePair); - nsRefPtr uriAsStringBuffer = + RefPtr uriAsStringBuffer = GetURIAsUtf16StringBuffer(paint.mPaint.mPaintServer); NS_ENSURE_TRUE(!!uriAsStringBuffer, false); nsIDocument* doc = aStyleContext->PresContext()->Document(); - nsRefPtr url = + RefPtr url = new mozilla::css::URLValue(paint.mPaint.mPaintServer, uriAsStringBuffer, doc->GetDocumentURI(), @@ -3506,7 +3506,7 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, } case eStyleAnimType_Shadow: { const nsCSSShadowArray *shadowArray = - *static_cast*>( + *static_cast*>( StyleDataAtOffset(styleStruct, ssOffset)); if (!shadowArray) { aComputedValue.SetAndAdoptCSSValueListValue(nullptr, eUnit_Shadow); diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index fec9c46435..e34a897c13 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -1234,7 +1234,7 @@ DOMCSSDeclarationImpl::SetCSSDeclaration(css::Declaration* aDecl) mozAutoDocUpdate updateBatch(owningDoc, UPDATE_STYLE, true); - nsRefPtr oldRule = mRule; + RefPtr oldRule = mRule; mRule = oldRule->DeclarationChanged(aDecl, true).take(); if (!mRule) return NS_ERROR_OUT_OF_MEMORY; @@ -1492,7 +1492,7 @@ StyleRule::GetType() const /* virtual */ already_AddRefed StyleRule::Clone() const { - nsRefPtr clone = new StyleRule(*this); + RefPtr clone = new StyleRule(*this); return clone.forget(); } @@ -1521,7 +1521,7 @@ StyleRule::GetExistingDOMRule() StyleRule::DeclarationChanged(Declaration* aDecl, bool aHandleContainer) { - nsRefPtr clone = new StyleRule(*this, aDecl); + RefPtr clone = new StyleRule(*this, aDecl); if (aHandleContainer) { CSSStyleSheet* sheet = GetStyleSheet(); diff --git a/layout/style/StyleRule.h b/layout/style/StyleRule.h index 317dafb335..6fdffb0775 100644 --- a/layout/style/StyleRule.h +++ b/layout/style/StyleRule.h @@ -386,8 +386,8 @@ private: private: nsCSSSelectorList* mSelector; // null for style attribute Declaration* mDeclaration; - nsRefPtr mImportantRule; // initialized by RuleMatched - nsRefPtr mDOMRule; + RefPtr mImportantRule; // initialized by RuleMatched + RefPtr mDOMRule; private: StyleRule& operator=(const StyleRule& aCopy) = delete; diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index a5afd2a1b7..8fff0e4c34 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -432,7 +432,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext, // the new list of animations with a given name than in the old // list, it will be the animations towards the of the beginning of // the list that do not match and are treated as new animations. - nsRefPtr oldAnim; + RefPtr oldAnim; size_t oldIdx = collection->mAnimations.Length(); while (oldIdx-- != 0) { CSSAnimation* a = collection->mAnimations[oldIdx]->AsCSSAnimation(); @@ -602,7 +602,7 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext, if (!result) { nsCOMArray rules; rules.AppendObject(aKeyframe); - nsRefPtr resultStrong = aPresContext->StyleSet()-> + RefPtr resultStrong = aPresContext->StyleSet()-> ResolveStyleByAddingRules(aParentStyleContext, rules); mCache.Put(aKeyframe, resultStrong); result = resultStrong; @@ -622,7 +622,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, const nsStyleDisplay *disp = aStyleContext->StyleDisplay(); - nsRefPtr styleWithoutAnimation; + RefPtr styleWithoutAnimation; for (size_t animIdx = 0, animEnd = disp->mAnimationNameCount; animIdx != animEnd; ++animIdx) { @@ -641,7 +641,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, continue; } - nsRefPtr dest = + RefPtr dest = new CSSAnimation(mPresContext->Document()->GetScopeObject(), src.GetName()); dest->SetOwningElement( @@ -658,7 +658,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, timing.mDirection = src.GetDirection(); timing.mFillMode = src.GetFillMode(); - nsRefPtr destEffect = + RefPtr destEffect = new KeyframeEffectReadOnly(mPresContext->Document(), aTarget, aStyleContext->GetPseudoType(), timing); dest->SetEffect(destEffect); @@ -759,14 +759,14 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, propData.mWinsInCascade = true; KeyframeData *fromKeyframe = nullptr; - nsRefPtr fromContext; + RefPtr fromContext; bool interpolated = true; for (uint32_t wpIdx = 0, wpEnd = keyframesWithProperty.Length(); wpIdx != wpEnd; ++wpIdx) { uint32_t kfIdx = keyframesWithProperty[wpIdx]; KeyframeData &toKeyframe = sortedKeyframes[kfIdx]; - nsRefPtr toContext = + RefPtr toContext = resolvedStyles.Get(mPresContext, aStyleContext, toKeyframe.mRule); if (fromKeyframe) { diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 8d924d9af7..9c608bafd6 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -26,7 +26,7 @@ class Promise; } /* namespace dom */ struct AnimationEventInfo { - nsRefPtr mElement; + RefPtr mElement; mozilla::InternalAnimationEvent mEvent; AnimationEventInfo(mozilla::dom::Element *aElement, diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 13b71b7e64..52c8cb38bd 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -1187,7 +1187,7 @@ protected: nsCOMPtr mSheetPrincipal; // The sheet we're parsing into - nsRefPtr mSheet; + RefPtr mSheet; // Used for @import rules mozilla::css::Loader* mChildLoader; // not ref counted, it owns us @@ -1276,7 +1276,7 @@ protected: WebkitBoxUnprefixState mWebkitBoxUnprefixState; // Stack of rule groups; used for @media and such. - InfallibleTArray > mGroupStack; + InfallibleTArray > mGroupStack; // During the parsing of a property (which may be a shorthand), the data // are stored in |mTempData|. (It is needed to ensure that parser @@ -2009,7 +2009,7 @@ CSSParserImpl::ParseKeyframeRule(const nsSubstring& aBuffer, css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI); InitScanner(scanner, reporter, aURI, aURI, nullptr); - nsRefPtr result = ParseKeyframeRule(); + RefPtr result = ParseKeyframeRule(); if (GetToken(true)) { // extra garbage at the end result = nullptr; @@ -3348,7 +3348,7 @@ CSSParserImpl::ParseMediaQueryExpression(nsMediaQuery* aQuery) { // Two integers separated by '/', with optional whitespace on // either side of the '/'. - nsRefPtr a = nsCSSValue::Array::Create(2); + RefPtr a = nsCSSValue::Array::Create(2); expr->mValue.SetArrayValue(a, eCSSUnit_Array); // We don't bother with ParseNonNegativeVariant since we have to // check for != 0 as well; no need to worry about the UngetToken @@ -3403,7 +3403,7 @@ CSSParserImpl::ParseMediaQueryExpression(nsMediaQuery* aQuery) bool CSSParserImpl::ParseImportRule(RuleAppendFunc aAppendFunc, void* aData) { - nsRefPtr media = new nsMediaList(); + RefPtr media = new nsMediaList(); uint32_t linenum, colnum; nsAutoString url; @@ -3438,7 +3438,7 @@ CSSParserImpl::ProcessImport(const nsString& aURLSpec, uint32_t aLineNumber, uint32_t aColumnNumber) { - nsRefPtr rule = new css::ImportRule(aMedia, aURLSpec, + RefPtr rule = new css::ImportRule(aMedia, aURLSpec, aLineNumber, aColumnNumber); (*aAppendFunc)(rule, aData); @@ -3510,12 +3510,12 @@ CSSParserImpl::ParseGroupRule(css::GroupRule* aRule, bool CSSParserImpl::ParseMediaRule(RuleAppendFunc aAppendFunc, void* aData) { - nsRefPtr media = new nsMediaList(); + RefPtr media = new nsMediaList(); uint32_t linenum, colnum; if (GetNextTokenLocation(true, &linenum, &colnum) && GatherMedia(media, true)) { // XXXbz this could use better error reporting throughout the method - nsRefPtr rule = new css::MediaRule(linenum, colnum); + RefPtr rule = new css::MediaRule(linenum, colnum); // Append first, so when we do SetMedia() the rule // knows what its stylesheet is. if (ParseGroupRule(rule, aAppendFunc, aData)) { @@ -3601,7 +3601,7 @@ CSSParserImpl::ParseMozDocumentRule(RuleAppendFunc aAppendFunc, void* aData) } } while (ExpectSymbol(',', true)); - nsRefPtr rule = new css::DocumentRule(linenum, colnum); + RefPtr rule = new css::DocumentRule(linenum, colnum); rule->SetURLs(urls); return ParseGroupRule(rule, aAppendFunc, aData); @@ -3655,7 +3655,7 @@ CSSParserImpl::ProcessNameSpace(const nsString& aPrefix, prefix = do_GetAtom(aPrefix); } - nsRefPtr rule = new css::NameSpaceRule(prefix, aURLSpec, + RefPtr rule = new css::NameSpaceRule(prefix, aURLSpec, aLineNumber, aColumnNumber); (*aAppendFunc)(rule, aData); @@ -3679,7 +3679,7 @@ CSSParserImpl::ParseFontFaceRule(RuleAppendFunc aAppendFunc, void* aData) return false; } - nsRefPtr rule(new nsCSSFontFaceRule(linenum, colnum)); + RefPtr rule(new nsCSSFontFaceRule(linenum, colnum)); for (;;) { if (!GetToken(true)) { @@ -3789,7 +3789,7 @@ CSSParserImpl::ParseFontFeatureValuesRule(RuleAppendFunc aAppendFunc, return false; } - nsRefPtr + RefPtr valuesRule(new nsCSSFontFeatureValuesRule(linenum, colnum)); // parse family list @@ -4025,11 +4025,11 @@ CSSParserImpl::ParseKeyframesRule(RuleAppendFunc aAppendFunc, void* aData) return false; } - nsRefPtr rule = new nsCSSKeyframesRule(name, + RefPtr rule = new nsCSSKeyframesRule(name, linenum, colnum); while (!ExpectSymbol('}', true)) { - nsRefPtr kid = ParseKeyframeRule(); + RefPtr kid = ParseKeyframeRule(); if (kid) { rule->AppendStyleRule(kid); } else { @@ -4068,7 +4068,7 @@ CSSParserImpl::ParsePageRule(RuleAppendFunc aAppendFunc, void* aData) } // Takes ownership of declaration. - nsRefPtr rule = new nsCSSPageRule(Move(declaration), + RefPtr rule = new nsCSSPageRule(Move(declaration), linenum, colnum); (*aAppendFunc)(rule, aData); @@ -4094,7 +4094,7 @@ CSSParserImpl::ParseKeyframeRule() } // Takes ownership of declaration, and steals contents of selectorList. - nsRefPtr rule = + RefPtr rule = new nsCSSKeyframeRule(selectorList, Move(declaration), linenum, colnum); return rule.forget(); } @@ -4180,7 +4180,7 @@ CSSParserImpl::ParseSupportsRule(RuleAppendFunc aAppendFunc, void* aProcessData) // errors don't get reported. nsAutoFailingSupportsRule failing(this, conditionMet); - nsRefPtr rule = new CSSSupportsRule(conditionMet, condition, + RefPtr rule = new CSSSupportsRule(conditionMet, condition, linenum, colnum); return ParseGroupRule(rule, aAppendFunc, aProcessData); } @@ -4455,7 +4455,7 @@ CSSParserImpl::ParseCounterStyleRule(RuleAppendFunc aAppendFunc, void* aData) return false; } - nsRefPtr rule = new nsCSSCounterStyleRule(name, + RefPtr rule = new nsCSSCounterStyleRule(name, linenum, colnum); for (;;) { @@ -5026,7 +5026,7 @@ CSSParserImpl::ParseRuleSet(RuleAppendFunc aAppendFunc, void* aData, // Translate the selector list and declaration block into style data - nsRefPtr rule = new css::StyleRule(slist, declaration, + RefPtr rule = new css::StyleRule(slist, declaration, linenum, colnum); (*aAppendFunc)(rule, aData); @@ -7626,7 +7626,7 @@ CSSParserImpl::ParseCounter(nsCSSValue& aValue) break; } - nsRefPtr val = + RefPtr val = nsCSSValue::Array::Create(unit == eCSSUnit_Counter ? 2 : 3); val->Item(0).SetStringValue(mToken.mIdent, eCSSUnit_Ident); @@ -7744,7 +7744,7 @@ CSSParserImpl::ParseSymbols(nsCSSValue& aValue) return false; } - nsRefPtr params = nsCSSValue::Array::Create(2); + RefPtr params = nsCSSValue::Array::Create(2); nsCSSValue& type = params->Item(0); nsCSSValue& symbols = params->Item(1); @@ -7794,7 +7794,7 @@ CSSParserImpl::SetValueToURL(nsCSSValue& aValue, const nsString& aURL) return false; } - nsRefPtr buffer(nsCSSValue::BufferFromString(aURL)); + RefPtr buffer(nsCSSValue::BufferFromString(aURL)); // Note: urlVal retains its own reference to |buffer|. mozilla::css::URLValue *urlVal = @@ -7821,7 +7821,7 @@ CSSParserImpl::ParseImageOrientation(nsCSSValue& aValue) nsCSSValue flip; if (ParseVariant(flip, VARIANT_KEYWORD, nsCSSProps::kImageOrientationFlipKTable)) { - nsRefPtr array = nsCSSValue::Array::Create(2); + RefPtr array = nsCSSValue::Array::Create(2); array->Item(0) = angle; array->Item(1) = flip; aValue.SetArrayValue(array, eCSSUnit_Array); @@ -8691,7 +8691,7 @@ CSSParserImpl::ParseGridTemplateAreas() return true; } - nsRefPtr areas = + RefPtr areas = new css::GridTemplateAreasValue(); nsDataHashtable areaIndices; for (;;) { @@ -8867,7 +8867,7 @@ CSSParserImpl::ParseGridTemplateAfterString(const nsCSSValue& aFirstLineNames) "ParseGridTemplateAfterString called with a non-string token"); nsCSSValue rowsValue; - nsRefPtr areas = + RefPtr areas = new css::GridTemplateAreasValue(); nsDataHashtable areaIndices; nsCSSValueList* rowsItem = rowsValue.SetListValue(); @@ -9326,7 +9326,7 @@ bool CSSParserImpl::ParseLinearGradient(nsCSSValue& aValue, bool aIsRepeating, bool aIsLegacy) { - nsRefPtr cssGradient + RefPtr cssGradient = new nsCSSValueGradient(false, aIsRepeating); if (!GetToken(true)) { @@ -9416,7 +9416,7 @@ bool CSSParserImpl::ParseRadialGradient(nsCSSValue& aValue, bool aIsRepeating, bool aIsLegacy) { - nsRefPtr cssGradient + RefPtr cssGradient = new nsCSSValueGradient(true, aIsRepeating); // [ || ] @@ -10743,7 +10743,7 @@ CSSParserImpl::ParseBackgroundItem(CSSParserImpl::BackgroundParseState& aState) eCSSUnit_Enumerated); aState.mOrigin->mValue.SetIntValue(NS_STYLE_BG_ORIGIN_PADDING, eCSSUnit_Enumerated); - nsRefPtr positionArr = nsCSSValue::Array::Create(4); + RefPtr positionArr = nsCSSValue::Array::Create(4); aState.mPosition->mValue.SetArrayValue(positionArr, eCSSUnit_Array); positionArr->Item(1).SetPercentValue(0.0f); positionArr->Item(3).SetPercentValue(0.0f); @@ -11138,7 +11138,7 @@ bool CSSParserImpl::ParseBoxPositionValues(nsCSSValuePair &aOut, bool CSSParserImpl::ParsePositionValue(nsCSSValue& aOut) { - nsRefPtr value = nsCSSValue::Array::Create(4); + RefPtr value = nsCSSValue::Array::Create(4); aOut.SetArrayValue(value, eCSSUnit_Array); // The following clarifies organisation of the array. @@ -11788,7 +11788,7 @@ CSSParserImpl::ParseCalc(nsCSSValue &aValue, int32_t aVariantMask) // One-iteration loop so we can break to the error-handling case. do { // The toplevel of a calc() is always an nsCSSValue::Array of length 1. - nsRefPtr arr = nsCSSValue::Array::Create(1); + RefPtr arr = nsCSSValue::Array::Create(1); if (!ParseCalcAdditiveExpression(arr->Item(0), aVariantMask)) break; @@ -11844,7 +11844,7 @@ CSSParserImpl::ParseCalcAdditiveExpression(nsCSSValue& aValue, if (!RequireWhitespace()) return false; - nsRefPtr arr = nsCSSValue::Array::Create(2); + RefPtr arr = nsCSSValue::Array::Create(2); arr->Item(0) = aValue; storage = &arr->Item(1); aValue.SetArrayValue(arr, unit); @@ -11945,7 +11945,7 @@ CSSParserImpl::ParseCalcMultiplicativeExpression(nsCSSValue& aValue, break; } - nsRefPtr arr = nsCSSValue::Array::Create(2); + RefPtr arr = nsCSSValue::Array::Create(2); arr->Item(0) = aValue; storage = &arr->Item(1); aValue.SetArrayValue(arr, unit); @@ -12231,7 +12231,7 @@ CSSParserImpl::ParseCursor() } // We have a URL, so make a value array with three values. - nsRefPtr val = nsCSSValue::Array::Create(3); + RefPtr val = nsCSSValue::Array::Create(3); val->Item(0) = cur->mValue; // Parse optional x and y position of cursor hotspot (css3-ui). @@ -13018,7 +13018,7 @@ AppendGeneric(nsCSSKeyword aKeyword, FontFamilyList *aFamilyList) bool CSSParserImpl::ParseFamily(nsCSSValue& aValue) { - nsRefPtr familyList = + RefPtr familyList = new css::FontFamilyListRefCnt(); nsAutoString family; bool single, quoted; @@ -13178,7 +13178,7 @@ CSSParserImpl::ParseFontSrc(nsCSSValue& aValue) if (values.Length() == 0) return false; - nsRefPtr srcVals + RefPtr srcVals = nsCSSValue::Array::Create(values.Length()); uint32_t i; @@ -13261,7 +13261,7 @@ CSSParserImpl::ParseFontRanges(nsCSSValue& aValue) if (ranges.Length() == 0) return false; - nsRefPtr srcVals + RefPtr srcVals = nsCSSValue::Array::Create(ranges.Length()); for (uint32_t i = 0; i < ranges.Length(); i++) @@ -13924,7 +13924,7 @@ CSSParserImpl::ParseFunction(nsCSSKeyword aFunction, * we'll truncate them at 2^16 - 2 arguments. */ uint16_t numArgs = std::min(foundValues.Length(), MAX_ALLOWED_ELEMS); - nsRefPtr convertedArray = + RefPtr convertedArray = aValue.InitFunction(aFunction, numArgs); /* Copy things over. */ @@ -14272,7 +14272,7 @@ CSSParserImpl::ParsePolygonFunction(nsCSSValue& aValue) item = item->mNext; } - nsRefPtr functionArray = + RefPtr functionArray = aValue.InitFunction(eCSSKeyword_polygon, numArgs); functionArray->Item(numArgs) = coordinates; if (numArgs > 1) { @@ -14324,7 +14324,7 @@ CSSParserImpl::ParseCircleOrEllipseFunction(nsCSSKeyword aKeyword, } size_t count = aKeyword == eCSSKeyword_circle ? 2 : 3; - nsRefPtr functionArray = + RefPtr functionArray = aValue.InitFunction(aKeyword, count); if (hasRadius) { functionArray->Item(1) = radiusX; @@ -14342,7 +14342,7 @@ CSSParserImpl::ParseCircleOrEllipseFunction(nsCSSKeyword aKeyword, bool CSSParserImpl::ParseInsetFunction(nsCSSValue& aValue) { - nsRefPtr functionArray = + RefPtr functionArray = aValue.InitFunction(eCSSKeyword_inset, 5); if (ParseVariant(functionArray->Item(1), VARIANT_LPCALC, nullptr)) { @@ -14362,7 +14362,7 @@ CSSParserImpl::ParseInsetFunction(nsCSSValue& aValue) return false; } - nsRefPtr radiusArray = nsCSSValue::Array::Create(4); + RefPtr radiusArray = nsCSSValue::Array::Create(4); functionArray->Item(5).SetArrayValue(radiusArray, eCSSUnit_Array); if (mToken.mType != eCSSToken_Ident || !mToken.mIdent.LowerCaseEqualsLiteral("round") || @@ -14724,7 +14724,7 @@ CSSParserImpl::ParseTransitionTimingFunctionValues(nsCSSValue& aValue) mToken.mIdent.LowerCaseEqualsLiteral("cubic-bezier"), "unexpected initial state"); - nsRefPtr val = nsCSSValue::Array::Create(4); + RefPtr val = nsCSSValue::Array::Create(4); float x1, x2, y1, y2; if (!ParseTransitionTimingFunctionValueComponent(x1, ',', true) || @@ -14774,7 +14774,7 @@ CSSParserImpl::ParseTransitionStepTimingFunctionValues(nsCSSValue& aValue) mToken.mIdent.LowerCaseEqualsLiteral("steps"), "unexpected initial state"); - nsRefPtr val = nsCSSValue::Array::Create(2); + RefPtr val = nsCSSValue::Array::Create(2); if (!ParseOneOrLargerVariant(val->Item(0), VARIANT_INTEGER, nullptr)) { return false; @@ -15059,7 +15059,7 @@ CSSParserImpl::ParseShadowItem(nsCSSValue& aValue, bool aIsBoxShadow) IndexInset // only for box-shadow }; - nsRefPtr val = nsCSSValue::Array::Create(6); + RefPtr val = nsCSSValue::Array::Create(6); if (aIsBoxShadow) { // Optional inset keyword (ignore errors) @@ -15462,7 +15462,7 @@ CSSParserImpl::ParseScrollSnapPoints(nsCSSValue& aValue, nsCSSProperty aPropID) SkipUntil(')'); return false; } - nsRefPtr functionArray = + RefPtr functionArray = aValue.InitFunction(eCSSKeyword_repeat, 1); functionArray->Item(1) = lengthValue; return true; diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 478bddfc32..c11cc9c0b8 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -278,7 +278,7 @@ enum nsStyleAnimType { // nsStyleSVGPaint values eStyleAnimType_PaintServer, - // nsRefPtr values + // RefPtr values eStyleAnimType_Shadow, // property not animatable diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 6fd8df9b63..4d2aa1ae85 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -543,7 +543,7 @@ RuleHash::~RuleHash() RuleValue* value = &(mUniversalRules[i]); nsAutoString selectorText; uint32_t lineNumber = value->mRule->GetLineNumber(); - nsRefPtr cssSheet = value->mRule->GetStyleSheet(); + RefPtr cssSheet = value->mRule->GetStyleSheet(); value->mSelector->ToString(selectorText, cssSheet); printf(" line %d, %s\n", diff --git a/layout/style/nsCSSRuleProcessor.h b/layout/style/nsCSSRuleProcessor.h index 3fc709b284..18d76f1450 100644 --- a/layout/style/nsCSSRuleProcessor.h +++ b/layout/style/nsCSSRuleProcessor.h @@ -56,7 +56,7 @@ class DocumentRule; class nsCSSRuleProcessor: public nsIStyleRuleProcessor { public: - typedef nsTArray> sheet_array_type; + typedef nsTArray> sheet_array_type; // aScopeElement must be non-null iff aSheetType is // nsStyleSet::eScopedDocSheet. @@ -253,7 +253,7 @@ private: // The scope element for this rule processor's scoped style sheets. // Only used if mSheetType == nsStyleSet::eScopedDocSheet. - nsRefPtr mScopeElement; + RefPtr mScopeElement; nsTArray mDocumentRules; nsDocumentRuleResultCacheKey mDocumentCacheKey; diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 2d8eca5f81..f9d8717db8 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -194,7 +194,7 @@ GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound) aFound = false; if (mGroupRule) { - nsRefPtr rule = mGroupRule->GetStyleRuleAt(aIndex); + RefPtr rule = mGroupRule->GetStyleRuleAt(aIndex); if (rule) { aFound = true; return rule->GetDOMRule(); @@ -227,7 +227,7 @@ ImportRule::ImportRule(const ImportRule& aCopy) // property of that @import rule, since it is null only if the target // sheet failed security checks. if (aCopy.mChildSheet) { - nsRefPtr sheet = + RefPtr sheet = aCopy.mChildSheet->Clone(nullptr, this, nullptr, nullptr); SetSheet(sheet); // SetSheet sets mMedia appropriately @@ -288,7 +288,7 @@ ImportRule::GetType() const /* virtual */ already_AddRefed ImportRule::Clone() const { - nsRefPtr clone = new ImportRule(*this); + RefPtr clone = new ImportRule(*this); return clone.forget(); } @@ -719,7 +719,7 @@ MediaRule::GetType() const /* virtual */ already_AddRefed MediaRule::Clone() const { - nsRefPtr clone = new MediaRule(*this); + RefPtr clone = new MediaRule(*this); return clone.forget(); } @@ -805,7 +805,7 @@ NS_IMETHODIMP MediaRule::SetConditionText(const nsAString& aConditionText) { if (!mMedia) { - nsRefPtr media = new nsMediaList(); + RefPtr media = new nsMediaList(); media->SetStyleSheet(GetStyleSheet()); nsresult rv = media->SetMediaText(aConditionText); if (NS_SUCCEEDED(rv)) { @@ -938,7 +938,7 @@ DocumentRule::GetType() const /* virtual */ already_AddRefed DocumentRule::Clone() const { - nsRefPtr clone = new DocumentRule(*this); + RefPtr clone = new DocumentRule(*this); return clone.forget(); } @@ -1192,7 +1192,7 @@ NameSpaceRule::GetType() const /* virtual */ already_AddRefed NameSpaceRule::Clone() const { - nsRefPtr clone = new NameSpaceRule(*this); + RefPtr clone = new NameSpaceRule(*this); return clone.forget(); } @@ -1560,7 +1560,7 @@ nsCSSFontFaceStyleDecl::WrapObject(JSContext *cx, JS::Handle aGivenPr /* virtual */ already_AddRefed nsCSSFontFaceRule::Clone() const { - nsRefPtr clone = new nsCSSFontFaceRule(*this); + RefPtr clone = new nsCSSFontFaceRule(*this); return clone.forget(); } @@ -1727,7 +1727,7 @@ nsCSSFontFaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const /* virtual */ already_AddRefed nsCSSFontFeatureValuesRule::Clone() const { - nsRefPtr clone = new nsCSSFontFeatureValuesRule(*this); + RefPtr clone = new nsCSSFontFeatureValuesRule(*this); return clone.forget(); } @@ -2050,7 +2050,7 @@ nsCSSKeyframeRule::~nsCSSKeyframeRule() /* virtual */ already_AddRefed nsCSSKeyframeRule::Clone() const { - nsRefPtr clone = new nsCSSKeyframeRule(*this); + RefPtr clone = new nsCSSKeyframeRule(*this); return clone.forget(); } @@ -2284,7 +2284,7 @@ nsCSSKeyframesRule::~nsCSSKeyframesRule() /* virtual */ already_AddRefed nsCSSKeyframesRule::Clone() const { - nsRefPtr clone = new nsCSSKeyframesRule(*this); + RefPtr clone = new nsCSSKeyframesRule(*this); return clone.forget(); } @@ -2418,7 +2418,7 @@ nsCSSKeyframesRule::AppendRule(const nsAString& aRule) nsCSSParser parser; // FIXME: pass filename and line number - nsRefPtr rule = + RefPtr rule = parser.ParseKeyframeRule(aRule, nullptr, 0); if (rule) { nsIDocument* doc = GetDocument(); @@ -2610,7 +2610,7 @@ nsCSSPageRule::~nsCSSPageRule() /* virtual */ already_AddRefed nsCSSPageRule::Clone() const { - nsRefPtr clone = new nsCSSPageRule(*this); + RefPtr clone = new nsCSSPageRule(*this); return clone.forget(); } @@ -2806,7 +2806,7 @@ CSSSupportsRule::GetType() const /* virtual */ already_AddRefed CSSSupportsRule::Clone() const { - nsRefPtr clone = new CSSSupportsRule(*this); + RefPtr clone = new CSSSupportsRule(*this); return clone.forget(); } @@ -2937,7 +2937,7 @@ nsCSSCounterStyleRule::~nsCSSCounterStyleRule() /* virtual */ already_AddRefed nsCSSCounterStyleRule::Clone() const { - nsRefPtr clone = new nsCSSCounterStyleRule(*this); + RefPtr clone = new nsCSSCounterStyleRule(*this); return clone.forget(); } diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 67cd342355..e23dc91e2c 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -98,7 +98,7 @@ public: protected: void AppendConditionText(nsAString& aOutput); - nsRefPtr mMedia; + RefPtr mMedia; }; class DocumentRule final : public GroupRule, @@ -286,7 +286,7 @@ protected: // nsFontFaceRuleContainer - used for associating sheet type with // specific @font-face rules struct nsFontFaceRuleContainer { - nsRefPtr mRule; + RefPtr mRule; uint8_t mSheetType; }; @@ -433,7 +433,7 @@ private: nsTArray mKeys; nsAutoPtr mDeclaration; // lazily created when needed: - nsRefPtr mDOMDeclaration; + RefPtr mDOMDeclaration; }; class nsCSSKeyframesRule final : public mozilla::css::GroupRule, @@ -562,8 +562,8 @@ public: private: nsAutoPtr mDeclaration; // lazily created when needed: - nsRefPtr mDOMDeclaration; - nsRefPtr mImportantRule; + RefPtr mDOMDeclaration; + RefPtr mImportantRule; }; namespace mozilla { diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index f2bfc177d9..6364695ed3 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -739,7 +739,7 @@ bool nsCSSValue::IsNonTransparentColor() const nsCSSValue::Array* nsCSSValue::InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs) { - nsRefPtr func = Array::Create(aNumArgs + 1); + RefPtr func = Array::Create(aNumArgs + 1); func->Item(0).SetIntValue(aFunctionId, eCSSUnit_Enumerated); SetArrayValue(func, eCSSUnit_Function); return func; @@ -765,7 +765,7 @@ nsCSSValue::EqualsFunction(nsCSSKeyword aFunctionId) const already_AddRefed nsCSSValue::BufferFromString(const nsString& aValue) { - nsRefPtr buffer = nsStringBuffer::FromString(aValue); + RefPtr buffer = nsStringBuffer::FromString(aValue); if (buffer) { return buffer.forget(); } @@ -2477,7 +2477,7 @@ css::ImageValue::ImageValue(nsIURI* aURI, nsStringBuffer* aString, } static PLDHashOperator -ClearRequestHashtable(nsISupports* aKey, nsRefPtr& aValue, +ClearRequestHashtable(nsISupports* aKey, RefPtr& aValue, void* aClosure) { mozilla::css::ImageValue* image = diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 39f14a084f..a03ab434d3 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -66,7 +66,7 @@ NS_NewComputedDOMStyle(dom::Element* aElement, const nsAString& aPseudoElt, nsIPresShell* aPresShell, nsComputedDOMStyle::StyleType aStyleType) { - nsRefPtr computedStyle; + RefPtr computedStyle; computedStyle = new nsComputedDOMStyle(aElement, aPseudoElt, aPresShell, aStyleType); return computedStyle.forget(); @@ -378,7 +378,7 @@ nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName, aReturn.Truncate(); ErrorResult error; - nsRefPtr val = GetPropertyCSSValue(aPropertyName, error); + RefPtr val = GetPropertyCSSValue(aPropertyName, error); if (error.Failed()) { return error.StealNSResult(); } @@ -462,7 +462,7 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement, // for this element. if (!result->HasPseudoElementData()) { // this function returns an addrefed style context - nsRefPtr ret = result; + RefPtr ret = result; return ret.forget(); } } @@ -470,7 +470,7 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement, // No frame has been created, or we have a pseudo, or we're looking // for the default style, so resolve the style ourselves. - nsRefPtr parentContext; + RefPtr parentContext; nsIContent* parent = aPseudo ? aElement : aElement->GetParent(); // Don't resolve parent context for document fragments. if (parent && parent->IsElement()) @@ -484,7 +484,7 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement, nsStyleSet *styleSet = presShell->StyleSet(); - nsRefPtr sc; + RefPtr sc; if (aPseudo) { nsCSSPseudoElements::Type type = nsCSSPseudoElements::GetPseudoType(aPseudo); if (type >= nsCSSPseudoElements::ePseudo_PseudoElementCount) { @@ -600,7 +600,7 @@ nsComputedDOMStyle::ClearStyleContext() } void -nsComputedDOMStyle::SetResolvedStyleContext(nsRefPtr&& aContext) +nsComputedDOMStyle::SetResolvedStyleContext(RefPtr&& aContext) { if (!mResolvedStyleContext) { mResolvedStyleContext = true; @@ -708,7 +708,7 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush) } #endif // Need to resolve a style context - nsRefPtr resolvedStyleContext = + RefPtr resolvedStyleContext = nsComputedDOMStyle::GetStyleContextForElementNoFlush( mContent->AsElement(), mPseudo, @@ -807,7 +807,7 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorRes return nullptr; } - nsRefPtr val; + RefPtr val; if (prop == eCSSPropertyExtra_variable) { val = DoGetCustomProperty(aPropertyName); } else { @@ -1843,7 +1843,7 @@ nsComputedDOMStyle::DoGetBackgroundColor() static void SetValueToCalc(const nsStyleCoord::CalcValue *aCalc, nsROCSSPrimitiveValue *aValue) { - nsRefPtr val = new nsROCSSPrimitiveValue; + RefPtr val = new nsROCSSPrimitiveValue; nsAutoString tmp, result; result.AppendLiteral("calc("); @@ -1937,7 +1937,7 @@ nsComputedDOMStyle::GetCSSGradientString(const nsStyleGradient* aGradient, bool needSep = false; nsAutoString tokenString; - nsRefPtr tmpVal = new nsROCSSPrimitiveValue; + RefPtr tmpVal = new nsROCSSPrimitiveValue; if (isRadial && !aGradient->mLegacySyntax) { if (aGradient->mSize != NS_STYLE_GRADIENT_SIZE_EXPLICIT_SIZE) { @@ -2052,7 +2052,7 @@ nsComputedDOMStyle::GetImageRectString(nsIURI* aURI, const nsStyleSides& aCropRect, nsString& aString) { - nsRefPtr valueList = GetROCSSValueList(true); + RefPtr valueList = GetROCSSValueList(true); // nsROCSSPrimitiveValue *valURI = new nsROCSSPrimitiveValue; @@ -5554,7 +5554,7 @@ nsComputedDOMStyle::CreatePrimitiveValueForClipPath( "wrong number of radii"); for (size_t i = 0; i < radii.Length(); ++i) { nsAutoString radius; - nsRefPtr value = new nsROCSSPrimitiveValue; + RefPtr value = new nsROCSSPrimitiveValue; bool clampNegativeCalc = true; SetValueToCoord(value, radii[i], clampNegativeCalc, nullptr, nsCSSProps::kShapeRadiusKTable); @@ -5564,7 +5564,7 @@ nsComputedDOMStyle::CreatePrimitiveValueForClipPath( } shapeFunctionString.AppendLiteral("at "); - nsRefPtr position = GetROCSSValueList(false); + RefPtr position = GetROCSSValueList(false); nsAutoString positionString; SetValueToPosition(aStyleBasicShape->GetPosition(), position); position->GetCssText(positionString); @@ -5637,7 +5637,7 @@ void nsComputedDOMStyle::SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord) { - nsRefPtr value = new nsROCSSPrimitiveValue; + RefPtr value = new nsROCSSPrimitiveValue; bool clampNegativeCalc = true; SetValueToCoord(value, aCoord, clampNegativeCalc); value->GetCssText(aCssText); @@ -5665,7 +5665,7 @@ nsComputedDOMStyle::CreatePrimitiveValueForStyleFilter( nsAutoString argumentString; if (aStyleFilter.GetType() == NS_STYLE_FILTER_DROP_SHADOW) { // Handle drop-shadow() - nsRefPtr shadowValue = + RefPtr shadowValue = GetCSSShadowArray(aStyleFilter.GetDropShadow(), StyleColor()->mColor, false); diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 6d35c6ecd8..5aa03c2ce2 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -134,7 +134,7 @@ private: // Helper functions called by UpdateCurrentStyleSources. void ClearStyleContext(); - void SetResolvedStyleContext(nsRefPtr&& aContext); + void SetResolvedStyleContext(RefPtr&& aContext); void SetFrameStyleContext(nsStyleContext* aContext); #define STYLE_STRUCT(name_, checkdata_cb_) \ diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp index 4496d038e8..26882c3b66 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -77,7 +77,7 @@ nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl) mElement->GetInlineStyleRule(); NS_ASSERTION(oldRule, "Element must have rule"); - nsRefPtr newRule = + RefPtr newRule = oldRule->DeclarationChanged(aDecl, false); if (!newRule) { return NS_ERROR_OUT_OF_MEMORY; @@ -140,7 +140,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation) // cannot fail css::Declaration *decl = new css::Declaration(); decl->InitializeEmpty(); - nsRefPtr newRule = new css::StyleRule(nullptr, decl, 0, 0); + RefPtr newRule = new css::StyleRule(nullptr, decl, 0, 0); // this *can* fail (inside SetAttrAndNotify, at least). nsresult rv; diff --git a/layout/style/nsDOMCSSAttrDeclaration.h b/layout/style/nsDOMCSSAttrDeclaration.h index 7efbbea090..a0c9aa35ad 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.h +++ b/layout/style/nsDOMCSSAttrDeclaration.h @@ -46,7 +46,7 @@ protected: virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) override; virtual nsIDocument* DocToUpdate() override; - nsRefPtr mElement; + RefPtr mElement; /* If true, this indicates that this nsDOMCSSAttributeDeclaration * should interact with mContent's SMIL override style rule (rather diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index 649815b2e7..b02b98ff3e 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -293,7 +293,7 @@ nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule, CSSParsingEnvironment& aCSSParseEnv) { nsIStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr; - nsRefPtr cssSheet(do_QueryObject(sheet)); + RefPtr cssSheet(do_QueryObject(sheet)); if (!cssSheet) { aCSSParseEnv.mPrincipal = nullptr; return; diff --git a/layout/style/nsDOMCSSRGBColor.h b/layout/style/nsDOMCSSRGBColor.h index d74f853e1d..d35196144b 100644 --- a/layout/style/nsDOMCSSRGBColor.h +++ b/layout/style/nsDOMCSSRGBColor.h @@ -58,10 +58,10 @@ public: private: virtual ~nsDOMCSSRGBColor(void); - nsRefPtr mRed; - nsRefPtr mGreen; - nsRefPtr mBlue; - nsRefPtr mAlpha; + RefPtr mRed; + RefPtr mGreen; + RefPtr mBlue; + RefPtr mAlpha; bool mHasAlpha; }; diff --git a/layout/style/nsDOMCSSRect.h b/layout/style/nsDOMCSSRect.h index 4092242c93..528d6d0f15 100644 --- a/layout/style/nsDOMCSSRect.h +++ b/layout/style/nsDOMCSSRect.h @@ -44,10 +44,10 @@ protected: virtual ~nsDOMCSSRect(void); private: - nsRefPtr mTop; - nsRefPtr mRight; - nsRefPtr mBottom; - nsRefPtr mLeft; + RefPtr mTop; + RefPtr mRight; + RefPtr mBottom; + RefPtr mLeft; }; #endif /* nsDOMCSSRect_h_ */ diff --git a/layout/style/nsDOMCSSValueList.h b/layout/style/nsDOMCSSValueList.h index 1fc48579cc..7f28001e85 100644 --- a/layout/style/nsDOMCSSValueList.h +++ b/layout/style/nsDOMCSSValueList.h @@ -67,7 +67,7 @@ private: bool mReadonly; // Are we read-only? - InfallibleTArray > mCSSValues; + InfallibleTArray > mCSSValues; }; #endif /* nsDOMCSSValueList_h___ */ diff --git a/layout/style/nsFontFaceLoader.h b/layout/style/nsFontFaceLoader.h index e47b12088f..5203c68c8b 100644 --- a/layout/style/nsFontFaceLoader.h +++ b/layout/style/nsFontFaceLoader.h @@ -50,9 +50,9 @@ protected: virtual ~nsFontFaceLoader(); private: - nsRefPtr mUserFontEntry; + RefPtr mUserFontEntry; nsCOMPtr mFontURI; - nsRefPtr mFontFaceSet; + RefPtr mFontFaceSet; nsCOMPtr mChannel; nsCOMPtr mLoadTimer; diff --git a/layout/style/nsFontFaceUtils.cpp b/layout/style/nsFontFaceUtils.cpp index b52f2a9b2a..92f6bd8276 100644 --- a/layout/style/nsFontFaceUtils.cpp +++ b/layout/style/nsFontFaceUtils.cpp @@ -34,7 +34,7 @@ StyleContextContainsFont(nsStyleContext* aStyleContext, // family name is in the fontlist, check to see if the font group // associated with the frame includes the specific userfont - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, getter_AddRefs(fm), 1.0f); diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 36c61c2fe5..9954f0a943 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -179,7 +179,7 @@ static const PLDHashTableOps MappedAttrTable_Ops = { // ----------------------------------------------------------- struct LangRuleTableEntry : public PLDHashEntryHdr { - nsRefPtr mRule; + RefPtr mRule; }; static PLDHashNumber @@ -426,7 +426,7 @@ nsHTMLStyleSheet::Reset() } nsresult -nsHTMLStyleSheet::ImplLinkColorSetter(nsRefPtr& aRule, nscolor aColor) +nsHTMLStyleSheet::ImplLinkColorSetter(RefPtr& aRule, nscolor aColor) { if (aRule && aRule->mColor == aColor) { return NS_OK; @@ -479,7 +479,7 @@ nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped) // We added a new entry to the hashtable, so we have a new unique set. entry->mAttributes = aMapped; } - nsRefPtr ret = entry->mAttributes; + RefPtr ret = entry->mAttributes; return ret.forget(); } diff --git a/layout/style/nsHTMLStyleSheet.h b/layout/style/nsHTMLStyleSheet.h index 390cfb782b..b8eb5e2487 100644 --- a/layout/style/nsHTMLStyleSheet.h +++ b/layout/style/nsHTMLStyleSheet.h @@ -92,7 +92,7 @@ private: }; // Implementation of SetLink/VisitedLink/ActiveLinkColor - nsresult ImplLinkColorSetter(nsRefPtr& aRule, nscolor aColor); + nsresult ImplLinkColorSetter(RefPtr& aRule, nscolor aColor); class GenericTableRule; friend class GenericTableRule; @@ -154,11 +154,11 @@ public: // for mLangRuleTable structures only private: nsIDocument* mDocument; - nsRefPtr mLinkRule; - nsRefPtr mVisitedRule; - nsRefPtr mActiveRule; - nsRefPtr mTableQuirkColorRule; - nsRefPtr mTableTHRule; + RefPtr mLinkRule; + RefPtr mVisitedRule; + RefPtr mActiveRule; + RefPtr mTableQuirkColorRule; + RefPtr mTableTHRule; PLDHashTable mMappedAttrTable; PLDHashTable mLangRuleTable; diff --git a/layout/style/nsICSSDeclaration.h b/layout/style/nsICSSDeclaration.h index e69dbf832b..40bf0f520b 100644 --- a/layout/style/nsICSSDeclaration.h +++ b/layout/style/nsICSSDeclaration.h @@ -76,7 +76,7 @@ public: NS_IMETHOD GetPropertyCSSValue(const nsAString& aProp, nsIDOMCSSValue** aVal) override { mozilla::ErrorResult error; - nsRefPtr val = GetPropertyCSSValue(aProp, error); + RefPtr val = GetPropertyCSSValue(aProp, error); if (error.Failed()) { return error.StealNSResult(); } diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 73f35aed0b..536baa6428 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -398,7 +398,7 @@ nsLayoutStylesheetCache::InitFromProfile() /* static */ void nsLayoutStylesheetCache::LoadSheetURL(const char* aURL, - nsRefPtr& aSheet, + RefPtr& aSheet, bool aEnableUnsafeRules) { nsCOMPtr uri; @@ -410,7 +410,7 @@ nsLayoutStylesheetCache::LoadSheetURL(const char* aURL, } void -nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr& aSheet) +nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, RefPtr& aSheet) { bool exists = false; aFile->Exists(&exists); @@ -436,7 +436,7 @@ ErrorLoadingBuiltinSheet(nsIURI* aURI, const char* aMsg) void nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, - nsRefPtr& aSheet, + RefPtr& aSheet, bool aEnableUnsafeRules) { if (!aURI) { @@ -463,7 +463,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, } /* static */ void -nsLayoutStylesheetCache::InvalidateSheet(nsRefPtr& aSheet) +nsLayoutStylesheetCache::InvalidateSheet(RefPtr& aSheet) { MOZ_ASSERT(gCSSLoader, "pref changed before we loaded a sheet?"); @@ -519,7 +519,7 @@ nsLayoutStylesheetCache::AppendPreferenceColorRule(CSSStyleSheet* aSheet, } void -nsLayoutStylesheetCache::BuildPreferenceSheet(nsRefPtr& aSheet, +nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr& aSheet, nsPresContext* aPresContext) { aSheet = new CSSStyleSheet(CORS_NONE, mozilla::net::RP_Default); diff --git a/layout/style/nsLayoutStylesheetCache.h b/layout/style/nsLayoutStylesheetCache.h index ff5dc711fb..c8960818ed 100644 --- a/layout/style/nsLayoutStylesheetCache.h +++ b/layout/style/nsLayoutStylesheetCache.h @@ -67,15 +67,15 @@ private: void InitFromProfile(); void InitMemoryReporter(); static void LoadSheetURL(const char* aURL, - nsRefPtr& aSheet, + RefPtr& aSheet, bool aEnableUnsafeRules); static void LoadSheetFile(nsIFile* aFile, - nsRefPtr& aSheet); - static void LoadSheet(nsIURI* aURI, nsRefPtr& aSheet, + RefPtr& aSheet); + static void LoadSheet(nsIURI* aURI, RefPtr& aSheet, bool aEnableUnsafeRules); - static void InvalidateSheet(nsRefPtr& aSheet); + static void InvalidateSheet(RefPtr& aSheet); static void DependentPrefChanged(const char* aPref, void* aData); - void BuildPreferenceSheet(nsRefPtr& aSheet, + void BuildPreferenceSheet(RefPtr& aSheet, nsPresContext* aPresContext); static void AppendPreferenceRule(mozilla::CSSStyleSheet* aSheet, const nsAString& aRule); @@ -84,24 +84,24 @@ private: static mozilla::StaticRefPtr gStyleCache; static mozilla::css::Loader* gCSSLoader; - nsRefPtr mChromePreferenceSheet; - nsRefPtr mContentPreferenceSheet; - nsRefPtr mCounterStylesSheet; - nsRefPtr mFormsSheet; - nsRefPtr mFullScreenOverrideSheet; - nsRefPtr mHTMLSheet; - nsRefPtr mMathMLSheet; - nsRefPtr mMinimalXULSheet; - nsRefPtr mNoFramesSheet; - nsRefPtr mNoScriptSheet; - nsRefPtr mNumberControlSheet; - nsRefPtr mQuirkSheet; - nsRefPtr mSVGSheet; - nsRefPtr mScrollbarsSheet; - nsRefPtr mUASheet; - nsRefPtr mUserChromeSheet; - nsRefPtr mUserContentSheet; - nsRefPtr mXULSheet; + RefPtr mChromePreferenceSheet; + RefPtr mContentPreferenceSheet; + RefPtr mCounterStylesSheet; + RefPtr mFormsSheet; + RefPtr mFullScreenOverrideSheet; + RefPtr mHTMLSheet; + RefPtr mMathMLSheet; + RefPtr mMinimalXULSheet; + RefPtr mNoFramesSheet; + RefPtr mNoScriptSheet; + RefPtr mNumberControlSheet; + RefPtr mQuirkSheet; + RefPtr mSVGSheet; + RefPtr mScrollbarsSheet; + RefPtr mUASheet; + RefPtr mUserChromeSheet; + RefPtr mUserContentSheet; + RefPtr mXULSheet; }; #endif diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index b000a57865..4b13f0ad26 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -197,7 +197,7 @@ GetIsResourceDocument(nsPresContext* aPresContext, const nsMediaFeature*, static nsresult MakeArray(const nsSize& aSize, nsCSSValue& aResult) { - nsRefPtr a = nsCSSValue::Array::Create(2); + RefPtr a = nsCSSValue::Array::Create(2); a->Item(0).SetIntValue(aSize.width, eCSSUnit_Integer); a->Item(1).SetIntValue(aSize.height, eCSSUnit_Integer); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index cd6ccc024b..4428d539fd 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -70,7 +70,7 @@ using namespace mozilla::dom; if ((context_)->PresContext()->IsDynamic()) { \ method_(request_); \ } else { \ - nsRefPtr req = nsContentUtils::GetStaticRequest(request_); \ + RefPtr req = nsContentUtils::GetStaticRequest(request_); \ method_(req); \ } @@ -303,7 +303,7 @@ GetMetricsFor(nsPresContext* aPresContext, orientation = gfxFont::eVertical; } } - nsRefPtr fm; + RefPtr fm; aPresContext->DeviceContext()->GetMetricsFor(font, aStyleFont->mLanguage, aStyleFont->mExplicitLanguage, @@ -469,7 +469,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue, } else { // This is not the root element or we are calculating something other // than font size, so rem is relative to the root element's font size. - nsRefPtr rootStyle; + RefPtr rootStyle; const nsStyleFont *rootStyleFont = styleFont; Element* docElement = aPresContext->Document()->GetRootElement(); @@ -512,7 +512,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue, } case eCSSUnit_XHeight: { aPresContext->SetUsesExChUnits(true); - nsRefPtr fm = + RefPtr fm = GetMetricsFor(aPresContext, aStyleContext, styleFont, aFontSize, aUseUserFontSet); aConditions.SetUncacheable(); @@ -520,7 +520,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue, } case eCSSUnit_Char: { aPresContext->SetUsesExChUnits(true); - nsRefPtr fm = + RefPtr fm = GetMetricsFor(aPresContext, aStyleContext, styleFont, aFontSize, aUseUserFontSet); gfxFloat zeroWidth = @@ -4046,7 +4046,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, MOZ_ASSERT(arrayLength > 0, "Non-null text-shadow list, yet we counted 0 items."); - nsRefPtr shadowList = + RefPtr shadowList = new(arrayLength) nsCSSShadowArray(arrayLength); if (!shadowList) @@ -6208,7 +6208,7 @@ ComputePositionValue(nsStyleContext* aStyleContext, NS_ASSERTION(aValue.GetUnit() == eCSSUnit_Array, "unexpected unit for CSS value"); - nsRefPtr positionArray = aValue.GetArrayValue(); + RefPtr positionArray = aValue.GetArrayValue(); const nsCSSValue &xEdge = positionArray->Item(0); const nsCSSValue &xOffset = positionArray->Item(1); const nsCSSValue &yEdge = positionArray->Item(2); @@ -7542,7 +7542,7 @@ SetGridTrackList(const nsCSSValue& aValue, static void SetGridTemplateAreas(const nsCSSValue& aValue, - nsRefPtr* aResult, + RefPtr* aResult, css::GridTemplateAreasValue* aParentValue, RuleNodeCacheConditions& aConditions) { @@ -9139,7 +9139,7 @@ nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, type); MOZ_ASSERT(foundKeyword, "unknown filter type"); if (type == NS_STYLE_FILTER_DROP_SHADOW) { - nsRefPtr shadowArray = GetShadowData( + RefPtr shadowArray = GetShadowData( filterFunction->Item(1).GetListValue(), aStyleContext, false, diff --git a/layout/style/nsRuleWalker.h b/layout/style/nsRuleWalker.h index b2715bf6f2..f2c4a7de7e 100644 --- a/layout/style/nsRuleWalker.h +++ b/layout/style/nsRuleWalker.h @@ -34,7 +34,7 @@ protected: public: void Forward(nsIStyleRule* aRule) { - NS_PRECONDITION(!nsRefPtr(do_QueryObject(aRule)), + NS_PRECONDITION(!RefPtr(do_QueryObject(aRule)), "Calling the wrong Forward() overload"); DoForward(aRule); } diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index c647aa5fc3..448f61617b 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -344,7 +344,7 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag, uint32_t threshold = 10; // The # of siblings we're willing to examine // before just giving this whole thing up. - nsRefPtr result; + RefPtr result; nsStyleContext *list = aRuleNode->IsRoot() ? mEmptyChild : mChild; if (list) { @@ -613,7 +613,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup) nsPresContext* presContext = PresContext(); mozilla::dom::Element* docElement = presContext->Document()->GetRootElement(); if (docElement) { - nsRefPtr rootStyle = + RefPtr rootStyle = presContext->StyleSet()->ResolveStyleFor(docElement, nullptr); auto dir = rootStyle->StyleVisibility()->mDirection; if (dir != StyleVisibility()->mDirection) { @@ -1185,7 +1185,7 @@ void nsStyleContext::Destroy() { // Get the pres context from our rule node. - nsRefPtr presContext = mRuleNode->PresContext(); + RefPtr presContext = mRuleNode->PresContext(); // Call our destructor. this->~nsStyleContext(); @@ -1203,7 +1203,7 @@ NS_NewStyleContext(nsStyleContext* aParentContext, nsRuleNode* aRuleNode, bool aSkipParentDisplayBasedStyleFixup) { - nsRefPtr context = + RefPtr context = new (aRuleNode->PresContext()) nsStyleContext(aParentContext, aPseudoTag, aPseudoType, aRuleNode, aSkipParentDisplayBasedStyleFixup); diff --git a/layout/style/nsStyleContext.h b/layout/style/nsStyleContext.h index d25fc32ec8..2c73dfa54b 100644 --- a/layout/style/nsStyleContext.h +++ b/layout/style/nsStyleContext.h @@ -566,7 +566,7 @@ private: // Style to be used instead for the R, G, and B components of color, // background-color, and border-*-color if the nearest ancestor link // element is visited (see RelevantLinkVisited()). - nsRefPtr mStyleIfVisited; + RefPtr mStyleIfVisited; // If this style context is for a pseudo-element or anonymous box, // the relevant atom. diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 0955e626bd..594bf9a04e 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -466,7 +466,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) // as scoped style roots. nsTArray sheets(count); for (uint32_t i = 0; i < count; i++) { - nsRefPtr sheet = + RefPtr sheet = do_QueryObject(mSheets[eScopedDocSheet].ObjectAt(i)); sheets.AppendElement(sheet); @@ -505,7 +505,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) scope->SetIsScopedStyleRoot(); // Create a rule processor for the scope. - nsTArray> sheetsForScope; + nsTArray> sheetsForScope; sheetsForScope.AppendElements(sheets.Elements() + start, end - start); nsCSSRuleProcessor* oldRP = oldScopedRuleProcessorHash.Get(scope); mScopedDocSheetRuleProcessors.AppendElement @@ -524,9 +524,9 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) // levels containing non-scoped CSS style sheets whose rule processors // we want to re-use nsCOMArray& sheets = mSheets[aType]; - nsTArray> cssSheets(sheets.Count()); + nsTArray> cssSheets(sheets.Count()); for (int32_t i = 0, i_end = sheets.Count(); i < i_end; ++i) { - nsRefPtr cssSheet = do_QueryObject(sheets[i]); + RefPtr cssSheet = do_QueryObject(sheets[i]); NS_ASSERTION(cssSheet, "not a CSS sheet"); cssSheets.AppendElement(cssSheet); } @@ -558,9 +558,9 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) // levels containing non-scoped CSS stylesheets whose rule processors // we don't want to re-use nsCOMArray& sheets = mSheets[aType]; - nsTArray> cssSheets(sheets.Count()); + nsTArray> cssSheets(sheets.Count()); for (int32_t i = 0, i_end = sheets.Count(); i < i_end; ++i) { - nsRefPtr cssSheet = do_QueryObject(sheets[i]); + RefPtr cssSheet = do_QueryObject(sheets[i]); NS_ASSERTION(cssSheet, "not a CSS sheet"); cssSheets.AppendElement(cssSheet); } @@ -584,7 +584,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) static bool IsScopedStyleSheet(nsIStyleSheet* aSheet) { - nsRefPtr cssSheet = do_QueryObject(aSheet); + RefPtr cssSheet = do_QueryObject(aSheet); NS_ASSERTION(cssSheet, "expected aSheet to be a CSSStyleSheet"); return cssSheet->GetScopeElement(); @@ -767,7 +767,7 @@ nsStyleSet::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument) nsresult nsStyleSet::RemoveDocStyleSheet(nsIStyleSheet *aSheet) { - nsRefPtr cssSheet = do_QueryObject(aSheet); + RefPtr cssSheet = do_QueryObject(aSheet); bool isScoped = cssSheet && cssSheet->GetScopeElement(); return RemoveStyleSheet(isScoped ? eScopedDocSheet : eDocSheet, aSheet); } @@ -928,7 +928,7 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext, (aFlags & eIsVisitedLink) : (aParentContext && aParentContext->RelevantLinkVisited()); - nsRefPtr result; + RefPtr result; if (aParentContext) result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode, aVisitedRuleNode, @@ -946,7 +946,7 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext, aRuleNode, aFlags & eSkipParentDisplayBasedStyleFixup); if (aVisitedRuleNode) { - nsRefPtr resultIfVisited = + RefPtr resultIfVisited = NS_NewStyleContext(parentIfVisited, aPseudoTag, aPseudoType, aVisitedRuleNode, aFlags & eSkipParentDisplayBasedStyleFixup); @@ -1030,7 +1030,7 @@ nsStyleSet::AddImportantRules(nsRuleNode* aCurrLevelNode, node = node->GetParent()) { // We guarantee that we never walk the root node here, so no need // to null-check GetRule(). Furthermore, it must be a CSS rule. - NS_ASSERTION(nsRefPtr(do_QueryObject(node->GetRule())), + NS_ASSERTION(RefPtr(do_QueryObject(node->GetRule())), "Unexpected non-CSS rule"); nsIStyleRule* impRule = @@ -1057,7 +1057,7 @@ nsStyleSet::AssertNoImportantRules(nsRuleNode* aCurrLevelNode, for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode; node = node->GetParent()) { - nsRefPtr rule(do_QueryObject(node->GetRule())); + RefPtr rule(do_QueryObject(node->GetRule())); NS_ASSERTION(rule, "Unexpected non-CSS rule"); NS_ASSERTION(!rule->GetImportantRule(), "Unexpected important rule"); @@ -1074,7 +1074,7 @@ nsStyleSet::AssertNoCSSRules(nsRuleNode* aCurrLevelNode, for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode; node = node->GetParent()) { nsIStyleRule *rule = node->GetRule(); - nsRefPtr cssRule(do_QueryObject(rule)); + RefPtr cssRule(do_QueryObject(rule)); NS_ASSERTION(!cssRule || !cssRule->Selector(), "Unexpected CSS rule"); } } @@ -1742,7 +1742,7 @@ nsStyleSet::ResolveStyleWithoutAnimation(dom::Element* aTarget, bool oldSkipAnimationRules = restyleManager->SkipAnimationRules(); restyleManager->SetSkipAnimationRules(true); - nsRefPtr result = + RefPtr result = ResolveStyleWithReplacement(aTarget, nullptr, aStyleContext->GetParent(), aStyleContext, aWhichToRemove, eSkipStartingAnimations); @@ -1904,7 +1904,7 @@ nsStyleSet::ProbePseudoElementStyle(Element* aParentElement, flags |= eSkipParentDisplayBasedStyleFixup; } - nsRefPtr result = + RefPtr result = GetContext(aParentContext, ruleNode, visitedRuleNode, pseudoTag, aType, aParentElement, flags); @@ -2123,7 +2123,7 @@ nsStyleSet::GetFontFeatureValuesLookup() } } - nsRefPtr lookup = mFontFeatureValuesLookup; + RefPtr lookup = mFontFeatureValuesLookup; return lookup.forget(); } @@ -2232,7 +2232,7 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext, // This short-circuit is OK because we don't call TryStartingTransition // during style reresolution if the style context pointer hasn't changed. if (aStyleContext->GetParent() == aNewParentContext) { - nsRefPtr ret = aStyleContext; + RefPtr ret = aStyleContext; return ret.forget(); } diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index ff041525f1..eb463d4c12 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -494,7 +494,7 @@ class nsStyleSet final // Rule processors for HTML5 scoped style sheets, one per scope. nsTArray > mScopedDocSheetRuleProcessors; - nsRefPtr mBindingManager; + RefPtr mBindingManager; nsRuleNode* mRuleTree; // This is the root of our rule tree. It is a // lexicographic tree of matched rules that style @@ -514,15 +514,15 @@ class nsStyleSet final // Empty style rules to force things that restrict which properties // apply into different branches of the rule tree. - nsRefPtr mFirstLineRule, mFirstLetterRule, mPlaceholderRule; + RefPtr mFirstLineRule, mFirstLetterRule, mPlaceholderRule; // Style rule which sets all properties to their initial values for // determining when context-sensitive values are in use. - nsRefPtr mInitialStyleRule; + RefPtr mInitialStyleRule; // Style rule that sets the internal -x-text-zoom property on // elements to disable the effect of text zooming. - nsRefPtr mDisableTextZoomStyleRule; + RefPtr mDisableTextZoomStyleRule; // Old rule trees, which should only be non-empty between // BeginReconstruct and EndReconstruct, but in case of bugs that cause @@ -530,7 +530,7 @@ class nsStyleSet final nsTArray mOldRuleTrees; // whether font feature values lookup object needs initialization - nsRefPtr mFontFeatureValuesLookup; + RefPtr mFontFeatureValuesLookup; }; #ifdef MOZILLA_INTERNAL_API diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 7bf141a1f3..7183ba6bc9 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1032,7 +1032,7 @@ struct nsStyleBorder { public: nsBorderColors** mBorderColors; // [reset] composite (stripe) colors - nsRefPtr mBoxShadow; // [reset] nullptr for 'none' + RefPtr mBoxShadow; // [reset] nullptr for 'none' public: nsStyleCorners mBorderRadius; // [reset] coord, percent @@ -1236,8 +1236,8 @@ struct nsStyleList { uint8_t mListStylePosition; // [inherited] private: nsString mListStyleType; // [inherited] - nsRefPtr mCounterStyle; // [inherited] - nsRefPtr mListStyleImage; // [inherited] + RefPtr mCounterStyle; // [inherited] + RefPtr mListStyleImage; // [inherited] nsStyleList& operator=(const nsStyleList& aOther) = delete; public: nsRect mImageRegion; // [inherited] the rect to use within an image @@ -1534,7 +1534,7 @@ struct nsStyleText { nsStyleCoord mLineHeight; // [inherited] coord, factor, normal nsStyleCoord mTextIndent; // [inherited] coord, percent, calc - nsRefPtr mTextShadow; // [inherited] nullptr in case of a zero-length + RefPtr mTextShadow; // [inherited] nullptr in case of a zero-length bool WhiteSpaceIsSignificant() const { return mWhiteSpace == NS_STYLE_WHITESPACE_PRE || @@ -1990,7 +1990,7 @@ struct nsStyleDisplay { // We guarantee that if mBinding is non-null, so are mBinding->GetURI() and // mBinding->mOriginPrincipal. - nsRefPtr mBinding; // [reset] + RefPtr mBinding; // [reset] nsRect mClip; // [reset] offsets from upper-left border edge float mOpacity; // [reset] uint8_t mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_* @@ -2039,7 +2039,7 @@ struct nsStyleDisplay { uint8_t mBackfaceVisibility; uint8_t mTransformStyle; uint8_t mTransformBox; // [reset] see nsStyleConsts.h - nsRefPtr mSpecifiedTransform; // [reset] + RefPtr mSpecifiedTransform; // [reset] nsStyleCoord mTransformOrigin[3]; // [reset] percent, coord, calc, 3rd param is coord, calc only nsStyleCoord mChildPerspective; // [reset] none, coord nsStyleCoord mPerspectiveOrigin[2]; // [reset] percent, coord, calc @@ -2319,7 +2319,7 @@ public: nsStyleGridTemplate mGridTemplateRows; // nullptr for 'none' - nsRefPtr mGridTemplateAreas; + RefPtr mGridTemplateAreas; nsStyleGridLine mGridColumnStart; nsStyleGridLine mGridColumnEnd; diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index cfc20feda7..d28fd772ab 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -238,7 +238,7 @@ NS_INTERFACE_MAP_END void nsTransitionManager::StyleContextChanged(dom::Element *aElement, nsStyleContext *aOldStyleContext, - nsRefPtr* aNewStyleContext /* inout */) + RefPtr* aNewStyleContext /* inout */) { nsStyleContext* newStyleContext = *aNewStyleContext; @@ -339,7 +339,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement, // style", which is the new style without any data from transitions, // but still inheriting from data that contains transitions that are // not stopping or starting right now. - nsRefPtr afterChangeStyle; + RefPtr afterChangeStyle; if (collection) { nsStyleSet* styleSet = mPresContext->StyleSet(); afterChangeStyle = @@ -670,7 +670,7 @@ nsTransitionManager::ConsiderStartingTransition( timing.mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL; timing.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS; - nsRefPtr pt = + RefPtr pt = new ElementPropertyTransition(aElement->OwnerDoc(), aElement, aNewStyleContext->GetPseudoType(), timing); pt->mStartForReversingTest = startForReversingTest; @@ -687,7 +687,7 @@ nsTransitionManager::ConsiderStartingTransition( segment.mToKey = 1; segment.mTimingFunction.Init(tf); - nsRefPtr animation = + RefPtr animation = new CSSTransition(mPresContext->Document()->GetScopeObject()); animation->SetOwningElement( OwningElementRef(*aElement, aNewStyleContext->GetPseudoType())); diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index 201eb3e47d..aa8e806bb5 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -254,7 +254,7 @@ public: */ void StyleContextChanged(mozilla::dom::Element *aElement, nsStyleContext *aOldStyleContext, - nsRefPtr* aNewStyleContext /* inout */); + RefPtr* aNewStyleContext /* inout */); /** * When we're resolving style for an element that previously didn't have diff --git a/layout/style/test/ParseCSS.cpp b/layout/style/test/ParseCSS.cpp index c74a88c2ec..457a0f7f4d 100644 --- a/layout/style/test/ParseCSS.cpp +++ b/layout/style/test/ParseCSS.cpp @@ -42,8 +42,8 @@ FileToURI(const char *aFilename, nsresult *aRv = 0) static int ParseCSSFile(nsIURI *aSheetURI) { - nsRefPtr = new mozilla::css::Loader(); - nsRefPtr sheet; + RefPtr = new mozilla::css::Loader(); + RefPtr sheet; loader->LoadSheetSync(aSheetURI, getter_AddRefs(sheet)); NS_ASSERTION(sheet, "sheet load failed"); /* This can happen if the file can't be found (e.g. you diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 0ba4f93622..23c1274cd6 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -3092,7 +3092,7 @@ SVGTextContextPaint::Paint::GetPattern(const DrawTarget* aDrawTarget, nsStyleSVGPaint nsStyleSVG::*aFillOrStroke, const gfxMatrix& aCTM) { - nsRefPtr pattern; + RefPtr pattern; if (mPatternCache.Get(aOpacity, getter_AddRefs(pattern))) { // Set the pattern matrix just in case it was messed with by a previous // caller. We should get the same matrix each time a pattern is constructed @@ -3745,7 +3745,7 @@ SVGTextFrame::PaintSVG(gfxContext& aContext, aContext.Multiply(canvasTMForChildren); gfxMatrix currentMatrix = aContext.CurrentMatrix(); - nsRefPtr caret = presContext->PresShell()->GetCaret(); + RefPtr caret = presContext->PresShell()->GetCaret(); nsRect caretRect; nsIFrame* caretFrame = caret->GetPaintGeometry(&caretRect); @@ -4169,7 +4169,7 @@ SVGTextFrame::SelectSubString(nsIContent* aContent, chit.NextWithinSubtree(nchars); nchars = chit.TextElementCharIndex() - charnum; - nsRefPtr frameSelection = GetFrameSelection(); + RefPtr frameSelection = GetFrameSelection(); frameSelection->HandleClick(content, charnum, charnum + nchars, false, false, CARET_ASSOCIATE_BEFORE); @@ -5211,7 +5211,7 @@ SVGTextFrame::DoGlyphPositioning() float actualTextLength = static_cast(presContext->AppUnitsToGfxUnits(frameLength) * factor); - nsRefPtr lengthAdjustEnum = element->LengthAdjust(); + RefPtr lengthAdjustEnum = element->LengthAdjust(); uint16_t lengthAdjust = lengthAdjustEnum->AnimVal(); switch (lengthAdjust) { case SVG_LENGTHADJUST_SPACINGANDGLYPHS: @@ -5778,7 +5778,7 @@ SetupInheritablePaint(const DrawTarget* aDrawTarget, nsSVGEffects::GetPaintServer(aFrame, &(style->*aFillOrStroke), aProperty); if (ps) { - nsRefPtr pattern = + RefPtr pattern = ps->GetPaintServerPattern(aFrame, aDrawTarget, aContextMatrix, aFillOrStroke, aOpacity); if (pattern) { @@ -5787,7 +5787,7 @@ SetupInheritablePaint(const DrawTarget* aDrawTarget, } } if (aOuterContextPaint) { - nsRefPtr pattern; + RefPtr pattern; switch ((style->*aFillOrStroke).mType) { case eStyleSVGPaintType_ContextFill: pattern = aOuterContextPaint->GetFillPattern(aDrawTarget, aOpacity, diff --git a/layout/svg/SVGTextFrame.h b/layout/svg/SVGTextFrame.h index 3b36b6158a..36769eed94 100644 --- a/layout/svg/SVGTextFrame.h +++ b/layout/svg/SVGTextFrame.h @@ -618,7 +618,7 @@ private: /** * The MutationObserver we have registered for the element subtree. */ - nsRefPtr mMutationObserver; + RefPtr mMutationObserver; /** * Cached canvasTM value. diff --git a/layout/svg/nsFilterInstance.cpp b/layout/svg/nsFilterInstance.cpp index ee6ab737be..bd1f2454ff 100644 --- a/layout/svg/nsFilterInstance.cpp +++ b/layout/svg/nsFilterInstance.cpp @@ -34,7 +34,7 @@ nsFilterInstance::GetFilterDescription(nsIContent* aFilteredElement, const nsTArray& aFilterChain, const UserSpaceMetrics& aMetrics, const gfxRect& aBBox, - nsTArray>& aOutAdditionalImages) + nsTArray>& aOutAdditionalImages) { gfxMatrix unused; // aPaintTransform arg not used since we're not painting nsFilterInstance instance(nullptr, aFilteredElement, aMetrics, @@ -364,7 +364,7 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource, } if (!mPaintTransform.IsSingular()) { - nsRefPtr gfx = new gfxContext(offscreenDT); + RefPtr gfx = new gfxContext(offscreenDT); gfx->Save(); gfx->Multiply(mPaintTransform * deviceToFilterSpace * @@ -443,7 +443,7 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT) if (!deviceToFilterSpace.Invert()) { return NS_ERROR_FAILURE; } - nsRefPtr ctx = new gfxContext(offscreenDT); + RefPtr ctx = new gfxContext(offscreenDT); ctx->SetMatrix( ctx->CurrentMatrix().Translate(-neededRect.TopLeft()). PreMultiply(deviceToFilterSpace)); diff --git a/layout/svg/nsFilterInstance.h b/layout/svg/nsFilterInstance.h index 5c3780e4e6..3a22185393 100644 --- a/layout/svg/nsFilterInstance.h +++ b/layout/svg/nsFilterInstance.h @@ -68,7 +68,7 @@ public: const nsTArray& aFilterChain, const UserSpaceMetrics& aMetrics, const gfxRect& aBBox, - nsTArray>& aOutAdditionalImages); + nsTArray>& aOutAdditionalImages); /** * Paint the given filtered frame. @@ -157,7 +157,7 @@ public: */ nsresult Render(gfxContext* aContext); - const FilterDescription& ExtractDescriptionAndAdditionalImages(nsTArray>& aOutAdditionalImages) + const FilterDescription& ExtractDescriptionAndAdditionalImages(nsTArray>& aOutAdditionalImages) { mInputImages.SwapElements(aOutAdditionalImages); return mFilterDescription; @@ -206,7 +206,7 @@ private: // The surface that contains the input rendering. // Set by BuildSourceImage / BuildSourcePaint. - mozilla::RefPtr mSourceSurface; + RefPtr mSourceSurface; // The position and size of mSourceSurface in filter space. // Set by BuildSourceImage / BuildSourcePaint. @@ -364,7 +364,7 @@ private: */ gfxMatrix mPaintTransform; - nsTArray> mInputImages; + nsTArray> mInputImages; nsTArray mPrimitiveDescriptions; FilterDescription mFilterDescription; bool mInitialized; diff --git a/layout/svg/nsSVGEffects.cpp b/layout/svg/nsSVGEffects.cpp index ed4dffee4b..6dc1b47c84 100644 --- a/layout/svg/nsSVGEffects.cpp +++ b/layout/svg/nsSVGEffects.cpp @@ -296,7 +296,7 @@ nsSVGFilterChainObserver::nsSVGFilterChainObserver(const nsTArray if (aFilters[i].GetType() != NS_STYLE_FILTER_URL) continue; - nsRefPtr reference = + RefPtr reference = new nsSVGFilterReference(aFilters[i].GetURL(), aFilteredElement, this); mReferences.AppendElement(reference); } diff --git a/layout/svg/nsSVGEffects.h b/layout/svg/nsSVGEffects.h index 08d81da100..e44a578f91 100644 --- a/layout/svg/nsSVGEffects.h +++ b/layout/svg/nsSVGEffects.h @@ -273,7 +273,7 @@ private: } } - nsTArray> mReferences; + nsTArray> mReferences; }; class nsSVGFilterProperty : public nsSVGFilterChainObserver { diff --git a/layout/svg/nsSVGFilterFrame.cpp b/layout/svg/nsSVGFilterFrame.cpp index 741e91c374..cc368b040b 100644 --- a/layout/svg/nsSVGFilterFrame.cpp +++ b/layout/svg/nsSVGFilterFrame.cpp @@ -86,7 +86,7 @@ nsSVGFilterFrame::GetFilterContent(nsIContent *aDefault) for (nsIContent* child = mContent->GetFirstChild(); child; child = child->GetNextSibling()) { - nsRefPtr primitive; + RefPtr primitive; CallQueryInterface(child, (nsSVGFE**)getter_AddRefs(primitive)); if (primitive) { return static_cast(mContent); diff --git a/layout/svg/nsSVGFilterInstance.cpp b/layout/svg/nsSVGFilterInstance.cpp index 00eb53f7a2..9dfdf22ccc 100644 --- a/layout/svg/nsSVGFilterInstance.cpp +++ b/layout/svg/nsSVGFilterInstance.cpp @@ -361,7 +361,7 @@ nsSVGFilterInstance::GetSourceIndices(nsSVGFE* aPrimitiveElement, nsresult nsSVGFilterInstance::BuildPrimitives(nsTArray& aPrimitiveDescrs, - nsTArray>& aInputImages) + nsTArray>& aInputImages) { mSourceGraphicIndex = GetLastResultIndex(aPrimitiveDescrs); @@ -372,11 +372,11 @@ nsSVGFilterInstance::BuildPrimitives(nsTArray& aPrim } // Get the filter primitive elements. - nsTArray > primitives; + nsTArray > primitives; for (nsIContent* child = mFilterElement->nsINode::GetFirstChild(); child; child = child->GetNextSibling()) { - nsRefPtr primitive; + RefPtr primitive; CallQueryInterface(child, (nsSVGFE**)getter_AddRefs(primitive)); if (primitive) { primitives.AppendElement(primitive); diff --git a/layout/svg/nsSVGFilterInstance.h b/layout/svg/nsSVGFilterInstance.h index ab37e78405..b4a6cbdb02 100644 --- a/layout/svg/nsSVGFilterInstance.h +++ b/layout/svg/nsSVGFilterInstance.h @@ -99,7 +99,7 @@ public: * new images from feImage filter primitive elements to the aInputImages list. */ nsresult BuildPrimitives(nsTArray& aPrimitiveDescrs, - nsTArray>& aInputImages); + nsTArray>& aInputImages); /** * Returns the user specified "filter region", in the filtered element's user diff --git a/layout/svg/nsSVGGradientFrame.cpp b/layout/svg/nsSVGGradientFrame.cpp index e26b95270f..e2ea80835c 100644 --- a/layout/svg/nsSVGGradientFrame.cpp +++ b/layout/svg/nsSVGGradientFrame.cpp @@ -235,7 +235,7 @@ nsSVGGradientFrame::GetPaintServerPattern(nsIFrame* aSource, // SVG specification says that no stops should be treated like // the corresponding fill or stroke had "none" specified. if (nStops == 0) { - nsRefPtr pattern = new gfxPattern(Color()); + RefPtr pattern = new gfxPattern(Color()); return pattern.forget(); } @@ -247,7 +247,7 @@ nsSVGGradientFrame::GetPaintServerPattern(nsIFrame* aSource, Color stopColor2 = Color::FromABGR(stopColor); stopColor2.a *= stopOpacity * aGraphicOpacity; - nsRefPtr pattern = new gfxPattern(stopColor2); + RefPtr pattern = new gfxPattern(stopColor2); return pattern.forget(); } @@ -272,7 +272,7 @@ nsSVGGradientFrame::GetPaintServerPattern(nsIFrame* aSource, return nullptr; } - nsRefPtr gradient = CreateGradient(); + RefPtr gradient = CreateGradient(); if (!gradient || gradient->CairoStatus()) return nullptr; @@ -499,7 +499,7 @@ nsSVGLinearGradientFrame::CreateGradient() x2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_X2); y2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y2); - nsRefPtr pattern = new gfxPattern(x1, y1, x2, y2); + RefPtr pattern = new gfxPattern(x1, y1, x2, y2); return pattern.forget(); } @@ -644,7 +644,7 @@ nsSVGRadialGradientFrame::CreateGradient() } } - nsRefPtr pattern = new gfxPattern(fx, fy, 0, cx, cy, r); + RefPtr pattern = new gfxPattern(fx, fy, 0, cx, cy, r); return pattern.forget(); } diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index 981e94b7bb..845da35e33 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -732,7 +732,7 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame, gfxRect overrideBounds(0, 0, aPaintServerSize.width, aPaintServerSize.height); overrideBounds.ScaleInverse(aFrame->PresContext()->AppUnitsPerDevPixel()); - nsRefPtr pattern = + RefPtr pattern = server->GetPaintServerPattern(aTarget, aDrawTarget, aContextMatrix, &nsStyleSVG::mFill, 1.0, &overrideBounds); @@ -749,15 +749,15 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame, gfxFloat scaleY = overrideBounds.Height() / aRenderSize.height; gfxMatrix scaleMatrix = gfxMatrix::Scaling(scaleX, scaleY); pattern->SetMatrix(scaleMatrix * pattern->GetMatrix()); - nsRefPtr drawable = + RefPtr drawable = new gfxPatternDrawable(pattern, aRenderSize); return drawable.forget(); } // We don't want to paint into a surface as long as we don't need to, so we // set up a drawing callback. - nsRefPtr cb = + RefPtr cb = new PaintFrameCallback(aFrame, aPaintServerSize, aRenderSize, aFlags); - nsRefPtr drawable = new gfxCallbackDrawable(cb, aRenderSize); + RefPtr drawable = new gfxCallbackDrawable(cb, aRenderSize); return drawable.forget(); } diff --git a/layout/svg/nsSVGMaskFrame.cpp b/layout/svg/nsSVGMaskFrame.cpp index 9421e66b6f..a4f3368a59 100644 --- a/layout/svg/nsSVGMaskFrame.cpp +++ b/layout/svg/nsSVGMaskFrame.cpp @@ -259,7 +259,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext, gfxMatrix maskSurfaceMatrix = aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft()); - nsRefPtr tmpCtx = new gfxContext(maskDT); + RefPtr tmpCtx = new gfxContext(maskDT); tmpCtx->SetMatrix(maskSurfaceMatrix); mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix; diff --git a/layout/svg/nsSVGPathGeometryFrame.cpp b/layout/svg/nsSVGPathGeometryFrame.cpp index 95c206dd4f..bd8bd4481f 100644 --- a/layout/svg/nsSVGPathGeometryFrame.cpp +++ b/layout/svg/nsSVGPathGeometryFrame.cpp @@ -496,7 +496,7 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace, // calculations. To avoid that and meet the expectations of web content we // have to use a CAIRO DrawTarget. The most efficient way to do that is to // wrap the cached cairo_surface_t from ScreenReferenceSurface(): - nsRefPtr refSurf = + RefPtr refSurf = gfxPlatform::GetPlatform()->ScreenReferenceSurface(); tmpDT = gfxPlatform::GetPlatform()-> CreateDrawTargetForSurface(refSurf, IntSize(1, 1)); diff --git a/layout/svg/nsSVGPatternFrame.cpp b/layout/svg/nsSVGPatternFrame.cpp index 90ff295150..50a8931669 100644 --- a/layout/svg/nsSVGPatternFrame.cpp +++ b/layout/svg/nsSVGPatternFrame.cpp @@ -377,7 +377,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget, } dt->ClearRect(Rect(0, 0, surfaceSize.width, surfaceSize.height)); - nsRefPtr gfx = new gfxContext(dt); + RefPtr gfx = new gfxContext(dt); if (aGraphicOpacity != 1.0f) { gfx->Save(); @@ -704,7 +704,7 @@ nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource, const gfxRect *aOverrideBounds) { if (aGraphicOpacity == 0.0f) { - nsRefPtr pattern = new gfxPattern(Color()); + RefPtr pattern = new gfxPattern(Color()); return pattern.forget(); } @@ -718,7 +718,7 @@ nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource, return nullptr; } - nsRefPtr pattern = new gfxPattern(surface, pMatrix); + RefPtr pattern = new gfxPattern(surface, pMatrix); if (!pattern || pattern->CairoStatus()) return nullptr; diff --git a/layout/svg/nsSVGUseFrame.cpp b/layout/svg/nsSVGUseFrame.cpp index ca4b32005d..a530858f06 100644 --- a/layout/svg/nsSVGUseFrame.cpp +++ b/layout/svg/nsSVGUseFrame.cpp @@ -166,7 +166,7 @@ nsSVGUseFrame::AttributeChanged(int32_t aNameSpaceID, void nsSVGUseFrame::DestroyFrom(nsIFrame* aDestructRoot) { - nsRefPtr use = static_cast(mContent); + RefPtr use = static_cast(mContent); nsSVGUseFrameBase::DestroyFrom(aDestructRoot); use->DestroyAnonymousContent(); } diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index 79f6dcbef1..98795cbedd 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -1289,7 +1289,7 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame, nsSVGEffects::GetPaintServer(aFrame, &style->mFill, nsSVGEffects::FillProperty()); if (ps) { - nsRefPtr pattern = + RefPtr pattern = ps->GetPaintServerPattern(aFrame, dt, aContext->CurrentMatrix(), &nsStyleSVG::mFill, opacity); if (pattern) { @@ -1300,7 +1300,7 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame, } if (aContextPaint) { - nsRefPtr pattern; + RefPtr pattern; switch (style->mFill.mType) { case eStyleSVGPaintType_ContextFill: pattern = aContextPaint->GetFillPattern(dt, opacity, @@ -1350,7 +1350,7 @@ nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, nsSVGEffects::GetPaintServer(aFrame, &style->mStroke, nsSVGEffects::StrokeProperty()); if (ps) { - nsRefPtr pattern = + RefPtr pattern = ps->GetPaintServerPattern(aFrame, dt, aContext->CurrentMatrix(), &nsStyleSVG::mStroke, opacity); if (pattern) { @@ -1361,7 +1361,7 @@ nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, } if (aContextPaint) { - nsRefPtr pattern; + RefPtr pattern; switch (style->mStroke.mType) { case eStyleSVGPaintType_ContextFill: pattern = aContextPaint->GetFillPattern(dt, opacity, diff --git a/layout/tables/nsCellMap.h b/layout/tables/nsCellMap.h index e424098e17..73df7d7ff2 100644 --- a/layout/tables/nsCellMap.h +++ b/layout/tables/nsCellMap.h @@ -583,7 +583,7 @@ protected: bool mIsBC; // Prescontext to deallocate and allocate celldata - nsRefPtr mPresContext; + RefPtr mPresContext; }; /** diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index d02628b0f5..78fec679d4 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -308,7 +308,7 @@ nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext, nsPresContext* presContext = PresContext(); displaySelection = DisplaySelection(presContext); if (displaySelection) { - nsRefPtr frameSelection = + RefPtr frameSelection = presContext->PresShell()->FrameSelection(); if (frameSelection->GetTableCellSelection()) { diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 9a4aa78d44..31b64c1603 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -649,7 +649,7 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsTableColGroupType aColGroupType) nsPresContext* presContext = PresContext(); nsIPresShell *shell = presContext->PresShell(); - nsRefPtr colGroupStyle; + RefPtr colGroupStyle; colGroupStyle = shell->StyleSet()-> ResolveAnonymousBoxStyle(nsCSSAnonBoxes::tableColGroup, mStyleContext); // Create a col group frame @@ -705,7 +705,7 @@ nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame, for (int32_t childX = startIndex; childX <= lastIndex; childX++) { nsIContent* iContent; - nsRefPtr styleContext; + RefPtr styleContext; nsStyleContext* parentStyleContext; // all anonymous cols that we create here use a pseudo style context of the diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 928d8606e5..01503282da 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -426,7 +426,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsRefPtr vm(view_manager(aDocShell)); + RefPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -516,7 +516,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsRefPtr vm(view_manager(mDocShell)); + RefPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/xul/PopupBoxObject.cpp b/layout/xul/PopupBoxObject.cpp index 083f7e2077..79931a18cb 100644 --- a/layout/xul/PopupBoxObject.cpp +++ b/layout/xul/PopupBoxObject.cpp @@ -271,7 +271,7 @@ PopupBoxObject::GetAnchorNode() const already_AddRefed PopupBoxObject::GetOuterScreenRect() { - nsRefPtr rect = new DOMRect(mContent); + RefPtr rect = new DOMRect(mContent); // Return an empty rectangle if the popup is not open. nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false)); diff --git a/layout/xul/grid/nsGridRowGroupLayout.cpp b/layout/xul/grid/nsGridRowGroupLayout.cpp index b98371d543..72ad10c8aa 100644 --- a/layout/xul/grid/nsGridRowGroupLayout.cpp +++ b/layout/xul/grid/nsGridRowGroupLayout.cpp @@ -26,7 +26,7 @@ already_AddRefed NS_NewGridRowGroupLayout() { - nsRefPtr layout = new nsGridRowGroupLayout(); + RefPtr layout = new nsGridRowGroupLayout(); return layout.forget(); } diff --git a/layout/xul/grid/nsGridRowLeafLayout.cpp b/layout/xul/grid/nsGridRowLeafLayout.cpp index 75965b318e..f9cd7614c3 100644 --- a/layout/xul/grid/nsGridRowLeafLayout.cpp +++ b/layout/xul/grid/nsGridRowLeafLayout.cpp @@ -22,7 +22,7 @@ already_AddRefed NS_NewGridRowLeafLayout() { - nsRefPtr layout = new nsGridRowLeafLayout(); + RefPtr layout = new nsGridRowLeafLayout(); return layout.forget(); } diff --git a/layout/xul/nsBoxLayoutState.h b/layout/xul/nsBoxLayoutState.h index 9375b75b45..89dac0aa5a 100644 --- a/layout/xul/nsBoxLayoutState.h +++ b/layout/xul/nsBoxLayoutState.h @@ -60,7 +60,7 @@ public: uint16_t GetReflowDepth() { return mReflowDepth; } private: - nsRefPtr mPresContext; + RefPtr mPresContext; nsRenderingContext *mRenderingContext; const nsHTMLReflowState *mOuterReflowState; uint32_t mLayoutFlags; diff --git a/layout/xul/nsDocElementBoxFrame.cpp b/layout/xul/nsDocElementBoxFrame.cpp index 086692cfa4..4d978617a4 100644 --- a/layout/xul/nsDocElementBoxFrame.cpp +++ b/layout/xul/nsDocElementBoxFrame.cpp @@ -91,7 +91,7 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsTArray& aElements) nsNodeInfoManager *nodeInfoManager = doc->NodeInfoManager(); // create the top-secret popupgroup node. shhhhh! - nsRefPtr nodeInfo; + RefPtr nodeInfo; nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::popupgroup, nullptr, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 814f666fdc..ce6f4e9e5d 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -79,7 +79,7 @@ nsImageBoxFrameEvent::Run() return NS_OK; } - nsRefPtr pres_context = pres_shell->GetPresContext(); + RefPtr pres_context = pres_shell->GetPresContext(); if (!pres_context) { return NS_OK; } @@ -190,7 +190,7 @@ nsImageBoxFrame::Init(nsIContent* aContent, nsIFrame* aPrevInFlow) { if (!mListener) { - nsRefPtr listener = new nsImageBoxListener(); + RefPtr listener = new nsImageBoxListener(); listener->SetFrame(this); mListener = listener.forget(); } diff --git a/layout/xul/nsImageBoxFrame.h b/layout/xul/nsImageBoxFrame.h index b96c429748..251224437f 100644 --- a/layout/xul/nsImageBoxFrame.h +++ b/layout/xul/nsImageBoxFrame.h @@ -116,7 +116,7 @@ private: nsSize mIntrinsicSize; nsSize mImageSize; - nsRefPtr mImageRequest; + RefPtr mImageRequest; nsCOMPtr mListener; int32_t mLoadFlags; diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp index 04f76d4b40..5ba679d54e 100644 --- a/layout/xul/nsListBoxBodyFrame.cpp +++ b/layout/xul/nsListBoxBodyFrame.cpp @@ -196,7 +196,7 @@ nsListBoxBodyFrame::Init(nsIContent* aContent, scrollbarFrame->SetScrollbarMediatorContent(GetContent()); } } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); mRowHeight = fm->MaxHeight(); } @@ -699,7 +699,7 @@ nsListBoxBodyFrame::ComputeIntrinsicISize(nsBoxLayoutState& aBoxLayoutState) nsCOMPtr firstRowContent(do_QueryInterface(firstRowEl)); if (firstRowContent) { - nsRefPtr styleContext; + RefPtr styleContext; nsPresContext *presContext = aBoxLayoutState.PresContext(); styleContext = presContext->StyleSet()-> ResolveStyleFor(firstRowContent->AsElement(), nullptr); @@ -727,7 +727,7 @@ nsListBoxBodyFrame::ComputeIntrinsicISize(nsBoxLayoutState& aBoxLayoutState) } } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(styleContext, getter_AddRefs(fm)); @@ -828,7 +828,7 @@ nsListBoxBodyFrame::InternalPositionChangedCallback() nsresult nsListBoxBodyFrame::InternalPositionChanged(bool aUp, int32_t aDelta) { - nsRefPtr ev = + RefPtr ev = new nsPositionChangedEvent(this, aUp, aDelta); nsresult rv = NS_DispatchToCurrentThread(ev); if (NS_SUCCEEDED(rv)) { @@ -846,7 +846,7 @@ nsListBoxBodyFrame::DoInternalPositionChangedSync(bool aUp, int32_t aDelta) nsWeakFrame weak(this); // Process all the pending position changes first - nsTArray< nsRefPtr > temp; + nsTArray< RefPtr > temp; temp.SwapElements(mPendingPositionChangeEvents); for (uint32_t i = 0; i < temp.Length(); ++i) { if (weak.IsAlive()) { @@ -868,7 +868,7 @@ nsListBoxBodyFrame::DoInternalPositionChanged(bool aUp, int32_t aDelta) if (aDelta == 0) return NS_OK; - nsRefPtr presContext(PresContext()); + RefPtr presContext(PresContext()); nsBoxLayoutState state(presContext); // begin timing how long it takes to scroll a row diff --git a/layout/xul/nsListBoxBodyFrame.h b/layout/xul/nsListBoxBodyFrame.h index 479261a216..89586f3d66 100644 --- a/layout/xul/nsListBoxBodyFrame.h +++ b/layout/xul/nsListBoxBodyFrame.h @@ -178,7 +178,7 @@ protected: int32_t ToRowIndex(nscoord aPos) const; void RemoveChildFrame(nsBoxLayoutState &aState, nsIFrame *aChild); - nsTArray< nsRefPtr > mPendingPositionChangeEvents; + nsTArray< RefPtr > mPendingPositionChangeEvents; nsCOMPtr mBoxObject; // frame markers diff --git a/layout/xul/nsListBoxLayout.cpp b/layout/xul/nsListBoxLayout.cpp index 97939ef78e..58224d7d0f 100644 --- a/layout/xul/nsListBoxLayout.cpp +++ b/layout/xul/nsListBoxLayout.cpp @@ -207,6 +207,6 @@ nsListBoxLayout::LayoutInternal(nsIFrame* aBox, nsBoxLayoutState& aState) already_AddRefed NS_NewListBoxLayout() { - nsRefPtr layout = new nsListBoxLayout(); + RefPtr layout = new nsListBoxLayout(); return layout.forget(); } diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index 2b8c85a956..65621534b0 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -95,7 +95,7 @@ public: domEventToFire.AssignLiteral("DOMMenuItemInactive"); } - nsRefPtr event = NS_NewDOMEvent(mMenu, mPresContext, nullptr); + RefPtr event = NS_NewDOMEvent(mMenu, mPresContext, nullptr); event->InitEvent(domEventToFire, true, true); event->SetTrusted(true); @@ -108,7 +108,7 @@ public: private: nsCOMPtr mMenu; - nsRefPtr mPresContext; + RefPtr mPresContext; bool mIsActivate; }; diff --git a/layout/xul/nsMenuFrame.h b/layout/xul/nsMenuFrame.h index 32d3eb6d03..7f0128a31f 100644 --- a/layout/xul/nsMenuFrame.h +++ b/layout/xul/nsMenuFrame.h @@ -273,13 +273,13 @@ protected: nsMenuType mType; // Reference to the mediator which wraps this frame. - nsRefPtr mTimerMediator; + RefPtr mTimerMediator; nsCOMPtr mOpenTimer; nsCOMPtr mBlinkTimer; uint8_t mBlinkState; // 0: not blinking, 1: off, 2: on - nsRefPtr mDelayedMenuCommandEvent; + RefPtr mDelayedMenuCommandEvent; nsString mGroupName; diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index d5b6aa7e15..ad45b3de19 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -358,7 +358,7 @@ NS_IMETHODIMP nsXULPopupShownEvent::HandleEvent(nsIDOMEvent* aEvent) if (popup) { // ResetPopupShownDispatcher will delete the reference to this, so keep // another one until Run is finished. - nsRefPtr event = this; + RefPtr event = this; // Only call Run if it the dispatcher was assigned. This avoids calling the // Run method if the transitionend event fires multiple times. if (popup->ClearPopupShownDispatcher()) { diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index a576f293c0..ac1cdefe74 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -156,7 +156,7 @@ protected: private: nsCOMPtr mPopup; - nsRefPtr mPresContext; + RefPtr mPresContext; }; class nsMenuPopupFrame final : public nsBoxFrame, public nsMenuParent, @@ -510,7 +510,7 @@ protected: nsMenuFrame* mCurrentMenu; // The current menu that is active. - nsRefPtr mPopupShownDispatcher; + RefPtr mPopupShownDispatcher; // A popup's preferred size may be different than its actual size stored in // mRect in the case where the popup was resized because it was too large diff --git a/layout/xul/nsSliderFrame.h b/layout/xul/nsSliderFrame.h index 1cbdda275f..e6e7fe15cc 100644 --- a/layout/xul/nsSliderFrame.h +++ b/layout/xul/nsSliderFrame.h @@ -171,7 +171,7 @@ private: void PageScroll(nscoord aChange); nsPoint mDestinationPoint; - nsRefPtr mMediator; + RefPtr mMediator; float mRatio; diff --git a/layout/xul/nsSplitterFrame.cpp b/layout/xul/nsSplitterFrame.cpp index 1057a7ad5b..f8ddcdf00b 100644 --- a/layout/xul/nsSplitterFrame.cpp +++ b/layout/xul/nsSplitterFrame.cpp @@ -288,7 +288,7 @@ nsSplitterFrame::Init(nsIContent* aContent, aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient, NS_LITERAL_STRING("vertical"), false); nsStyleContext* parentStyleContext = StyleContext()->GetParent(); - nsRefPtr newContext = PresContext()->StyleSet()-> + RefPtr newContext = PresContext()->StyleSet()-> ResolveStyleFor(aContent->AsElement(), parentStyleContext); SetStyleContextWithoutNotification(newContext); } @@ -387,7 +387,7 @@ nsSplitterFrame::HandleEvent(nsPresContext* aPresContext, } nsWeakFrame weakFrame(this); - nsRefPtr kungFuDeathGrip(mInner); + RefPtr kungFuDeathGrip(mInner); switch (aEvent->mMessage) { case eMouseMove: mInner->MouseDrag(aPresContext, aEvent); diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 778850ee5d..4968e3ba3b 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -455,7 +455,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext, } while (0 != decorMask && (f = nsLayoutUtils::GetParentOrPlaceholderFor(f))); - nsRefPtr fontMet; + RefPtr fontMet; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)); nscoord offset; @@ -474,7 +474,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext, presContext->RoundAppUnitsToNearestDevPixels(aTextRect.y + ascent); } - nsRefPtr ctx = aRenderingContext.ThebesContext(); + RefPtr ctx = aRenderingContext.ThebesContext(); gfxPoint pt(presContext->AppUnitsToGfxUnits(aTextRect.x), presContext->AppUnitsToGfxUnits(aTextRect.y)); gfxFloat width = presContext->AppUnitsToGfxUnits(aTextRect.width); @@ -627,7 +627,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsPresContext* aPresContext, return 0; } - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); // see if the text will completely fit in the width given @@ -956,7 +956,7 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState) nsRect scrollBounds(nsPoint(0, 0), GetSize()); nsRect textRect = mTextDrawRect; - nsRefPtr fontMet; + RefPtr fontMet; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)); nsBoundingMetrics metrics = fontMet->GetInkBoundsForVisualOverflow(mCroppedTitle.get(), @@ -1018,7 +1018,7 @@ nsTextBoxFrame::GetTextSize(nsPresContext* aPresContext, const nsString& aString, nsSize& aSize, nscoord& aAscent) { - nsRefPtr fontMet; + RefPtr fontMet; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)); aSize.height = fontMet->MaxHeight(); aSize.width = diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index e1f091c3e1..a0c97a9192 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -292,7 +292,7 @@ nsXULPopupManager::Rollup(uint32_t aCount, bool aFlush, } nsPresContext* presContext = item->Frame()->PresContext(); - nsRefPtr viewManager = presContext->PresShell()->GetViewManager(); + RefPtr viewManager = presContext->PresShell()->GetViewManager(); HidePopup(item->Content(), true, true, false, true, lastPopup); @@ -841,7 +841,7 @@ CheckCaretDrawingState() if (!presShell) return; - nsRefPtr caret = presShell->GetCaret(); + RefPtr caret = presShell->GetCaret(); if (!caret) return; caret->SchedulePaint(); @@ -1500,7 +1500,7 @@ nsXULPopupManager::FirePopupHidingEvent(nsIContent* aPopup, return; if (nsLayoutUtils::HasCurrentTransitions(popupFrame)) { - nsRefPtr ender = new TransitionEnder(aPopup, aDeselectMenu); + RefPtr ender = new TransitionEnder(aPopup, aDeselectMenu); aPopup->AddSystemEventListener(NS_LITERAL_STRING("transitionend"), ender, false, false); return; @@ -1893,7 +1893,7 @@ nsXULPopupManager::UpdateMenuItems(nsIContent* aPopup) grandChild->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command); if (!command.IsEmpty()) { // We do! Look it up in our document - nsRefPtr commandElement = + RefPtr commandElement = document->GetElementById(command); if (commandElement) { nsAutoString commandValue; @@ -2661,7 +2661,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsRefPtr kungFuDeathGrip = shell->GetViewManager(); + RefPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp index 0f25c5845c..7f278ffb65 100644 --- a/layout/xul/nsXULTooltipListener.cpp +++ b/layout/xul/nsXULTooltipListener.cpp @@ -697,7 +697,7 @@ nsXULTooltipListener::KillTooltipTimer() void nsXULTooltipListener::sTooltipCallback(nsITimer *aTimer, void *aListener) { - nsRefPtr instance = mInstance; + RefPtr instance = mInstance; if (instance) instance->ShowTooltip(); } diff --git a/layout/xul/tree/TreeBoxObject.cpp b/layout/xul/tree/TreeBoxObject.cpp index 61f3db24f1..730bdf5017 100644 --- a/layout/xul/tree/TreeBoxObject.cpp +++ b/layout/xul/tree/TreeBoxObject.cpp @@ -575,7 +575,7 @@ TreeBoxObject::GetCoordsForCellItem(int32_t row, nsTreeColumn& col, const nsAStr { int32_t x, y, w, h; GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h); - nsRefPtr rect = new DOMRect(mContent, x, y, w, h); + RefPtr rect = new DOMRect(mContent, x, y, w, h); return rect.forget(); } diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 13f0fb4f68..34920a76aa 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -598,7 +598,7 @@ nsTreeBodyFrame::GetSelectionRegion(nsIScriptableRegion **aRegion) NS_ENSURE_TRUE(region, NS_ERROR_FAILURE); region->Init(); - nsRefPtr presContext = PresContext(); + RefPtr presContext = PresContext(); nsIntRect rect = mRect.ToOutsidePixels(presContext->AppUnitsPerCSSPixel()); nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame(); @@ -643,7 +643,7 @@ nsTreeBodyFrame::InvalidateColumn(nsITreeColumn* aCol) if (mUpdateBatchNest) return NS_OK; - nsRefPtr col = GetColumnImpl(aCol); + RefPtr col = GetColumnImpl(aCol); if (!col) return NS_ERROR_INVALID_ARG; @@ -699,7 +699,7 @@ nsTreeBodyFrame::InvalidateCell(int32_t aIndex, nsITreeColumn* aCol) if (aIndex < 0 || aIndex > mPageLength) return NS_OK; - nsRefPtr col = GetColumnImpl(aCol); + RefPtr col = GetColumnImpl(aCol); if (!col) return NS_ERROR_INVALID_ARG; @@ -753,7 +753,7 @@ nsTreeBodyFrame::InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColu if (mUpdateBatchNest) return NS_OK; - nsRefPtr col = GetColumnImpl(aCol); + RefPtr col = GetColumnImpl(aCol); if (!col) return NS_ERROR_INVALID_ARG; @@ -912,7 +912,7 @@ nsTreeBodyFrame::CheckOverflow(const ScrollParts& aParts) nsWeakFrame weakFrame(this); - nsRefPtr presContext = PresContext(); + RefPtr presContext = PresContext(); nsCOMPtr presShell = presContext->GetPresShell(); nsCOMPtr content = mContent; @@ -1250,7 +1250,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n // we add in borders and padding to the text dimension and give that back. nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(textContext, getter_AddRefs(fm)); nscoord height = fm->MaxHeight(); @@ -1621,7 +1621,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect, AdjustForBorderPadding(textContext, textRect); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(textContext, getter_AddRefs(fm)); AdjustForCellText(cellText, aRowIndex, aColumn, rc, *fm, textRect); @@ -1749,7 +1749,7 @@ nsTreeBodyFrame::GetCellWidth(int32_t aRow, nsTreeColumn* aCol, // Get the borders and padding for the text. GetBorderPadding(textContext, bp); - nsRefPtr fm; + RefPtr fm; nsLayoutUtils::GetFontMetricsForStyleContext(textContext, getter_AddRefs(fm)); // Get the width of the text itself @@ -1766,7 +1766,7 @@ nsTreeBodyFrame::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *_retval) nscoord currentSize, desiredSize; nsresult rv; - nsRefPtr col = GetColumnImpl(aCol); + RefPtr col = GetColumnImpl(aCol); if (!col) return NS_ERROR_INVALID_ARG; @@ -2113,7 +2113,7 @@ nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContex nsAutoString imageSrc; mView->GetImageSrc(aRowIndex, aCol, imageSrc); - nsRefPtr styleRequest; + RefPtr styleRequest; if (!aUseContext && !imageSrc.IsEmpty()) { aAllowImageRegions = false; } @@ -2171,7 +2171,7 @@ nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContex listener->AddCell(aRowIndex, aCol); nsCOMPtr imgNotificationObserver = listener; - nsRefPtr imageRequest; + RefPtr imageRequest; if (styleRequest) { styleRequest->Clone(imgNotificationObserver, getter_AddRefs(imageRequest)); } else { @@ -3627,7 +3627,7 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex, textRect.Deflate(bp); // Compute our text size. - nsRefPtr fontMet; + RefPtr fontMet; nsLayoutUtils::GetFontMetricsForStyleContext(textContext, getter_AddRefs(fontMet)); @@ -4019,7 +4019,7 @@ nsresult nsTreeBodyFrame::EnsureRowIsVisibleInternal(const ScrollParts& aParts, nsresult nsTreeBodyFrame::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol) { - nsRefPtr col = GetColumnImpl(aCol); + RefPtr col = GetColumnImpl(aCol); if (!col) return NS_ERROR_INVALID_ARG; @@ -4083,7 +4083,7 @@ nsTreeBodyFrame::ScrollToColumn(nsITreeColumn* aCol) nsresult nsTreeBodyFrame::ScrollToColumnInternal(const ScrollParts& aParts, nsITreeColumn* aCol) { - nsRefPtr col = GetColumnImpl(aCol); + RefPtr col = GetColumnImpl(aCol); if (!col) return NS_ERROR_INVALID_ARG; @@ -4562,7 +4562,7 @@ nsTreeBodyFrame::PostScrollEvent() if (mScrollEvent.IsPending()) return; - nsRefPtr ev = new ScrollEvent(this); + RefPtr ev = new ScrollEvent(this); if (NS_FAILED(NS_DispatchToCurrentThread(ev))) { NS_WARNING("failed to dispatch ScrollEvent"); } else { @@ -4642,7 +4642,7 @@ nsTreeBodyFrame::FireRowCountChangedEvent(int32_t aIndex, int32_t aCount) event->SetTrusted(true); - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(content, event); asyncDispatcher->PostDOMEvent(); } @@ -4714,7 +4714,7 @@ nsTreeBodyFrame::FireInvalidateEvent(int32_t aStartRowIdx, int32_t aEndRowIdx, event->SetTrusted(true); - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(content, event); asyncDispatcher->PostDOMEvent(); } @@ -4755,7 +4755,7 @@ nsTreeBodyFrame::FullScrollbarsUpdate(bool aNeedsFullInvalidation) // recursion during reflow. Do the first overflow check synchronously, but // force any nested checks to round-trip through the event loop. See bug // 905909. - nsRefPtr checker = new nsOverflowChecker(this); + RefPtr checker = new nsOverflowChecker(this); if (!mCheckingOverflow) { nsContentUtils::AddScriptRunner(checker); } else { diff --git a/layout/xul/tree/nsTreeBodyFrame.h b/layout/xul/tree/nsTreeBodyFrame.h index c38e23fd3f..c2dc678f87 100644 --- a/layout/xul/tree/nsTreeBodyFrame.h +++ b/layout/xul/tree/nsTreeBodyFrame.h @@ -71,7 +71,7 @@ public: // non-virtual signatures like nsITreeBodyFrame already_AddRefed Columns() const { - nsRefPtr cols = mColumns; + RefPtr cols = mColumns; return cols.forget(); } already_AddRefed GetExistingView() const @@ -559,13 +559,13 @@ protected: // Data Members nsRevocableEventPtr mScrollEvent; - nsRefPtr mScrollbarActivity; + RefPtr mScrollbarActivity; // The cached box object parent. nsCOMPtr mTreeBoxObject; // Cached column information. - nsRefPtr mColumns; + RefPtr mColumns; // The current view for this tree widget. We get all of our row and cell data // from the view. diff --git a/layout/xul/tree/nsTreeColumns.h b/layout/xul/tree/nsTreeColumns.h index ae4afee2d7..00f77f7be5 100644 --- a/layout/xul/tree/nsTreeColumns.h +++ b/layout/xul/tree/nsTreeColumns.h @@ -144,7 +144,7 @@ private: int8_t mCropStyle; int8_t mTextAlignment; - nsRefPtr mNext; + RefPtr mNext; nsTreeColumn* mPrevious; }; diff --git a/layout/xul/tree/nsTreeContentView.cpp b/layout/xul/tree/nsTreeContentView.cpp index 1730838d19..c0a95bda68 100644 --- a/layout/xul/tree/nsTreeContentView.cpp +++ b/layout/xul/tree/nsTreeContentView.cpp @@ -21,7 +21,7 @@ using namespace mozilla; #define NS_ENSURE_NATIVE_COLUMN(_col) \ - nsRefPtr col = nsTreeBodyFrame::GetColumnImpl(_col); \ + RefPtr col = nsTreeBodyFrame::GetColumnImpl(_col); \ if (!col) { \ return NS_ERROR_INVALID_ARG; \ } diff --git a/layout/xul/tree/nsTreeSelection.cpp b/layout/xul/tree/nsTreeSelection.cpp index 10ffa06e6b..fbae1a9dec 100644 --- a/layout/xul/tree/nsTreeSelection.cpp +++ b/layout/xul/tree/nsTreeSelection.cpp @@ -648,7 +648,7 @@ NS_IMETHODIMP nsTreeSelection::SetCurrentIndex(int32_t aIndex) NS_NAMED_LITERAL_STRING(DOMMenuItemActive, "DOMMenuItemActive"); NS_NAMED_LITERAL_STRING(DOMMenuItemInactive, "DOMMenuItemInactive"); - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(treeDOMNode, (aIndex != -1 ? DOMMenuItemActive : DOMMenuItemInactive), @@ -837,7 +837,7 @@ nsTreeSelection::FireOnSelectHandler() nsCOMPtr node(do_QueryInterface(elt)); NS_ENSURE_STATE(node); - nsRefPtr asyncDispatcher = + RefPtr asyncDispatcher = new AsyncEventDispatcher(node, NS_LITERAL_STRING("select"), true, false); asyncDispatcher->RunDOMEventWhenSafe(); return NS_OK; @@ -846,7 +846,7 @@ nsTreeSelection::FireOnSelectHandler() void nsTreeSelection::SelectCallback(nsITimer *aTimer, void *aClosure) { - nsRefPtr self = static_cast(aClosure); + RefPtr self = static_cast(aClosure); if (self) { self->FireOnSelectHandler(); aTimer->Cancel(); diff --git a/layout/xul/tree/nsTreeStyleCache.cpp b/layout/xul/tree/nsTreeStyleCache.cpp index b8b2ec8db4..96aa489fee 100644 --- a/layout/xul/tree/nsTreeStyleCache.cpp +++ b/layout/xul/tree/nsTreeStyleCache.cpp @@ -76,7 +76,7 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator, } if (!result) { // We missed the cache. Resolve this pseudo-style. - nsRefPtr newResult = aPresContext->StyleSet()-> + RefPtr newResult = aPresContext->StyleSet()-> ResolveXULTreePseudoStyle(aContent->AsElement(), aPseudoElement, aContext, aComparator); diff --git a/media/gmp-clearkey/0.1/ClearKeySessionManager.h b/media/gmp-clearkey/0.1/ClearKeySessionManager.h index 7c11db694b..5e007cba90 100644 --- a/media/gmp-clearkey/0.1/ClearKeySessionManager.h +++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.h @@ -76,7 +76,7 @@ private: void ClearInMemorySessionData(ClearKeySession* aSession); void Serialize(const ClearKeySession* aSession, std::vector& aOutKeyData); - mozilla::RefPtr mDecryptionManager; + RefPtr mDecryptionManager; GMPDecryptorCallback* mCallback; GMPThread* mThread; diff --git a/media/libstagefright/binding/AnnexB.cpp b/media/libstagefright/binding/AnnexB.cpp index e8d404d798..82ca2ff9c7 100644 --- a/media/libstagefright/binding/AnnexB.cpp +++ b/media/libstagefright/binding/AnnexB.cpp @@ -59,7 +59,7 @@ AnnexB::ConvertSampleToAnnexB(mozilla::MediaRawData* aSample) // Prepend the Annex B NAL with SPS and PPS tables to keyframes. if (aSample->mKeyframe) { - nsRefPtr annexB = + RefPtr annexB = ConvertExtraDataToAnnexB(aSample->mExtraData); if (!samplewriter->Prepend(annexB->Elements(), annexB->Length())) { return false; @@ -87,7 +87,7 @@ AnnexB::ConvertExtraDataToAnnexB(const mozilla::MediaByteBuffer* aExtraData) // [5] | unused | numSps | // +------+------+------+------+------+------+------+------+ - nsRefPtr annexB = new mozilla::MediaByteBuffer; + RefPtr annexB = new mozilla::MediaByteBuffer; ByteReader reader(*aExtraData); const uint8_t* ptr = reader.Read(5); @@ -236,7 +236,7 @@ AnnexB::ConvertSampleToAVCC(mozilla::MediaRawData* aSample) already_AddRefed AnnexB::ExtractExtraData(const mozilla::MediaRawData* aSample) { - nsRefPtr extradata = new mozilla::MediaByteBuffer; + RefPtr extradata = new mozilla::MediaByteBuffer; if (IsAVCC(aSample) && HasSPS(aSample->mExtraData)) { // We already have an explicit extradata, re-use it. extradata = aSample->mExtraData; diff --git a/media/libstagefright/binding/H264.cpp b/media/libstagefright/binding/H264.cpp index ce8d555389..91c9798ed9 100644 --- a/media/libstagefright/binding/H264.cpp +++ b/media/libstagefright/binding/H264.cpp @@ -91,7 +91,7 @@ H264::DecodeNALUnit(const mozilla::MediaByteBuffer* aNAL) return nullptr; } - nsRefPtr rbsp = new mozilla::MediaByteBuffer; + RefPtr rbsp = new mozilla::MediaByteBuffer; ByteReader reader(aNAL); uint8_t nal_unit_type = reader.ReadU8() & 0x1f; uint32_t nalUnitHeaderBytes = 1; @@ -490,10 +490,10 @@ H264::DecodeSPSFromExtraData(const mozilla::MediaByteBuffer* aExtraData, SPSData return false; } - nsRefPtr rawNAL = new mozilla::MediaByteBuffer; + RefPtr rawNAL = new mozilla::MediaByteBuffer; rawNAL->AppendElements(ptr, length); - nsRefPtr sps = DecodeNALUnit(rawNAL); + RefPtr sps = DecodeNALUnit(rawNAL); reader.DiscardRemaining(); diff --git a/media/libstagefright/binding/Index.cpp b/media/libstagefright/binding/Index.cpp index 9343b9a419..e532058438 100644 --- a/media/libstagefright/binding/Index.cpp +++ b/media/libstagefright/binding/Index.cpp @@ -8,7 +8,7 @@ #include "mp4_demuxer/MoofParser.h" #include "mp4_demuxer/SinfParser.h" #include "nsAutoPtr.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include #include @@ -98,7 +98,7 @@ already_AddRefed SampleIterator::GetNext() return nullptr; } - nsRefPtr sample = new MediaRawData(); + RefPtr sample = new MediaRawData(); sample->mTimecode= s->mDecodeTime; sample->mTime = s->mCompositionRange.start; sample->mDuration = s->mCompositionRange.Length(); diff --git a/media/libstagefright/binding/MP4Metadata.cpp b/media/libstagefright/binding/MP4Metadata.cpp index 1ce840273d..1b97e0723b 100644 --- a/media/libstagefright/binding/MP4Metadata.cpp +++ b/media/libstagefright/binding/MP4Metadata.cpp @@ -63,7 +63,7 @@ public: virtual status_t reconnectAtOffset(off64_t offset) { return NO_ERROR; } private: - nsRefPtr mSource; + RefPtr mSource; }; static inline bool diff --git a/media/libstagefright/binding/MoofParser.cpp b/media/libstagefright/binding/MoofParser.cpp index 12c7944e4c..4f519a9671 100644 --- a/media/libstagefright/binding/MoofParser.cpp +++ b/media/libstagefright/binding/MoofParser.cpp @@ -120,7 +120,7 @@ public: } private: - nsRefPtr mStream; + RefPtr mStream; }; bool @@ -130,7 +130,7 @@ MoofParser::BlockingReadNextMoof() mSource->Length(&length); nsTArray byteRanges; byteRanges.AppendElement(MediaByteRange(0, length)); - nsRefPtr stream = new BlockingStream(mSource); + RefPtr stream = new BlockingStream(mSource); BoxContext context(stream, byteRanges); for (Box box(&context, mOffset); box.IsAvailable(); box = box.Next()) { @@ -151,7 +151,7 @@ MoofParser::ScanForMetadata(mozilla::MediaByteRange& aFtyp, mSource->Length(&length); nsTArray byteRanges; byteRanges.AppendElement(MediaByteRange(0, length)); - nsRefPtr stream = new BlockingStream(mSource); + RefPtr stream = new BlockingStream(mSource); BoxContext context(stream, byteRanges); for (Box box(&context, mOffset); box.IsAvailable(); box = box.Next()) { @@ -185,13 +185,13 @@ MoofParser::Metadata() if (!ftyp.Length() || !moov.Length()) { return nullptr; } - nsRefPtr metadata = new MediaByteBuffer(); + RefPtr metadata = new MediaByteBuffer(); if (!metadata->SetLength(ftyp.Length() + moov.Length(), fallible)) { // OOM return nullptr; } - nsRefPtr stream = new BlockingStream(mSource); + RefPtr stream = new BlockingStream(mSource); size_t read; bool rv = stream->ReadAt(ftyp.mStart, metadata->Elements(), ftyp.Length(), &read); diff --git a/media/libstagefright/binding/include/mp4_demuxer/Box.h b/media/libstagefright/binding/include/mp4_demuxer/Box.h index e94d10ae09..edc5d1d0ee 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/Box.h +++ b/media/libstagefright/binding/include/mp4_demuxer/Box.h @@ -28,7 +28,7 @@ public: { } - nsRefPtr mSource; + RefPtr mSource; const nsTArray& mByteRanges; }; diff --git a/media/libstagefright/binding/include/mp4_demuxer/BufferStream.h b/media/libstagefright/binding/include/mp4_demuxer/BufferStream.h index 659027d22c..bb703db5d6 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/BufferStream.h +++ b/media/libstagefright/binding/include/mp4_demuxer/BufferStream.h @@ -39,7 +39,7 @@ public: private: ~BufferStream(); int64_t mStartOffset; - nsRefPtr mData; + RefPtr mData; }; } diff --git a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index 72ca168511..d8c866b3fd 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -9,7 +9,7 @@ #include "MediaInfo.h" #include "mozilla/Types.h" #include "mozilla/Vector.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsString.h" #include "nsString.h" #include "nsTArray.h" diff --git a/media/libstagefright/binding/include/mp4_demuxer/Index.h b/media/libstagefright/binding/include/mp4_demuxer/Index.h index c958a35a89..33f2e4b09a 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/Index.h +++ b/media/libstagefright/binding/include/mp4_demuxer/Index.h @@ -34,7 +34,7 @@ public: private: Sample* Get(); void Next(); - nsRefPtr mIndex; + RefPtr mIndex; size_t mCurrentMoof; size_t mCurrentSample; }; diff --git a/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h b/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h index f2cbfd6a34..33eda84fe2 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h +++ b/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h @@ -51,7 +51,7 @@ private: int32_t aIndex) const; nsAutoPtr mPrivate; CryptoFile mCrypto; - nsRefPtr mSource; + RefPtr mSource; }; } // namespace mp4_demuxer diff --git a/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h b/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h index 3d82701330..ee2a22d7fa 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h +++ b/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h @@ -235,7 +235,7 @@ public: MediaByteRange FirstCompleteMediaHeader(); mozilla::MediaByteRange mInitRange; - nsRefPtr mSource; + RefPtr mSource; uint64_t mOffset; nsTArray mMoofOffsets; Mvhd mMvhd; diff --git a/media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h b/media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h index ac4236f6d0..219465f178 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h +++ b/media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h @@ -7,7 +7,7 @@ #include "MediaResource.h" #include "mp4_demuxer/Stream.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" namespace mp4_demuxer { @@ -40,7 +40,7 @@ protected: virtual ~ResourceStream(); private: - nsRefPtr mResource; + RefPtr mResource; uint32_t mPinCount; }; diff --git a/media/mtransport/nr_socket_prsock.cpp b/media/mtransport/nr_socket_prsock.cpp index eed63b82dd..c327dde84e 100644 --- a/media/mtransport/nr_socket_prsock.cpp +++ b/media/mtransport/nr_socket_prsock.cpp @@ -908,7 +908,7 @@ abort: NS_IMPL_ISUPPORTS(NrSocketIpcProxy, nsIUDPSocketInternal) nsresult -NrSocketIpcProxy::Init(const nsRefPtr& socket) +NrSocketIpcProxy::Init(const RefPtr& socket) { nsresult rv; sts_thread_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); @@ -1048,7 +1048,7 @@ NS_IMETHODIMP NrSocketIpc::CallListenerReceivedData(const nsACString &host, RefPtr msg(new nr_udp_message(addr, buf)); RUN_ON_THREAD(sts_thread_, - mozilla::WrapRunnable(nsRefPtr(this), + mozilla::WrapRunnable(RefPtr(this), &NrSocketIpc::recv_callback_s, msg), NS_DISPATCH_NORMAL); @@ -1160,7 +1160,7 @@ int NrSocketIpc::create(nr_transport_addr *addr) { state_ = NR_CONNECTING; RUN_ON_THREAD(io_thread_, - mozilla::WrapRunnable(nsRefPtr(this), + mozilla::WrapRunnable(RefPtr(this), &NrSocketIpc::create_i, host, static_cast(port)), NS_DISPATCH_NORMAL); @@ -1203,7 +1203,7 @@ int NrSocketIpc::sendto(const void *msg, size_t len, int flags, nsAutoPtr buf(new DataBuffer(static_cast(msg), len)); RUN_ON_THREAD(io_thread_, - mozilla::WrapRunnable(nsRefPtr(this), + mozilla::WrapRunnable(RefPtr(this), &NrSocketIpc::sendto_i, addr, buf), NS_DISPATCH_NORMAL); @@ -1217,7 +1217,7 @@ void NrSocketIpc::close() { state_ = NR_CLOSING; RUN_ON_THREAD(io_thread_, - mozilla::WrapRunnable(nsRefPtr(this), + mozilla::WrapRunnable(RefPtr(this), &NrSocketIpc::close_i), NS_DISPATCH_NORMAL); @@ -1330,7 +1330,7 @@ void NrSocketIpc::create_i(const nsACString &host, const uint16_t port) { socketChild = nullptr; } - nsRefPtr proxy(new NrSocketIpcProxy); + RefPtr proxy(new NrSocketIpcProxy); rv = proxy->Init(this); if (NS_FAILED(rv)) { err_ = true; @@ -1381,7 +1381,7 @@ void NrSocketIpc::close_i() { // static void NrSocketIpc::release_child_i(nsIUDPSocketChild* aChild, nsCOMPtr sts_thread) { - nsRefPtr socket_child_ref = + RefPtr socket_child_ref = already_AddRefed(aChild); if (socket_child_ref) { socket_child_ref->Close(); diff --git a/media/mtransport/nr_socket_prsock.h b/media/mtransport/nr_socket_prsock.h index 36543d3bd9..4e8b041c1e 100644 --- a/media/mtransport/nr_socket_prsock.h +++ b/media/mtransport/nr_socket_prsock.h @@ -260,7 +260,7 @@ private: NrSocketIpcState state_; std::queue > received_msgs_; - nsRefPtr socket_child_; // only accessed from the io_thread + RefPtr socket_child_; // only accessed from the io_thread nsCOMPtr sts_thread_; const nsCOMPtr io_thread_; ReentrantMonitor monitor_; @@ -273,12 +273,12 @@ public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIUDPSOCKETINTERNAL - nsresult Init(const nsRefPtr& socket); + nsresult Init(const RefPtr& socket); private: virtual ~NrSocketIpcProxy(); - nsRefPtr socket_; + RefPtr socket_; nsCOMPtr sts_thread_; }; diff --git a/media/mtransport/nriceresolver.cpp b/media/mtransport/nriceresolver.cpp index f5e74eec2b..0bea3b8d06 100644 --- a/media/mtransport/nriceresolver.cpp +++ b/media/mtransport/nriceresolver.cpp @@ -149,7 +149,7 @@ int NrIceResolver::resolve(nr_resolver_resource *resource, int _status; MOZ_ASSERT(allocated_resolvers_ > 0); ASSERT_ON_THREAD(sts_thread_); - nsRefPtr pr; + RefPtr pr; uint32_t resolve_flags = 0; if (resource->transport_protocol != IPPROTO_UDP && diff --git a/media/mtransport/runnable_utils.h b/media/mtransport/runnable_utils.h index 3733fcbeb1..df0d42b8a9 100644 --- a/media/mtransport/runnable_utils.h +++ b/media/mtransport/runnable_utils.h @@ -244,7 +244,7 @@ public: return NS_OK; } private: - nsRefPtr ref_; + RefPtr ref_; }; template diff --git a/media/mtransport/test/TestSyncRunnable.cpp b/media/mtransport/test/TestSyncRunnable.cpp index f466ed963f..4215ccfdcc 100644 --- a/media/mtransport/test/TestSyncRunnable.cpp +++ b/media/mtransport/test/TestSyncRunnable.cpp @@ -46,8 +46,8 @@ public: TEST_F(TestSyncRunnable, TestDispatch) { - nsRefPtr r(new TestRunnable()); - nsRefPtr s(new SyncRunnable(r)); + RefPtr r(new TestRunnable()); + RefPtr s(new SyncRunnable(r)); s->DispatchToThread(gThread); ASSERT_TRUE(r->ran()); @@ -55,7 +55,7 @@ TEST_F(TestSyncRunnable, TestDispatch) TEST_F(TestSyncRunnable, TestDispatchStatic) { - nsRefPtr r(new TestRunnable()); + RefPtr r(new TestRunnable()); SyncRunnable::DispatchToThread(gThread, r); ASSERT_TRUE(r->ran()); } diff --git a/media/mtransport/test/buffered_stun_socket_unittest.cpp b/media/mtransport/test/buffered_stun_socket_unittest.cpp index 40e9e31b48..ad00715cab 100644 --- a/media/mtransport/test/buffered_stun_socket_unittest.cpp +++ b/media/mtransport/test/buffered_stun_socket_unittest.cpp @@ -54,7 +54,7 @@ class BufferedStunSocketTest : public ::testing::Test { } void SetUp() { - nsRefPtr dummy(new DummySocket()); + RefPtr dummy(new DummySocket()); int r = nr_socket_buffered_stun_create( dummy->get_nr_socket(), @@ -76,7 +76,7 @@ class BufferedStunSocketTest : public ::testing::Test { nr_socket *socket() { return test_socket_; } protected: - nsRefPtr dummy_; + RefPtr dummy_; nr_socket *test_socket_; nr_transport_addr remote_addr_; }; diff --git a/media/mtransport/test/ice_unittest.cpp b/media/mtransport/test/ice_unittest.cpp index e7a20e557a..d7ada0b6af 100644 --- a/media/mtransport/test/ice_unittest.cpp +++ b/media/mtransport/test/ice_unittest.cpp @@ -301,7 +301,7 @@ class IceTestPeer : public sigslot::has_slots<> { snprintf(name, sizeof(name), "%s:stream%d", name_.c_str(), (int)streams_.size()); - mozilla::RefPtr stream = + RefPtr stream = ice_ctx_->CreateStream(static_cast(name), components); ice_ctx_->SetStream(streams_.size(), stream); @@ -798,7 +798,7 @@ class IceTestPeer : public sigslot::has_slots<> { // If we are connected, then try to trickle to the // other side. if (remote_ && remote_->remote_ && (trickle_mode_ != TRICKLE_SIMULATE)) { - std::vector >::iterator it = + std::vector >::iterator it = std::find(streams_.begin(), streams_.end(), stream); ASSERT_NE(streams_.end(), it); size_t index = it - streams_.begin(); @@ -1063,8 +1063,8 @@ class IceTestPeer : public sigslot::has_slots<> { private: std::string name_; - nsRefPtr ice_ctx_; - std::vector > streams_; + RefPtr ice_ctx_; + std::vector > streams_; std::map > candidates_; // Maps from stream id to list of remote trickle candidates std::map > @@ -1076,7 +1076,7 @@ class IceTestPeer : public sigslot::has_slots<> { size_t received_; size_t sent_; NrIceResolverFake fake_resolver_; - nsRefPtr dns_resolver_; + RefPtr dns_resolver_; IceTestPeer *remote_; CandidateFilter candidate_filter_; NrIceCandidate::Type expected_local_type_; @@ -1087,7 +1087,7 @@ class IceTestPeer : public sigslot::has_slots<> { TrickleMode trickle_mode_; int trickled_; bool simulate_ice_lite_; - nsRefPtr nat_; + RefPtr nat_; }; void SchedulableTrickleCandidate::Trickle() { diff --git a/media/mtransport/test/multi_tcp_socket_unittest.cpp b/media/mtransport/test/multi_tcp_socket_unittest.cpp index bc6535ab3d..0be1f28ce1 100644 --- a/media/mtransport/test/multi_tcp_socket_unittest.cpp +++ b/media/mtransport/test/multi_tcp_socket_unittest.cpp @@ -266,7 +266,7 @@ class MultiTcpSocketTest : public ::testing::Test { } std::vector socks; Atomic readable; - nsRefPtr ice_ctx_; + RefPtr ice_ctx_; }; } diff --git a/media/mtransport/test/proxy_tunnel_socket_unittest.cpp b/media/mtransport/test/proxy_tunnel_socket_unittest.cpp index 2705af3b73..a5af236787 100644 --- a/media/mtransport/test/proxy_tunnel_socket_unittest.cpp +++ b/media/mtransport/test/proxy_tunnel_socket_unittest.cpp @@ -116,7 +116,7 @@ class ProxyTunnelSocketTest : public ::testing::Test { } void SetUp() { - nsRefPtr dummy(new DummySocket()); + RefPtr dummy(new DummySocket()); nr_resolver_ = resolver_impl_.get_nr_resolver(); @@ -144,7 +144,7 @@ class ProxyTunnelSocketTest : public ::testing::Test { nr_socket *socket() { return nr_socket_; } protected: - nsRefPtr socket_impl_; + RefPtr socket_impl_; DummyResolver resolver_impl_; nr_socket *nr_socket_; nr_resolver *nr_resolver_; @@ -181,7 +181,7 @@ TEST_F(ProxyTunnelSocketTest, TestConnectProxyHostRequest) { int r = nr_socket_destroy(&nr_socket_); ASSERT_EQ(0, r); - nsRefPtr dummy(new DummySocket()); + RefPtr dummy(new DummySocket()); nr_proxy_tunnel_config_set_proxy(config_, kProxyHost.c_str(), kProxyPort); diff --git a/media/mtransport/test/sctp_unittest.cpp b/media/mtransport/test/sctp_unittest.cpp index a27faf3a0d..dfadace063 100644 --- a/media/mtransport/test/sctp_unittest.cpp +++ b/media/mtransport/test/sctp_unittest.cpp @@ -199,7 +199,7 @@ class TransportTestPeer : public sigslot::has_slots<> { bool connected() const { return connected_; } static TransportResult SendPacket_s(const unsigned char* data, size_t len, - const mozilla::RefPtr& flow) { + const RefPtr& flow) { TransportResult res = flow->SendPacket(data, len); delete data; // we always allocate return res; @@ -288,14 +288,14 @@ class TransportTestPeer : public sigslot::has_slots<> { bool connected_; size_t sent_; size_t received_; - mozilla::RefPtr flow_; + RefPtr flow_; TransportLayerLoopback *loopback_; struct sockaddr_conn local_addr_; struct sockaddr_conn remote_addr_; struct socket *sctp_; nsCOMPtr timer_; - nsRefPtr periodic_; + RefPtr periodic_; }; diff --git a/media/mtransport/test/stunserver.h b/media/mtransport/test/stunserver.h index ad8cfb8b82..93fed74d8b 100644 --- a/media/mtransport/test/stunserver.h +++ b/media/mtransport/test/stunserver.h @@ -97,7 +97,7 @@ class TestStunTcpServer: public TestStunServer { TestStunTcpServer() : ice_ctx_(nullptr) {} - nsRefPtr ice_ctx_; + RefPtr ice_ctx_; private: virtual int TryOpenListenSocket(nr_local_addr* addr, uint16_t port); static TestStunTcpServer *Create(int address_family); diff --git a/media/mtransport/test/test_nr_socket_unittest.cpp b/media/mtransport/test/test_nr_socket_unittest.cpp index 425ec39fb3..8a16712664 100644 --- a/media/mtransport/test/test_nr_socket_unittest.cpp +++ b/media/mtransport/test/test_nr_socket_unittest.cpp @@ -61,11 +61,11 @@ class TestNrSocketTest : public ::testing::Test { sts_ = nullptr; } - nsRefPtr CreateTestNrSocket_s(const char *ip_str, + RefPtr CreateTestNrSocket_s(const char *ip_str, TestNat *nat) { // If no nat is supplied, we create a default NAT which is disabled. This // is how we simulate a non-natted socket. - nsRefPtr sock(new TestNrSocket(nat ? nat : new TestNat)); + RefPtr sock(new TestNrSocket(nat ? nat : new TestNat)); nr_transport_addr address; nr_str_port_to_transport_addr(ip_str, 0, IPPROTO_UDP, &address); int r = sock->create(&address); @@ -92,9 +92,9 @@ class TestNrSocketTest : public ::testing::Test { } } - nsRefPtr CreatePrivateAddrs(size_t size, + RefPtr CreatePrivateAddrs(size_t size, const char* ip_str = "127.0.0.1") { - nsRefPtr result; + RefPtr result; sts_->Dispatch( WrapRunnableRet(&result, this, @@ -105,8 +105,8 @@ class TestNrSocketTest : public ::testing::Test { return result; } - nsRefPtr CreatePrivateAddrs_s(size_t count, const char* ip_str) { - nsRefPtr nat(new TestNat); + RefPtr CreatePrivateAddrs_s(size_t count, const char* ip_str) { + RefPtr nat(new TestNat); while (count--) { auto sock = CreateTestNrSocket_s(ip_str, nat); if (!sock) { @@ -264,9 +264,9 @@ class TestNrSocketTest : public ::testing::Test { Atomic wait_done_for_main_; nsCOMPtr sts_; - std::vector> public_addrs_; - std::vector> private_addrs_; - std::vector> nats_; + std::vector> public_addrs_; + std::vector> private_addrs_; + std::vector> nats_; }; } // namespace mozilla @@ -284,7 +284,7 @@ TEST_F(TestNrSocketTest, PublicConnectivity) { } TEST_F(TestNrSocketTest, PrivateConnectivity) { - nsRefPtr nat(CreatePrivateAddrs(2)); + RefPtr nat(CreatePrivateAddrs(2)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; @@ -295,7 +295,7 @@ TEST_F(TestNrSocketTest, PrivateConnectivity) { } TEST_F(TestNrSocketTest, NoConnectivityWithoutPinhole) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; CreatePublicAddrs(1); @@ -304,10 +304,10 @@ TEST_F(TestNrSocketTest, NoConnectivityWithoutPinhole) { } TEST_F(TestNrSocketTest, NoConnectivityBetweenSubnets) { - nsRefPtr nat1(CreatePrivateAddrs(1)); + RefPtr nat1(CreatePrivateAddrs(1)); nat1->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat1->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; - nsRefPtr nat2(CreatePrivateAddrs(1)); + RefPtr nat2(CreatePrivateAddrs(1)); nat2->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat2->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; @@ -318,7 +318,7 @@ TEST_F(TestNrSocketTest, NoConnectivityBetweenSubnets) { } TEST_F(TestNrSocketTest, FullConeAcceptIngress) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; CreatePublicAddrs(2); @@ -341,7 +341,7 @@ TEST_F(TestNrSocketTest, FullConeAcceptIngress) { } TEST_F(TestNrSocketTest, FullConeOnePinhole) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; CreatePublicAddrs(2); @@ -373,7 +373,7 @@ TEST_F(TestNrSocketTest, FullConeOnePinhole) { // does allow this, it has other behavior (see below) that prevents this test // from working. TEST_F(TestNrSocketTest, DISABLED_AddressRestrictedCone) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::ADDRESS_DEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; CreatePublicAddrs(2, "127.0.0.1"); @@ -441,7 +441,7 @@ TEST_F(TestNrSocketTest, DISABLED_AddressRestrictedCone) { } TEST_F(TestNrSocketTest, RestrictedCone) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::PORT_DEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; CreatePublicAddrs(2); @@ -480,7 +480,7 @@ TEST_F(TestNrSocketTest, RestrictedCone) { } TEST_F(TestNrSocketTest, PortDependentMappingFullCone) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::PORT_DEPENDENT; CreatePublicAddrs(2); @@ -524,7 +524,7 @@ TEST_F(TestNrSocketTest, PortDependentMappingFullCone) { } TEST_F(TestNrSocketTest, Symmetric) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::PORT_DEPENDENT; nat->mapping_type_ = TestNat::PORT_DEPENDENT; CreatePublicAddrs(2); @@ -561,7 +561,7 @@ TEST_F(TestNrSocketTest, Symmetric) { } TEST_F(TestNrSocketTest, BlockUdp) { - nsRefPtr nat(CreatePrivateAddrs(2)); + RefPtr nat(CreatePrivateAddrs(2)); nat->block_udp_ = true; CreatePublicAddrs(1); @@ -578,7 +578,7 @@ TEST_F(TestNrSocketTest, BlockUdp) { } TEST_F(TestNrSocketTest, DenyHairpinning) { - nsRefPtr nat(CreatePrivateAddrs(2)); + RefPtr nat(CreatePrivateAddrs(2)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; CreatePublicAddrs(1); @@ -596,7 +596,7 @@ TEST_F(TestNrSocketTest, DenyHairpinning) { } TEST_F(TestNrSocketTest, AllowHairpinning) { - nsRefPtr nat(CreatePrivateAddrs(2)); + RefPtr nat(CreatePrivateAddrs(2)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_timeout_ = 30000; @@ -616,7 +616,7 @@ TEST_F(TestNrSocketTest, AllowHairpinning) { } TEST_F(TestNrSocketTest, FullConeTimeout) { - nsRefPtr nat(CreatePrivateAddrs(1)); + RefPtr nat(CreatePrivateAddrs(1)); nat->filtering_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_type_ = TestNat::ENDPOINT_INDEPENDENT; nat->mapping_timeout_ = 200; diff --git a/media/mtransport/test/transport_unittests.cpp b/media/mtransport/test/transport_unittests.cpp index 8e2441f82b..409e5d4dda 100644 --- a/media/mtransport/test/transport_unittests.cpp +++ b/media/mtransport/test/transport_unittests.cpp @@ -611,7 +611,7 @@ class TransportTestPeer : public sigslot::has_slots<> { (int)streams_.size()); // Create the media stream - mozilla::RefPtr stream = + RefPtr stream = ice_ctx_->CreateStream(static_cast(name), 1); ASSERT_TRUE(stream != nullptr); @@ -799,15 +799,15 @@ class TransportTestPeer : public sigslot::has_slots<> { std::string name_; nsCOMPtr target_; size_t received_; - mozilla::RefPtr flow_; + RefPtr flow_; TransportLayerLoopback *loopback_; TransportLayerLogging *logging_; TransportLayerLossy *lossy_; TransportLayerDtls *dtls_; TransportLayerIce *ice_; - mozilla::RefPtr identity_; - mozilla::RefPtr ice_ctx_; - std::vector > streams_; + RefPtr identity_; + RefPtr ice_ctx_; + std::vector > streams_; std::map > candidates_; TransportTestPeer *peer_; bool gathering_complete_; @@ -1221,7 +1221,7 @@ TEST_F(TransportTest, TestDheOnlyFails) { } TEST(PushTests, LayerFail) { - mozilla::RefPtr flow = new TransportFlow(); + RefPtr flow = new TransportFlow(); nsresult rv; bool destroyed1, destroyed2; @@ -1241,7 +1241,7 @@ TEST(PushTests, LayerFail) { } TEST(PushTests, LayersFail) { - mozilla::RefPtr flow = new TransportFlow(); + RefPtr flow = new TransportFlow(); nsresult rv; bool destroyed1, destroyed2, destroyed3; diff --git a/media/mtransport/test_nr_socket.cpp b/media/mtransport/test_nr_socket.cpp index 1d6c8ca195..8d8bdf0ee6 100644 --- a/media/mtransport/test_nr_socket.cpp +++ b/media/mtransport/test_nr_socket.cpp @@ -192,7 +192,7 @@ TestNrSocket::~TestNrSocket() { nat_->erase_socket(this); } -nsRefPtr TestNrSocket::create_external_socket( +RefPtr TestNrSocket::create_external_socket( const nr_transport_addr &dest_addr) const { MOZ_ASSERT(nat_->enabled_); MOZ_ASSERT(!nat_->is_an_internal_tuple(dest_addr)); @@ -215,7 +215,7 @@ nsRefPtr TestNrSocket::create_external_socket( return nullptr; } - nsRefPtr external_socket = new NrSocket; + RefPtr external_socket = new NrSocket; if ((r = external_socket->create(&nat_external_addr))) { r_log(LOG_GENERIC,LOG_CRIT, "%s: Failure in NrSocket::create: %d", @@ -251,7 +251,7 @@ int TestNrSocket::sendto(const void *msg, size_t len, // See if we have already made the external socket we need to use. PortMapping *similar_port_mapping = get_port_mapping(*to, nat_->mapping_type_); - nsRefPtr external_socket; + RefPtr external_socket; if (similar_port_mapping) { external_socket = similar_port_mapping->external_socket_; @@ -385,7 +385,7 @@ int TestNrSocket::connect(nr_transport_addr *addr) { return NrSocket::connect(addr); } - nsRefPtr external_socket(create_external_socket(*addr)); + RefPtr external_socket(create_external_socket(*addr)); if (!external_socket) { return R_INTERNAL; } @@ -661,7 +661,7 @@ TestNrSocket::PortMapping* TestNrSocket::get_port_mapping( TestNrSocket::PortMapping* TestNrSocket::create_port_mapping( const nr_transport_addr &remote_address, - const nsRefPtr &external_socket) const { + const RefPtr &external_socket) const { r_log(LOG_GENERIC, LOG_INFO, "TestNrSocket %s creating port mapping %s -> %s", my_addr_.as_string, external_socket->my_addr().as_string, @@ -672,7 +672,7 @@ TestNrSocket::PortMapping* TestNrSocket::create_port_mapping( TestNrSocket::PortMapping::PortMapping( const nr_transport_addr &remote_address, - const nsRefPtr &external_socket) : + const RefPtr &external_socket) : external_socket_(external_socket) { // TODO(bug 1170299): Remove const_cast when no longer necessary nr_transport_addr_copy(&remote_address_, @@ -730,7 +730,7 @@ int TestNrSocket::PortMapping::sendto(const void *msg, if (r == R_WOULDBLOCK) { r_log(LOG_GENERIC, LOG_INFO, "Enqueueing UDP packet to %s", to.as_string); - send_queue_.push_back(nsRefPtr(new UdpPacket(msg, len, to))); + send_queue_.push_back(RefPtr(new UdpPacket(msg, len, to))); return 0; } else if (r) { r_log(LOG_GENERIC,LOG_ERR, "Error: %d", r); diff --git a/media/mtransport/test_nr_socket.h b/media/mtransport/test_nr_socket.h index 8fd2f148aa..48818a4bd7 100644 --- a/media/mtransport/test_nr_socket.h +++ b/media/mtransport/test_nr_socket.h @@ -215,7 +215,7 @@ class TestNrSocket : public NrSocket { class PortMapping { public: PortMapping(const nr_transport_addr &remote_address, - const nsRefPtr &external_socket); + const RefPtr &external_socket); int sendto(const void *msg, size_t len, const nr_transport_addr &to); int async_wait(int how, NR_async_cb cb, void *cb_arg, @@ -225,7 +225,7 @@ class TestNrSocket : public NrSocket { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PortMapping); PRIntervalTime last_used_; - nsRefPtr external_socket_; + RefPtr external_socket_; // For non-symmetric, most of the data here doesn't matter nr_transport_addr remote_address_; @@ -235,7 +235,7 @@ class TestNrSocket : public NrSocket { // If external_socket_ returns E_WOULDBLOCK, we don't want to propagate // that to the code using the TestNrSocket. We can also perhaps use this // to help simulate things like latency. - std::list> send_queue_; + std::list> send_queue_; }; bool is_port_mapping_stale(const PortMapping &port_mapping) const; @@ -264,17 +264,17 @@ class TestNrSocket : public NrSocket { TestNat::NatBehavior filter) const; PortMapping* create_port_mapping( const nr_transport_addr &remote_addr, - const nsRefPtr &external_socket) const; - nsRefPtr create_external_socket( + const RefPtr &external_socket) const; + RefPtr create_external_socket( const nr_transport_addr &remote_addr) const; - nsRefPtr readable_socket_; - nsRefPtr nat_; + RefPtr readable_socket_; + RefPtr nat_; // Since our comparison logic is different depending on what kind of NAT // we simulate, and the STL does not make it very easy to switch out the // comparison function at runtime, and these lists are going to be very // small anyway, we just brute-force it. - std::list> port_mappings_; + std::list> port_mappings_; }; } // namespace mozilla diff --git a/media/mtransport/transportlayerloopback.h b/media/mtransport/transportlayerloopback.h index 2790834dad..59aac11c3a 100644 --- a/media/mtransport/transportlayerloopback.h +++ b/media/mtransport/transportlayerloopback.h @@ -132,7 +132,7 @@ class TransportLayerLoopback : public TransportLayer { nsCOMPtr timer_; std::queue packets_; PRLock *packets_lock_; - nsRefPtr deliverer_; + RefPtr deliverer_; }; } // close namespace diff --git a/media/mtransport/transportlayerprsock.h b/media/mtransport/transportlayerprsock.h index 60db5eb465..ac732c9460 100644 --- a/media/mtransport/transportlayerprsock.h +++ b/media/mtransport/transportlayerprsock.h @@ -109,7 +109,7 @@ class TransportLayerPrsock : public TransportLayer { } PRFileDesc *fd_; - nsRefPtr handler_; + RefPtr handler_; nsCOMPtr stservice_; }; diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp index ca86a85dee..b2f7cdd4ae 100644 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp @@ -41,7 +41,7 @@ const unsigned int WebrtcAudioConduit::CODEC_PLNAME_SIZE = 32; /** * Factory Method for AudioConduit */ -mozilla::RefPtr AudioSessionConduit::Create() +RefPtr AudioSessionConduit::Create() { CSFLogDebug(logTag, "%s ", __FUNCTION__); NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); @@ -331,7 +331,7 @@ MediaConduitErrorCode WebrtcAudioConduit::Init() // AudioSessionConduit Implementation MediaConduitErrorCode -WebrtcAudioConduit::SetTransmitterTransport(mozilla::RefPtr aTransport) +WebrtcAudioConduit::SetTransmitterTransport(RefPtr aTransport) { CSFLogDebug(logTag, "%s ", __FUNCTION__); @@ -342,7 +342,7 @@ WebrtcAudioConduit::SetTransmitterTransport(mozilla::RefPtr } MediaConduitErrorCode -WebrtcAudioConduit::SetReceiverTransport(mozilla::RefPtr aTransport) +WebrtcAudioConduit::SetReceiverTransport(RefPtr aTransport) { CSFLogDebug(logTag, "%s ", __FUNCTION__); diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.h b/media/webrtc/signaling/src/media-conduit/AudioConduit.h index 507f3d7a67..cd3fe8e6a3 100644 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h @@ -99,9 +99,9 @@ public: * Register External Transport to this Conduit. RTP and RTCP frames from the VoiceEngine * shall be passed to the registered transport for transporting externally. */ - virtual MediaConduitErrorCode SetTransmitterTransport(mozilla::RefPtr aTransport) override; + virtual MediaConduitErrorCode SetTransmitterTransport(RefPtr aTransport) override; - virtual MediaConduitErrorCode SetReceiverTransport(mozilla::RefPtr aTransport) override; + virtual MediaConduitErrorCode SetReceiverTransport(RefPtr aTransport) override; /** * Function to deliver externally captured audio sample for encoding and transport @@ -252,8 +252,8 @@ private: webrtc::VoiceEngine* mVoiceEngine; mozilla::ReentrantMonitor mTransportMonitor; - mozilla::RefPtr mTransmitterTransport; - mozilla::RefPtr mReceiverTransport; + RefPtr mTransmitterTransport; + RefPtr mReceiverTransport; ScopedCustomReleasePtr mPtrVoENetwork; ScopedCustomReleasePtr mPtrVoEBase; ScopedCustomReleasePtr mPtrVoECodec; diff --git a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h index 7f6846b40f..05bfa023f4 100644 --- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h +++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h @@ -387,7 +387,7 @@ public: * return: Concrete AudioSessionConduitObject or nullptr in the case * of failure */ - static mozilla::RefPtr Create(); + static RefPtr Create(); virtual ~AudioSessionConduit() {} diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index 40ccb8c12d..7380d0c495 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -46,7 +46,7 @@ const unsigned int WebrtcVideoConduit::CODEC_PLNAME_SIZE = 32; /** * Factory Method for VideoConduit */ -mozilla::RefPtr +RefPtr VideoSessionConduit::Create() { NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); @@ -493,7 +493,7 @@ WebrtcVideoConduit::SyncTo(WebrtcAudioConduit *aConduit) } MediaConduitErrorCode -WebrtcVideoConduit::AttachRenderer(mozilla::RefPtr aVideoRenderer) +WebrtcVideoConduit::AttachRenderer(RefPtr aVideoRenderer) { CSFLogDebug(logTag, "%s ", __FUNCTION__); @@ -547,7 +547,7 @@ WebrtcVideoConduit::DetachRenderer() } MediaConduitErrorCode -WebrtcVideoConduit::SetTransmitterTransport(mozilla::RefPtr aTransport) +WebrtcVideoConduit::SetTransmitterTransport(RefPtr aTransport) { CSFLogDebug(logTag, "%s ", __FUNCTION__); @@ -558,7 +558,7 @@ WebrtcVideoConduit::SetTransmitterTransport(mozilla::RefPtr } MediaConduitErrorCode -WebrtcVideoConduit::SetReceiverTransport(mozilla::RefPtr aTransport) +WebrtcVideoConduit::SetReceiverTransport(RefPtr aTransport) { CSFLogDebug(logTag, "%s ", __FUNCTION__); diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.h b/media/webrtc/signaling/src/media-conduit/VideoConduit.h index 670689f40f..6c3e41ea5b 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h @@ -79,7 +79,7 @@ public: * Note: Multiple invocations of this API shall remove an existing renderer * and attaches the new to the Conduit. */ - virtual MediaConduitErrorCode AttachRenderer(mozilla::RefPtr aVideoRenderer) override; + virtual MediaConduitErrorCode AttachRenderer(RefPtr aVideoRenderer) override; virtual void DetachRenderer() override; /** @@ -130,9 +130,9 @@ public: * Register Transport for this Conduit. RTP and RTCP frames from the VideoEngine * shall be passed to the registered transport for transporting externally. */ - virtual MediaConduitErrorCode SetTransmitterTransport(mozilla::RefPtr aTransport) override; + virtual MediaConduitErrorCode SetTransmitterTransport(RefPtr aTransport) override; - virtual MediaConduitErrorCode SetReceiverTransport(mozilla::RefPtr aTransport) override; + virtual MediaConduitErrorCode SetReceiverTransport(RefPtr aTransport) override; /** * Function to select and change the encoding resolution based on incoming frame size @@ -310,9 +310,9 @@ private: webrtc::VideoEngine* mVideoEngine; mozilla::ReentrantMonitor mTransportMonitor; - mozilla::RefPtr mTransmitterTransport; - mozilla::RefPtr mReceiverTransport; - mozilla::RefPtr mRenderer; + RefPtr mTransmitterTransport; + RefPtr mReceiverTransport; + RefPtr mRenderer; ScopedCustomReleasePtr mPtrViEBase; ScopedCustomReleasePtr mPtrViECapture; @@ -348,7 +348,7 @@ private: static const unsigned int sAlphaDen = 8; static const unsigned int sRoundingPadding = 1024; - mozilla::RefPtr mSyncedTo; + RefPtr mSyncedTo; nsAutoPtr mExternalSendCodec; nsAutoPtr mExternalRecvCodec; diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp index b9f452040d..89fc906ed9 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp @@ -149,7 +149,7 @@ WebrtcGmpVideoEncoder::InitEncode(const webrtc::VideoCodec* aCodecSettings, nsCOMPtr currentThread(do_GetCurrentThread()); MOZ_ASSERT(currentThread != mGMPThread); - nsRefPtr initDone(new InitDoneRunnable()); + RefPtr initDone(new InitDoneRunnable()); mGMPThread->Dispatch(WrapRunnable(this, &WebrtcGmpVideoEncoder::InitEncode_g, aCodecSettings, @@ -257,7 +257,7 @@ WebrtcGmpVideoEncoder::Encode(const webrtc::I420VideoFrame& aInputImage, LOGD(("GMP Encode: resolution change from %ux%u to %dx%d", mCodecParams.mWidth, mCodecParams.mHeight, aInputImage.width(), aInputImage.height())); - nsRefPtr initDone(new InitDoneRunnable()); + RefPtr initDone(new InitDoneRunnable()); nsCOMPtr task( WrapRunnable(this, &WebrtcGmpVideoEncoder::RegetEncoderForResolutionChange, @@ -604,7 +604,7 @@ WebrtcGmpVideoDecoder::InitDecode(const webrtc::VideoCodec* aCodecSettings, } } - nsRefPtr initDone(new InitDoneRunnable()); + RefPtr initDone(new InitDoneRunnable()); mGMPThread->Dispatch(WrapRunnable(this, &WebrtcGmpVideoDecoder::InitDecode_g, aCodecSettings, diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h index 25f0415b47..f9b72b05eb 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h +++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h @@ -158,7 +158,7 @@ private: private: WebrtcGmpVideoEncoder* mEncoder; - nsRefPtr mInitDone; + RefPtr mInitDone; const webrtc::VideoCodec* mCodecSettings; uint32_t mMaxPayloadSize; }; @@ -199,7 +199,7 @@ private: private: WebrtcGmpVideoEncoder* mEncoder; - nsRefPtr mInitDone; + RefPtr mInitDone; uint32_t mWidth; uint32_t mHeight; }; @@ -334,7 +334,7 @@ private: private: WebrtcGmpVideoDecoder* mDecoder; - nsRefPtr mInitDone; + RefPtr mInitDone; }; virtual int32_t Decode_g(const webrtc::EncodedImage& aInputImage, diff --git a/media/webrtc/signaling/src/media/CSFAudioControlWrapper.h b/media/webrtc/signaling/src/media/CSFAudioControlWrapper.h index 49f3b89237..0faccbd0df 100644 --- a/media/webrtc/signaling/src/media/CSFAudioControlWrapper.h +++ b/media/webrtc/signaling/src/media/CSFAudioControlWrapper.h @@ -37,6 +37,6 @@ namespace CSF private: virtual ~AudioControlWrapper(); - mozilla::RefPtr _realAudioControl; + RefPtr _realAudioControl; }; }; diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 132a1f244f..04d2f0c275 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -76,7 +76,7 @@ nsresult MediaPipeline::Init() { RUN_ON_THREAD(sts_thread_, WrapRunnable( - nsRefPtr(this), + RefPtr(this), &MediaPipeline::Init_s), NS_DISPATCH_NORMAL); @@ -843,7 +843,7 @@ UnsetTrackId(MediaStreamGraphImpl* graph) { { listener_->UnsetTrackIdImpl(); } - nsRefPtr listener_; + RefPtr listener_; }; graph->AppendMessage(new Message(this)); #else @@ -1293,7 +1293,7 @@ static void AddTrackAndListener(MediaStream* source, TrackID track_id_; TrackRate track_rate_; nsAutoPtr segment_; - nsRefPtr listener_; + RefPtr listener_; const RefPtr completed_; }; @@ -1380,7 +1380,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { MOZ_MTLOG(ML_DEBUG, "Audio conduit returned buffer of length " << samples_length); - nsRefPtr samples = SharedBuffer::Create(samples_length * sizeof(uint16_t)); + RefPtr samples = SharedBuffer::Create(samples_length * sizeof(uint16_t)); int16_t *samples_data = static_cast(samples->Data()); AudioSegment segment; // We derive the number of channels of the stream from the number of samples @@ -1479,7 +1479,7 @@ void MediaPipelineReceiveVideo::PipelineListener::RenderVideoFrame( #else ImageFormat format = ImageFormat::PLANAR_YCBCR; #endif - nsRefPtr image = image_container_->CreateImage(format); + RefPtr image = image_container_->CreateImage(format); PlanarYCbCrImage* yuvImage = static_cast(image.get()); uint8_t* frame = const_cast(static_cast (buffer)); @@ -1515,9 +1515,9 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { ReentrantMonitorAutoEnter enter(monitor_); #if defined(MOZILLA_XPCOMRT_API) - nsRefPtr image = image_; + RefPtr image = image_; #elif defined(MOZILLA_INTERNAL_API) - nsRefPtr image = image_; + RefPtr image = image_; // our constructor sets track_rate_ to the graph rate MOZ_ASSERT(track_rate_ == source_->GraphRate()); #endif diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h index 1718ae7a2c..1a31ac3bcc 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h @@ -748,10 +748,10 @@ class MediaPipelineReceiveVideo : public MediaPipelineReceive { int width_; int height_; #if defined(MOZILLA_XPCOMRT_API) - nsRefPtr image_; + RefPtr image_; #elif defined(MOZILLA_INTERNAL_API) - nsRefPtr image_container_; - nsRefPtr image_; + RefPtr image_container_; + RefPtr image_; #endif mozilla::ReentrantMonitor monitor_; // Monitor for processing WebRTC frames. // Protects image_ against: diff --git a/media/webrtc/signaling/src/mediapipeline/SrtpFlow.h b/media/webrtc/signaling/src/mediapipeline/SrtpFlow.h index eaf0eb3698..9bb9c2a673 100644 --- a/media/webrtc/signaling/src/mediapipeline/SrtpFlow.h +++ b/media/webrtc/signaling/src/mediapipeline/SrtpFlow.h @@ -32,7 +32,7 @@ class SrtpFlow { public: - static mozilla::RefPtr Create(int cipher_suite, + static RefPtr Create(int cipher_suite, bool inbound, const void *key, size_t key_len); diff --git a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp index df063637fb..8c1920952b 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp @@ -433,7 +433,7 @@ MediaPipelineFactory::CreateMediaPipelineReceiving( const RefPtr& aConduit) { // We will error out earlier if this isn't here. - nsRefPtr stream = + RefPtr stream = mPCMedia->GetRemoteStreamById(aTrack.GetStreamId()); RefPtr pipeline; @@ -512,7 +512,7 @@ MediaPipelineFactory::CreateMediaPipelineSending( nsresult rv; // This is checked earlier - nsRefPtr stream = + RefPtr stream = mPCMedia->GetLocalStreamById(aTrack.GetStreamId()); // Now we have all the pieces, create the pipeline @@ -816,11 +816,11 @@ MediaPipelineFactory::ConfigureVideoCodecMode(const JsepTrack& aTrack, VideoSessionConduit& aConduit) { #if !defined(MOZILLA_EXTERNAL_LINKAGE) - nsRefPtr stream = + RefPtr stream = mPCMedia->GetLocalStreamById(aTrack.GetStreamId()); //get video track - nsRefPtr videotrack = + RefPtr videotrack = stream->GetVideoTrackByTrackId(aTrack.GetTrackId()); if (!videotrack) { @@ -829,7 +829,7 @@ MediaPipelineFactory::ConfigureVideoCodecMode(const JsepTrack& aTrack, } //get video source type - nsRefPtr mediastream = + RefPtr mediastream = mPCMedia->GetLocalStreamById(aTrack.GetStreamId())->GetMediaStream(); DOMLocalMediaStream* domLocalStream = mediastream->AsDOMLocalMediaStream(); diff --git a/media/webrtc/signaling/src/peerconnection/MediaStreamList.h b/media/webrtc/signaling/src/peerconnection/MediaStreamList.h index 686af6d946..de9040227d 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaStreamList.h +++ b/media/webrtc/signaling/src/peerconnection/MediaStreamList.h @@ -44,7 +44,7 @@ public: private: virtual ~MediaStreamList(); - nsRefPtr mPeerConnection; + RefPtr mPeerConnection; StreamType mType; }; diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp index 08e0b87314..feec34d97e 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp @@ -75,7 +75,7 @@ public: MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv)); // Make sure we're not deleted while still inside ::Observe() - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); PeerConnectionCtx::gPeerConnectionCtxShutdown = nullptr; } return NS_OK; diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index aa6c510c66..67ca61eb8a 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -177,7 +177,7 @@ public: TracksAvailableCallback(size_t numNewAudioTracks, size_t numNewVideoTracks, const std::string& pcHandle, - nsRefPtr aObserver) + RefPtr aObserver) : DOMMediaStream::OnTracksAvailableCallback() , mObserver(aObserver) , mPcHandle(pcHandle) @@ -193,7 +193,7 @@ public: return; } - nsTArray> tracks; + nsTArray> tracks; aStream->GetTracks(tracks); std::string streamId = PeerConnectionImpl::GetStreamId(*aStream); @@ -255,7 +255,7 @@ public: } private: - nsRefPtr mObserver; + RefPtr mObserver; const std::string mPcHandle; }; #endif @@ -448,7 +448,7 @@ PeerConnectionImpl::MakeMediaStream() MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, AudioChannel::Normal); - nsRefPtr stream = + RefPtr stream = DOMMediaStream::CreateSourceStream(GetWindow(), graph); #if !defined(MOZILLA_EXTERNAL_LINKAGE) // Make the stream data (audio/video samples) accessible to the receiving page. @@ -474,19 +474,19 @@ PeerConnectionImpl::MakeMediaStream() } nsresult -PeerConnectionImpl::CreateRemoteSourceStreamInfo(nsRefPtr* +PeerConnectionImpl::CreateRemoteSourceStreamInfo(RefPtr* aInfo, const std::string& aStreamID) { MOZ_ASSERT(aInfo); PC_AUTO_ENTER_API_CALL_NO_CHECK(); - nsRefPtr stream = MakeMediaStream(); + RefPtr stream = MakeMediaStream(); if (!stream) { return NS_ERROR_FAILURE; } - nsRefPtr remote; + RefPtr remote; remote = new RemoteSourceStreamInfo(stream.forget(), mMedia, aStreamID); *aInfo = remote; @@ -556,7 +556,7 @@ PeerConnectionConfiguration::AddIceServer(const RTCIceServer &aServer) // http://tools.ietf.org/html/draft-nandakumar-rtcweb-stun-uri-02#section-3 // http://tools.ietf.org/html/draft-petithuguenin-behave-turn-uri-03#section-3 // we parse out the query-string, and use ParseAuthority() on the rest - nsRefPtr url; + RefPtr url; nsresult rv = NS_NewURI(getter_AddRefs(url), urls[i]); NS_ENSURE_SUCCESS(rv, rv); bool isStun = false, isStuns = false, isTurn = false, isTurns = false; @@ -870,7 +870,7 @@ PeerConnectionImpl::SetCertificate(mozilla::dom::RTCCertificate& aCertificate) } } -const nsRefPtr& +const RefPtr& PeerConnectionImpl::Certificate() const { PC_AUTO_ENTER_API_CALL_NO_CHECK(); @@ -878,7 +878,7 @@ PeerConnectionImpl::Certificate() const } #endif -mozilla::RefPtr +RefPtr PeerConnectionImpl::Identity() const { PC_AUTO_ENTER_API_CALL_NO_CHECK(); @@ -886,7 +886,7 @@ PeerConnectionImpl::Identity() const MOZ_ASSERT(mCertificate); return mCertificate->CreateDtlsIdentity(); #else - mozilla::RefPtr id = mIdentity; + RefPtr id = mIdentity; return id; #endif } @@ -1218,7 +1218,7 @@ PeerConnectionImpl::InitializeDataChannel() } // use the specified TransportFlow - nsRefPtr flow = mMedia->GetTransportFlow(level, false).get(); + RefPtr flow = mMedia->GetTransportFlow(level, false).get(); CSFLogDebug(logTag, "Transportflow[%u] = %p", static_cast(level), flow.get()); if (flow) { @@ -1248,7 +1248,7 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel, ErrorResult &rv) { #if !defined(MOZILLA_EXTERNAL_LINKAGE) - nsRefPtr result; + RefPtr result; rv = CreateDataChannel(aLabel, aProtocol, aType, outOfOrderAllowed, aMaxTime, aMaxNum, aExternalNegotiated, aStream, getter_AddRefs(result)); @@ -1273,7 +1273,7 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel, MOZ_ASSERT(aRetval); #if !defined(MOZILLA_EXTERNAL_LINKAGE) - nsRefPtr dataChannel; + RefPtr dataChannel; DataChannelConnection::Type theType = static_cast(aType); @@ -1341,8 +1341,8 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel, // if (!tmp) { // return; // } -// nsRefPtr tmp2 = do_QueryObject(tmp); -// nsRefPtr pco = static_cast(&*tmp2); +// RefPtr tmp2 = do_QueryObject(tmp); +// RefPtr pco = static_cast(&*tmp2); static already_AddRefed do_QueryObjectReferent(nsIWeakReference* aRawPtr) { @@ -1350,20 +1350,20 @@ do_QueryObjectReferent(nsIWeakReference* aRawPtr) { if (!tmp) { return nullptr; } - nsRefPtr tmp2 = do_QueryObject(tmp); - nsRefPtr tmp3 = static_cast(&*tmp2); + RefPtr tmp2 = do_QueryObject(tmp); + RefPtr tmp3 = static_cast(&*tmp2); return tmp3.forget(); } #if !defined(MOZILLA_EXTERNAL_LINKAGE) // Not a member function so that we don't need to keep the PC live. -static void NotifyDataChannel_m(nsRefPtr aChannel, - nsRefPtr aObserver) +static void NotifyDataChannel_m(RefPtr aChannel, + RefPtr aObserver) { MOZ_ASSERT(NS_IsMainThread()); JSErrorResult rv; - nsRefPtr channel = static_cast(&*aChannel); + RefPtr channel = static_cast(&*aChannel); aObserver->NotifyDataChannel(*channel, rv); NS_DataChannelAppReady(aChannel); } @@ -1374,7 +1374,7 @@ PeerConnectionImpl::NotifyDataChannel(already_AddRefed aChannel) { PC_AUTO_ENTER_API_CALL_NO_CHECK(); - // XXXkhuey this is completely fucked up. We can't use nsRefPtr + // XXXkhuey this is completely fucked up. We can't use RefPtr // here because DataChannel's AddRef/Release are non-virtual and not visible // if !MOZILLA_INTERNAL_API, but this function leaks the DataChannel if // !MOZILLA_INTERNAL_API because it never transfers the ref to @@ -1392,7 +1392,7 @@ PeerConnectionImpl::NotifyDataChannel(already_AddRefed aChannel) mHaveDataStream = true; - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return; } @@ -1447,7 +1447,7 @@ PeerConnectionImpl::CreateOffer(const JsepOfferOptions& aOptions) { PC_AUTO_ENTER_API_CALL(true); - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return NS_OK; } @@ -1501,7 +1501,7 @@ PeerConnectionImpl::CreateAnswer() { PC_AUTO_ENTER_API_CALL(true); - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return NS_OK; } @@ -1549,7 +1549,7 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) } JSErrorResult rv; - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return NS_OK; } @@ -1634,7 +1634,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) } JSErrorResult jrv; - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return NS_OK; } @@ -1721,7 +1721,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) std::string streamId = i->first; std::vector>& tracks = i->second; - nsRefPtr info = + RefPtr info = mMedia->GetRemoteStreamById(streamId); if (!info) { nsresult nrv = CreateRemoteSourceStreamInfo(&info, streamId); @@ -1792,7 +1792,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) mJsepSession->GetRemoteTracksRemoved(); for (auto i = removedTracks.begin(); i != removedTracks.end(); ++i) { - nsRefPtr info = + RefPtr info = mMedia->GetRemoteStreamById((*i)->GetStreamId()); if (!info) { MOZ_ASSERT(false, "A stream/track was removed that wasn't in PCMedia. " @@ -1878,7 +1878,7 @@ PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, un PC_AUTO_ENTER_API_CALL(true); JSErrorResult rv; - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return NS_OK; } @@ -2140,7 +2140,7 @@ PeerConnectionImpl::RemoveTrack(MediaStreamTrack& aTrack) { } std::string streamId = PeerConnectionImpl::GetStreamId(*stream); - nsRefPtr info = media()->GetLocalStreamById(streamId); + RefPtr info = media()->GetLocalStreamById(streamId); if (!info) { CSFLogError(logTag, "%s: Unknown stream", __FUNCTION__); @@ -2172,7 +2172,7 @@ PeerConnectionImpl::ReplaceTrack(MediaStreamTrack& aThisTrack, MediaStreamTrack& aWithTrack) { PC_AUTO_ENTER_API_CALL(true); - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return NS_ERROR_UNEXPECTED; } @@ -2420,7 +2420,7 @@ PeerConnectionImpl::PluginCrash(uint32_t aPluginID, init.mBubbles = true; init.mCancelable = true; - nsRefPtr event = + RefPtr event = PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init); event->SetTrusted(true); @@ -2537,7 +2537,7 @@ PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState, CloseInt(); } - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return; } @@ -2697,7 +2697,7 @@ SendLocalIceCandidateToContentImpl(nsWeakPtr weakPCObserver, uint16_t level, const std::string& mid, const std::string& candidate) { - nsRefPtr pco = do_QueryObjectReferent(weakPCObserver); + RefPtr pco = do_QueryObjectReferent(weakPCObserver); if (!pco) { return; } @@ -2813,7 +2813,7 @@ void PeerConnectionImpl::IceConnectionStateChange( MOZ_ASSERT_UNREACHABLE("Unexpected mIceConnectionState!"); } - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return; } @@ -2853,7 +2853,7 @@ PeerConnectionImpl::IceGatheringStateChange( MOZ_ASSERT_UNREACHABLE("Unexpected mIceGatheringState!"); } - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return; } @@ -3312,7 +3312,7 @@ void PeerConnectionImpl::DeliverStatsReportToPCObserver_m( // Is the PeerConnectionImpl still around? PeerConnectionWrapper pcw(pcHandle); if (pcw.impl()) { - nsRefPtr pco = + RefPtr pco = do_QueryObjectReferent(pcw.impl()->mPCObserver); if (pco) { JSErrorResult rv; @@ -3349,7 +3349,7 @@ PeerConnectionImpl::OnNegotiationNeeded() mShouldSuppressNegotiationNeeded = true; - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + RefPtr pco = do_QueryObjectReferent(mPCObserver); if (!pco) { return; } @@ -3387,7 +3387,7 @@ PeerConnectionImpl::startCallTelem() { #endif NS_IMETHODIMP -PeerConnectionImpl::GetLocalStreams(nsTArray >& result) +PeerConnectionImpl::GetLocalStreams(nsTArray >& result) { PC_AUTO_ENTER_API_CALL_NO_CHECK(); #if !defined(MOZILLA_EXTERNAL_LINKAGE) @@ -3403,7 +3403,7 @@ PeerConnectionImpl::GetLocalStreams(nsTArray >& result } NS_IMETHODIMP -PeerConnectionImpl::GetRemoteStreams(nsTArray >& result) +PeerConnectionImpl::GetRemoteStreams(nsTArray >& result) { PC_AUTO_ENTER_API_CALL_NO_CHECK(); #if !defined(MOZILLA_EXTERNAL_LINKAGE) diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h index 3489faf170..33967d9ea8 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h @@ -221,8 +221,8 @@ class RTCStatsQuery { friend class PeerConnectionImpl; std::string pcName; bool internalStats; - nsTArray> pipelines; - mozilla::RefPtr iceCtx; + nsTArray> pipelines; + RefPtr iceCtx; bool grabAllLevels; DOMHighResTimeStamp now; }; @@ -278,7 +278,7 @@ public: static PeerConnectionImpl* CreatePeerConnection(); already_AddRefed MakeMediaStream(); - nsresult CreateRemoteSourceStreamInfo(nsRefPtr* aInfo, + nsresult CreateRemoteSourceStreamInfo(RefPtr* aInfo, const std::string& aId); // DataConnection observers @@ -291,7 +291,7 @@ public: ; // Get the media object - const nsRefPtr& media() const { + const RefPtr& media() const { PC_AUTO_ENTER_API_CALL_NO_CHECK(); return mMedia; } @@ -361,10 +361,10 @@ public: #if !defined(MOZILLA_EXTERNAL_LINKAGE) void SetCertificate(mozilla::dom::RTCCertificate& aCertificate); - const nsRefPtr& Certificate() const; + const RefPtr& Certificate() const; #endif // This is a hack to support external linkage. - mozilla::RefPtr Identity() const; + RefPtr Identity() const; NS_IMETHODIMP_TO_ERRORRESULT(CreateOffer, ErrorResult &rv, const RTCOfferOptions& aOptions) @@ -561,13 +561,13 @@ public: uint16_t aStream); NS_IMETHODIMP_TO_ERRORRESULT(GetLocalStreams, ErrorResult &rv, - nsTArray >& result) + nsTArray >& result) { rv = GetLocalStreams(result); } NS_IMETHODIMP_TO_ERRORRESULT(GetRemoteStreams, ErrorResult &rv, - nsTArray >& result) + nsTArray >& result) { rv = GetRemoteStreams(result); } @@ -724,9 +724,9 @@ private: // void if they are not yet identified, and no identity setting has been set nsAutoPtr mPeerIdentity; // The certificate we are using. - nsRefPtr mCertificate; + RefPtr mCertificate; #else - mozilla::RefPtr mIdentity; + RefPtr mIdentity; #endif // Whether an app should be prevented from accessing media produced by the PC // If this is true, then media will not be sent until mPeerIdentity matches @@ -747,12 +747,12 @@ private: #if !defined(MOZILLA_EXTERNAL_LINKAGE) // DataConnection that's used to get all the DataChannels - nsRefPtr mDataConnection; + RefPtr mDataConnection; #endif bool mAllowIceLoopback; bool mAllowIceLinkLocal; - nsRefPtr mMedia; + RefPtr mMedia; // The JSEP negotiation session. mozilla::UniquePtr mUuidGen; @@ -796,7 +796,7 @@ class PeerConnectionWrapper PeerConnectionImpl *impl() { return impl_; } private: - nsRefPtr impl_; + RefPtr impl_; }; } // end mozilla namespace diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp index 13b2fde4c9..475fe88ffe 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp @@ -142,7 +142,7 @@ void SourceStreamInfo::DetachMedia_m() already_AddRefed PeerConnectionImpl::Constructor(const dom::GlobalObject& aGlobal, ErrorResult& rv) { - nsRefPtr pc = new PeerConnectionImpl(&aGlobal); + RefPtr pc = new PeerConnectionImpl(&aGlobal); CSFLogDebug(logTag, "Created PeerConnection: %p", pc.get()); @@ -281,7 +281,7 @@ nsresult PeerConnectionMedia::Init(const std::vector& stun_serv return NS_ERROR_FAILURE; } - nsRefPtr handler = new ProtocolProxyQueryHandler(this); + RefPtr handler = new ProtocolProxyQueryHandler(this); rv = pps->AsyncResolve(channel, nsIProtocolProxyService::RESOLVE_PREFER_HTTPS_PROXY | nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL, @@ -677,7 +677,7 @@ PeerConnectionMedia::AddTrack(DOMMediaStream* aMediaStream, CSFLogDebug(logTag, "%s: MediaStream: %p", __FUNCTION__, aMediaStream); - nsRefPtr localSourceStream = + RefPtr localSourceStream = GetLocalStreamById(streamId); if (!localSourceStream) { @@ -698,7 +698,7 @@ PeerConnectionMedia::RemoveLocalTrack(const std::string& streamId, CSFLogDebug(logTag, "%s: stream: %s track: %s", __FUNCTION__, streamId.c_str(), trackId.c_str()); - nsRefPtr localSourceStream = + RefPtr localSourceStream = GetLocalStreamById(streamId); if (!localSourceStream) { return NS_ERROR_ILLEGAL_VALUE; @@ -720,7 +720,7 @@ PeerConnectionMedia::RemoveRemoteTrack(const std::string& streamId, CSFLogDebug(logTag, "%s: stream: %s track: %s", __FUNCTION__, streamId.c_str(), trackId.c_str()); - nsRefPtr remoteSourceStream = + RefPtr remoteSourceStream = GetRemoteStreamById(streamId); if (!remoteSourceStream) { return NS_ERROR_ILLEGAL_VALUE; @@ -867,7 +867,7 @@ PeerConnectionMedia::GetRemoteStreamById(const std::string& id) } nsresult -PeerConnectionMedia::AddRemoteStream(nsRefPtr aInfo) +PeerConnectionMedia::AddRemoteStream(RefPtr aInfo) { ASSERT_ON_THREAD(mMainThread); @@ -1209,10 +1209,10 @@ SourceStreamInfo::AnyCodecHasPluginID(uint64_t aPluginID) } #if !defined(MOZILLA_EXTERNAL_LINKAGE) -nsRefPtr +RefPtr SourceStreamInfo::GetVideoTrackByTrackId(const std::string& trackId) { - nsTArray> videoTracks; + nsTArray> videoTracks; mMediaStream->GetVideoTracks(videoTracks); @@ -1231,7 +1231,7 @@ SourceStreamInfo::GetVideoTrackByTrackId(const std::string& trackId) nsresult SourceStreamInfo::StorePipeline( const std::string& trackId, - const mozilla::RefPtr& aPipeline) + const RefPtr& aPipeline) { MOZ_ASSERT(mPipelines.find(trackId) == mPipelines.end()); if (mPipelines.find(trackId) != mPipelines.end()) { diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h index 69d2f96b86..b1e849644c 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h @@ -108,10 +108,10 @@ public: void DetachMedia_m(); bool AnyCodecHasPluginID(uint64_t aPluginID); #if !defined(MOZILLA_EXTERNAL_LINKAGE) - nsRefPtr GetVideoTrackByTrackId(const std::string& trackId); + RefPtr GetVideoTrackByTrackId(const std::string& trackId); #endif protected: - nsRefPtr mMediaStream; + RefPtr mMediaStream; PeerConnectionMedia *mParent; const std::string mId; // These get set up before we generate our local description, the pipelines @@ -292,7 +292,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> { RemoteSourceStreamInfo* GetRemoteStreamById(const std::string& id); // Add a remote stream. - nsresult AddRemoteStream(nsRefPtr aInfo); + nsresult AddRemoteStream(RefPtr aInfo); nsresult ReplaceTrack(const std::string& oldStreamId, const std::string& oldTrackId, @@ -480,11 +480,11 @@ class PeerConnectionMedia : public sigslot::has_slots<> { // A list of streams returned from GetUserMedia // This is only accessed on the main thread (with one special exception) - nsTArray > mLocalSourceStreams; + nsTArray > mLocalSourceStreams; // A list of streams provided by the other side // This is only accessed on the main thread (with one special exception) - nsTArray > mRemoteSourceStreams; + nsTArray > mRemoteSourceStreams; std::map>> mConduits; @@ -492,7 +492,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> { RefPtr mIceCtx; // DNS - nsRefPtr mDNSResolver; + RefPtr mDNSResolver; // Transport flows: even is RTP, odd is RTCP std::map > mTransportFlows; diff --git a/media/webrtc/signaling/test/FakeMediaStreams.h b/media/webrtc/signaling/test/FakeMediaStreams.h index 33e5f7f24c..eec0265bbe 100644 --- a/media/webrtc/signaling/test/FakeMediaStreams.h +++ b/media/webrtc/signaling/test/FakeMediaStreams.h @@ -187,7 +187,7 @@ class Fake_SourceMediaStream : public Fake_MediaStream { ADDTRACK_QUEUED = 0x01 // Queue track add until FinishAddTracks() }; - void AddVideoSink(const nsRefPtr& aSink) { + void AddVideoSink(const RefPtr& aSink) { mSink = aSink; } @@ -276,8 +276,8 @@ class Fake_SourceMediaStream : public Fake_MediaStream { uint64_t mDesiredTime; bool mPullEnabled; bool mStop; - nsRefPtr mPeriodic; - nsRefPtr mSink; + RefPtr mPeriodic; + RefPtr mSink; nsCOMPtr mTimer; }; @@ -352,7 +352,7 @@ public: CreateSourceStream(nsIDOMWindow* aWindow, mozilla::MediaStreamGraph* aGraph, uint32_t aHintContents = 0) { Fake_SourceMediaStream *source = new Fake_SourceMediaStream(); - nsRefPtr ds = new Fake_DOMMediaStream(source); + RefPtr ds = new Fake_DOMMediaStream(source); ds->SetHintContents(aHintContents); return ds.forget(); @@ -378,13 +378,13 @@ public: void SetHintContents(uint32_t aHintContents) { mHintContents = aHintContents; } void - GetTracks(nsTArray >& aTracks) + GetTracks(nsTArray >& aTracks) { GetAudioTracks(aTracks); GetVideoTracks(aTracks); } - void GetAudioTracks(nsTArray >& aTracks) + void GetAudioTracks(nsTArray >& aTracks) { if (mHintContents & HINT_CONTENTS_AUDIO) { aTracks.AppendElement(mAudioTrack); @@ -392,7 +392,7 @@ public: } void - GetVideoTracks(nsTArray >& aTracks) + GetVideoTracks(nsTArray >& aTracks) { if (mHintContents & HINT_CONTENTS_VIDEO) { aTracks.AppendElement(mVideoTrack); @@ -417,13 +417,13 @@ public: void RemovePrincipalChangeObserver(void* ignoredObserver) {} private: - nsRefPtr mMediaStream; + RefPtr mMediaStream; // tells the SDP generator about whether this // MediaStream probably has audio and/or video uint32_t mHintContents; - nsRefPtr mVideoTrack; - nsRefPtr mAudioTrack; + RefPtr mVideoTrack; + RefPtr mAudioTrack; std::string mID; }; @@ -441,7 +441,7 @@ class Fake_MediaStreamBase : public Fake_MediaStream { private: nsCOMPtr mTimer; - nsRefPtr mPeriodic; + RefPtr mPeriodic; }; diff --git a/media/webrtc/signaling/test/FakeMediaStreamsImpl.h b/media/webrtc/signaling/test/FakeMediaStreamsImpl.h index ed28875042..30ce661564 100644 --- a/media/webrtc/signaling/test/FakeMediaStreamsImpl.h +++ b/media/webrtc/signaling/test/FakeMediaStreamsImpl.h @@ -96,7 +96,7 @@ void Fake_AudioStreamSource::Periodic() { return; } //Generate Signed 16 Bit Audio samples - nsRefPtr samples = + RefPtr samples = mozilla::SharedBuffer::Create(AUDIO_BUFFER_SIZE * NUM_CHANNELS * sizeof(int16_t)); int16_t* data = reinterpret_cast(samples->Data()); for(int i=0; i<(1600*2); i++) { @@ -146,7 +146,7 @@ Fake_VideoStreamSource::Notify(nsITimer* aTimer) #if 0 mozilla::layers::BufferRecycleBin bin; - nsRefPtr image = new + RefPtr image = new mozilla::layers::PlanarYCbCrImage(&bin); const uint8_t lumaBpp = 8; diff --git a/media/webrtc/signaling/test/mediaconduit_unittests.cpp b/media/webrtc/signaling/test/mediaconduit_unittests.cpp index a27d560c02..96119eff64 100644 --- a/media/webrtc/signaling/test/mediaconduit_unittests.cpp +++ b/media/webrtc/signaling/test/mediaconduit_unittests.cpp @@ -83,7 +83,7 @@ public: void SetRate(int r) { rate = r; } - void Init(mozilla::RefPtr aSession) + void Init(RefPtr aSession) { mSession = aSession; mLen = ((width * height) * 3 / 2); @@ -109,7 +109,7 @@ public: } private: -mozilla::RefPtr mSession; +RefPtr mSession; mozilla::ScopedDeletePtr mFrame; int mLen; int width, height; @@ -141,8 +141,8 @@ public: { } - void Init(mozilla::RefPtr aSession, - mozilla::RefPtr aOtherSession, + void Init(RefPtr aSession, + RefPtr aOtherSession, std::string fileIn, std::string fileOut) { @@ -157,8 +157,8 @@ public: private: - mozilla::RefPtr mSession; - mozilla::RefPtr mOtherSession; + RefPtr mSession; + RefPtr mOtherSession; std::string iFile; std::string oFile; @@ -459,8 +459,8 @@ public: } //Treat this object as Audio Transport - void SetAudioSession(mozilla::RefPtr aSession, - mozilla::RefPtr + void SetAudioSession(RefPtr aSession, + RefPtr aOtherSession) { mAudioSession = aSession; @@ -469,8 +469,8 @@ public: } // Treat this object as Video Transport - void SetVideoSession(mozilla::RefPtr aSession, - mozilla::RefPtr + void SetVideoSession(RefPtr aSession, + RefPtr aOtherSession) { mVideoSession = aSession; @@ -479,10 +479,10 @@ public: } private: - mozilla::RefPtr mAudioSession; - mozilla::RefPtr mVideoSession; - mozilla::RefPtr mOtherVideoSession; - mozilla::RefPtr mOtherAudioSession; + RefPtr mAudioSession; + RefPtr mVideoSession; + RefPtr mOtherVideoSession; + RefPtr mOtherAudioSession; int numPkts; bool mAudio, mVideo; }; @@ -681,7 +681,7 @@ class TransportConduitTest : public ::testing::Test void TestVideoConduitCodecAPI() { int err = 0; - mozilla::RefPtr videoSession; + RefPtr videoSession; //get pointer to VideoSessionConduit mozilla::SyncRunnable::DispatchToThread(gMainThread, WrapRunnableNMRet(&videoSession, @@ -942,16 +942,16 @@ class TransportConduitTest : public ::testing::Test private: //Audio Conduit Test Objects - mozilla::RefPtr mAudioSession; - mozilla::RefPtr mAudioSession2; - mozilla::RefPtr mAudioTransport; + RefPtr mAudioSession; + RefPtr mAudioSession2; + RefPtr mAudioTransport; AudioSendAndReceive audioTester; //Video Conduit Test Objects - mozilla::RefPtr mVideoSession; - mozilla::RefPtr mVideoSession2; - mozilla::RefPtr mVideoRenderer; - mozilla::RefPtr mVideoTransport; + RefPtr mVideoSession; + RefPtr mVideoSession2; + RefPtr mVideoRenderer; + RefPtr mVideoTransport; VideoSendAndReceive videoTester; mozilla::VideoEncoder* mExternalEncoder; diff --git a/media/webrtc/signaling/test/mediapipeline_unittest.cpp b/media/webrtc/signaling/test/mediapipeline_unittest.cpp index e2484926d6..be33c8c230 100644 --- a/media/webrtc/signaling/test/mediapipeline_unittest.cpp +++ b/media/webrtc/signaling/test/mediapipeline_unittest.cpp @@ -123,7 +123,7 @@ class TransportInfo { flow_ = nullptr; } - mozilla::RefPtr flow_; + RefPtr flow_; TransportLayerLoopback *loopback_; TransportLayerDtls *dtls_; }; @@ -228,12 +228,12 @@ class TestAgent { protected: mozilla::AudioCodecConfig audio_config_; - mozilla::RefPtr audio_conduit_; - nsRefPtr audio_; + RefPtr audio_conduit_; + RefPtr audio_; // TODO(bcampen@mozilla.com): Right now this does not let us test RTCP in // both directions; only the sender's RTCP is sent, but the receiver should // be sending it too. - mozilla::RefPtr audio_pipeline_; + RefPtr audio_pipeline_; TransportInfo audio_rtp_transport_; TransportInfo audio_rtcp_transport_; TransportInfo bundle_transport_; diff --git a/media/webrtc/signaling/test/signaling_unittests.cpp b/media/webrtc/signaling/test/signaling_unittests.cpp index 71f16d8b68..8573c2dc9f 100644 --- a/media/webrtc/signaling/test/signaling_unittests.cpp +++ b/media/webrtc/signaling/test/signaling_unittests.cpp @@ -404,7 +404,7 @@ TestObserver::OnAddStream(DOMMediaStream &stream, ER&) // We know that the media stream is secretly a Fake_SourceMediaStream, // so now we can start it pulling from us - nsRefPtr fs = + RefPtr fs = static_cast(stream.GetStream()); test_utils->sts_target()->Dispatch( @@ -631,7 +631,7 @@ class PCDispatchWrapper : public nsSupportsWeakReference virtual ~PCDispatchWrapper() {} public: - explicit PCDispatchWrapper(const nsRefPtr& peerConnection) + explicit PCDispatchWrapper(const RefPtr& peerConnection) : pc_(peerConnection) {} NS_DECL_THREADSAFE_ISUPPORTS @@ -640,7 +640,7 @@ class PCDispatchWrapper : public nsSupportsWeakReference return pc_; } - const nsRefPtr& media() const { + const RefPtr& media() const { return pc_->media(); } @@ -869,8 +869,8 @@ class PCDispatchWrapper : public nsSupportsWeakReference } private: - nsRefPtr pc_; - nsRefPtr observer_; + RefPtr pc_; + RefPtr observer_; }; NS_IMPL_ISUPPORTS(PCDispatchWrapper, nsISupportsWeakReference) @@ -1076,10 +1076,10 @@ class SignalingAgent { stream = audio_stream; } - nsRefPtr domMediaStream = new DOMMediaStream(stream); + RefPtr domMediaStream = new DOMMediaStream(stream); domMediaStream->SetHintContents(hint); - nsTArray> tracks; + nsTArray> tracks; domMediaStream->GetTracks(tracks); for (uint32_t i = 0; i < tracks.Length(); i++) { Msid msid = {domMediaStream->GetId(), tracks[i]->GetId()}; @@ -1228,7 +1228,7 @@ class SignalingAgent { void RemoveTrack(size_t streamIndex, bool videoTrack = false) { ASSERT_LT(streamIndex, domMediaStreams_.size()); - nsTArray> tracks; + nsTArray> tracks; domMediaStreams_[streamIndex]->GetTracks(tracks); for (size_t i = 0; i < tracks.Length(); ++i) { if (!!tracks[i]->AsVideoStreamTrack() == videoTrack) { @@ -1242,7 +1242,7 @@ class SignalingAgent { } void RemoveStream(size_t index) { - nsTArray> tracks; + nsTArray> tracks; domMediaStreams_[index]->GetTracks(tracks); for (uint32_t i = 0; i < tracks.Length(); i++) { ASSERT_EQ(pc->RemoveTrack(tracks[i]), NS_OK); @@ -1506,7 +1506,7 @@ class SignalingAgent { // the SDP. For now, we just specify audio/video, since a given DOMMediaStream // can have only one of each anyway. Once this is fixed, we will need to // pass a real track id if we want to test that case. - mozilla::RefPtr GetMediaPipeline( + RefPtr GetMediaPipeline( bool local, size_t stream, bool video) { SourceStreamInfo* streamInfo; if (local) { @@ -1541,11 +1541,11 @@ class SignalingAgent { } public: - nsRefPtr pc; - nsRefPtr pObserver; + RefPtr pc; + RefPtr pObserver; std::string offer_; std::string answer_; - std::vector> domMediaStreams_; + std::vector> domMediaStreams_; PeerConnectionConfiguration cfg_; const std::string name; bool mBundleEnabled; @@ -1576,8 +1576,8 @@ static void AddIceCandidateToPeer(nsWeakPtr weak_observer, return; } - nsRefPtr tmp2 = do_QueryObject(tmp); - nsRefPtr observer = static_cast(&*tmp2); + RefPtr tmp2 = do_QueryObject(tmp); + RefPtr observer = static_cast(&*tmp2); if (!observer) { return; @@ -4045,7 +4045,7 @@ TEST_P(SignalingTest, MaxFsFrCalleeCodec) // Checking callee's video sending configuration does respect max-fs and // max-fr in SDP offer. - mozilla::RefPtr pipeline = + RefPtr pipeline = a2_->GetMediaPipeline(1, 0, 1); ASSERT_TRUE(pipeline); mozilla::MediaSessionConduit *conduit = pipeline->Conduit(); @@ -4090,7 +4090,7 @@ TEST_P(SignalingTest, MaxFsFrCallerCodec) // Checking caller's video sending configuration does respect max-fs and // max-fr in SDP answer. - mozilla::RefPtr pipeline = + RefPtr pipeline = a1_->GetMediaPipeline(1, 0, 1); ASSERT_TRUE(pipeline); mozilla::MediaSessionConduit *conduit = pipeline->Conduit(); diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index 118148a721..f265769194 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -51,6 +51,8 @@ // and rarely used) valloc. #define MOZ_REPLACE_ONLY_MEMALIGN 1 +#ifndef PAGE_SIZE +#define DMD_DEFINED_PAGE_SIZE #ifdef XP_WIN #define PAGE_SIZE GetPageSize() static long GetPageSize() @@ -59,12 +61,16 @@ static long GetPageSize() GetSystemInfo(&si); return si.dwPageSize; } -#else +#else // XP_WIN #define PAGE_SIZE sysconf(_SC_PAGESIZE) -#endif +#endif // XP_WIN +#endif // PAGE_SIZE #include "replace_malloc.h" #undef MOZ_REPLACE_ONLY_MEMALIGN +#ifdef DMD_DEFINED_PAGE_SIZE +#undef DMD_DEFINED_PAGE_SIZE #undef PAGE_SIZE +#endif // DMD_DEFINED_PAGE_SIZE #include "DMD.h" @@ -76,13 +82,13 @@ class DMDBridge : public ReplaceMallocBridge virtual DMDFuncs* GetDMDFuncs() override; }; -static DMDBridge sDMDBridge; -static DMDFuncs sDMDFuncs; +static DMDBridge* gDMDBridge; +static DMDFuncs gDMDFuncs; DMDFuncs* DMDBridge::GetDMDFuncs() { - return &sDMDFuncs; + return &gDMDFuncs; } inline void @@ -90,7 +96,7 @@ StatusMsg(const char* aFmt, ...) { va_list ap; va_start(ap, aFmt); - sDMDFuncs.StatusMsg(aFmt, ap); + gDMDFuncs.StatusMsg(aFmt, ap); va_end(ap); } @@ -362,7 +368,13 @@ class Options // Like "Live", but also outputs the same data for dead blocks. This mode // does cumulative heap profiling, which is good for identifying where large // amounts of short-lived allocations occur. - Cumulative + Cumulative, + + // Like "Live", but this mode also outputs for each live block the address + // of the block and the values contained in the blocks. This mode is useful + // for investigating leaks, by helping to figure out which blocks refer to + // other blocks. This mode disables sampling. + Scan }; char* mDMDEnvVar; // a saved copy, for later printing @@ -384,6 +396,9 @@ public: bool IsLiveMode() const { return mMode == Live; } bool IsDarkMatterMode() const { return mMode == DarkMatter; } bool IsCumulativeMode() const { return mMode == Cumulative; } + bool IsScanMode() const { return mMode == Scan; } + + const char* ModeString() const; const char* DMDEnvVar() const { return mDMDEnvVar; } @@ -1209,7 +1224,7 @@ replace_init(const malloc_table_t* aMallocTable) ReplaceMallocBridge* replace_get_bridge() { - return &mozilla::dmd::sDMDBridge; + return mozilla::dmd::gDMDBridge; } void* @@ -1447,6 +1462,8 @@ Options::Options(const char* aDMDEnvVar) mMode = Options::DarkMatter; } else if (strcmp(arg, "--mode=cumulative") == 0) { mMode = Options::Cumulative; + } else if (strcmp(arg, "--mode=scan") == 0) { + mMode = Options::Scan; } else if (GetLong(arg, "--sample-below", 1, mSampleBelowSize.mMax, &myLong)) { @@ -1470,6 +1487,10 @@ Options::Options(const char* aDMDEnvVar) *e = replacedChar; } } + + if (mMode == Options::Scan) { + mSampleBelowSize.mActual = 1; + } } void @@ -1496,6 +1517,24 @@ Options::BadArg(const char* aArg) exit(1); } +const char* +Options::ModeString() const +{ + switch (mMode) { + case Live: + return "live"; + case DarkMatter: + return "dark-matter"; + case Cumulative: + return "cumulative"; + case Scan: + return "scan"; + default: + MOZ_ASSERT(false); + return "(unknown DMD mode)"; + } +} + //--------------------------------------------------------------------------- // DMD start-up //--------------------------------------------------------------------------- @@ -1516,6 +1555,7 @@ static void Init(const malloc_table_t* aMallocTable) { gMallocTable = aMallocTable; + gDMDBridge = InfallibleAllocPolicy::new_(); // DMD is controlled by the |DMD| environment variable. const char* e = getenv("DMD"); @@ -1743,6 +1783,41 @@ private: char mIdBuf[kIdBufLen]; }; +// Helper class for converting a pointer value to a string. +class ToStringConverter +{ +public: + const char* ToPtrString(const void* aPtr) + { + snprintf(kPtrBuf, sizeof(kPtrBuf) - 1, "%" PRIxPTR, (uintptr_t)aPtr); + return kPtrBuf; + } + +private: + char kPtrBuf[32]; +}; + +static void +WriteBlockContents(JSONWriter& aWriter, const LiveBlock& aBlock) +{ + MOZ_ASSERT(!aBlock.IsSampled(), "Sampled blocks do not have accurate sizes"); + + size_t numWords = aBlock.ReqSize() / sizeof(uintptr_t*); + if (numWords == 0) { + return; + } + + aWriter.StartArrayProperty("contents", aWriter.SingleLineStyle); + { + const uintptr_t** block = (const uintptr_t**)aBlock.Address(); + ToStringConverter sc; + for (size_t i = 0; i < numWords; ++i) { + aWriter.StringElement(sc.ToPtrString(block[i])); + } + } + aWriter.EndArray(); +} + static void AnalyzeImpl(UniquePtr aWriter) { @@ -1777,19 +1852,7 @@ AnalyzeImpl(UniquePtr aWriter) writer.NullProperty("dmdEnvVar"); } - const char* mode; - if (gOptions->IsLiveMode()) { - mode = "live"; - } else if (gOptions->IsDarkMatterMode()) { - mode = "dark-matter"; - } else if (gOptions->IsCumulativeMode()) { - mode = "cumulative"; - } else { - MOZ_ASSERT(false); - mode = "(unknown DMD mode)"; - } - writer.StringProperty("mode", mode); - + writer.StringProperty("mode", gOptions->ModeString()); writer.IntProperty("sampleBelowSize", gOptions->SampleBelowSize()); } writer.EndObject(); @@ -1797,6 +1860,7 @@ AnalyzeImpl(UniquePtr aWriter) StatusMsg(" Constructing the heap block list...\n"); ToIdStringConverter isc; + ToStringConverter sc; writer.StartArrayProperty("blockList"); { @@ -1808,6 +1872,10 @@ AnalyzeImpl(UniquePtr aWriter) writer.StartObjectElement(writer.SingleLineStyle); { if (!b.IsSampled()) { + if (gOptions->IsScanMode()) { + writer.StringProperty("addr", sc.ToPtrString(b.Address())); + WriteBlockContents(writer, b); + } writer.IntProperty("req", b.ReqSize()); if (b.SlopSize() > 0) { writer.IntProperty("slop", b.SlopSize()); @@ -1815,7 +1883,6 @@ AnalyzeImpl(UniquePtr aWriter) } writer.StringProperty("alloc", isc.ToIdString(b.AllocStackTrace())); if (gOptions->IsDarkMatterMode() && b.NumReports() > 0) { - MOZ_ASSERT(gOptions->IsDarkMatterMode()); writer.StartArrayProperty("reps"); { if (b.ReportStackTrace1()) { diff --git a/memory/replace/dmd/DMD.h b/memory/replace/dmd/DMD.h index 961bf3f269..5760952e8c 100644 --- a/memory/replace/dmd/DMD.h +++ b/memory/replace/dmd/DMD.h @@ -192,7 +192,16 @@ ClearReports() // // is mandatory if it is greater than one, but omitted otherwise. // // (Blocks with identical properties don't have to be aggregated via // // this property, but it can greatly reduce output file size.) -// "num": 5 +// "num": 5, +// +// // The address of the block. This is mandatory in "scan" mode for +// // non-sampled blocks, but omitted otherwise. +// "addr": "4e4e4e4e", +// +// // The contents of the block, read one word at a time. This is +// // mandatory in "scan" mode for non-sampled blocks at least one word +// // long, but omitted otherwise. +// "contents": ["0", "6", "7f7f7f7f", "0"] // }, // // // An example of a sampled heap block. diff --git a/memory/replace/dmd/block_analyzer.py b/memory/replace/dmd/block_analyzer.py new file mode 100644 index 0000000000..230cdd0e7e --- /dev/null +++ b/memory/replace/dmd/block_analyzer.py @@ -0,0 +1,265 @@ +#!/usr/bin/python + +# 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/. + +# From a scan mode DMD log, extract some information about a +# particular block, such as its allocation stack or which other blocks +# contain pointers to it. This can be useful when investigating leaks +# caused by unknown references to refcounted objects. + +import json +import gzip +import sys +import argparse +import re + + +# The DMD output version this script handles. +outputVersion = 4 + +# If --ignore-alloc-fns is specified, stack frames containing functions that +# match these strings will be removed from the *start* of stack traces. (Once +# we hit a non-matching frame, any subsequent frames won't be removed even if +# they do match.) +allocatorFns = [ + 'malloc (', + 'replace_malloc', + 'replace_calloc', + 'replace_realloc', + 'replace_memalign', + 'replace_posix_memalign', + 'malloc_zone_malloc', + 'moz_xmalloc', + 'moz_xcalloc', + 'moz_xrealloc', + 'operator new(', + 'operator new[](', + 'g_malloc', + 'g_slice_alloc', + 'callocCanGC', + 'reallocCanGC', + 'vpx_malloc', + 'vpx_calloc', + 'vpx_realloc', + 'vpx_memalign', + 'js_malloc', + 'js_calloc', + 'js_realloc', + 'pod_malloc', + 'pod_calloc', + 'pod_realloc', + 'nsTArrayInfallibleAllocator::Malloc', + # This one necessary to fully filter some sequences of allocation functions + # that happen in practice. Note that ??? entries that follow non-allocation + # functions won't be stripped, as explained above. + '???', +] + +#### + +# Command line arguments + +def range_1_24(string): + value = int(string) + if value < 1 or value > 24: + msg = '{:s} is not in the range 1..24'.format(string) + raise argparse.ArgumentTypeError(msg) + return value + +parser = argparse.ArgumentParser(description='Analyze the heap graph to find out things about an object. \ +By default this prints out information about blocks that point to the given block.') + +parser.add_argument('dmd_log_file_name', + help='clamped DMD log file name') + +parser.add_argument('block', + help='address of the block of interest') + +parser.add_argument('--info', dest='info', action='store_true', + default=False, + help='Print out information about the block.') + +parser.add_argument('-sfl', '--max-stack-frame-length', type=int, + default=150, + help='Maximum number of characters to print from each stack frame') + +parser.add_argument('-a', '--ignore-alloc-fns', action='store_true', + help='ignore allocation functions at the start of traces') + +parser.add_argument('-f', '--max-frames', type=range_1_24, + help='maximum number of frames to consider in each trace') + +parser.add_argument('-c', '--chain-reports', action='store_true', + help='if only one block is found to hold onto the object, report the next one, too') + + +#### + + +class BlockData: + def __init__(self, json_block): + self.addr = json_block['addr'] + + if 'contents' in json_block: + contents = json_block['contents'] + else: + contents = [] + self.contents = [] + for c in contents: + self.contents.append(int(c, 16)) + + self.req_size = json_block['req'] + + self.alloc_stack = json_block['alloc'] + + +def print_trace_segment(args, stacks, block): + (traceTable, frameTable) = stacks + + for l in traceTable[block.alloc_stack]: + # The 5: is to remove the bogus leading "#00: " from the stack frame. + print ' ', frameTable[l][5:args.max_stack_frame_length] + + +def show_referrers(args, blocks, stacks, block): + visited = set([]) + + anyFound = False + + while True: + referrers = {} + + for b, data in blocks.iteritems(): + which_edge = 0 + for e in data.contents: + if e == block: + # 8 is the number of bytes per word on a 64-bit system. + # XXX This means that this output will be wrong for logs from 32-bit systems! + referrers.setdefault(b, []).append(8 * which_edge) + anyFound = True + which_edge += 1 + + for r in referrers: + sys.stdout.write('0x{} size = {} bytes'.format(blocks[r].addr, blocks[r].req_size)) + plural = 's' if len(referrers[r]) > 1 else '' + sys.stdout.write(' at byte offset' + plural + ' ' + (', '.join(str(x) for x in referrers[r]))) + print + print_trace_segment(args, stacks, blocks[r]) + print + + if args.chain_reports: + if len(referrers) == 0: + sys.stdout.write('Found no more referrers.\n') + break + if len(referrers) > 1: + sys.stdout.write('Found too many referrers.\n') + break + + sys.stdout.write('Chaining to next referrer.\n\n') + for r in referrers: + block = r + if block in visited: + sys.stdout.write('Found a loop.\n') + break + visited.add(block) + else: + break + + if not anyFound: + print 'No referrers found.' + + +def show_block_info(args, blocks, stacks, block): + b = blocks[block] + sys.stdout.write('block: 0x{}\n'.format(b.addr)) + sys.stdout.write('requested size: {} bytes\n'.format(b.req_size)) + sys.stdout.write('\n') + sys.stdout.write('block contents: ') + for c in b.contents: + v = '0' if c == 0 else blocks[c].addr + sys.stdout.write('0x{} '.format(v)) + sys.stdout.write('\n\n') + sys.stdout.write('allocation stack:\n') + print_trace_segment(args, stacks, b) + return + + +def cleanupTraceTable(args, frameTable, traceTable): + # Remove allocation functions at the start of traces. + if args.ignore_alloc_fns: + # Build a regexp that matches every function in allocatorFns. + escapedAllocatorFns = map(re.escape, allocatorFns) + fn_re = re.compile('|'.join(escapedAllocatorFns)) + + # Remove allocator fns from each stack trace. + for traceKey, frameKeys in traceTable.items(): + numSkippedFrames = 0 + for frameKey in frameKeys: + frameDesc = frameTable[frameKey] + if re.search(fn_re, frameDesc): + numSkippedFrames += 1 + else: + break + if numSkippedFrames > 0: + traceTable[traceKey] = frameKeys[numSkippedFrames:] + + # Trim the number of frames. + for traceKey, frameKeys in traceTable.items(): + if len(frameKeys) > args.max_frames: + traceTable[traceKey] = frameKeys[:args.max_frames] + + +def loadGraph(options): + # Handle gzipped input if necessary. + isZipped = options.dmd_log_file_name.endswith('.gz') + opener = gzip.open if isZipped else open + + with opener(options.dmd_log_file_name, 'rb') as f: + j = json.load(f) + + if j['version'] != outputVersion: + raise Exception("'version' property isn't '{:d}'".format(outputVersion)) + + invocation = j['invocation'] + sampleBelowSize = invocation['sampleBelowSize'] + heapIsSampled = sampleBelowSize > 1 + if heapIsSampled: + raise Exception("Heap analysis is not going to work with sampled blocks.") + + block_list = j['blockList'] + blocks = {} + + for json_block in block_list: + blocks[int(json_block['addr'], 16)] = BlockData(json_block) + + traceTable = j['traceTable'] + frameTable = j['frameTable'] + + cleanupTraceTable(options, frameTable, traceTable) + + return (blocks, (traceTable, frameTable)) + + +def analyzeLogs(): + options = parser.parse_args() + + (blocks, stacks) = loadGraph(options) + + block = int(options.block, 16) + + if not block in blocks: + print 'Object', block, 'not found in traces.' + print 'It could still be the target of some nodes.' + return + + if options.info: + show_block_info(options, blocks, stacks, block) + return + + show_referrers(options, blocks, stacks, block) + + +if __name__ == "__main__": + analyzeLogs() diff --git a/memory/replace/dmd/dmd.py b/memory/replace/dmd/dmd.py index a6d0110c2a..72e14c2985 100755 --- a/memory/replace/dmd/dmd.py +++ b/memory/replace/dmd/dmd.py @@ -18,6 +18,7 @@ import re import shutil import sys import tempfile +from bisect import bisect_right # The DMD output version this script handles. outputVersion = 4 @@ -190,6 +191,12 @@ variable is used to find breakpad symbols for stack fixing. p.add_argument('--no-fix-stacks', action='store_true', help='do not fix stacks') + p.add_argument('--clamp-contents', action='store_true', + help='for a scan mode log, clamp addresses to the start of live blocks, or zero if not in one') + + p.add_argument('--print-clamp-stats', action='store_true', + help='print information about the results of pointer clamping; mostly useful for debugging clamping') + p.add_argument('--filter-stacks-for-testing', action='store_true', help='filter stack traces; only useful for testing purposes') @@ -261,6 +268,9 @@ def getDigestFromFile(args, inputFile): if not args.no_fix_stacks: fixStackTraces(inputFile, isZipped, opener) + if args.clamp_contents: + clampBlockList(args, inputFile, isZipped, opener) + with opener(inputFile, 'rb') as f: j = json.load(f) @@ -276,6 +286,10 @@ def getDigestFromFile(args, inputFile): traceTable = j['traceTable'] frameTable = j['frameTable'] + # For the purposes of this script, 'scan' behaves like 'live'. + if mode == 'scan': + mode = 'live' + if not mode in ['live', 'dark-matter', 'cumulative']: raise Exception("bad 'mode' property: '{:s}'".format(mode)) @@ -698,6 +712,197 @@ def printDigest(args, digest): out('}\n') +############################# +# Pretty printer for DMD JSON +############################# + +def prettyPrintDmdJson(out, j): + out.write('{\n') + + out.write(' "version": {0},\n'.format(j['version'])) + out.write(' "invocation": ') + json.dump(j['invocation'], out, sort_keys=True) + out.write(',\n') + + out.write(' "blockList": [') + first = True + for b in j['blockList']: + out.write('' if first else ',') + out.write('\n ') + json.dump(b, out, sort_keys=True) + first = False + out.write('\n ],\n') + + out.write(' "traceTable": {') + first = True + for k, l in j['traceTable'].iteritems(): + out.write('' if first else ',') + out.write('\n "{0}": {1}'.format(k, json.dumps(l))) + first = False + out.write('\n },\n') + + out.write(' "frameTable": {') + first = True + for k, v in j['frameTable'].iteritems(): + out.write('' if first else ',') + out.write('\n "{0}": "{1}"'.format(k, v)) + first = False + out.write('\n }\n') + + out.write('}\n') + + +################################################################## +# Code for clamping addresses using conservative pointer analysis. +################################################################## + +# Start is the address of the first byte of the block, while end is +# the address of the first byte after the final byte in the block. +class AddrRange: + def __init__(self, block, length): + self.block = block + self.start = int(block, 16) + self.length = length + self.end = self.start + self.length + + assert self.start > 0 + assert length >= 0 + + +class ClampStats: + def __init__(self): + # Number of pointers already pointing to the start of a block. + self.startBlockPtr = 0 + + # Number of pointers pointing to the middle of a block. These + # are clamped to the start of the block they point into. + self.midBlockPtr = 0 + + # Number of null pointers. + self.nullPtr = 0 + + # Number of non-null pointers that didn't point into the middle + # of any blocks. These are clamped to null. + self.nonNullNonBlockPtr = 0 + + + def clampedBlockAddr(self, sameAddress): + if sameAddress: + self.startBlockPtr += 1 + else: + self.midBlockPtr += 1 + + def nullAddr(self): + self.nullPtr += 1 + + def clampedNonBlockAddr(self): + self.nonNullNonBlockPtr += 1 + + def log(self): + sys.stderr.write('Results:\n') + sys.stderr.write(' Number of pointers already pointing to start of blocks: ' + str(self.startBlockPtr) + '\n') + sys.stderr.write(' Number of pointers clamped to start of blocks: ' + str(self.midBlockPtr) + '\n') + sys.stderr.write(' Number of non-null pointers not pointing into blocks clamped to null: ' + str(self.nonNullNonBlockPtr) + '\n') + sys.stderr.write(' Number of null pointers: ' + str(self.nullPtr) + '\n') + + +# Search the block ranges array for a block that address points into. +# The search is carried out in an array of starting addresses for each blocks +# because it is faster. +def clampAddress(blockRanges, blockStarts, clampStats, address): + i = bisect_right(blockStarts, address) + + # Any addresses completely out of the range should have been eliminated already. + assert i > 0 + r = blockRanges[i - 1] + assert r.start <= address + + if address >= r.end: + assert address < blockRanges[i].start + clampStats.clampedNonBlockAddr() + return '0' + + clampStats.clampedBlockAddr(r.start == address) + return r.block + + +def clampBlockList(args, inputFileName, isZipped, opener): + # XXX This isn't very efficient because we end up reading and writing + # the file multiple times. + with opener(inputFileName, 'rb') as f: + j = json.load(f) + + if j['version'] != outputVersion: + raise Exception("'version' property isn't '{:d}'".format(outputVersion)) + + # Check that the invocation is reasonable for contents clamping. + invocation = j['invocation'] + if invocation['sampleBelowSize'] > 1: + raise Exception("Heap analysis is not going to work with sampled blocks.") + if invocation['mode'] != 'scan': + raise Exception("Log was taken in mode " + invocation['mode'] + " not scan") + + sys.stderr.write('Creating block range list.\n') + blockList = j['blockList'] + blockRanges = [] + for block in blockList: + blockRanges.append(AddrRange(block['addr'], block['req'])) + blockRanges.sort(key=lambda r: r.start) + + # Make sure there are no overlapping blocks. + prevRange = blockRanges[0] + for currRange in blockRanges[1:]: + assert prevRange.end <= currRange.start + prevRange = currRange + + sys.stderr.write('Clamping block contents.\n') + clampStats = ClampStats() + firstAddr = blockRanges[0].start + lastAddr = blockRanges[-1].end + + blockStarts = [] + for r in blockRanges: + blockStarts.append(r.start) + + for block in blockList: + # Small blocks don't have any contents. + if not 'contents' in block: + continue + + cont = block['contents'] + for i in range(len(cont)): + address = int(cont[i], 16) + + if address == 0: + clampStats.nullAddr() + continue + + # If the address is before the first block or after the last + # block then it can't be within a block. + if address < firstAddr or address >= lastAddr: + clampStats.clampedNonBlockAddr() + cont[i] = '0' + continue + + cont[i] = clampAddress(blockRanges, blockStarts, clampStats, address) + + # Remove any trailing nulls. + while len(cont) and cont[-1] == '0': + cont.pop() + + if args.print_clamp_stats: + clampStats.log() + + sys.stderr.write('Saving file.\n') + tmpFile = tempfile.NamedTemporaryFile(delete=False) + tmpFilename = tmpFile.name + if isZipped: + tmpFile = gzip.GzipFile(filename='', fileobj=tmpFile) + prettyPrintDmdJson(tmpFile, j) + tmpFile.close() + shutil.move(tmpFilename, inputFileName) + + def main(): args = parseCommandLine() digest = getDigestFromFile(args, args.input_file) diff --git a/memory/replace/dmd/test/SmokeDMD.cpp b/memory/replace/dmd/test/SmokeDMD.cpp index ea422a2b66..d9de24d9d9 100644 --- a/memory/replace/dmd/test/SmokeDMD.cpp +++ b/memory/replace/dmd/test/SmokeDMD.cpp @@ -333,6 +333,27 @@ TestSampled(const char* aTestName, const char* aMode, int aSeven) Analyze(Move(f)); } +void +TestScan(int aSeven) +{ + auto f = MakeUnique("basic-scan.json"); + + ResetEverything("--mode=scan"); + + uintptr_t* p = (uintptr_t*) malloc(6 * sizeof(uintptr_t*)); + UseItOrLoseIt(p, aSeven); + + // Hard-coded values checked by scan-test.py + p[0] = 0x123; // outside a block, small value + p[1] = 0x0; // null + p[2] = (uintptr_t)((uint8_t*)p - 1); // pointer outside a block, but nearby + p[3] = (uintptr_t)p; // pointer to start of a block + p[4] = (uintptr_t)((uint8_t*)p + 1); // pointer into a block + p[5] = 0x0; // trailing null + + Analyze(Move(f)); +} + void RunTests() { @@ -363,6 +384,8 @@ RunTests() TestUnsampled("unsampled", 2, "cumulative", seven); TestSampled("sampled", "live", seven); + + TestScan(seven); } int main() diff --git a/memory/replace/dmd/test/basic-scan-32-expected.txt b/memory/replace/dmd/test/basic-scan-32-expected.txt new file mode 100644 index 0000000000..341888b8a0 --- /dev/null +++ b/memory/replace/dmd/test/basic-scan-32-expected.txt @@ -0,0 +1,26 @@ +#----------------------------------------------------------------- +# dmd.py --filter-stacks-for-testing -o basic-scan-32-actual.txt --clamp-contents basic-scan.json + +Invocation { + $DMD = '--mode=scan' + Mode = 'live' + Sample-below size = 1 +} + +#----------------------------------------------------------------- + +Live { + 1 block in heap block record 1 of 1 + 32 bytes (24 requested / 8 slop) + 100.00% of the heap (100.00% cumulative) + Allocated at { + #01: ... DMD.cpp ... + } +} + +#----------------------------------------------------------------- + +Summary { + Total: 32 bytes in 1 blocks +} + diff --git a/memory/replace/dmd/test/basic-scan-64-expected.txt b/memory/replace/dmd/test/basic-scan-64-expected.txt new file mode 100644 index 0000000000..6920ae3a0e --- /dev/null +++ b/memory/replace/dmd/test/basic-scan-64-expected.txt @@ -0,0 +1,26 @@ +#----------------------------------------------------------------- +# dmd.py --filter-stacks-for-testing -o basic-scan-64-actual.txt --clamp-contents basic-scan.json + +Invocation { + $DMD = '--mode=scan' + Mode = 'live' + Sample-below size = 1 +} + +#----------------------------------------------------------------- + +Live { + 1 block in heap block record 1 of 1 + 48 bytes (48 requested / 0 slop) + 100.00% of the heap (100.00% cumulative) + Allocated at { + #01: ... DMD.cpp ... + } +} + +#----------------------------------------------------------------- + +Summary { + Total: 48 bytes in 1 blocks +} + diff --git a/memory/replace/dmd/test/scan-test.py b/memory/replace/dmd/test/scan-test.py new file mode 100644 index 0000000000..32c4109932 --- /dev/null +++ b/memory/replace/dmd/test/scan-test.py @@ -0,0 +1,87 @@ +#! /usr/bin/env python +# +# 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/. + +'''Testing for the JSON file emitted by DMD heap scan mode when running SmokeDMD.''' + +from __future__ import print_function, division + +import argparse +import gzip +import json +import sys + +# The DMD output version this script handles. +outputVersion = 4 + + +def parseCommandLine(): + description = ''' +Ensure that DMD heap scan mode creates the correct output when run with SmokeDMD. +This is only for testing. Input files can be gzipped. +''' + p = argparse.ArgumentParser(description=description) + + p.add_argument('--clamp-contents', action='store_true', + help='expect that the contents of the JSON input file have had their addresses clamped') + + p.add_argument('input_file', + help='a file produced by DMD') + + return p.parse_args(sys.argv[1:]) + + +def checkScanContents(contents, expected): + if len(contents) != len(expected): + raise Exception("Expected " + str(len(expected)) + " things in contents but found " + str(len(contents))) + + for i in range(len(expected)): + if contents[i] != expected[i]: + raise Exception("Expected to find " + expected[i] + " at offset " + str(i) + " but found " + contents[i]) + + +def main(): + args = parseCommandLine() + + # Handle gzipped input if necessary. + isZipped = args.input_file.endswith('.gz') + opener = gzip.open if isZipped else open + + with opener(args.input_file, 'rb') as f: + j = json.load(f) + + if j['version'] != outputVersion: + raise Exception("'version' property isn't '{:d}'".format(outputVersion)) + + invocation = j['invocation'] + + mode = invocation['mode'] + if mode != 'scan': + raise Exception("bad 'mode' property: '{:s}'".format(mode)) + + sampleBelowSize = invocation['sampleBelowSize'] + if sampleBelowSize != 1: + raise Exception("Expected sampleBelowSize of 1 but got " + sampleBelowSize) + + blockList = j['blockList'] + + if len(blockList) != 1: + raise Exception("Expected only one block") + + b = blockList[0] + + # The expected values are based on hard-coded values in SmokeDMD.cpp. + if args.clamp_contents: + expected = ['0', '0', '0', b['addr'], b['addr']] + else: + addr = int(b['addr'], 16) + expected = ['123', '0', str(format(addr - 1, 'x')), b['addr'], + str(format(addr + 1, 'x')), '0'] + + checkScanContents(b['contents'], expected) + + +if __name__ == '__main__': + main() diff --git a/memory/replace/dmd/test/test_dmd.js b/memory/replace/dmd/test/test_dmd.js index eaa1b9ac82..584256cea2 100644 --- a/memory/replace/dmd/test/test_dmd.js +++ b/memory/replace/dmd/test/test_dmd.js @@ -36,6 +36,8 @@ let gDmdTestFile = getExecutable("SmokeDMD" + (gIsWindows ? ".exe" : "")); let gDmdScriptFile = getExecutable("dmd.py"); +let gScanTestFile = FileUtils.getFile("CurWorkD", ["scan-test.py"]); + function readFile(aFile) { let fstream = Cc["@mozilla.org/network/file-input-stream;1"] .createInstance(Ci.nsIFileInputStream); @@ -113,6 +115,16 @@ function test(aPrefix, aArgs) { actualFile.remove(true); } +// Run scan-test.py on the JSON file and see if it succeeds. +function scanTest(aJsonFilePath, aExtraArgs) { + let args = [ + gScanTestFile.path, + aJsonFilePath, + ].concat(aExtraArgs); + + return runProcess(new FileUtils.File(gPythonName), args) == 0; +} + function run_test() { let jsonFile, jsonFile2; @@ -148,6 +160,22 @@ function run_test() { test2("sampled", "live"); + // Heap scan testing. + jsonFile = FileUtils.getFile("CurWorkD", ["basic-scan.json"]); + ok(scanTest(jsonFile.path), "Basic scan test"); + + let is64Bit = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime).is64Bit; + let basicScanFileName = "basic-scan-" + (is64Bit ? "64" : "32"); + test(basicScanFileName, ["--clamp-contents", jsonFile.path]); + ok(scanTest(jsonFile.path, ["--clamp-contents"]), "Scan with address clamping"); + // Run the generic test a second time to ensure that the first time produced + // valid JSON output. "--clamp-contents" is passed in so we don't have to have + // more variants of the files. + test(basicScanFileName, ["--clamp-contents", jsonFile.path]); + jsonFile.remove(true); + + // These tests only test the post-processing script. They use hand-written // JSON files as input. Ideally the JSON files would contain comments // explaining how they work, but JSON doesn't allow comments, so I've put diff --git a/memory/replace/dmd/test/xpcshell.ini b/memory/replace/dmd/test/xpcshell.ini index 057736a2fb..a583c1c18c 100644 --- a/memory/replace/dmd/test/xpcshell.ini +++ b/memory/replace/dmd/test/xpcshell.ini @@ -1,5 +1,7 @@ [DEFAULT] support-files = + basic-scan-32-expected.txt + basic-scan-64-expected.txt full-empty-live-expected.txt full-empty-dark-matter-expected.txt full-empty-cumulative-expected.txt @@ -8,6 +10,7 @@ support-files = full-unsampled2-dark-matter-expected.txt full-unsampled2-cumulative-expected.txt full-sampled-live-expected.txt + scan-test.py script-max-frames.json script-max-frames-8-expected.txt script-max-frames-3-expected.txt diff --git a/mfbt/AlreadyAddRefed.h b/mfbt/AlreadyAddRefed.h index d141bc6420..b2c35d3403 100644 --- a/mfbt/AlreadyAddRefed.h +++ b/mfbt/AlreadyAddRefed.h @@ -84,13 +84,13 @@ struct MOZ_MUST_USE MOZ_NON_AUTOABLE already_AddRefed * already_AddRefed * Foo() * { - * nsRefPtr x = ...; + * RefPtr x = ...; * return x.forget(); * } * * The autoconversion allows one to omit the idiom * - * nsRefPtr y = x.forget(); + * RefPtr y = x.forget(); * return y.forget(); * * Note that nsRefPtr is the XPCOM reference counting smart pointer class. diff --git a/mfbt/RefCounted.h b/mfbt/RefCounted.h index 5532cffc4d..873e40ea6a 100644 --- a/mfbt/RefCounted.h +++ b/mfbt/RefCounted.h @@ -29,8 +29,6 @@ namespace mozilla { -template class RefPtr; - /** * RefCounted is a sort of a "mixin" for a class T. RefCounted * manages, well, refcounting for T, and because RefCounted is @@ -45,8 +43,8 @@ template class RefPtr; * do so will abort DEBUG builds. * * Live RefCounted have refcount > 0. The lifetime (refcounts) of - * live RefCounted are controlled by nsRefPtr and - * nsRefPtr. Upon a transition from refcounted==1 + * live RefCounted are controlled by RefPtr and + * RefPtr. Upon a transition from refcounted==1 * to 0, the RefCounted "dies" and is destroyed. The "destroyed" * state is represented in DEBUG builds by refcount==0xffffdead. This * state distinguishes use-before-ref (refcount==0) from @@ -92,8 +90,6 @@ enum RefCountAtomicity template class RefCounted { - friend class RefPtr; - protected: RefCounted() : mRefCnt(0) {} ~RefCounted() { MOZ_ASSERT(mRefCnt == detail::DEAD); } diff --git a/mfbt/RefPtr.h b/mfbt/RefPtr.h index a1ad86031e..cb95fbdb2a 100644 --- a/mfbt/RefPtr.h +++ b/mfbt/RefPtr.h @@ -4,207 +4,600 @@ * 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/. */ -/* Helpers for defining and using refcounted objects. */ - #ifndef mozilla_RefPtr_h #define mozilla_RefPtr_h #include "mozilla/AlreadyAddRefed.h" #include "mozilla/Assertions.h" -#include "mozilla/Atomics.h" #include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/RefCounted.h" -#include "mozilla/RefCountType.h" -#include "mozilla/nsRefPtr.h" -#include "mozilla/TypeTraits.h" -#if defined(MOZILLA_INTERNAL_API) -#include "nsXPCOM.h" -#endif -#if defined(MOZILLA_INTERNAL_API) && \ - !defined(MOZILLA_XPCOMRT_API) && \ - (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING)) -#define MOZ_REFCOUNTED_LEAK_CHECKING -#endif +/*****************************************************************************/ + +// template class RefPtrGetterAddRefs; + +class nsCOMPtr_helper; namespace mozilla { +template class OwningNonNull; +} // namespace mozilla -template class OutParamRef; -template OutParamRef byRef(RefPtr&); - -/** - * RefPtr points to a refcounted thing that has AddRef and Release - * methods to increase/decrease the refcount, respectively. After a - * RefPtr is assigned a T*, the T* can be used through the RefPtr - * as if it were a T*. - * - * A RefPtr can forget its underlying T*, which results in the T* - * being wrapped in a temporary object until the T* is either - * re-adopted from or released by the temporary. - */ -template +template class RefPtr { - // To allow them to use unref() - friend class OutParamRef; +private: + void + assign_with_AddRef(T* aRawPtr) + { + if (aRawPtr) { + AddRefTraits::AddRef(aRawPtr); + } + assign_assuming_AddRef(aRawPtr); + } - struct DontRef {}; + void + assign_assuming_AddRef(T* aNewPtr) + { + T* oldPtr = mRawPtr; + mRawPtr = aNewPtr; + if (oldPtr) { + AddRefTraits::Release(oldPtr); + } + } + +private: + T* MOZ_OWNING_REF mRawPtr; public: - RefPtr() : mPtr(0) {} - RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {} - MOZ_IMPLICIT RefPtr(already_AddRefed& aOther) : mPtr(aOther.take()) {} - MOZ_IMPLICIT RefPtr(already_AddRefed&& aOther) : mPtr(aOther.take()) {} - MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {} + typedef T element_type; - template - MOZ_IMPLICIT RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.get())) {} + ~RefPtr() + { + if (mRawPtr) { + AddRefTraits::Release(mRawPtr); + } + } - ~RefPtr() { unref(mPtr); } + // Constructors - RefPtr& operator=(const RefPtr& aOther) + RefPtr() + : mRawPtr(0) + // default constructor { - assign(ref(aOther.mPtr)); - return *this; } - RefPtr& operator=(already_AddRefed& aOther) + + RefPtr(const RefPtr& aSmartPtr) + : mRawPtr(aSmartPtr.mRawPtr) + // copy-constructor { - assign(aOther.take()); - return *this; + if (mRawPtr) { + AddRefTraits::AddRef(mRawPtr); + } } - RefPtr& operator=(already_AddRefed&& aOther) + + RefPtr(RefPtr&& aRefPtr) + : mRawPtr(aRefPtr.mRawPtr) { - assign(aOther.take()); - return *this; + aRefPtr.mRawPtr = nullptr; } - RefPtr& operator=(T* aVal) + + // construct from a raw pointer (of the right type) + + MOZ_IMPLICIT RefPtr(T* aRawPtr) + : mRawPtr(aRawPtr) { - assign(ref(aVal)); + if (mRawPtr) { + AddRefTraits::AddRef(mRawPtr); + } + } + + template + MOZ_IMPLICIT RefPtr(already_AddRefed& aSmartPtr) + : mRawPtr(aSmartPtr.take()) + // construct from |already_AddRefed| + { + } + + template + MOZ_IMPLICIT RefPtr(already_AddRefed&& aSmartPtr) + : mRawPtr(aSmartPtr.take()) + // construct from |otherRefPtr.forget()| + { + } + + template + MOZ_IMPLICIT RefPtr(const RefPtr& aSmartPtr) + : mRawPtr(aSmartPtr.get()) + // copy-construct from a smart pointer with a related pointer type + { + if (mRawPtr) { + AddRefTraits::AddRef(mRawPtr); + } + } + + template + MOZ_IMPLICIT RefPtr(RefPtr&& aSmartPtr) + : mRawPtr(aSmartPtr.forget().take()) + // construct from |Move(RefPtr)|. + { + } + + MOZ_IMPLICIT RefPtr(const nsCOMPtr_helper& aHelper); + + // Defined in OwningNonNull.h + template + MOZ_IMPLICIT RefPtr(const mozilla::OwningNonNull& aOther); + + // Assignment operators + + RefPtr& + operator=(const RefPtr& aRhs) + // copy assignment operator + { + assign_with_AddRef(aRhs.mRawPtr); return *this; } - template - RefPtr& operator=(const RefPtr& aOther) + template + RefPtr& + operator=(const RefPtr& aRhs) + // assign from an RefPtr of a related pointer type { - assign(ref(aOther.get())); + assign_with_AddRef(aRhs.get()); return *this; } - already_AddRefed forget() + RefPtr& + operator=(T* aRhs) + // assign from a raw pointer (of the right type) { - T* tmp = mPtr; - mPtr = nullptr; - return already_AddRefed(tmp); + assign_with_AddRef(aRhs); + return *this; + } + + template + RefPtr& + operator=(already_AddRefed& aRhs) + // assign from |already_AddRefed| + { + assign_assuming_AddRef(aRhs.take()); + return *this; + } + + template + RefPtr& + operator=(already_AddRefed && aRhs) + // assign from |otherRefPtr.forget()| + { + assign_assuming_AddRef(aRhs.take()); + return *this; + } + + RefPtr& operator=(const nsCOMPtr_helper& aHelper); + + RefPtr& + operator=(RefPtr && aRefPtr) + { + assign_assuming_AddRef(aRefPtr.mRawPtr); + aRefPtr.mRawPtr = nullptr; + return *this; + } + + // Defined in OwningNonNull.h + template + RefPtr& + operator=(const mozilla::OwningNonNull& aOther); + + // Other pointer operators + + void + swap(RefPtr& aRhs) + // ...exchange ownership with |aRhs|; can save a pair of refcount operations + { + T* temp = aRhs.mRawPtr; + aRhs.mRawPtr = mRawPtr; + mRawPtr = temp; + } + + void + swap(T*& aRhs) + // ...exchange ownership with |aRhs|; can save a pair of refcount operations + { + T* temp = aRhs; + aRhs = mRawPtr; + mRawPtr = temp; + } + + already_AddRefed + forget() + // return the value of mRawPtr and null out mRawPtr. Useful for + // already_AddRefed return values. + { + T* temp = 0; + swap(temp); + return already_AddRefed(temp); + } + + template + void + forget(I** aRhs) + // Set the target of aRhs to the value of mRawPtr and null out mRawPtr. + // Useful to avoid unnecessary AddRef/Release pairs with "out" + // parameters where aRhs bay be a T** or an I** where I is a base class + // of T. + { + MOZ_ASSERT(aRhs, "Null pointer passed to forget!"); + *aRhs = mRawPtr; + mRawPtr = 0; + } + + T* + get() const + /* + Prefer the implicit conversion provided automatically by |operator T*() const|. + Use |get()| to resolve ambiguity or to get a castable pointer. + */ + { + return const_cast(mRawPtr); } - T* get() const { return mPtr; } operator T*() const #ifdef MOZ_HAVE_REF_QUALIFIERS & #endif - { return mPtr; } - T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mPtr; } - T& operator*() const { return *mPtr; } + /* + ...makes an |RefPtr| act like its underlying raw pointer type whenever it + is used in a context where a raw pointer is expected. It is this operator + that makes an |RefPtr| substitutable for a raw pointer. + + Prefer the implicit use of this operator to calling |get()|, except where + necessary to resolve ambiguity. + */ + { + return get(); + } #ifdef MOZ_HAVE_REF_QUALIFIERS - // Don't allow implicit conversion of temporary RefPtr to raw pointer, because - // the refcount might be one and the pointer will immediately become invalid. + // Don't allow implicit conversion of temporary RefPtr to raw pointer, + // because the refcount might be one and the pointer will immediately become + // invalid. operator T*() const && = delete; - // Needed to avoid the deleted operator above - explicit operator bool() const { return !!mPtr; } + // These are needed to avoid the deleted operator above. XXX Why is operator! + // needed separately? Shouldn't the compiler prefer using the non-deleted + // operator bool instead of the deleted operator T*? + explicit operator bool() const { return !!mRawPtr; } + bool operator!() const { return !mRawPtr; } #endif -private: - void assign(T* aVal) + T* + operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { - T* tmp = mPtr; - mPtr = aVal; - unref(tmp); + MOZ_ASSERT(mRawPtr != 0, + "You can't dereference a NULL RefPtr with operator->()."); + return get(); } - T* MOZ_OWNING_REF mPtr; - - static MOZ_ALWAYS_INLINE T* ref(T* aVal) + template + class Proxy { - if (aVal) { - aVal->AddRef(); + typedef R (T::*member_function)(Args...); + T* mRawPtr; + member_function mFunction; + public: + Proxy(T* aRawPtr, member_function aFunction) + : mRawPtr(aRawPtr), + mFunction(aFunction) + { } - return aVal; - } - - static MOZ_ALWAYS_INLINE void unref(T* aVal) - { - if (aVal) { - aVal->Release(); + template + R operator()(ActualArgs&&... aArgs) + { + return ((*mRawPtr).*mFunction)(mozilla::Forward(aArgs)...); } - } -}; + }; -/** - * OutParamRef is a wrapper that tracks a refcounted pointer passed as - * an outparam argument to a function. OutParamRef implements COM T** - * outparam semantics: this requires the callee to AddRef() the T* - * returned through the T** outparam on behalf of the caller. This - * means the caller (through OutParamRef) must Release() the old - * object contained in the tracked RefPtr. It's OK if the callee - * returns the same T* passed to it through the T** outparam, as long - * as the callee obeys the COM discipline. - * - * Prefer returning already_AddRefed from functions over creating T** - * outparams and passing OutParamRef to T**. Prefer RefPtr* - * outparams over T** outparams. - */ -template -class OutParamRef -{ - friend OutParamRef byRef(RefPtr&); + template + Proxy operator->*(R (T::*aFptr)(Args...)) const + { + MOZ_ASSERT(mRawPtr != 0, + "You can't dereference a NULL RefPtr with operator->*()."); + return Proxy(get(), aFptr); + } + + RefPtr* + get_address() + // This is not intended to be used by clients. See |address_of| + // below. + { + return this; + } + + const RefPtr* + get_address() const + // This is not intended to be used by clients. See |address_of| + // below. + { + return this; + } public: - ~OutParamRef() + T& + operator*() const { - RefPtr::unref(mRefPtr.mPtr); - mRefPtr.mPtr = mTmp; + MOZ_ASSERT(mRawPtr != 0, + "You can't dereference a NULL RefPtr with operator*()."); + return *get(); } - operator T**() { return &mTmp; } - + T** + StartAssignment() + { + assign_assuming_AddRef(0); + return reinterpret_cast(&mRawPtr); + } private: - explicit OutParamRef(RefPtr& p) : mRefPtr(p), mTmp(p.get()) {} - - RefPtr& mRefPtr; - T* mTmp; - - OutParamRef() = delete; - OutParamRef& operator=(const OutParamRef&) = delete; + // This helper class makes |RefPtr| possible by casting away + // the constness from the pointer when calling AddRef() and Release(). + // This is necessary because AddRef() and Release() implementations can't + // generally expected to be const themselves (without heavy use of |mutable| + // and |const_cast| in their own implementations). + // This should be sound because while |RefPtr| provides a const + // view of an object, the object itself should be const (it would have to be + // allocated as |new const T| or similar to itself be const). + template + struct AddRefTraits + { + static void AddRef(U* aPtr) { + aPtr->AddRef(); + } + static void Release(U* aPtr) { + aPtr->Release(); + } + }; + template + struct AddRefTraits + { + static void AddRef(const U* aPtr) { + const_cast(aPtr)->AddRef(); + } + static void Release(const U* aPtr) { + const_cast(aPtr)->Release(); + } + }; }; -/** - * byRef cooperates with OutParamRef to implement COM outparam semantics. - */ -template -OutParamRef -byRef(RefPtr& aPtr) +class nsCycleCollectionTraversalCallback; +template +void +CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback, + T* aChild, const char* aName, uint32_t aFlags); + +template +inline void +ImplCycleCollectionUnlink(RefPtr& aField) { - return OutParamRef(aPtr); + aField = nullptr; +} + +template +inline void +ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, + RefPtr& aField, + const char* aName, + uint32_t aFlags = 0) +{ + CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags); +} + +template +inline RefPtr* +address_of(RefPtr& aPtr) +{ + return aPtr.get_address(); +} + +template +inline const RefPtr* +address_of(const RefPtr& aPtr) +{ + return aPtr.get_address(); +} + +template +class RefPtrGetterAddRefs +/* + ... + + This class is designed to be used for anonymous temporary objects in the + argument list of calls that return COM interface pointers, e.g., + + RefPtr fooP; + ...->GetAddRefedPointer(getter_AddRefs(fooP)) + + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. + + When initialized with a |RefPtr|, as in the example above, it returns + a |void**|, a |T**|, or an |nsISupports**| as needed, that the + outer call (|GetAddRefedPointer| in this case) can fill in. + + This type should be a nested class inside |RefPtr|. +*/ +{ +public: + explicit + RefPtrGetterAddRefs(RefPtr& aSmartPtr) + : mTargetSmartPtr(aSmartPtr) + { + // nothing else to do + } + + operator void**() + { + return reinterpret_cast(mTargetSmartPtr.StartAssignment()); + } + + operator T**() + { + return mTargetSmartPtr.StartAssignment(); + } + + T*& + operator*() + { + return *(mTargetSmartPtr.StartAssignment()); + } + +private: + RefPtr& mTargetSmartPtr; +}; + +template +inline RefPtrGetterAddRefs +getter_AddRefs(RefPtr& aSmartPtr) +/* + Used around a |RefPtr| when + ...makes the class |RefPtrGetterAddRefs| invisible. +*/ +{ + return RefPtrGetterAddRefs(aSmartPtr); +} + + +// Comparing two |RefPtr|s + +template +inline bool +operator==(const RefPtr& aLhs, const RefPtr& aRhs) +{ + return static_cast(aLhs.get()) == static_cast(aRhs.get()); +} + + +template +inline bool +operator!=(const RefPtr& aLhs, const RefPtr& aRhs) +{ + return static_cast(aLhs.get()) != static_cast(aRhs.get()); +} + + +// Comparing an |RefPtr| to a raw pointer + +template +inline bool +operator==(const RefPtr& aLhs, const U* aRhs) +{ + return static_cast(aLhs.get()) == static_cast(aRhs); +} + +template +inline bool +operator==(const U* aLhs, const RefPtr& aRhs) +{ + return static_cast(aLhs) == static_cast(aRhs.get()); +} + +template +inline bool +operator!=(const RefPtr& aLhs, const U* aRhs) +{ + return static_cast(aLhs.get()) != static_cast(aRhs); +} + +template +inline bool +operator!=(const U* aLhs, const RefPtr& aRhs) +{ + return static_cast(aLhs) != static_cast(aRhs.get()); +} + +template +inline bool +operator==(const RefPtr& aLhs, U* aRhs) +{ + return static_cast(aLhs.get()) == const_cast(aRhs); +} + +template +inline bool +operator==(U* aLhs, const RefPtr& aRhs) +{ + return const_cast(aLhs) == static_cast(aRhs.get()); +} + +template +inline bool +operator!=(const RefPtr& aLhs, U* aRhs) +{ + return static_cast(aLhs.get()) != const_cast(aRhs); +} + +template +inline bool +operator!=(U* aLhs, const RefPtr& aRhs) +{ + return const_cast(aLhs) != static_cast(aRhs.get()); +} + +// Comparing an |RefPtr| to |nullptr| + +template +inline bool +operator==(const RefPtr& aLhs, decltype(nullptr)) +{ + return aLhs.get() == nullptr; +} + +template +inline bool +operator==(decltype(nullptr), const RefPtr& aRhs) +{ + return nullptr == aRhs.get(); +} + +template +inline bool +operator!=(const RefPtr& aLhs, decltype(nullptr)) +{ + return aLhs.get() != nullptr; +} + +template +inline bool +operator!=(decltype(nullptr), const RefPtr& aRhs) +{ + return nullptr != aRhs.get(); +} + +/*****************************************************************************/ + +template +inline already_AddRefed +do_AddRef(T*&& aObj) +{ + RefPtr ref(aObj); + return ref.forget(); +} + +namespace mozilla { + +/** + * Helper function to be able to conveniently write things like: + * + * already_AddRefed + * f(...) + * { + * return MakeAndAddRef(...); + * } + */ +template +already_AddRefed +MakeAndAddRef(Args&&... aArgs) +{ + RefPtr p(new T(Forward(aArgs)...)); + return p.forget(); } } // namespace mozilla -// Declared in nsRefPtr.h -template template -nsRefPtr::nsRefPtr(mozilla::RefPtr&& aOther) - : nsRefPtr(aOther.forget()) -{ -} - -template template -nsRefPtr& -nsRefPtr::operator=(mozilla::RefPtr&& aOther) -{ - assign_assuming_AddRef(aOther.forget().take()); - return *this; -} - #endif /* mozilla_RefPtr_h */ diff --git a/mfbt/moz.build b/mfbt/moz.build index d3ba9e1de6..6d062c2351 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -59,7 +59,6 @@ EXPORTS.mozilla = [ 'MemoryChecking.h', 'MemoryReporting.h', 'Move.h', - 'nsRefPtr.h', 'NullPtr.h', 'NumericLimits.h', 'Opaque.h', diff --git a/mfbt/nsRefPtr.h b/mfbt/nsRefPtr.h deleted file mode 100644 index deb8777751..0000000000 --- a/mfbt/nsRefPtr.h +++ /dev/null @@ -1,613 +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 mozilla_nsRefPtr_h -#define mozilla_nsRefPtr_h - -#include "mozilla/AlreadyAddRefed.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -/*****************************************************************************/ - -// template class nsRefPtrGetterAddRefs; - -class nsCOMPtr_helper; - -namespace mozilla { -template class OwningNonNull; -template class RefPtr; -} // namespace mozilla - -template -class nsRefPtr -{ -private: - void - assign_with_AddRef(T* aRawPtr) - { - if (aRawPtr) { - AddRefTraits::AddRef(aRawPtr); - } - assign_assuming_AddRef(aRawPtr); - } - - void - assign_assuming_AddRef(T* aNewPtr) - { - T* oldPtr = mRawPtr; - mRawPtr = aNewPtr; - if (oldPtr) { - AddRefTraits::Release(oldPtr); - } - } - -private: - T* MOZ_OWNING_REF mRawPtr; - -public: - typedef T element_type; - - ~nsRefPtr() - { - if (mRawPtr) { - AddRefTraits::Release(mRawPtr); - } - } - - // Constructors - - nsRefPtr() - : mRawPtr(0) - // default constructor - { - } - - nsRefPtr(const nsRefPtr& aSmartPtr) - : mRawPtr(aSmartPtr.mRawPtr) - // copy-constructor - { - if (mRawPtr) { - AddRefTraits::AddRef(mRawPtr); - } - } - - nsRefPtr(nsRefPtr&& aRefPtr) - : mRawPtr(aRefPtr.mRawPtr) - { - aRefPtr.mRawPtr = nullptr; - } - - // construct from a raw pointer (of the right type) - - MOZ_IMPLICIT nsRefPtr(T* aRawPtr) - : mRawPtr(aRawPtr) - { - if (mRawPtr) { - AddRefTraits::AddRef(mRawPtr); - } - } - - template - MOZ_IMPLICIT nsRefPtr(already_AddRefed& aSmartPtr) - : mRawPtr(aSmartPtr.take()) - // construct from |already_AddRefed| - { - } - - template - MOZ_IMPLICIT nsRefPtr(already_AddRefed&& aSmartPtr) - : mRawPtr(aSmartPtr.take()) - // construct from |otherRefPtr.forget()| - { - } - - template - MOZ_IMPLICIT nsRefPtr(const nsRefPtr& aSmartPtr) - : mRawPtr(aSmartPtr.get()) - // copy-construct from a smart pointer with a related pointer type - { - if (mRawPtr) { - AddRefTraits::AddRef(mRawPtr); - } - } - - template - MOZ_IMPLICIT nsRefPtr(nsRefPtr&& aSmartPtr) - : mRawPtr(aSmartPtr.forget().take()) - // construct from |Move(nsRefPtr)|. - { - } - - MOZ_IMPLICIT nsRefPtr(const nsCOMPtr_helper& aHelper); - - // Defined in OwningNonNull.h - template - MOZ_IMPLICIT nsRefPtr(const mozilla::OwningNonNull& aOther); - - // Defined in RefPtr.h - template - MOZ_IMPLICIT nsRefPtr(mozilla::RefPtr&& aOther); - - // Assignment operators - - nsRefPtr& - operator=(const nsRefPtr& aRhs) - // copy assignment operator - { - assign_with_AddRef(aRhs.mRawPtr); - return *this; - } - - template - nsRefPtr& - operator=(const nsRefPtr& aRhs) - // assign from an nsRefPtr of a related pointer type - { - assign_with_AddRef(aRhs.get()); - return *this; - } - - nsRefPtr& - operator=(T* aRhs) - // assign from a raw pointer (of the right type) - { - assign_with_AddRef(aRhs); - return *this; - } - - template - nsRefPtr& - operator=(already_AddRefed& aRhs) - // assign from |already_AddRefed| - { - assign_assuming_AddRef(aRhs.take()); - return *this; - } - - template - nsRefPtr& - operator=(already_AddRefed && aRhs) - // assign from |otherRefPtr.forget()| - { - assign_assuming_AddRef(aRhs.take()); - return *this; - } - - nsRefPtr& operator=(const nsCOMPtr_helper& aHelper); - - nsRefPtr& - operator=(nsRefPtr && aRefPtr) - { - assign_assuming_AddRef(aRefPtr.mRawPtr); - aRefPtr.mRawPtr = nullptr; - return *this; - } - - // Defined in OwningNonNull.h - template - nsRefPtr& - operator=(const mozilla::OwningNonNull& aOther); - - // Defined in RefPtr.h - template - nsRefPtr& - operator=(mozilla::RefPtr&& aOther); - - // Other pointer operators - - void - swap(nsRefPtr& aRhs) - // ...exchange ownership with |aRhs|; can save a pair of refcount operations - { - T* temp = aRhs.mRawPtr; - aRhs.mRawPtr = mRawPtr; - mRawPtr = temp; - } - - void - swap(T*& aRhs) - // ...exchange ownership with |aRhs|; can save a pair of refcount operations - { - T* temp = aRhs; - aRhs = mRawPtr; - mRawPtr = temp; - } - - already_AddRefed - forget() - // return the value of mRawPtr and null out mRawPtr. Useful for - // already_AddRefed return values. - { - T* temp = 0; - swap(temp); - return already_AddRefed(temp); - } - - template - void - forget(I** aRhs) - // Set the target of aRhs to the value of mRawPtr and null out mRawPtr. - // Useful to avoid unnecessary AddRef/Release pairs with "out" - // parameters where aRhs bay be a T** or an I** where I is a base class - // of T. - { - MOZ_ASSERT(aRhs, "Null pointer passed to forget!"); - *aRhs = mRawPtr; - mRawPtr = 0; - } - - T* - get() const - /* - Prefer the implicit conversion provided automatically by |operator T*() const|. - Use |get()| to resolve ambiguity or to get a castable pointer. - */ - { - return const_cast(mRawPtr); - } - - operator T*() const -#ifdef MOZ_HAVE_REF_QUALIFIERS - & -#endif - /* - ...makes an |nsRefPtr| act like its underlying raw pointer type whenever it - is used in a context where a raw pointer is expected. It is this operator - that makes an |nsRefPtr| substitutable for a raw pointer. - - Prefer the implicit use of this operator to calling |get()|, except where - necessary to resolve ambiguity. - */ - { - return get(); - } - -#ifdef MOZ_HAVE_REF_QUALIFIERS - // Don't allow implicit conversion of temporary nsRefPtr to raw pointer, - // because the refcount might be one and the pointer will immediately become - // invalid. - operator T*() const && = delete; - - // These are needed to avoid the deleted operator above. XXX Why is operator! - // needed separately? Shouldn't the compiler prefer using the non-deleted - // operator bool instead of the deleted operator T*? - explicit operator bool() const { return !!mRawPtr; } - bool operator!() const { return !mRawPtr; } -#endif - - T* - operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN - { - MOZ_ASSERT(mRawPtr != 0, - "You can't dereference a NULL nsRefPtr with operator->()."); - return get(); - } - - template - class Proxy - { - typedef R (T::*member_function)(Args...); - T* mRawPtr; - member_function mFunction; - public: - Proxy(T* aRawPtr, member_function aFunction) - : mRawPtr(aRawPtr), - mFunction(aFunction) - { - } - template - R operator()(ActualArgs&&... aArgs) - { - return ((*mRawPtr).*mFunction)(mozilla::Forward(aArgs)...); - } - }; - - template - Proxy operator->*(R (T::*aFptr)(Args...)) const - { - MOZ_ASSERT(mRawPtr != 0, - "You can't dereference a NULL nsRefPtr with operator->*()."); - return Proxy(get(), aFptr); - } - - nsRefPtr* - get_address() - // This is not intended to be used by clients. See |address_of| - // below. - { - return this; - } - - const nsRefPtr* - get_address() const - // This is not intended to be used by clients. See |address_of| - // below. - { - return this; - } - -public: - T& - operator*() const - { - MOZ_ASSERT(mRawPtr != 0, - "You can't dereference a NULL nsRefPtr with operator*()."); - return *get(); - } - - T** - StartAssignment() - { - assign_assuming_AddRef(0); - return reinterpret_cast(&mRawPtr); - } -private: - // This helper class makes |nsRefPtr| possible by casting away - // the constness from the pointer when calling AddRef() and Release(). - // This is necessary because AddRef() and Release() implementations can't - // generally expected to be const themselves (without heavy use of |mutable| - // and |const_cast| in their own implementations). - // This should be sound because while |nsRefPtr| provides a const - // view of an object, the object itself should be const (it would have to be - // allocated as |new const T| or similar to itself be const). - template - struct AddRefTraits - { - static void AddRef(U* aPtr) { - aPtr->AddRef(); - } - static void Release(U* aPtr) { - aPtr->Release(); - } - }; - template - struct AddRefTraits - { - static void AddRef(const U* aPtr) { - const_cast(aPtr)->AddRef(); - } - static void Release(const U* aPtr) { - const_cast(aPtr)->Release(); - } - }; -}; - -class nsCycleCollectionTraversalCallback; -template -void -CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback, - T* aChild, const char* aName, uint32_t aFlags); - -template -inline void -ImplCycleCollectionUnlink(nsRefPtr& aField) -{ - aField = nullptr; -} - -template -inline void -ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, - nsRefPtr& aField, - const char* aName, - uint32_t aFlags = 0) -{ - CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags); -} - -template -inline nsRefPtr* -address_of(nsRefPtr& aPtr) -{ - return aPtr.get_address(); -} - -template -inline const nsRefPtr* -address_of(const nsRefPtr& aPtr) -{ - return aPtr.get_address(); -} - -template -class nsRefPtrGetterAddRefs -/* - ... - - This class is designed to be used for anonymous temporary objects in the - argument list of calls that return COM interface pointers, e.g., - - nsRefPtr fooP; - ...->GetAddRefedPointer(getter_AddRefs(fooP)) - - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. - - When initialized with a |nsRefPtr|, as in the example above, it returns - a |void**|, a |T**|, or an |nsISupports**| as needed, that the - outer call (|GetAddRefedPointer| in this case) can fill in. - - This type should be a nested class inside |nsRefPtr|. -*/ -{ -public: - explicit - nsRefPtrGetterAddRefs(nsRefPtr& aSmartPtr) - : mTargetSmartPtr(aSmartPtr) - { - // nothing else to do - } - - operator void**() - { - return reinterpret_cast(mTargetSmartPtr.StartAssignment()); - } - - operator T**() - { - return mTargetSmartPtr.StartAssignment(); - } - - T*& - operator*() - { - return *(mTargetSmartPtr.StartAssignment()); - } - -private: - nsRefPtr& mTargetSmartPtr; -}; - -template -inline nsRefPtrGetterAddRefs -getter_AddRefs(nsRefPtr& aSmartPtr) -/* - Used around a |nsRefPtr| when - ...makes the class |nsRefPtrGetterAddRefs| invisible. -*/ -{ - return nsRefPtrGetterAddRefs(aSmartPtr); -} - - -// Comparing two |nsRefPtr|s - -template -inline bool -operator==(const nsRefPtr& aLhs, const nsRefPtr& aRhs) -{ - return static_cast(aLhs.get()) == static_cast(aRhs.get()); -} - - -template -inline bool -operator!=(const nsRefPtr& aLhs, const nsRefPtr& aRhs) -{ - return static_cast(aLhs.get()) != static_cast(aRhs.get()); -} - - -// Comparing an |nsRefPtr| to a raw pointer - -template -inline bool -operator==(const nsRefPtr& aLhs, const U* aRhs) -{ - return static_cast(aLhs.get()) == static_cast(aRhs); -} - -template -inline bool -operator==(const U* aLhs, const nsRefPtr& aRhs) -{ - return static_cast(aLhs) == static_cast(aRhs.get()); -} - -template -inline bool -operator!=(const nsRefPtr& aLhs, const U* aRhs) -{ - return static_cast(aLhs.get()) != static_cast(aRhs); -} - -template -inline bool -operator!=(const U* aLhs, const nsRefPtr& aRhs) -{ - return static_cast(aLhs) != static_cast(aRhs.get()); -} - -template -inline bool -operator==(const nsRefPtr& aLhs, U* aRhs) -{ - return static_cast(aLhs.get()) == const_cast(aRhs); -} - -template -inline bool -operator==(U* aLhs, const nsRefPtr& aRhs) -{ - return const_cast(aLhs) == static_cast(aRhs.get()); -} - -template -inline bool -operator!=(const nsRefPtr& aLhs, U* aRhs) -{ - return static_cast(aLhs.get()) != const_cast(aRhs); -} - -template -inline bool -operator!=(U* aLhs, const nsRefPtr& aRhs) -{ - return const_cast(aLhs) != static_cast(aRhs.get()); -} - -// Comparing an |nsRefPtr| to |nullptr| - -template -inline bool -operator==(const nsRefPtr& aLhs, decltype(nullptr)) -{ - return aLhs.get() == nullptr; -} - -template -inline bool -operator==(decltype(nullptr), const nsRefPtr& aRhs) -{ - return nullptr == aRhs.get(); -} - -template -inline bool -operator!=(const nsRefPtr& aLhs, decltype(nullptr)) -{ - return aLhs.get() != nullptr; -} - -template -inline bool -operator!=(decltype(nullptr), const nsRefPtr& aRhs) -{ - return nullptr != aRhs.get(); -} - -/*****************************************************************************/ - -template -inline already_AddRefed -do_AddRef(T*&& aObj) -{ - nsRefPtr ref(aObj); - return ref.forget(); -} - -namespace mozilla { - -/** - * Helper function to be able to conveniently write things like: - * - * already_AddRefed - * f(...) - * { - * return MakeAndAddRef(...); - * } - */ -template -already_AddRefed -MakeAndAddRef(Args&&... aArgs) -{ - nsRefPtr p(new T(Forward(aArgs)...)); - return p.forget(); -} - -} // namespace mozilla - -#endif /* mozilla_nsRefPtr_h */ diff --git a/mfbt/tests/TestRefPtr.cpp b/mfbt/tests/TestRefPtr.cpp index 316f91df2b..44056dcd76 100644 --- a/mfbt/tests/TestRefPtr.cpp +++ b/mfbt/tests/TestRefPtr.cpp @@ -8,7 +8,7 @@ #include "mozilla/RefCounted.h" using mozilla::RefCounted; -using mozilla::RefPtr; +using RefPtr; class Foo : public RefCounted { diff --git a/modules/libjar/InterceptedJARChannel.cpp b/modules/libjar/InterceptedJARChannel.cpp index b5c4579427..bea5e2186b 100644 --- a/modules/libjar/InterceptedJARChannel.cpp +++ b/modules/libjar/InterceptedJARChannel.cpp @@ -13,11 +13,9 @@ using namespace mozilla::net; NS_IMPL_ISUPPORTS(InterceptedJARChannel, nsIInterceptedChannel) InterceptedJARChannel::InterceptedJARChannel(nsJARChannel* aChannel, - nsINetworkInterceptController* aController, - bool aIsNavigation) + nsINetworkInterceptController* aController) : mController(aController) , mChannel(aChannel) -, mIsNavigation(aIsNavigation) { } @@ -28,13 +26,6 @@ InterceptedJARChannel::GetResponseBody(nsIOutputStream** aStream) return NS_OK; } -NS_IMETHODIMP -InterceptedJARChannel::GetIsNavigation(bool* aIsNavigation) -{ - *aIsNavigation = mIsNavigation; - return NS_OK; -} - NS_IMETHODIMP InterceptedJARChannel::GetInternalContentPolicyType(nsContentPolicyType* aPolicyType) { @@ -87,12 +78,18 @@ InterceptedJARChannel::SynthesizeHeader(const nsACString& aName, } NS_IMETHODIMP -InterceptedJARChannel::FinishSynthesizedResponse() +InterceptedJARChannel::FinishSynthesizedResponse(const nsACString& aFinalURLSpec) { if (NS_WARN_IF(!mChannel)) { return NS_ERROR_NOT_AVAILABLE; } + if (!aFinalURLSpec.IsEmpty()) { + // We don't support rewriting responses for JAR channels where the principal + // needs to be modified. + return NS_ERROR_NOT_IMPLEMENTED; + } + mChannel->OverrideWithSynthesizedResponse(mSynthesizedInput, mContentType); mResponseBody = nullptr; diff --git a/modules/libjar/InterceptedJARChannel.h b/modules/libjar/InterceptedJARChannel.h index 1aa8bb68cc..f1dd2e78e7 100644 --- a/modules/libjar/InterceptedJARChannel.h +++ b/modules/libjar/InterceptedJARChannel.h @@ -33,7 +33,7 @@ class InterceptedJARChannel : public nsIInterceptedChannel nsCOMPtr mController; // The actual channel being intercepted. - nsRefPtr mChannel; + RefPtr mChannel; // Reader-side of the synthesized response body. nsCOMPtr mSynthesizedInput; @@ -44,14 +44,10 @@ class InterceptedJARChannel : public nsIInterceptedChannel // The content type of the synthesized response. nsCString mContentType; - // Wether this intercepted channel was performing a navigation. - bool mIsNavigation; - virtual ~InterceptedJARChannel() {}; public: InterceptedJARChannel(nsJARChannel* aChannel, - nsINetworkInterceptController* aController, - bool aIsNavigation); + nsINetworkInterceptController* aController); NS_DECL_ISUPPORTS NS_DECL_NSIINTERCEPTEDCHANNEL diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index 6f2dc4071c..887737793c 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -104,7 +104,7 @@ MozExternalRefCountType nsJAR::Release(void) nsrefcnt count; NS_PRECONDITION(0 != mRefCnt, "dup release"); - nsRefPtr cache; + RefPtr cache; if (mRefCnt == 2) { // don't use a lock too frequently // Use a mutex here to guarantee mCache is not racing and the target instance // is still valid to increase ref-count. @@ -146,7 +146,7 @@ nsJAR::Open(nsIFile* zipFile) // The omnijar is special, it is opened early on and closed late // this avoids reopening it - nsRefPtr zip = mozilla::Omnijar::GetReader(zipFile); + RefPtr zip = mozilla::Omnijar::GetReader(zipFile); if (zip) { mZip = zip; return NS_OK; @@ -172,7 +172,7 @@ nsJAR::OpenInner(nsIZipReader *aZipReader, const nsACString &aZipEntry) mOuterZipEntry.Assign(aZipEntry); - nsRefPtr handle; + RefPtr handle; rv = nsZipHandle::Init(static_cast(aZipReader)->mZip.get(), PromiseFlatCString(aZipEntry).get(), getter_AddRefs(handle)); if (NS_FAILED(rv)) @@ -189,7 +189,7 @@ nsJAR::OpenMemory(void* aData, uint32_t aLength) mOpened = true; - nsRefPtr handle; + RefPtr handle; nsresult rv = nsZipHandle::Init(static_cast(aData), aLength, getter_AddRefs(handle)); if (NS_FAILED(rv)) @@ -215,8 +215,8 @@ nsJAR::Close() mGlobalStatus = JAR_MANIFEST_NOT_PARSED; mTotalItemsInManifest = 0; - nsRefPtr greOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); - nsRefPtr appOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); + RefPtr greOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); + RefPtr appOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); if (mZip == greOmni || mZip == appOmni) { mZip = new nsZipArchive(); @@ -360,8 +360,8 @@ nsJAR::GetSigningCert(const nsACString& aFilename, nsIX509Cert** aSigningCert) // Don't check signatures in the omnijar - this is only // interesting for extensions/XPIs. - nsRefPtr greOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); - nsRefPtr appOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); + RefPtr greOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); + RefPtr appOmni = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); if (mZip == greOmni || mZip == appOmni) return NS_OK; @@ -430,7 +430,7 @@ nsJAR::GetNSPRFileDesc(PRFileDesc** aNSPRFileDesc) return NS_ERROR_FAILURE; } - nsRefPtr handle = mZip->GetFD(); + RefPtr handle = mZip->GetFD(); if (!handle) { return NS_ERROR_FAILURE; } @@ -1142,7 +1142,7 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result) uri.Insert(NS_LITERAL_CSTRING("file:"), 0); - nsRefPtr zip; + RefPtr zip; mZips.Get(uri, getter_AddRefs(zip)); if (zip) { #ifdef ZIP_CACHE_HIT_RATE @@ -1188,7 +1188,7 @@ nsZipReaderCache::GetInnerZip(nsIFile* zipFile, const nsACString &entry, uri.AppendLiteral("!/"); uri.Append(entry); - nsRefPtr zip; + RefPtr zip; mZips.Get(uri, getter_AddRefs(zip)); if (zip) { #ifdef ZIP_CACHE_HIT_RATE @@ -1231,7 +1231,7 @@ nsZipReaderCache::GetFd(nsIFile* zipFile, PRFileDesc** aRetVal) uri.Insert(NS_LITERAL_CSTRING("file:"), 0); MutexAutoLock lock(mLock); - nsRefPtr zip; + RefPtr zip; mZips.Get(uri, getter_AddRefs(zip)); if (!zip) { return NS_ERROR_FAILURE; @@ -1241,7 +1241,7 @@ nsZipReaderCache::GetFd(nsIFile* zipFile, PRFileDesc** aRetVal) rv = zip->GetNSPRFileDesc(aRetVal); // Do this to avoid possible deadlock on mLock with ReleaseZip(). MutexAutoUnlock unlock(mLock); - nsRefPtr zipTemp = zip.forget(); + RefPtr zipTemp = zip.forget(); return rv; #endif /* XP_WIN */ } @@ -1340,7 +1340,7 @@ nsZipReaderCache::ReleaseZip(nsJAR* zip) // Retrieving and removing the JAR must be done without an extra AddRef // and Release, or we'll trigger nsJAR::Release's magic refcount 1 case // an extra time and trigger a deadlock. - nsRefPtr removed; + RefPtr removed; mZips.Remove(uri, getter_AddRefs(removed)); NS_ASSERTION(removed, "botched"); NS_ASSERTION(oldest == removed, "removed wrong entry"); @@ -1352,7 +1352,7 @@ nsZipReaderCache::ReleaseZip(nsJAR* zip) } static PLDHashOperator -FindFlushableZip(const nsACString &aKey, nsRefPtr& aCurrent, void*) +FindFlushableZip(const nsACString &aKey, RefPtr& aCurrent, void*) { if (aCurrent->GetReleaseTime() != PR_INTERVAL_NO_TIMEOUT) { aCurrent->SetZipReaderCache(nullptr); @@ -1388,7 +1388,7 @@ nsZipReaderCache::Observe(nsISupports *aSubject, MutexAutoLock lock(mLock); - nsRefPtr zip; + RefPtr zip; mZips.Get(uri, getter_AddRefs(zip)); if (!zip) return NS_OK; diff --git a/modules/libjar/nsJAR.h b/modules/libjar/nsJAR.h index f472bd94a0..d863d3708d 100644 --- a/modules/libjar/nsJAR.h +++ b/modules/libjar/nsJAR.h @@ -104,7 +104,7 @@ class nsJAR final : public nsIZipReader //-- Private data members nsCOMPtr mZipFile; // The zip/jar file on disk nsCString mOuterZipEntry; // The entry in the zip this zip is reading from - nsRefPtr mZip; // The underlying zip archive + RefPtr mZip; // The underlying zip archive ManifestDataHashtable mManifestData; // Stores metadata for each entry bool mParsedManifest; // True if manifest has been parsed nsCOMPtr mSigningCert; // The entity which signed this file diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index ef05b9c245..a4ae98d74c 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -314,7 +314,7 @@ nsJARChannel::CreateJarInput(nsIZipReaderCache *jarCache, nsJARInputThunk **resu if (NS_FAILED(rv)) return rv; - nsRefPtr input = new nsJARInputThunk(reader, + RefPtr input = new nsJARInputThunk(reader, mJarURI, mJarEntry, jarCache != nullptr @@ -367,7 +367,7 @@ nsJARChannel::LookupFile(bool aAllowAsync) nsAutoCString scheme; rv = mJarBaseURI->GetScheme(scheme); if (NS_SUCCEEDED(rv) && scheme.EqualsLiteral("remoteopenfile")) { - nsRefPtr remoteFile = new RemoteOpenFileChild(); + RefPtr remoteFile = new RemoteOpenFileChild(); rv = remoteFile->Init(mJarBaseURI, mAppURI); NS_ENSURE_SUCCESS(rv, rv); mJarFile = remoteFile; @@ -447,7 +447,7 @@ nsJARChannel::OpenLocalFile() // Local files are always considered safe. mIsUnsafe = false; - nsRefPtr input; + RefPtr input; nsresult rv = CreateJarInput(gJarHandler->JarCache(), getter_AddRefs(input)); if (NS_SUCCEEDED(rv)) { @@ -845,7 +845,7 @@ nsJARChannel::Open(nsIInputStream **stream) return NS_ERROR_NOT_IMPLEMENTED; } - nsRefPtr input; + RefPtr input; rv = CreateJarInput(gJarHandler->JarCache(), getter_AddRefs(input)); if (NS_FAILED(rv)) return rv; @@ -887,11 +887,8 @@ nsJARChannel::ShouldIntercept() getter_AddRefs(controller)); bool shouldIntercept = false; if (controller && !BypassServiceWorker() && mLoadInfo) { - bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI; - nsContentPolicyType type = mLoadInfo->InternalContentPolicyType(); nsresult rv = controller->ShouldPrepareForIntercept(mAppURI, - isNavigation, - type, + nsContentUtils::IsNonSubresourceRequest(this), &shouldIntercept); NS_ENSURE_SUCCESS(rv, false); } @@ -973,9 +970,8 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx) NS_GET_IID(nsINetworkInterceptController), getter_AddRefs(controller)); - bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI; - nsRefPtr intercepted = - new InterceptedJARChannel(this, controller, isNavigation); + RefPtr intercepted = + new InterceptedJARChannel(this, controller); intercepted->NotifyController(); // We get the JAREntry so we can infer the content type later in case @@ -1216,7 +1212,7 @@ nsJARChannel::OnDownloadComplete(MemoryDownloader* aDownloader, if (NS_SUCCEEDED(status)) { mTempMem = Move(aData); - nsRefPtr input; + RefPtr input; rv = CreateJarInput(nullptr, getter_AddRefs(input)); if (NS_SUCCEEDED(rv)) { // create input stream pump diff --git a/modules/libjar/nsJARChannel.h b/modules/libjar/nsJARChannel.h index b8cad253af..8c5d6f6ab6 100644 --- a/modules/libjar/nsJARChannel.h +++ b/modules/libjar/nsJARChannel.h @@ -135,7 +135,7 @@ private: nsCString mJarEntry; nsCString mInnerJarEntry; - nsRefPtr mSynthesizedResponsePump; + RefPtr mSynthesizedResponsePump; int64_t mSynthesizedStreamLength; // True if this channel should not download any remote files. diff --git a/modules/libjar/nsJARInputStream.h b/modules/libjar/nsJARInputStream.h index 87565a40cf..959d8b7353 100644 --- a/modules/libjar/nsJARInputStream.h +++ b/modules/libjar/nsJARInputStream.h @@ -40,14 +40,14 @@ class nsJARInputStream final : public nsIInputStream private: ~nsJARInputStream() { Close(); } - nsRefPtr mFd; // handle for reading + RefPtr mFd; // handle for reading uint32_t mOutSize; // inflated size uint32_t mInCrc; // CRC as provided by the zipentry uint32_t mOutCrc; // CRC as calculated by me z_stream mZs; // zip data structure /* For directory reading */ - nsRefPtr mJar; // string reference to zipreader + RefPtr mJar; // string reference to zipreader uint32_t mNameLen; // length of dirname nsCString mBuffer; // storage for generated text of stream uint32_t mCurPos; // Current position in buffer diff --git a/modules/libjar/nsJARProtocolHandler.cpp b/modules/libjar/nsJARProtocolHandler.cpp index 971c577bbb..4398e1e8eb 100644 --- a/modules/libjar/nsJARProtocolHandler.cpp +++ b/modules/libjar/nsJARProtocolHandler.cpp @@ -192,7 +192,7 @@ nsJARProtocolHandler::NewURI(const nsACString &aSpec, { nsresult rv = NS_OK; - nsRefPtr jarURI = new nsJARURI(); + RefPtr jarURI = new nsJARURI(); if (!jarURI) return NS_ERROR_OUT_OF_MEMORY; diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index 67d0acef55..0367b988fe 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -255,7 +255,7 @@ nsJARURI::SetSpecWithBase(const nsACString &aSpec, nsIURI* aBaseURL) if (!aBaseURL) return NS_ERROR_MALFORMED_URI; - nsRefPtr otherJAR; + RefPtr otherJAR; aBaseURL->QueryInterface(NS_GET_IID(nsJARURI), getter_AddRefs(otherJAR)); NS_ENSURE_TRUE(otherJAR, NS_NOINTERFACE); @@ -465,7 +465,7 @@ nsJARURI::EqualsInternal(nsIURI *other, if (!other) return NS_OK; // not equal - nsRefPtr otherJAR; + RefPtr otherJAR; other->QueryInterface(NS_GET_IID(nsJARURI), getter_AddRefs(otherJAR)); if (!otherJAR) return NS_OK; // not equal diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index a97e1c7d38..c93f59196d 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -198,7 +198,7 @@ nsresult nsZipHandle::Init(nsIFile *file, nsZipHandle **ret, return NS_ERROR_FAILURE; } - nsRefPtr handle = new nsZipHandle(); + RefPtr handle = new nsZipHandle(); if (!handle) { PR_MemUnmap(buf, (uint32_t) size); PR_CloseFileMap(map); @@ -223,7 +223,7 @@ nsresult nsZipHandle::Init(nsIFile *file, nsZipHandle **ret, nsresult nsZipHandle::Init(nsZipArchive *zip, const char *entry, nsZipHandle **ret) { - nsRefPtr handle = new nsZipHandle(); + RefPtr handle = new nsZipHandle(); if (!handle) return NS_ERROR_OUT_OF_MEMORY; @@ -245,7 +245,7 @@ nsresult nsZipHandle::Init(nsZipArchive *zip, const char *entry, nsresult nsZipHandle::Init(const uint8_t* aData, uint32_t aLen, nsZipHandle **aRet) { - nsRefPtr handle = new nsZipHandle(); + RefPtr handle = new nsZipHandle(); handle->mFileData = aData; handle->mLen = aLen; @@ -309,7 +309,7 @@ nsresult nsZipArchive::OpenArchive(nsZipHandle *aZipHandle, PRFileDesc *aFd) nsresult nsZipArchive::OpenArchive(nsIFile *aFile) { - nsRefPtr handle; + RefPtr handle; #if defined(XP_WIN) mozilla::AutoFDClose fd; nsresult rv = nsZipHandle::Init(aFile, getter_AddRefs(handle), diff --git a/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index bf6f915b2c..d66545f890 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -221,7 +221,7 @@ private: bool mBuiltSynthetics; // file handle - nsRefPtr mFd; + RefPtr mFd; // file URI, for logging nsCString mURI; @@ -250,7 +250,7 @@ public: nsresult FindNext(const char** aResult, uint16_t* aNameLen); private: - nsRefPtr mArchive; + RefPtr mArchive; char* mPattern; nsZipItem* mItem; uint16_t mSlot; @@ -334,7 +334,7 @@ public: } protected: - nsRefPtr mZipHandle; + RefPtr mZipHandle; nsAutoArrayPtr mAutoBuf; uint8_t *mReturnBuf; uint32_t mReadlen; diff --git a/modules/libjar/zipwriter/nsZipDataStream.h b/modules/libjar/zipwriter/nsZipDataStream.h index e76497f105..ffa455274c 100644 --- a/modules/libjar/zipwriter/nsZipDataStream.h +++ b/modules/libjar/zipwriter/nsZipDataStream.h @@ -34,8 +34,8 @@ private: nsCOMPtr mOutput; nsCOMPtr mStream; - nsRefPtr mWriter; - nsRefPtr mHeader; + RefPtr mWriter; + RefPtr mHeader; nsresult CompleteEntry(); nsresult ProcessData(nsIRequest *aRequest, nsISupports *aContext, diff --git a/modules/libjar/zipwriter/nsZipWriter.cpp b/modules/libjar/zipwriter/nsZipWriter.cpp index 9cf778267a..d2054dde57 100644 --- a/modules/libjar/zipwriter/nsZipWriter.cpp +++ b/modules/libjar/zipwriter/nsZipWriter.cpp @@ -476,7 +476,7 @@ nsresult nsZipWriter::AddEntryStream(const nsACString & aZipEntry, if (mEntryHash.Get(aZipEntry, nullptr)) return NS_ERROR_FILE_ALREADY_EXISTS; - nsRefPtr header = new nsZipHeader(); + RefPtr header = new nsZipHeader(); NS_ENSURE_TRUE(header, NS_ERROR_OUT_OF_MEMORY); header->Init(aZipEntry, aModTime, ZIP_ATTRS(aPermissions, ZIP_ATTRS_FILE), mCDSOffset); @@ -486,7 +486,7 @@ nsresult nsZipWriter::AddEntryStream(const nsACString & aZipEntry, return rv; } - nsRefPtr stream = new nsZipDataStream(); + RefPtr stream = new nsZipDataStream(); if (!stream) { SeekCDS(); return NS_ERROR_OUT_OF_MEMORY; @@ -856,7 +856,7 @@ nsresult nsZipWriter::InternalAddEntryDirectory(const nsACString & aZipEntry, PRTime aModTime, uint32_t aPermissions) { - nsRefPtr header = new nsZipHeader(); + RefPtr header = new nsZipHeader(); NS_ENSURE_TRUE(header, NS_ERROR_OUT_OF_MEMORY); uint32_t zipAttributes = ZIP_ATTRS(aPermissions, ZIP_ATTRS_DIRECTORY); @@ -984,7 +984,7 @@ inline nsresult nsZipWriter::BeginProcessingAddition(nsZipQueueItem* aItem, uint32_t zipAttributes = ZIP_ATTRS(aItem->mPermissions, ZIP_ATTRS_FILE); if (aItem->mStream || aItem->mChannel) { - nsRefPtr header = new nsZipHeader(); + RefPtr header = new nsZipHeader(); NS_ENSURE_TRUE(header, NS_ERROR_OUT_OF_MEMORY); header->Init(aItem->mZipEntry, aItem->mModTime, zipAttributes, @@ -992,7 +992,7 @@ inline nsresult nsZipWriter::BeginProcessingAddition(nsZipQueueItem* aItem, nsresult rv = header->WriteFileHeader(mStream); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr stream = new nsZipDataStream(); + RefPtr stream = new nsZipDataStream(); NS_ENSURE_TRUE(stream, NS_ERROR_OUT_OF_MEMORY); rv = stream->Init(this, mStream, header, aItem->mCompression); NS_ENSURE_SUCCESS(rv, rv); diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 1c1c1e8458..40a1981f31 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -421,7 +421,7 @@ Preferences::GetInstanceForService() // RegisterStrongMemoryReporter calls GetService(nsIMemoryReporter). To // avoid a potential recursive GetService() call, we can't register the // memory reporter here; instead, do it off a runnable. - nsRefPtr runnable = + RefPtr runnable = new AddPreferencesMemoryReporterRunnable(); NS_DispatchToMainThread(runnable); @@ -745,7 +745,7 @@ Preferences::GetBranch(const char *aPrefRoot, nsIPrefBranch **_retval) if ((nullptr != aPrefRoot) && (*aPrefRoot != '\0')) { // TODO: - cache this stuff and allow consumers to share branches (hold weak references I think) - nsRefPtr prefBranch = new nsPrefBranch(aPrefRoot, false); + RefPtr prefBranch = new nsPrefBranch(aPrefRoot, false); prefBranch.forget(_retval); rv = NS_OK; } else { @@ -767,7 +767,7 @@ Preferences::GetDefaultBranch(const char *aPrefRoot, nsIPrefBranch **_retval) } // TODO: - cache this stuff and allow consumers to share branches (hold weak references I think) - nsRefPtr prefBranch = new nsPrefBranch(aPrefRoot, true); + RefPtr prefBranch = new nsPrefBranch(aPrefRoot, true); if (!prefBranch) return NS_ERROR_OUT_OF_MEMORY; @@ -1234,7 +1234,7 @@ static nsresult pref_InitInitialObjects() const char *entryName; uint16_t entryNameLen; - nsRefPtr jarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); + RefPtr jarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); if (jarReader) { // Load jar:$gre/omni.jar!/gecko.js rv = pref_ReadPrefFromJar(jarReader, "gecko.js"); @@ -1299,7 +1299,7 @@ static nsresult pref_InitInitialObjects() // Load jar:$app/omni.jar!/defaults/preferences/*.js // or jar:$gre/omni.jar!/defaults/preferences/*.js. - nsRefPtr appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); + RefPtr appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); // GetReader(mozilla::Omnijar::APP) returns null when $app == $gre, in which // case we look for app-specific default preferences in $gre. if (!appJarReader) @@ -1672,7 +1672,7 @@ Preferences::RegisterCallback(PrefChangedFunc aCallback, NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); ValueObserverHashKey hashKey(aPref, aCallback); - nsRefPtr observer; + RefPtr observer; gObserverTable->Get(&hashKey, getter_AddRefs(observer)); if (observer) { observer->AppendClosure(aClosure); @@ -1712,7 +1712,7 @@ Preferences::UnregisterCallback(PrefChangedFunc aCallback, NS_ENSURE_TRUE(sPreferences, NS_ERROR_NOT_AVAILABLE); ValueObserverHashKey hashKey(aPref, aCallback); - nsRefPtr observer; + RefPtr observer; gObserverTable->Get(&hashKey, getter_AddRefs(observer)); if (!observer) { return NS_OK; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 14a2e3de6f..9b0ba3f8dd 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1409,6 +1409,7 @@ pref("javascript.options.asyncstack", true); #else pref("javascript.options.asyncstack", false); #endif +pref("javascript.options.throw_on_asmjs_validation_failure", false); pref("javascript.options.ion.offthread_compilation", true); // This preference instructs the JS engine to discard the // source of any privileged JS after compilation. This saves diff --git a/mozglue/linker/BaseElf.h b/mozglue/linker/BaseElf.h index a7b708b50b..19f9061bce 100644 --- a/mozglue/linker/BaseElf.h +++ b/mozglue/linker/BaseElf.h @@ -81,7 +81,7 @@ public: /* Appropriated Mappable */ /* /!\ we rely on this being nullptr for BaseElf instances, but not * CustomElf instances. */ - mozilla::RefPtr mappable; + RefPtr mappable; /* Base address where the library is loaded */ MappedPtr base; diff --git a/mozglue/linker/CustomElf.cpp b/mozglue/linker/CustomElf.cpp index 6ceaee485c..e51208d446 100644 --- a/mozglue/linker/CustomElf.cpp +++ b/mozglue/linker/CustomElf.cpp @@ -97,7 +97,7 @@ private: mappable->munmap(buf, length); } - mozilla::RefPtr mappable; + RefPtr mappable; }; diff --git a/mozglue/linker/CustomElf.h b/mozglue/linker/CustomElf.h index 430ce76659..5ecc7da085 100644 --- a/mozglue/linker/CustomElf.h +++ b/mozglue/linker/CustomElf.h @@ -135,7 +135,7 @@ private: } /* List of dependent libraries */ - std::vector > dependencies; + std::vector > dependencies; /* List of .rel.dyn/.rela.dyn relocations */ Array relocations; diff --git a/mozglue/linker/ElfLoader.cpp b/mozglue/linker/ElfLoader.cpp index e87678ef79..10c5fd3b05 100644 --- a/mozglue/linker/ElfLoader.cpp +++ b/mozglue/linker/ElfLoader.cpp @@ -1205,7 +1205,7 @@ void SEGVHandler::handler(int signum, siginfo_t *info, void *context) /* Check whether we segfaulted in the address space of a CustomElf. We're * only expecting that to happen as an access error. */ if (info->si_code == SEGV_ACCERR) { - mozilla::RefPtr handle = + RefPtr handle = ElfLoader::Singleton.GetHandleByPtr(info->si_addr); BaseElf *elf; if (handle && (elf = handle->AsBaseElf())) { diff --git a/mozglue/linker/ElfLoader.h b/mozglue/linker/ElfLoader.h index a5bdaacb48..247efca862 100644 --- a/mozglue/linker/ElfLoader.h +++ b/mozglue/linker/ElfLoader.h @@ -235,7 +235,7 @@ private: char *path; /* Mappable object keeping the result of GetMappable() */ - mutable mozilla::RefPtr mappable; + mutable RefPtr mappable; }; /** @@ -462,14 +462,14 @@ private: /* System loader handle for the library/program containing our code. This * is used to resolve wrapped functions. */ - mozilla::RefPtr self_elf; + RefPtr self_elf; #if defined(ANDROID) /* System loader handle for the libc. This is used to resolve weak symbols * that some libcs contain that the Android linker won't dlsym(). Normally, * we wouldn't treat non-Android differently, but glibc uses versioned * symbols which this linker doesn't support. */ - mozilla::RefPtr libc; + RefPtr libc; #endif /* Bookkeeping */ diff --git a/mozglue/linker/Mappable.h b/mozglue/linker/Mappable.h index 7e3981dc9e..56f5dccd5f 100644 --- a/mozglue/linker/Mappable.h +++ b/mozglue/linker/Mappable.h @@ -174,7 +174,7 @@ private: MappableDeflate(_MappableBuffer *buf, Zip *zip, Zip::Stream *stream); /* Zip reference */ - mozilla::RefPtr zip; + RefPtr zip; /* Decompression buffer */ mozilla::UniquePtr<_MappableBuffer> buffer; @@ -214,7 +214,7 @@ private: MappableSeekableZStream(Zip *zip); /* Zip reference */ - mozilla::RefPtr zip; + RefPtr zip; /* Decompression buffer */ mozilla::UniquePtr<_MappableBuffer> buffer; diff --git a/mozglue/linker/Zip.cpp b/mozglue/linker/Zip.cpp index 3344a9a349..94f083f802 100644 --- a/mozglue/linker/Zip.cpp +++ b/mozglue/linker/Zip.cpp @@ -44,7 +44,7 @@ Zip::Create(const char *filename) already_AddRefed Zip::Create(const char *filename, void *mapped, size_t size) { - mozilla::RefPtr zip = new Zip(filename, mapped, size); + RefPtr zip = new Zip(filename, mapped, size); // If neither the first Local File entry nor central directory entries // have been found, the zip was invalid. @@ -188,7 +188,7 @@ ZipCollection::GetZip(const char *path) for (std::vector::iterator it = Singleton.zips.begin(); it < Singleton.zips.end(); ++it) { if ((*it)->GetName() && (strcmp((*it)->GetName(), path) == 0)) { - mozilla::RefPtr zip = *it; + RefPtr zip = *it; return zip.forget(); } } diff --git a/mozglue/linker/tests/TestZip.cpp b/mozglue/linker/tests/TestZip.cpp index 389c385281..1cf86367dc 100644 --- a/mozglue/linker/tests/TestZip.cpp +++ b/mozglue/linker/tests/TestZip.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) } chdir(argv[1]); Zip::Stream s; - mozilla::RefPtr z = ZipCollection::GetZip("test.zip"); + RefPtr z = ZipCollection::GetZip("test.zip"); for (size_t i = 0; i < sizeof(test_entries) / sizeof(*test_entries); i++) { if (!z->GetStream(test_entries[i], &s)) { fprintf(stderr, "TEST-UNEXPECTED-FAIL | TestZip | test.zip: Couldn't get entry \"%s\"\n", test_entries[i]); diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index a5eda27862..63882a2fd4 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -77,7 +77,7 @@ public: } private: - nsRefPtr mSaver; + RefPtr mSaver; nsCOMPtr mTarget; }; @@ -521,7 +521,7 @@ BackgroundFileSaver::ProcessStateChange() rv = mActualTarget->Clone(getter_AddRefs(actualTargetToNotify)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr event = + RefPtr event = new NotifyTargetChangeRunnable(this, actualTargetToNotify); NS_ENSURE_TRUE(event, NS_ERROR_FAILURE); diff --git a/netwerk/base/ChannelDiverterParent.h b/netwerk/base/ChannelDiverterParent.h index a039ecaabf..047e1c68a9 100644 --- a/netwerk/base/ChannelDiverterParent.h +++ b/netwerk/base/ChannelDiverterParent.h @@ -31,7 +31,7 @@ public: virtual void ActorDestroy(ActorDestroyReason aWhy) override; private: - nsRefPtr mDivertableChannelParent; + RefPtr mDivertableChannelParent; }; } // namespace net diff --git a/netwerk/base/ClosingService.cpp b/netwerk/base/ClosingService.cpp index fbd5e0f3b6..84e1111747 100644 --- a/netwerk/base/ClosingService.cpp +++ b/netwerk/base/ClosingService.cpp @@ -20,7 +20,7 @@ public: mClosingService = nullptr; } - nsRefPtr mClosingService; + RefPtr mClosingService; }; namespace mozilla { diff --git a/netwerk/base/Dashboard.cpp b/netwerk/base/Dashboard.cpp index a95bd45991..cf180dc1eb 100644 --- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -176,7 +176,7 @@ ConnectionData::OnTransportStatus(nsITransport *aTransport, nsresult aStatus, GetErrorString(aStatus, mStatus); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (mDashboard, &Dashboard::GetConnectionStatus, this); mThread->Dispatch(event, NS_DISPATCH_NORMAL); @@ -198,7 +198,7 @@ ConnectionData::Notify(nsITimer *aTimer) mStatus.AssignLiteral(MOZ_UTF16("NS_ERROR_NET_TIMEOUT")); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (mDashboard, &Dashboard::GetConnectionStatus, this); mThread->Dispatch(event, NS_DISPATCH_NORMAL); @@ -245,7 +245,7 @@ public: } nsCOMPtr mRecord; - nsRefPtr mHelper; + RefPtr mHelper; }; NS_IMPL_ISUPPORTS0(LookupArgument) @@ -286,9 +286,9 @@ LookupHelper::OnLookupComplete(nsICancelable *aRequest, mCancel = nullptr; mStatus = aStatus; - nsRefPtr arg = new LookupArgument(aRecord, this); + RefPtr arg = new LookupArgument(aRecord, this); nsCOMPtr event = - NS_NewRunnableMethodWithArg >( + NS_NewRunnableMethodWithArg >( this, &LookupHelper::ConstructAnswer, arg); mThread->Dispatch(event, NS_DISPATCH_NORMAL); @@ -350,12 +350,12 @@ Dashboard::~Dashboard() NS_IMETHODIMP Dashboard::RequestSockets(NetDashboardCallback *aCallback) { - nsRefPtr socketData = new SocketData(); + RefPtr socketData = new SocketData(); socketData->mCallback = new nsMainThreadPtrHolder(aCallback, true); socketData->mThread = NS_GetCurrentThread(); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetSocketsDispatch, socketData); gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -364,14 +364,14 @@ Dashboard::RequestSockets(NetDashboardCallback *aCallback) nsresult Dashboard::GetSocketsDispatch(SocketData *aSocketData) { - nsRefPtr socketData = aSocketData; + RefPtr socketData = aSocketData; if (gSocketTransportService) { gSocketTransportService->GetSocketConnections(&socketData->mData); socketData->mTotalSent = gSocketTransportService->GetSentBytes(); socketData->mTotalRecv = gSocketTransportService->GetReceivedBytes(); } nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetSockets, socketData); socketData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -380,7 +380,7 @@ Dashboard::GetSocketsDispatch(SocketData *aSocketData) nsresult Dashboard::GetSockets(SocketData *aSocketData) { - nsRefPtr socketData = aSocketData; + RefPtr socketData = aSocketData; AutoSafeJSContext cx; mozilla::dom::SocketsDict dict; @@ -421,13 +421,13 @@ Dashboard::GetSockets(SocketData *aSocketData) NS_IMETHODIMP Dashboard::RequestHttpConnections(NetDashboardCallback *aCallback) { - nsRefPtr httpData = new HttpData(); + RefPtr httpData = new HttpData(); httpData->mCallback = new nsMainThreadPtrHolder(aCallback, true); httpData->mThread = NS_GetCurrentThread(); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetHttpDispatch, httpData); gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -436,10 +436,10 @@ Dashboard::RequestHttpConnections(NetDashboardCallback *aCallback) nsresult Dashboard::GetHttpDispatch(HttpData *aHttpData) { - nsRefPtr httpData = aHttpData; + RefPtr httpData = aHttpData; HttpInfo::GetHttpConnectionData(&httpData->mData); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetHttpConnections, httpData); httpData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -449,7 +449,7 @@ Dashboard::GetHttpDispatch(HttpData *aHttpData) nsresult Dashboard::GetHttpConnections(HttpData *aHttpData) { - nsRefPtr httpData = aHttpData; + RefPtr httpData = aHttpData; AutoSafeJSContext cx; mozilla::dom::HttpConnDict dict; @@ -599,13 +599,13 @@ Dashboard::NewMsgReceived(const nsACString& aHost, uint32_t aSerial, uint32_t aL NS_IMETHODIMP Dashboard::RequestWebsocketConnections(NetDashboardCallback *aCallback) { - nsRefPtr wsRequest = new WebSocketRequest(); + RefPtr wsRequest = new WebSocketRequest(); wsRequest->mCallback = new nsMainThreadPtrHolder(aCallback, true); wsRequest->mThread = NS_GetCurrentThread(); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetWebSocketConnections, wsRequest); wsRequest->mThread->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -614,7 +614,7 @@ Dashboard::RequestWebsocketConnections(NetDashboardCallback *aCallback) nsresult Dashboard::GetWebSocketConnections(WebSocketRequest *aWsRequest) { - nsRefPtr wsRequest = aWsRequest; + RefPtr wsRequest = aWsRequest; AutoSafeJSContext cx; mozilla::dom::WebSocketDict dict; @@ -651,7 +651,7 @@ Dashboard::GetWebSocketConnections(WebSocketRequest *aWsRequest) NS_IMETHODIMP Dashboard::RequestDNSInfo(NetDashboardCallback *aCallback) { - nsRefPtr dnsData = new DnsData(); + RefPtr dnsData = new DnsData(); dnsData->mCallback = new nsMainThreadPtrHolder(aCallback, true); @@ -667,7 +667,7 @@ Dashboard::RequestDNSInfo(NetDashboardCallback *aCallback) } nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetDnsInfoDispatch, dnsData); gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -676,12 +676,12 @@ Dashboard::RequestDNSInfo(NetDashboardCallback *aCallback) nsresult Dashboard::GetDnsInfoDispatch(DnsData *aDnsData) { - nsRefPtr dnsData = aDnsData; + RefPtr dnsData = aDnsData; if (mDnsService) { mDnsService->GetDNSCacheEntries(&dnsData->mData); } nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetDNSCacheEntries, dnsData); dnsData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; @@ -749,7 +749,7 @@ Dashboard::RequestDNSLookup(const nsACString &aHost, } } - nsRefPtr helper = new LookupHelper(); + RefPtr helper = new LookupHelper(); helper->mCallback = new nsMainThreadPtrHolder(aCallback, true); helper->mThread = NS_GetCurrentThread(); @@ -797,7 +797,7 @@ Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort, NetDashboardCallback *aCallback) { nsresult rv; - nsRefPtr connectionData = new ConnectionData(this); + RefPtr connectionData = new ConnectionData(this); connectionData->mHost = aHost; connectionData->mPort = aPort; connectionData->mProtocol = aProtocol; @@ -811,7 +811,7 @@ Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort, if (NS_FAILED(rv)) { mozilla::net::GetErrorString(rv, connectionData->mStatus); nsCOMPtr event = - NS_NewRunnableMethodWithArg > + NS_NewRunnableMethodWithArg > (this, &Dashboard::GetConnectionStatus, connectionData); connectionData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); return rv; @@ -823,7 +823,7 @@ Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort, nsresult Dashboard::GetConnectionStatus(ConnectionData *aConnectionData) { - nsRefPtr connectionData = aConnectionData; + RefPtr connectionData = aConnectionData; AutoSafeJSContext cx; mozilla::dom::ConnStatusDict dict; @@ -841,7 +841,7 @@ Dashboard::GetConnectionStatus(ConnectionData *aConnectionData) nsresult Dashboard::TestNewConnection(ConnectionData *aConnectionData) { - nsRefPtr connectionData = aConnectionData; + RefPtr connectionData = aConnectionData; nsresult rv; if (!connectionData->mHost.Length() || diff --git a/netwerk/base/EventTokenBucket.cpp b/netwerk/base/EventTokenBucket.cpp index 3f28e6d10f..088b7636d0 100644 --- a/netwerk/base/EventTokenBucket.cpp +++ b/netwerk/base/EventTokenBucket.cpp @@ -126,7 +126,7 @@ EventTokenBucket::~EventTokenBucket() // Complete any queued events to prevent hangs while (mEvents.GetSize()) { - nsRefPtr cancelable = + RefPtr cancelable = dont_AddRef(static_cast(mEvents.PopFront())); cancelable->Fire(); } @@ -220,7 +220,7 @@ EventTokenBucket::SubmitEvent(ATokenBucketEvent *event, nsICancelable **cancelab UpdateCredits(); - nsRefPtr cancelEvent = new TokenBucketCancelable(event); + RefPtr cancelEvent = new TokenBucketCancelable(event); // When this function exits the cancelEvent needs 2 references, one for the // mEvents queue and one for the caller of SubmitEvent() @@ -259,7 +259,7 @@ EventTokenBucket::DispatchEvents() return; while (mEvents.GetSize() && mUnitCost <= mCredit) { - nsRefPtr cancelable = + RefPtr cancelable = dont_AddRef(static_cast(mEvents.PopFront())); if (cancelable->mEvent) { SOCKET_LOG(("EventTokenBucket::DispachEvents [%p] " diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index 62441ab355..c45f19db8f 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -31,6 +31,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mLoadingContext(do_GetWeakReference(aLoadingContext)) , mSecurityFlags(aSecurityFlags) , mInternalContentPolicyType(aContentPolicyType) + , mTainting(LoadTainting::Basic) , mUpgradeInsecureRequests(false) , mInnerWindowID(0) , mOuterWindowID(0) @@ -80,6 +81,8 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, mUpgradeInsecureRequests = aLoadingContext->OwnerDoc()->GetUpgradeInsecureRequests(); } + + mOriginAttributes = BasePrincipal::Cast(mLoadingPrincipal)->OriginAttributesRef(); } LoadInfo::LoadInfo(const LoadInfo& rhs) @@ -108,6 +111,8 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, uint64_t aParentOuterWindowID, bool aEnforceSecurity, bool aInitialSecurityCheckDone, + const OriginAttributes& aOriginAttributes, + nsTArray>& aRedirectChainIncludingInternalRedirects, nsTArray>& aRedirectChain) : mLoadingPrincipal(aLoadingPrincipal) , mTriggeringPrincipal(aTriggeringPrincipal) @@ -119,11 +124,15 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mParentOuterWindowID(aParentOuterWindowID) , mEnforceSecurity(aEnforceSecurity) , mInitialSecurityCheckDone(aInitialSecurityCheckDone) + , mOriginAttributes(aOriginAttributes) , mIsFromProcessingFrameAttributes(false) { MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mTriggeringPrincipal); + mRedirectChainIncludingInternalRedirects.SwapElements( + aRedirectChainIncludingInternalRedirects); + mRedirectChain.SwapElements(aRedirectChain); } @@ -134,7 +143,7 @@ LoadInfo::~LoadInfo() already_AddRefed LoadInfo::CloneWithNewSecFlags(nsSecurityFlags aSecurityFlags) const { - nsRefPtr copy(new LoadInfo(*this)); + RefPtr copy(new LoadInfo(*this)); copy->mSecurityFlags = aSecurityFlags; return copy.forget(); } @@ -144,7 +153,7 @@ NS_IMPL_ISUPPORTS(LoadInfo, nsILoadInfo) already_AddRefed LoadInfo::Clone() const { - nsRefPtr copy(new LoadInfo(*this)); + RefPtr copy(new LoadInfo(*this)); return copy.forget(); } @@ -305,6 +314,44 @@ LoadInfo::GetIsFromProcessingFrameAttributes(bool *aIsFromProcessingFrameAttribu return NS_OK; } +NS_IMETHODIMP +LoadInfo::GetScriptableOriginAttributes(JSContext* aCx, + JS::MutableHandle aOriginAttributes) +{ + if (NS_WARN_IF(!ToJSValue(aCx, mOriginAttributes, aOriginAttributes))) { + return NS_ERROR_FAILURE; + } + return NS_OK; +} + +NS_IMETHODIMP +LoadInfo::SetScriptableOriginAttributes(JSContext* aCx, + JS::Handle aOriginAttributes) +{ + OriginAttributes attrs; + if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { + return NS_ERROR_INVALID_ARG; + } + + mOriginAttributes = attrs; + return NS_OK; +} + +nsresult +LoadInfo::GetOriginAttributes(mozilla::OriginAttributes* aOriginAttributes) +{ + NS_ENSURE_ARG(aOriginAttributes); + *aOriginAttributes = mOriginAttributes; + return NS_OK; +} + +nsresult +LoadInfo::SetOriginAttributes(const mozilla::OriginAttributes& aOriginAttributes) +{ + mOriginAttributes = aOriginAttributes; + return NS_OK; +} + NS_IMETHODIMP LoadInfo::SetEnforceSecurity(bool aEnforceSecurity) { @@ -343,13 +390,31 @@ LoadInfo::GetInitialSecurityCheckDone(bool* aResult) } NS_IMETHODIMP -LoadInfo::AppendRedirectedPrincipal(nsIPrincipal* aPrincipal) +LoadInfo::AppendRedirectedPrincipal(nsIPrincipal* aPrincipal, bool aIsInternalRedirect) { NS_ENSURE_ARG(aPrincipal); - mRedirectChain.AppendElement(aPrincipal); + mRedirectChainIncludingInternalRedirects.AppendElement(aPrincipal); + if (!aIsInternalRedirect) { + mRedirectChain.AppendElement(aPrincipal); + } return NS_OK; } +NS_IMETHODIMP +LoadInfo::GetRedirectChainIncludingInternalRedirects(JSContext* aCx, JS::MutableHandle aChain) +{ + if (!ToJSValue(aCx, mRedirectChainIncludingInternalRedirects, aChain)) { + return NS_ERROR_OUT_OF_MEMORY; + } + return NS_OK; +} + +const nsTArray>& +LoadInfo::RedirectChainIncludingInternalRedirects() +{ + return mRedirectChainIncludingInternalRedirects; +} + NS_IMETHODIMP LoadInfo::GetRedirectChain(JSContext* aCx, JS::MutableHandle aChain) { @@ -365,4 +430,23 @@ LoadInfo::RedirectChain() return mRedirectChain; } +NS_IMETHODIMP +LoadInfo::GetTainting(uint32_t* aTaintingOut) +{ + MOZ_ASSERT(aTaintingOut); + *aTaintingOut = static_cast(mTainting); + return NS_OK; +} + +NS_IMETHODIMP +LoadInfo::MaybeIncreaseTainting(uint32_t aTainting) +{ + NS_ENSURE_ARG(aTainting <= TAINTING_OPAQUE); + LoadTainting tainting = static_cast(aTainting); + if (tainting > mTainting) { + mTainting = tainting; + } + return NS_OK; +} + } // namespace mozilla diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h index 6a76c29ece..877c85bf5b 100644 --- a/netwerk/base/LoadInfo.h +++ b/netwerk/base/LoadInfo.h @@ -14,6 +14,8 @@ #include "nsIURI.h" #include "nsTArray.h" +#include "mozilla/BasePrincipal.h" + class nsINode; namespace mozilla { @@ -70,6 +72,8 @@ private: uint64_t aParentOuterWindowID, bool aEnforceSecurity, bool aInitialSecurityCheckDone, + const OriginAttributes& aOriginAttributes, + nsTArray>& aRedirectChainIncludingInternalRedirects, nsTArray>& aRedirectChain); LoadInfo(const LoadInfo& rhs); @@ -85,12 +89,15 @@ private: nsWeakPtr mLoadingContext; nsSecurityFlags mSecurityFlags; nsContentPolicyType mInternalContentPolicyType; + LoadTainting mTainting; bool mUpgradeInsecureRequests; uint64_t mInnerWindowID; uint64_t mOuterWindowID; uint64_t mParentOuterWindowID; bool mEnforceSecurity; bool mInitialSecurityCheckDone; + OriginAttributes mOriginAttributes; + nsTArray> mRedirectChainIncludingInternalRedirects; nsTArray> mRedirectChain; // Is true if this load was triggered by processing the attributes of the diff --git a/netwerk/base/LoadTainting.h b/netwerk/base/LoadTainting.h new file mode 100644 index 0000000000..e2633969f7 --- /dev/null +++ b/netwerk/base/LoadTainting.h @@ -0,0 +1,43 @@ +/* -*- 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 mozilla_LoadTainting_h +#define mozilla_LoadTainting_h + +namespace mozilla { + +// Define an enumeration to reflect the concept of response tainting from the +// the fetch spec: +// +// https://fetch.spec.whatwg.org/#concept-request-response-tainting +// +// Roughly the tainting means: +// +// * Basic: the request resulted in a same-origin or non-http load +// * CORS: the request resulted in a cross-origin load with CORS headers +// * Opaque: the request resulted in a cross-origin load without CORS headers +// +// The enumeration is purposefully designed such that more restrictive tainting +// corresponds to a higher integral value. +// +// NOTE: Checking the tainting is not currently adequate. You *must* still +// check the final URL and CORS mode on the channel. +// +// These values are currently only set on the channel LoadInfo when the request +// was initiated through fetch() or when a service worker interception occurs. +// In the future we should set the tainting value within necko so that it is +// consistently applied. Once that is done consumers can replace checks against +// the final URL and CORS mode with checks against tainting. +enum class LoadTainting : uint8_t +{ + Basic = 0, + CORS = 1, + Opaque = 2 +}; + +} // namespace mozilla + +#endif // mozilla_LoadTainting_h diff --git a/netwerk/base/MemoryDownloader.cpp b/netwerk/base/MemoryDownloader.cpp index 1b9f5e94af..1c50eb0826 100644 --- a/netwerk/base/MemoryDownloader.cpp +++ b/netwerk/base/MemoryDownloader.cpp @@ -41,7 +41,7 @@ MemoryDownloader::OnStopRequest(nsIRequest* aRequest, MOZ_ASSERT(!mData == NS_FAILED(mStatus)); Data data; data.swap(mData); - nsRefPtr observer; + RefPtr observer; observer.swap(mObserver); observer->OnDownloadComplete(this, aRequest, aCtxt, aStatus, mozilla::Move(data)); diff --git a/netwerk/base/MemoryDownloader.h b/netwerk/base/MemoryDownloader.h index 56e265485f..35f5009b8c 100644 --- a/netwerk/base/MemoryDownloader.h +++ b/netwerk/base/MemoryDownloader.h @@ -54,7 +54,7 @@ private: uint32_t count, uint32_t *writeCount); - nsRefPtr mObserver; + RefPtr mObserver; Data mData; nsresult mStatus; }; diff --git a/netwerk/base/OfflineObserver.h b/netwerk/base/OfflineObserver.h index 02e52e1ffd..dc73002088 100644 --- a/netwerk/base/OfflineObserver.h +++ b/netwerk/base/OfflineObserver.h @@ -13,7 +13,7 @@ namespace mozilla { namespace net { /** - * Parents should extend this class and have a nsRefPtr member. + * Parents should extend this class and have a RefPtr member. * The constructor should initialize the member to new OfflineObserver(this) * and the destructor should call RemoveObserver on the member. * diff --git a/netwerk/base/Predictor.cpp b/netwerk/base/Predictor.cpp index 7b23970b6a..88413c178a 100644 --- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -562,7 +562,7 @@ Predictor::Init() do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr lci = + RefPtr lci = new LoadContextInfo(false, nsILoadContextInfo::NO_APP_ID, false, false); rv = cacheStorageService->DiskCacheStorage(lci, false, @@ -627,7 +627,7 @@ public: { MOZ_ASSERT(!NS_IsMainThread(), "Cleaning up old files on main thread!"); nsresult rv = CheckForAndDeleteOldDBFiles(); - nsRefPtr runner = + RefPtr runner = new PredictorThreadShutdownRunner(mIOThread, NS_SUCCEEDED(rv)); NS_DispatchToMainThread(runner); return NS_OK; @@ -698,7 +698,7 @@ Predictor::MaybeCleanupOldDBFiles() ioThread->Dispatch(nuwaRunner, NS_DISPATCH_NORMAL); #endif - nsRefPtr runner = + RefPtr runner = new PredictorOldCleanupRunner(ioThread, dbFile); ioThread->Dispatch(runner, NS_DISPATCH_NORMAL); } @@ -728,7 +728,7 @@ Predictor::Create(nsISupports *aOuter, const nsIID& aIID, return NS_ERROR_NO_AGGREGATION; } - nsRefPtr svc = new Predictor(); + RefPtr svc = new Predictor(); if (IsNeckoChild()) { // Child threads only need to be call into the public interface methods // so we don't bother with initialization @@ -848,7 +848,7 @@ Predictor::Predict(nsIURI *targetURI, nsIURI *sourceURI, // First we open the regular cache entry, to ensure we don't gum up the works // waiting on the less-important predictor-only cache entry - nsRefPtr uriAction = + RefPtr uriAction = new Predictor::Action(Predictor::Action::IS_FULL_URI, Predictor::Action::DO_PREDICT, argReason, targetURI, nullptr, verifier, this); @@ -870,7 +870,7 @@ Predictor::Predict(nsIURI *targetURI, nsIURI *sourceURI, originKey = targetOrigin; } - nsRefPtr originAction = + RefPtr originAction = new Predictor::Action(Predictor::Action::IS_ORIGIN, Predictor::Action::DO_PREDICT, argReason, targetOrigin, nullptr, verifier, this); @@ -985,7 +985,7 @@ Predictor::PredictForPageload(nsICacheEntry *entry, uint8_t stackCount, mPreconnects.AppendElement(redirectURI); Predictor::Reason reason; reason.mPredict = nsINetworkPredictor::PREDICT_LOAD; - nsRefPtr redirectAction = + RefPtr redirectAction = new Predictor::Action(Predictor::Action::IS_FULL_URI, Predictor::Action::DO_PREDICT, reason, redirectURI, nullptr, verifier, this, stackCount + 1); @@ -1322,7 +1322,7 @@ Predictor::Learn(nsIURI *targetURI, nsIURI *sourceURI, // We always open the full uri (general cache) entry first, so we don't gum up // the works waiting on predictor-only entries to open - nsRefPtr uriAction = + RefPtr uriAction = new Predictor::Action(Predictor::Action::IS_FULL_URI, Predictor::Action::DO_LEARN, argReason, targetURI, sourceURI, nullptr, this); @@ -1350,7 +1350,7 @@ Predictor::Learn(nsIURI *targetURI, nsIURI *sourceURI, uriAction); // Now we open the origin-only (and therefore predictor-only) entry - nsRefPtr originAction = + RefPtr originAction = new Predictor::Action(Predictor::Action::IS_ORIGIN, Predictor::Action::DO_LEARN, argReason, targetOrigin, sourceOrigin, nullptr, this); @@ -1509,7 +1509,7 @@ Predictor::LearnForSubresource(nsICacheEntry *entry, nsIURI *targetURI) resourceCount = atoi(s.BeginReading()); } if (resourceCount >= mMaxResourcesPerEntry) { - nsRefPtr cleaner = + RefPtr cleaner = new Predictor::SpaceCleaner(this); entry->VisitMetaData(cleaner); cleaner->Finalize(entry); @@ -1662,7 +1662,7 @@ Predictor::Reset() return NS_OK; } - nsRefPtr reset = new Predictor::Resetter(this); + RefPtr reset = new Predictor::Resetter(this); PREDICTOR_LOG((" created a resetter")); mCacheDiskStorage->AsyncVisitStorage(reset, true); PREDICTOR_LOG((" Cache async launched, returning now")); diff --git a/netwerk/base/Predictor.h b/netwerk/base/Predictor.h index 4b4aca6f4a..7e02c06da6 100644 --- a/netwerk/base/Predictor.h +++ b/netwerk/base/Predictor.h @@ -17,7 +17,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIObserver.h" #include "nsISpeculativeConnect.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsString.h" #include "nsTArray.h" @@ -112,7 +112,7 @@ private: nsCOMPtr mVerifier; TimeStamp mStartTime; uint8_t mStackCount; - nsRefPtr mPredictor; + RefPtr mPredictor; }; class Resetter : public nsICacheEntryOpenCallback, @@ -134,7 +134,7 @@ private: uint32_t mEntriesToVisit; nsTArray mKeysToDelete; - nsRefPtr mPredictor; + RefPtr mPredictor; nsTArray> mURIsToVisit; }; @@ -156,7 +156,7 @@ private: virtual ~SpaceCleaner() { } uint32_t mLRUStamp; const char *mKeyToDelete; - nsRefPtr mPredictor; + RefPtr mPredictor; }; // Observer-related stuff @@ -356,7 +356,7 @@ private: nsCOMPtr mDnsService; - nsRefPtr mDNSListener; + RefPtr mDNSListener; nsTArray> mPreconnects; nsTArray> mPreresolves; diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 85c6d28468..53c40255ae 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -358,7 +358,7 @@ ProxyAutoConfig::ResolveAddress(const nsCString &aHostName, if (!dns) return false; - nsRefPtr helper = new PACResolver(); + RefPtr helper = new PACResolver(); if (NS_FAILED(dns->AsyncResolve(aHostName, nsIDNSService::RESOLVE_PRIORITY_MEDIUM, diff --git a/netwerk/base/SchedulingContextService.cpp b/netwerk/base/SchedulingContextService.cpp index 0bbc557c42..68f94c9dee 100644 --- a/netwerk/base/SchedulingContextService.cpp +++ b/netwerk/base/SchedulingContextService.cpp @@ -141,7 +141,7 @@ SchedulingContextService::Create(nsISupports *aOuter, const nsIID& aIID, void ** return NS_ERROR_NO_AGGREGATION; } - nsRefPtr svc = new SchedulingContextService(); + RefPtr svc = new SchedulingContextService(); nsresult rv = svc->Init(); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/base/StreamingProtocolService.cpp b/netwerk/base/StreamingProtocolService.cpp index 3e1396f85d..3df3326bc1 100644 --- a/netwerk/base/StreamingProtocolService.cpp +++ b/netwerk/base/StreamingProtocolService.cpp @@ -31,14 +31,14 @@ StreamingProtocolControllerService::GetInstance() sSingleton = new StreamingProtocolControllerService(); ClearOnShutdown(&sSingleton); } - nsRefPtr service = sSingleton.get(); + RefPtr service = sSingleton.get(); return service.forget(); } NS_IMETHODIMP StreamingProtocolControllerService::Create(nsIChannel *aChannel, nsIStreamingProtocolController **aResult) { - nsRefPtr mediacontroller; + RefPtr mediacontroller; nsCOMPtr uri; nsAutoCString scheme; diff --git a/netwerk/base/TLSServerSocket.cpp b/netwerk/base/TLSServerSocket.cpp index 94e888fb37..6bc845fe62 100644 --- a/netwerk/base/TLSServerSocket.cpp +++ b/netwerk/base/TLSServerSocket.cpp @@ -73,13 +73,13 @@ TLSServerSocket::CreateClientTransport(PRFileDesc* aClientFD, MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); nsresult rv; - nsRefPtr trans = new nsSocketTransport; + RefPtr trans = new nsSocketTransport; if (NS_WARN_IF(!trans)) { mCondition = NS_ERROR_OUT_OF_MEMORY; return; } - nsRefPtr info = new TLSServerConnectionInfo(); + RefPtr info = new TLSServerConnectionInfo(); info->mServerSocket = this; info->mTransport = trans; nsCOMPtr infoSupports = @@ -270,7 +270,7 @@ NS_IMETHODIMP TLSServerSecurityObserverProxy::OnHandshakeDone(nsITLSServerSocket* aServer, nsITLSClientStatus* aStatus) { - nsRefPtr r = + RefPtr r = new OnHandshakeDoneRunnable(mListener, aServer, aStatus); return NS_DispatchToMainThread(r); } @@ -410,7 +410,7 @@ TLSServerConnectionInfo::GetMacLength(uint32_t* aMacLength) void TLSServerConnectionInfo::HandshakeCallback(PRFileDesc* aFD, void* aArg) { - nsRefPtr info = + RefPtr info = static_cast(aArg); nsISocketTransport* transport = info->mTransport; // No longer needed outside this function, so clear the weak ref diff --git a/netwerk/base/TLSServerSocket.h b/netwerk/base/TLSServerSocket.h index 83d392e50e..fd47fc9189 100644 --- a/netwerk/base/TLSServerSocket.h +++ b/netwerk/base/TLSServerSocket.h @@ -59,7 +59,7 @@ private: static void HandshakeCallback(PRFileDesc* aFD, void* aArg); nsresult HandshakeCallback(PRFileDesc* aFD); - nsRefPtr mServerSocket; + RefPtr mServerSocket; // Weak ref to the transport, to avoid cycles since the transport holds a // reference to the TLSServerConnectionInfo object. This is not handed out to // anyone, and is only used in HandshakeCallback to close the transport in diff --git a/netwerk/base/Tickler.cpp b/netwerk/base/Tickler.cpp index 4b8e05dd10..c6669cca4e 100644 --- a/netwerk/base/Tickler.cpp +++ b/netwerk/base/Tickler.cpp @@ -260,7 +260,7 @@ NS_IMPL_ISUPPORTS(TicklerTimer, nsITimerCallback) NS_IMETHODIMP TicklerTimer::Notify(nsITimer *timer) { - nsRefPtr tickler = do_QueryReferent(mTickler); + RefPtr tickler = do_QueryReferent(mTickler); if (!tickler) return NS_ERROR_FAILURE; MutexAutoLock lock(tickler->mLock); diff --git a/netwerk/base/moz.build b/netwerk/base/moz.build index 61ac28d117..fe14165c6a 100644 --- a/netwerk/base/moz.build +++ b/netwerk/base/moz.build @@ -69,7 +69,9 @@ XPIDL_SOURCES += [ 'nsINSSErrorsService.idl', 'nsINullChannel.idl', 'nsIPACGenerator.idl', + 'nsIPackagedAppChannelListener.idl', 'nsIPackagedAppService.idl', + 'nsIPackagedAppUtils.idl', 'nsIPackagedAppVerifier.idl', 'nsIParentChannel.idl', 'nsIParentRedirectingChannel.idl', @@ -166,6 +168,7 @@ EXPORTS += [ EXPORTS.mozilla += [ 'LoadInfo.h', + 'LoadTainting.h', ] EXPORTS.mozilla.net += [ diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index 6fbbb1426c..c407fc323c 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -54,7 +54,7 @@ public: return NS_OK; } private: - nsRefPtr mCopier; + RefPtr mCopier; nsCOMPtr mTarget; }; diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 26475fd47e..bc0ccf0f6f 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -116,7 +116,7 @@ nsBaseChannel::Redirect(nsIChannel *newChannel, uint32_t redirectFlags, // we support nsIHttpEventSink if we are an HTTP channel and if this is not // an internal redirect. - nsRefPtr redirectCallbackHelper = + RefPtr redirectCallbackHelper = new nsAsyncRedirectVerifyHelper(); bool checkRedirectSynchronously = !openNewChannel; @@ -178,7 +178,7 @@ nsBaseChannel::ContinueRedirect() nsCOMPtr uriPrincipal; nsIScriptSecurityManager *sm = nsContentUtils::GetSecurityManager(); sm->GetChannelURIPrincipal(this, getter_AddRefs(uriPrincipal)); - mLoadInfo->AppendRedirectedPrincipal(uriPrincipal); + mLoadInfo->AppendRedirectedPrincipal(uriPrincipal, false); } } @@ -312,7 +312,7 @@ nsBaseChannel::ClassifyURI() } if (mLoadFlags & LOAD_CLASSIFY_URI) { - nsRefPtr classifier = new nsChannelClassifier(); + RefPtr classifier = new nsChannelClassifier(); if (classifier) { classifier->Start(this); } else { @@ -852,7 +852,7 @@ nsBaseChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, } else { class OnTransportStatusAsyncEvent : public nsRunnable { - nsRefPtr mChannel; + RefPtr mChannel; int64_t mProgress; int64_t mContentLength; public: diff --git a/netwerk/base/nsBaseChannel.h b/netwerk/base/nsBaseChannel.h index 56b56bc4c1..f472d066e8 100644 --- a/netwerk/base/nsBaseChannel.h +++ b/netwerk/base/nsBaseChannel.h @@ -260,12 +260,12 @@ private: } private: - nsRefPtr mChannel; + RefPtr mChannel; nsCOMPtr mNewChannel; }; friend class RedirectRunnable; - nsRefPtr mPump; + RefPtr mPump; nsCOMPtr mProgressSink; nsCOMPtr mOriginalURI; nsCOMPtr mOwner; diff --git a/netwerk/base/nsDirectoryIndexStream.cpp b/netwerk/base/nsDirectoryIndexStream.cpp index 37d4e4b69c..3a70aa7676 100644 --- a/netwerk/base/nsDirectoryIndexStream.cpp +++ b/netwerk/base/nsDirectoryIndexStream.cpp @@ -164,7 +164,7 @@ nsDirectoryIndexStream::~nsDirectoryIndexStream() nsresult nsDirectoryIndexStream::Create(nsIFile* aDir, nsIInputStream** aResult) { - nsRefPtr result = new nsDirectoryIndexStream(); + RefPtr result = new nsDirectoryIndexStream(); if (! result) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsIDivertableChannel.idl b/netwerk/base/nsIDivertableChannel.idl index ca1d966538..4c28ca7dca 100644 --- a/netwerk/base/nsIDivertableChannel.idl +++ b/netwerk/base/nsIDivertableChannel.idl @@ -22,7 +22,7 @@ interface nsIStreamListener; * A channel implementing this interface allows diverting from an * nsIStreamListener in the child process to one in the parent. */ -[uuid(4430e0d0-ff70-45f5-99dc-b5fd06943fc1)] +[uuid(7a9bf52d-f828-4b31-b8df-b40fdd37d007)] interface nsIDivertableChannel : nsISupports { /** @@ -57,4 +57,22 @@ interface nsIDivertableChannel : nsISupports * canceled channel. */ ChannelDiverterChild divertToParent(); + + /** + * nsUnknownDecoder delays calling OnStartRequest until it gets enough data + * to decide about the content type (until OnDataAvaiable is called). In a + * OnStartRequest DivertToParent can be called but some OnDataAvailables are + * already called and therefore can not be diverted to parent. + * + * nsUnknownDecoder will call UnknownDecoderInvolvedKeepData in its + * OnStartRequest function and when it calls OnStartRequest of the next + * listener it will call UnknownDecoderInvolvedOnStartRequestCalled. In this + * function Child process will decide to discarge data if it is not diverting + * to parent or keep them if it is diverting to parent. + */ + void unknownDecoderInvolvedKeepData(); + + void unknownDecoderInvolvedOnStartRequestCalled(); + + readonly attribute bool divertingToParent; }; diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index 01a651504d..963107b394 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -13,16 +13,20 @@ interface nsIPrincipal; %{C++ #include "nsTArray.h" +#include "mozilla/BasePrincipal.h" +#include "mozilla/LoadTainting.h" %} [ref] native const_nsIPrincipalArray(const nsTArray>); +native OriginAttributes(mozilla::OriginAttributes); +[ref] native const_OriginAttributesRef(const mozilla::OriginAttributes); typedef unsigned long nsSecurityFlags; /** * An nsILoadOwner represents per-load information about who started the load. */ -[scriptable, builtinclass, uuid(ef0080f3-33f5-475f-a3d6-9fd3be0612e3)] +[scriptable, builtinclass, uuid(45a4a9e1-b50d-468a-a01c-43de5c38c8db)] interface nsILoadInfo : nsISupports { /** @@ -289,17 +293,7 @@ interface nsILoadInfo : nsISupports * Warning: If the loadingDocument is null, then the * upgradeInsecureRequests is false. */ - readonly attribute boolean upgradeInsecureRequests; - -%{ C++ - inline bool GetUpgradeInsecureRequests() - { - bool result; - mozilla::DebugOnly rv = GetUpgradeInsecureRequests(&result); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - return result; - } -%} + [infallible] readonly attribute boolean upgradeInsecureRequests; /** * Typically these are the window IDs of the window in which the element being @@ -313,31 +307,28 @@ interface nsILoadInfo : nsISupports * available. parentOuterWindowID will be the same as outerWindowID if the * window has no parent. */ - readonly attribute unsigned long long innerWindowID; - readonly attribute unsigned long long outerWindowID; - readonly attribute unsigned long long parentOuterWindowID; + [infallible] readonly attribute unsigned long long innerWindowID; + [infallible] readonly attribute unsigned long long outerWindowID; + [infallible] readonly attribute unsigned long long parentOuterWindowID; + + /** + * Customized OriginAttributes within LoadInfo to allow overwriting of the + * default originAttributes from the loadingPrincipal. + */ + [implicit_jscontext, binaryname(ScriptableOriginAttributes)] + attribute jsval originAttributes; + + [noscript, nostdcall, binaryname(GetOriginAttributes)] + OriginAttributes binaryGetOriginAttributes(); + + [noscript, nostdcall, binaryname(SetOriginAttributes)] + void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs); %{ C++ - inline uint64_t GetInnerWindowID() + inline mozilla::OriginAttributes GetOriginAttributes() { - uint64_t result; - mozilla::DebugOnly rv = GetInnerWindowID(&result); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - return result; - } - - inline uint64_t GetOuterWindowID() - { - uint64_t result; - mozilla::DebugOnly rv = GetOuterWindowID(&result); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - return result; - } - - inline uint64_t GetParentOuterWindowID() - { - uint64_t result; - mozilla::DebugOnly rv = GetParentOuterWindowID(&result); + mozilla::OriginAttributes result; + mozilla::DebugOnly rv = GetOriginAttributes(&result); MOZ_ASSERT(NS_SUCCEEDED(rv)); return result; } @@ -353,17 +344,7 @@ interface nsILoadInfo : nsISupports * to anything else than true will be discareded. * */ - attribute bool enforceSecurity; - -%{ C++ - inline bool GetEnforceSecurity() - { - bool result; - mozilla::DebugOnly rv = GetEnforceSecurity(&result); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - return result; - } -%} + [infallible] attribute boolean enforceSecurity; /** * Whenever a channel is evaluated by the ContentSecurityManager @@ -378,34 +359,43 @@ interface nsILoadInfo : nsISupports * * Please note, once the flag is set to true it must remain true * throughout the lifetime of the channel. Trying to set it - * to anything else than true will be discareded. + * to anything else than true will be discarded. * */ - attribute bool initialSecurityCheckDone; - -%{ C++ - inline bool GetInitialSecurityCheckDone() - { - bool result; - mozilla::DebugOnly rv = GetInitialSecurityCheckDone(&result); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - return result; - } -%} + [infallible] attribute boolean initialSecurityCheckDone; /** * Whenever a channel gets redirected, append the principal of the * channel [before the channels got redirected] to the loadinfo, * so that at every point this array lets us reason about all the * redirects this channel went through. + * @param aPrincipal, the channelURIPrincipal before the channel + * got redirected. + * @param aIsInternalRedirect should be true if the channel is going + * through an internal redirect, otherwise false. */ - void appendRedirectedPrincipal(in nsIPrincipal aPrincipal); + void appendRedirectedPrincipal(in nsIPrincipal principal, + in boolean isInternalRedirect); /** - * An array of nsIPrincipal that store the redirects associated with this + * An array of nsIPrincipals which stores redirects associated with this * channel. This array is filled whether or not the channel has ever been * opened. The last element of the array is associated with the most recent - * channel. + * redirect. Please note, that this array *includes* internal redirects. + */ + [implicit_jscontext] + readonly attribute jsval redirectChainIncludingInternalRedirects; + + /** + * A C++-friendly version of redirectChain. + * Please note that this array has the same lifetime as the + * loadInfo object - use with caution! + */ + [noscript, notxpcom, nostdcall, binaryname(RedirectChainIncludingInternalRedirects)] + const_nsIPrincipalArray binaryRedirectChainIncludingInternalRedirects(); + + /** + * Same as RedirectChain but does *not* include internal redirects. */ [implicit_jscontext] readonly attribute jsval redirectChain; @@ -418,6 +408,56 @@ interface nsILoadInfo : nsISupports [noscript, notxpcom, nostdcall, binaryname(RedirectChain)] const_nsIPrincipalArray binaryRedirectChain(); + /** + * Constants reflecting the channel tainting. These are mainly defined here + * for script. Internal C++ code should use the enum defined in LoadTainting.h. + * See LoadTainting.h for documentation. + */ + const unsigned long TAINTING_BASIC = 0; + const unsigned long TAINTING_CORS = 1; + const unsigned long TAINTING_OPAQUE = 2; + + /** + * Determine the associated channel's current tainting. Note, this can + * change due to a service worker intercept, so it should be checked after + * OnStartRequest() fires. + */ + readonly attribute unsigned long tainting; + + /** + * Note a new tainting level and possibly increase the current tainting + * to match. If the tainting level is already greater than the given + * value, then there is no effect. It is not possible to reduce the tainting + * level on an existing channel/loadinfo. + */ + void maybeIncreaseTainting(in unsigned long aTainting); + + /** + * Various helper code to provide more convenient C++ access to the tainting + * attribute and maybeIncreaseTainting(). + */ +%{C++ + static_assert(TAINTING_BASIC == static_cast(mozilla::LoadTainting::Basic), + "basic tainting enums should match"); + static_assert(TAINTING_CORS == static_cast(mozilla::LoadTainting::CORS), + "cors tainting enums should match"); + static_assert(TAINTING_OPAQUE == static_cast(mozilla::LoadTainting::Opaque), + "opaque tainting enums should match"); + + mozilla::LoadTainting GetTainting() + { + uint32_t tainting = TAINTING_BASIC; + MOZ_ALWAYS_TRUE(NS_SUCCEEDED(GetTainting(&tainting))); + return static_cast(tainting); + } + + void MaybeIncreaseTainting(mozilla::LoadTainting aTainting) + { + uint32_t tainting = static_cast(aTainting); + MOZ_ALWAYS_TRUE(NS_SUCCEEDED(MaybeIncreaseTainting(tainting))); + } +%} + /** * This attribute will be true if this is a load triggered by * https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl index e0c3eb2715..e0942dda14 100644 --- a/netwerk/base/nsINetworkInterceptController.idl +++ b/netwerk/base/nsINetworkInterceptController.idl @@ -27,7 +27,7 @@ class ChannelInfo; * which do not implement nsIChannel. */ -[scriptable, uuid(91d430cc-7e04-4df1-a3c0-879fa30f7ab9)] +[scriptable, uuid(afe6aae6-a80d-405b-856e-df36c19bf3c8)] interface nsIInterceptedChannel : nsISupports { /** @@ -51,9 +51,11 @@ interface nsIInterceptedChannel : nsISupports /** * Instruct a channel that has been intercepted that a response has been * synthesized and can now be read. No further header modification is allowed - * after this point. + * after this point. The caller may optionally pass a spec for a URL that + * this response originates from; an empty string will cause the original + * intercepted request's URL to be used instead. */ - void finishSynthesizedResponse(); + void finishSynthesizedResponse(in ACString finalURLSpec); /** * Cancel the pending intercepted request. @@ -72,11 +74,6 @@ interface nsIInterceptedChannel : nsISupports */ readonly attribute nsIChannel channel; - /** - * True if the underlying request was caused by a navigation attempt. - */ - readonly attribute bool isNavigation; - /** * This method allows to override the channel info for the channel. */ @@ -112,7 +109,7 @@ interface nsIFetchEventDispatcher : nsISupports * request should be intercepted before any network request is initiated. */ -[scriptable, uuid(7157fe12-20e3-45db-b09e-68fdf6d0614f)] +[scriptable, uuid(49eb1997-90fb-49d6-a25d-41f51c7c99e8)] interface nsINetworkInterceptController : nsISupports { /** @@ -122,7 +119,7 @@ interface nsINetworkInterceptController : nsISupports * @param aURI the URI being requested by a channel * @param aIsNavigate True if the request is for a navigation, false for a fetch. */ - bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNavigate, in nsContentPolicyType aType); + bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNonSubresourceRequest); /** * Notification when a given intercepted channel is prepared to accept a synthesized diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index ec6b26a819..39298a4b87 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -668,7 +668,6 @@ nsIOService::NewChannelFromURIWithLoadInfo(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** result) { - NS_ENSURE_ARG_POINTER(aLoadInfo); return NewChannelFromURIWithProxyFlagsInternal(aURI, nullptr, // aProxyURI 0, // aProxyFlags @@ -1749,8 +1748,8 @@ public: { } private: - nsRefPtr mCallbacks; - nsRefPtr mIOService; + RefPtr mCallbacks; + RefPtr mIOService; }; NS_IMPL_ISUPPORTS(IOServiceProxyCallback, nsIProtocolProxyCallback) @@ -1845,7 +1844,7 @@ nsIOService::SpeculativeConnectInternal(nsIURI *aURI, } nsCOMPtr cancelable; - nsRefPtr callback = + RefPtr callback = new IOServiceProxyCallback(aCallbacks, this); nsCOMPtr pps2 = do_QueryInterface(pps); if (pps2) { @@ -1879,7 +1878,7 @@ nsIOService::NotifyAppOfflineStatus(uint32_t appId, int32_t state) MOZ_ASSERT(observerService, "The observer service should not be null"); if (observerService) { - nsRefPtr info = new nsAppOfflineInfo(appId, state); + RefPtr info = new nsAppOfflineInfo(appId, state); observerService->NotifyObservers( info, NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC, diff --git a/netwerk/base/nsIPackagedAppChannelListener.idl b/netwerk/base/nsIPackagedAppChannelListener.idl new file mode 100644 index 0000000000..0f25be1700 --- /dev/null +++ b/netwerk/base/nsIPackagedAppChannelListener.idl @@ -0,0 +1,25 @@ +/* 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 "nsISupports.idl" + +/** + * nsIPackagedAppChannelListener + */ +[scriptable, uuid(27caf7d0-3c0e-11e5-b970-0800200c9a66)] +interface nsIPackagedAppChannelListener : nsISupports +{ + /** + * @param aPackageId + * the package identifier of the signed package that we are going + * to load. The identifier will be defined in the manifest of the + * package. + * + * This callback is to notify a signed package is about to load. Some + * component else will be in charge of responding to this fact properly. + * The procotol layer should have no idea what to do with this. + * + */ + void onStartSignedPackageRequest(in ACString aPackageId); +}; diff --git a/netwerk/base/nsIPackagedAppUtils.idl b/netwerk/base/nsIPackagedAppUtils.idl new file mode 100644 index 0000000000..5080b4d9ee --- /dev/null +++ b/netwerk/base/nsIPackagedAppUtils.idl @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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 "nsISupports.idl" + +interface nsIVerificationCallback; + +%{C++ +#define NS_PACKAGEDAPPUTILS_CONTRACTID "@mozilla.org/network/packaged-app-utils;1" +%} + +/** + * A package using privileged APIs should be signed by marketplace or trust- + * worthy developers. When Necko receives such a package, it has to + * extract the manifest and the signature and calls verifyManifest(...) to verify + * the manifest. nsIPackagedAppUtils will parse the manifest and + * store the hash values of each resource. When a resource is ready, Necko + * will calculate its hash value (including the header like Content-Location: xxx), + * and calls checkIntegrity(...) to verify the integrity. + * + * For more detail: + * https://wiki.mozilla.org/FirefoxOS/New_security_model/Packaging + */ + +[scriptable, uuid(d0a98a69-a215-4cf9-abb3-7a0b9237cd27)] +interface nsIPackagedAppUtils : nsISupports +{ + /** + * @aHeader is the package's header including + * - "manifest-signature: xxxxxx" (base64 encoding) + * @aManifest is the manifest of the package + * - the multipart header is included + * - manifest must be the first resource of the package + * @aCallback is the callback, see comments of nsIVerificationCallback below + */ + void verifyManifest(in ACString aHeader, + in ACString aManifest, + in nsIVerificationCallback aVerifier); + + /** + * @aFileName is the name of a resource in the package + * @aHashValue is the hash value of this resource named aFileName + * - aHashValue should be computed by the caller of this method + * @aCallback is the callback, see comments of nsIVerificationCallback below + */ + void checkIntegrity(in ACString aFileName, + in ACString aHashValue, + in nsIVerificationCallback aVerifier); +}; + +/** + * The callback passed to verifyManifest and checkIntegrity + */ +[scriptable, uuid(e1912028-93e5-4378-aa3f-a58702937169)] +interface nsIVerificationCallback : nsISupports +{ + /** + * @aForManifest + * - true if it's called by verifyManifest + * - false if it's called by checkIntegrity + * @aSuccess + * - true if the verification succeeds, false otherwise + */ + void fireVerifiedEvent(in boolean aForManifest, + in boolean aSuccess); +}; diff --git a/netwerk/base/nsInputStreamPump.cpp b/netwerk/base/nsInputStreamPump.cpp index ab12742fa5..1cfae6055b 100644 --- a/netwerk/base/nsInputStreamPump.cpp +++ b/netwerk/base/nsInputStreamPump.cpp @@ -63,7 +63,7 @@ nsInputStreamPump::Create(nsInputStreamPump **result, bool closeWhenDone) { nsresult rv = NS_ERROR_OUT_OF_MEMORY; - nsRefPtr pump = new nsInputStreamPump(); + RefPtr pump = new nsInputStreamPump(); if (pump) { rv = pump->Init(stream, streamPos, streamLen, segsize, segcount, closeWhenDone); diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index fe311314cc..c1fa8a314e 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -507,7 +507,7 @@ NS_NewLoadGroup(nsILoadGroup **aResult, nsIPrincipal *aPrincipal) do_CreateInstance(NS_LOADGROUP_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr loadContext = new LoadContext(aPrincipal); + RefPtr loadContext = new LoadContext(aPrincipal); rv = group->SetNotificationCallbacks(loadContext); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/base/nsNetUtil.inl b/netwerk/base/nsNetUtil.inl index 0db65ee72d..bf58f9a650 100644 --- a/netwerk/base/nsNetUtil.inl +++ b/netwerk/base/nsNetUtil.inl @@ -200,34 +200,38 @@ NS_NewChannelInternal(nsIChannel **outChannel, // NS_NewChannelInternal is mostly called for channel redirects. We should allow // the creation of a channel even if the original channel did not have a loadinfo // attached. - if (!aLoadInfo) { - return NS_NewChannelInternal(outChannel, - aUri, - nullptr, // aLoadingNode - nullptr, // aLoadingPrincipal - nullptr, // aTriggeringPrincipal - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService); - } - nsresult rv = NS_NewChannelInternal(outChannel, - aUri, - aLoadInfo->LoadingNode(), - aLoadInfo->LoadingPrincipal(), - aLoadInfo->TriggeringPrincipal(), - aLoadInfo->GetSecurityFlags(), - aLoadInfo->InternalContentPolicyType(), - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService); + NS_ENSURE_ARG_POINTER(outChannel); + + nsCOMPtr grip; + nsresult rv = net_EnsureIOService(&aIoService, grip); NS_ENSURE_SUCCESS(rv, rv); - // Please note that we still call SetLoadInfo on the channel because - // we want the same instance of the loadInfo to be set on the channel. - (*outChannel)->SetLoadInfo(aLoadInfo); + + nsCOMPtr channel; + rv = aIoService->NewChannelFromURIWithLoadInfo( + aUri, + aLoadInfo, + getter_AddRefs(channel)); + NS_ENSURE_SUCCESS(rv, rv); + + if (aLoadGroup) { + rv = channel->SetLoadGroup(aLoadGroup); + NS_ENSURE_SUCCESS(rv, rv); + } + + if (aCallbacks) { + rv = channel->SetNotificationCallbacks(aCallbacks); + NS_ENSURE_SUCCESS(rv, rv); + } + + if (aLoadFlags != nsIRequest::LOAD_NORMAL) { + // Retain the LOAD_REPLACE load flag if set. + nsLoadFlags normalLoadFlags = 0; + channel->GetLoadFlags(&normalLoadFlags); + rv = channel->SetLoadFlags(aLoadFlags | (normalLoadFlags & nsIChannel::LOAD_REPLACE)); + NS_ENSURE_SUCCESS(rv, rv); + } + + channel.forget(outChannel); return NS_OK; } diff --git a/netwerk/base/nsPACMan.cpp b/netwerk/base/nsPACMan.cpp index 743bb3ef02..232bfebc53 100644 --- a/netwerk/base/nsPACMan.cpp +++ b/netwerk/base/nsPACMan.cpp @@ -83,7 +83,7 @@ public: } private: - nsRefPtr mCallback; + RefPtr mCallback; nsresult mStatus; nsCString mPACString; nsCString mPACURL; @@ -135,7 +135,7 @@ public: } private: - nsRefPtr mPACMan; + RefPtr mPACMan; }; //----------------------------------------------------------------------------- @@ -161,7 +161,7 @@ public: } private: - nsRefPtr mPACMan; + RefPtr mPACMan; }; //----------------------------------------------------------------------------- @@ -208,7 +208,7 @@ public: mPACMan->mPAC.Init(mSetupPACURI, mSetupPACData); - nsRefPtr runnable = new PACLoadComplete(mPACMan); + RefPtr runnable = new PACLoadComplete(mPACMan); NS_DispatchToMainThread(runnable); return NS_OK; } @@ -218,7 +218,7 @@ public: } private: - nsRefPtr mPACMan; + RefPtr mPACMan; bool mCancel; nsresult mCancelStatus; @@ -263,7 +263,7 @@ PendingPACQuery::Complete(nsresult status, const nsCString &pacString) { if (!mCallback) return; - nsRefPtr runnable = new ExecuteCallback(mCallback, status); + RefPtr runnable = new ExecuteCallback(mCallback, status); runnable->SetPACString(pacString); if (mOnMainThreadOnly) NS_DispatchToMainThread(runnable); @@ -277,7 +277,7 @@ PendingPACQuery::UseAlternatePACFile(const nsCString &pacURL) if (!mCallback) return; - nsRefPtr runnable = new ExecuteCallback(mCallback, NS_OK); + RefPtr runnable = new ExecuteCallback(mCallback, NS_OK); runnable->SetPACURL(pacURL); if (mOnMainThreadOnly) NS_DispatchToMainThread(runnable); @@ -319,7 +319,7 @@ nsPACMan::~nsPACMan() mPACThread->Shutdown(); } else { - nsRefPtr runnable = new ShutdownThread(mPACThread); + RefPtr runnable = new ShutdownThread(mPACThread); NS_DispatchToMainThread(runnable); } } @@ -339,7 +339,7 @@ nsPACMan::Shutdown() CancelExistingLoad(); PostCancelPendingQ(NS_ERROR_ABORT); - nsRefPtr runnable = new WaitForThreadShutdown(this); + RefPtr runnable = new WaitForThreadShutdown(this); NS_DispatchToMainThread(runnable); } @@ -357,7 +357,7 @@ nsPACMan::AsyncGetProxyForURI(nsIURI *uri, uint32_t appId, TimeStamp::Now() > mScheduledReload) LoadPACFromURI(EmptyCString()); - nsRefPtr query = + RefPtr query = new PendingPACQuery(this, uri, appId, isInBrowser, callback, mainThreadResponse); @@ -381,7 +381,7 @@ nsPACMan::PostQuery(PendingPACQuery *query) } // add a reference to the query while it is in the pending list - nsRefPtr addref(query); + RefPtr addref(query); mPendingQ.insertBack(addref.forget().take()); ProcessPendingQ(); return NS_OK; @@ -520,7 +520,7 @@ void nsPACMan::PostProcessPendingQ() { MOZ_ASSERT(NS_IsMainThread(), "wrong thread"); - nsRefPtr pending = + RefPtr pending = new ExecutePACThreadAction(this); if (mPACThread) mPACThread->Dispatch(pending, nsIEventTarget::DISPATCH_NORMAL); @@ -530,7 +530,7 @@ void nsPACMan::PostCancelPendingQ(nsresult status) { MOZ_ASSERT(NS_IsMainThread(), "wrong thread"); - nsRefPtr pending = + RefPtr pending = new ExecutePACThreadAction(this); pending->CancelQueue(status); if (mPACThread) @@ -541,7 +541,7 @@ void nsPACMan::CancelPendingQ(nsresult status) { MOZ_ASSERT(!NS_IsMainThread(), "wrong thread"); - nsRefPtr query; + RefPtr query; while (!mPendingQ.isEmpty()) { query = dont_AddRef(mPendingQ.popLast()); @@ -578,7 +578,7 @@ nsPACMan::ProcessPending() if (mInProgress || (IsLoading() && !mLoadFailureCount)) return false; - nsRefPtr query(dont_AddRef(mPendingQ.popFirst())); + RefPtr query(dont_AddRef(mPendingQ.popFirst())); if (mShutdown || IsLoading()) { query->Complete(NS_ERROR_NOT_AVAILABLE, EmptyCString()); @@ -668,7 +668,7 @@ nsPACMan::OnStreamComplete(nsIStreamLoader *loader, // the PAC evaluator (NS_PROXYAUTOCONFIG_CONTRACTID) on the pac thread, because // that is where it will be used. - nsRefPtr pending = + RefPtr pending = new ExecutePACThreadAction(this); pending->SetupPAC(text, dataLen, pacURI); if (mPACThread) diff --git a/netwerk/base/nsPACMan.h b/netwerk/base/nsPACMan.h index 28249e8136..c802303fad 100644 --- a/netwerk/base/nsPACMan.h +++ b/netwerk/base/nsPACMan.h @@ -78,7 +78,7 @@ public: nsString mAppOrigin; private: - nsRefPtr mCallback; + RefPtr mCallback; bool mOnMainThreadOnly; }; diff --git a/netwerk/base/nsProtocolProxyService.cpp b/netwerk/base/nsProtocolProxyService.cpp index a4174d8590..e84ee898c5 100644 --- a/netwerk/base/nsProtocolProxyService.cpp +++ b/netwerk/base/nsProtocolProxyService.cpp @@ -264,7 +264,7 @@ private: nsresult rv = mPPS->ConfigureFromPAC(mPACURL, false); if (NS_SUCCEEDED(rv)) { // now that the load is triggered, we can resubmit the query - nsRefPtr newRequest = + RefPtr newRequest = new nsAsyncResolveRequest(mPPS, mChannel, mAppId, mIsInBrowser, mResolveFlags, mCallback); @@ -1187,7 +1187,7 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIChannel *aChannel, // Use the PAC thread to do the work, so we don't have to reimplement that // code, but block this thread on that completion. - nsRefPtr ctx = new nsAsyncBridgeRequest(); + RefPtr ctx = new nsAsyncBridgeRequest(); ctx->Lock(); if (NS_SUCCEEDED(mPACMan->AsyncGetProxyForURI(uri, NECKO_NO_APP_ID, false, ctx, false))) { @@ -1247,7 +1247,7 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags NS_GetAppInfo(channel, &appId, &isInBrowser); *result = nullptr; - nsRefPtr ctx = + RefPtr ctx = new nsAsyncResolveRequest(this, channel, appId, isInBrowser, flags, callback); diff --git a/netwerk/base/nsProtocolProxyService.h b/netwerk/base/nsProtocolProxyService.h index 900330cf55..e9813c87a4 100644 --- a/netwerk/base/nsProtocolProxyService.h +++ b/netwerk/base/nsProtocolProxyService.h @@ -389,7 +389,7 @@ protected: bool mSOCKSProxyRemoteDNS; bool mProxyOverTLS; - nsRefPtr mPACMan; // non-null if we are using PAC + RefPtr mPACMan; // non-null if we are using PAC nsCOMPtr mSystemProxySettings; PRTime mSessionStart; diff --git a/netwerk/base/nsRequestObserverProxy.cpp b/netwerk/base/nsRequestObserverProxy.cpp index 195d24db1e..344e4413d6 100644 --- a/netwerk/base/nsRequestObserverProxy.cpp +++ b/netwerk/base/nsRequestObserverProxy.cpp @@ -34,7 +34,7 @@ nsARequestObserverEvent::nsARequestObserverEvent(nsIRequest *request) class nsOnStartRequestEvent : public nsARequestObserverEvent { - nsRefPtr mProxy; + RefPtr mProxy; public: nsOnStartRequestEvent(nsRequestObserverProxy *proxy, nsIRequest *request) @@ -73,7 +73,7 @@ public: class nsOnStopRequestEvent : public nsARequestObserverEvent { - nsRefPtr mProxy; + RefPtr mProxy; public: nsOnStopRequestEvent(nsRequestObserverProxy *proxy, nsIRequest *request) diff --git a/netwerk/base/nsSerializationHelper.cpp b/netwerk/base/nsSerializationHelper.cpp index a19e082049..68f971eae4 100644 --- a/netwerk/base/nsSerializationHelper.cpp +++ b/netwerk/base/nsSerializationHelper.cpp @@ -20,7 +20,7 @@ using namespace mozilla; nsresult NS_SerializeToString(nsISerializable* obj, nsCSubstring& str) { - nsRefPtr stream(new nsBase64Encoder()); + RefPtr stream(new nsBase64Encoder()); if (!stream) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsServerSocket.cpp b/netwerk/base/nsServerSocket.cpp index 82b341b9d2..d9ca570bf4 100644 --- a/netwerk/base/nsServerSocket.cpp +++ b/netwerk/base/nsServerSocket.cpp @@ -158,7 +158,7 @@ void nsServerSocket::CreateClientTransport(PRFileDesc* aClientFD, const NetAddr& aClientAddr) { - nsRefPtr trans = new nsSocketTransport; + RefPtr trans = new nsSocketTransport; if (NS_WARN_IF(!trans)) { mCondition = NS_ERROR_OUT_OF_MEMORY; return; @@ -483,7 +483,7 @@ NS_IMETHODIMP ServerSocketListenerProxy::OnSocketAccepted(nsIServerSocket* aServ, nsISocketTransport* aTransport) { - nsRefPtr r = + RefPtr r = new OnSocketAcceptedRunnable(mListener, aServ, aTransport); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } @@ -492,7 +492,7 @@ NS_IMETHODIMP ServerSocketListenerProxy::OnStopListening(nsIServerSocket* aServ, nsresult aStatus) { - nsRefPtr r = + RefPtr r = new OnStopListeningRunnable(mListener, aServ, aStatus); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } diff --git a/netwerk/base/nsSimpleURI.cpp b/netwerk/base/nsSimpleURI.cpp index 238608fb87..7accb23036 100644 --- a/netwerk/base/nsSimpleURI.cpp +++ b/netwerk/base/nsSimpleURI.cpp @@ -429,7 +429,7 @@ nsSimpleURI::EqualsInternal(nsIURI* other, NS_ENSURE_ARG_POINTER(other); NS_PRECONDITION(result, "null pointer"); - nsRefPtr otherUri; + RefPtr otherUri; nsresult rv = other->QueryInterface(kThisSimpleURIImplementationCID, getter_AddRefs(otherUri)); if (NS_FAILED(rv)) { @@ -495,7 +495,7 @@ nsresult nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode, nsIURI** result) { - nsRefPtr url = StartClone(refHandlingMode); + RefPtr url = StartClone(refHandlingMode); if (!url) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index a16d352a17..acd24d00e3 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -80,7 +80,7 @@ public: } private: - nsRefPtr mTransport; + RefPtr mTransport; uint32_t mType; nsresult mStatus; @@ -1234,7 +1234,7 @@ nsSocketTransport::InitiateSocket() crashOnNonLocalConnections && !(IsIPAddrAny(&mNetAddr) || IsIPAddrLocal(&mNetAddr))) { nsAutoCString ipaddr; - nsRefPtr netaddr = new nsNetAddr(&mNetAddr); + RefPtr netaddr = new nsNetAddr(&mNetAddr); netaddr->GetAddress(ipaddr); fprintf_stderr(stderr, "FATAL ERROR: Non-local network connections are disabled and a connection " diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index 48184853c1..199df1df2b 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -354,7 +354,7 @@ private: // A delete protector reference to gSocketTransportService held for lifetime // of 'this'. Sometimes used interchangably with gSocketTransportService due // to scoping. - nsRefPtr mSocketTransportService; + RefPtr mSocketTransportService; nsCOMPtr mCallbacks; nsCOMPtr mEventSink; diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 534be02096..e1ebf92184 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -701,7 +701,7 @@ nsSocketTransportService::CreateRoutedTransport(const char **types, NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(port >= 0 && port <= 0xFFFF, NS_ERROR_ILLEGAL_VALUE); - nsRefPtr trans = new nsSocketTransport(); + RefPtr trans = new nsSocketTransport(); nsresult rv = trans->Init(types, typeCount, host, port, hostRoute, portRoute, proxyInfo); if (NS_FAILED(rv)) { return rv; @@ -729,7 +729,7 @@ nsSocketTransportService::CreateUnixDomainTransport(nsIFile *aPath, if (NS_FAILED(rv)) return rv; - nsRefPtr trans = new nsSocketTransport(); + RefPtr trans = new nsSocketTransport(); rv = trans->InitWithFilename(path.get()); if (NS_FAILED(rv)) diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index caf6db9798..2a32781649 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -1846,7 +1846,7 @@ nsStandardURL::EqualsInternal(nsIURI *unknownOther, NS_ENSURE_ARG_POINTER(unknownOther); NS_PRECONDITION(result, "null pointer"); - nsRefPtr other; + RefPtr other; nsresult rv = unknownOther->QueryInterface(kThisImplCID, getter_AddRefs(other)); if (NS_FAILED(rv)) { @@ -1963,7 +1963,7 @@ nsStandardURL::CloneInternal(nsStandardURL::RefHandlingEnum refHandlingMode, nsIURI **result) { - nsRefPtr clone = StartClone(); + RefPtr clone = StartClone(); if (!clone) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsTemporaryFileInputStream.h b/netwerk/base/nsTemporaryFileInputStream.h index d63f48b288..32bdf468a8 100644 --- a/netwerk/base/nsTemporaryFileInputStream.h +++ b/netwerk/base/nsTemporaryFileInputStream.h @@ -47,7 +47,7 @@ public: private: virtual ~nsTemporaryFileInputStream() { } - nsRefPtr mFileDescOwner; + RefPtr mFileDescOwner; uint64_t mStartPos; uint64_t mEndPos; bool mClosed; diff --git a/netwerk/base/nsTransportUtils.cpp b/netwerk/base/nsTransportUtils.cpp index 0c6a7d5eeb..835c7c0bbb 100644 --- a/netwerk/base/nsTransportUtils.cpp +++ b/netwerk/base/nsTransportUtils.cpp @@ -79,7 +79,7 @@ public: return NS_OK; } - nsRefPtr mProxy; + RefPtr mProxy; // parameters to OnTransportStatus nsCOMPtr mTransport; @@ -97,7 +97,7 @@ nsTransportEventSinkProxy::OnTransportStatus(nsITransport *transport, int64_t progressMax) { nsresult rv = NS_OK; - nsRefPtr event; + RefPtr event; { MutexAutoLock lock(mLock); diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 730392ff6e..f0afd760e5 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -86,7 +86,7 @@ public: } private: - nsRefPtr mSocket; + RefPtr mSocket; PRSocketOptionData mOpt; }; @@ -487,7 +487,7 @@ nsUDPSocket::OnSocketReady(PRFileDesc *fd, int16_t outFlags) return; } - nsRefPtr os = new nsUDPOutputStream(this, mFD, prClientAddr); + RefPtr os = new nsUDPOutputStream(this, mFD, prClientAddr); rv = NS_AsyncCopy(pipeIn, os, mSts, NS_ASYNCCOPY_VIA_READSEGMENTS, UDP_PACKET_CHUNK_SIZE); @@ -723,7 +723,7 @@ nsUDPSocket::SaveNetworkStats(bool aEnforce) if (aEnforce || total > NETWORK_STATS_THRESHOLD) { // Create the event to save the network statistics. // the event is then dispathed to the main thread. - nsRefPtr event = + RefPtr event = new SaveNetworkStatsEvent(mAppId, mIsInBrowserElement, mActiveNetworkInfo, mByteReadCount, mByteWriteCount, false); NS_DispatchToMainThread(event); @@ -810,7 +810,7 @@ NS_IMETHODIMP SocketListenerProxy::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage) { - nsRefPtr r = + RefPtr r = new OnPacketReceivedRunnable(mListener, aSocket, aMessage); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } @@ -819,7 +819,7 @@ NS_IMETHODIMP SocketListenerProxy::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus) { - nsRefPtr r = + RefPtr r = new OnStopListeningRunnable(mListener, aSocket, aStatus); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } @@ -915,7 +915,7 @@ NS_IMETHODIMP SocketListenerProxyBackground::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage) { - nsRefPtr r = + RefPtr r = new OnPacketReceivedRunnable(mListener, aSocket, aMessage); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } @@ -924,7 +924,7 @@ NS_IMETHODIMP SocketListenerProxyBackground::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus) { - nsRefPtr r = + RefPtr r = new OnStopListeningRunnable(mListener, aSocket, aStatus); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } @@ -975,7 +975,7 @@ public: private: virtual ~PendingSend() {} - nsRefPtr mSocket; + RefPtr mSocket; uint16_t mPort; FallibleTArray mData; }; @@ -1018,7 +1018,7 @@ public: private: virtual ~PendingSendStream() {} - nsRefPtr mSocket; + RefPtr mSocket; uint16_t mPort; nsCOMPtr mStream; }; @@ -1057,7 +1057,7 @@ public: NS_DECL_NSIRUNNABLE private: - nsRefPtr mSocket; + RefPtr mSocket; const NetAddr mAddr; FallibleTArray mData; }; @@ -1196,7 +1196,7 @@ nsUDPSocket::SendBinaryStreamWithAddress(const NetAddr *aAddr, nsIInputStream *a PR_InitializeNetAddr(PR_IpAddrAny, 0, &prAddr); NetAddrToPRNetAddr(aAddr, &prAddr); - nsRefPtr os = new nsUDPOutputStream(this, mFD, prAddr); + RefPtr os = new nsUDPOutputStream(this, mFD, prAddr); return NS_AsyncCopy(aStream, os, mSts, NS_ASYNCCOPY_VIA_READSEGMENTS, UDP_PACKET_CHUNK_SIZE); } diff --git a/netwerk/base/nsUDPSocket.h b/netwerk/base/nsUDPSocket.h index 567ce40207..a29328218a 100644 --- a/netwerk/base/nsUDPSocket.h +++ b/netwerk/base/nsUDPSocket.h @@ -67,7 +67,7 @@ private: nsCOMPtr mListener; nsCOMPtr mListenerTarget; bool mAttached; - nsRefPtr mSts; + RefPtr mSts; uint64_t mByteReadCount; uint64_t mByteWriteCount; @@ -114,7 +114,7 @@ public: private: virtual ~nsUDPOutputStream(); - nsRefPtr mSocket; + RefPtr mSocket; PRFileDesc *mFD; PRNetAddr mPrClientAddr; bool mIsClosed; diff --git a/netwerk/cache/nsApplicationCache.h b/netwerk/cache/nsApplicationCache.h index 86b2323e79..fc85010057 100644 --- a/netwerk/cache/nsApplicationCache.h +++ b/netwerk/cache/nsApplicationCache.h @@ -21,7 +21,7 @@ public: private: virtual ~nsApplicationCache(); - nsRefPtr mDevice; + RefPtr mDevice; nsCString mGroup; nsCString mClientID; bool mValid; diff --git a/netwerk/cache/nsApplicationCacheService.cpp b/netwerk/cache/nsApplicationCacheService.cpp index 65ad9c4da3..3bbde2d5ba 100644 --- a/netwerk/cache/nsApplicationCacheService.cpp +++ b/netwerk/cache/nsApplicationCacheService.cpp @@ -75,7 +75,7 @@ nsApplicationCacheService::CreateApplicationCache(const nsACString &group, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->CreateApplicationCache(group, out); @@ -90,7 +90,7 @@ nsApplicationCacheService::CreateCustomApplicationCache(const nsACString & group if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetCustomOfflineDevice(profileDir, quota, getter_AddRefs(device)); @@ -105,7 +105,7 @@ nsApplicationCacheService::GetApplicationCache(const nsACString &clientID, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->GetApplicationCache(clientID, out); @@ -118,7 +118,7 @@ nsApplicationCacheService::GetActiveCache(const nsACString &group, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->GetActiveCache(group, out); @@ -130,7 +130,7 @@ nsApplicationCacheService::DeactivateGroup(const nsACString &group) if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->DeactivateGroup(group); @@ -144,7 +144,7 @@ nsApplicationCacheService::ChooseApplicationCache(const nsACString &key, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); @@ -158,7 +158,7 @@ nsApplicationCacheService::CacheOpportunistically(nsIApplicationCache* cache, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->CacheOpportunistically(cache, key); @@ -170,7 +170,7 @@ nsApplicationCacheService::DiscardByAppId(int32_t appID, bool isInBrowser) if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->DiscardByAppId(appID, isInBrowser); @@ -183,7 +183,7 @@ nsApplicationCacheService::GetGroups(uint32_t *count, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->GetGroups(count, keys); @@ -196,7 +196,7 @@ nsApplicationCacheService::GetGroupsTimeOrdered(uint32_t *count, if (!mCacheService) return NS_ERROR_UNEXPECTED; - nsRefPtr device; + RefPtr device; nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); NS_ENSURE_SUCCESS(rv, rv); return device->GetGroupsTimeOrdered(count, keys); @@ -246,7 +246,7 @@ nsApplicationCacheService::AppClearDataObserverInit() { nsCOMPtr observerService = services::GetObserverService(); if (observerService) { - nsRefPtr obs + RefPtr obs = new AppCacheClearDataObserver(); observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA, /*holdsWeak=*/ false); diff --git a/netwerk/cache/nsApplicationCacheService.h b/netwerk/cache/nsApplicationCacheService.h index 371c6b1922..73bd32206c 100644 --- a/netwerk/cache/nsApplicationCacheService.h +++ b/netwerk/cache/nsApplicationCacheService.h @@ -22,7 +22,7 @@ public: private: ~nsApplicationCacheService(); - nsRefPtr mCacheService; + RefPtr mCacheService; }; #endif // _nsApplicationCacheService_h_ diff --git a/netwerk/cache/nsCacheEntry.cpp b/netwerk/cache/nsCacheEntry.cpp index b2e90c6905..abf58c6418 100644 --- a/netwerk/cache/nsCacheEntry.cpp +++ b/netwerk/cache/nsCacheEntry.cpp @@ -249,7 +249,7 @@ nsCacheEntry::DetachDescriptors() void nsCacheEntry::GetDescriptors( - nsTArray > &outDescriptors) + nsTArray > &outDescriptors) { nsCacheEntryDescriptor * descriptor = (nsCacheEntryDescriptor *)PR_LIST_HEAD(&mDescriptorQ); diff --git a/netwerk/cache/nsCacheEntry.h b/netwerk/cache/nsCacheEntry.h index cbd8696599..84ae2fa6f5 100644 --- a/netwerk/cache/nsCacheEntry.h +++ b/netwerk/cache/nsCacheEntry.h @@ -195,7 +195,7 @@ public: bool RemoveDescriptor( nsCacheEntryDescriptor * descriptor, bool * doomEntry); - void GetDescriptors(nsTArray > &outDescriptors); + void GetDescriptors(nsTArray > &outDescriptors); private: friend class nsCacheEntryHashTable; diff --git a/netwerk/cache/nsCacheEntryDescriptor.cpp b/netwerk/cache/nsCacheEntryDescriptor.cpp index 80209307b2..b235ec2154 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.cpp +++ b/netwerk/cache/nsCacheEntryDescriptor.cpp @@ -64,7 +64,7 @@ public: } private: - nsRefPtr mDescriptor; + RefPtr mDescriptor; nsICacheListener *mListener; nsCOMPtr mThread; }; @@ -555,8 +555,8 @@ nsCacheEntryDescriptor::MarkValid() NS_IMETHODIMP nsCacheEntryDescriptor::Close() { - nsRefPtr outputWrapper; - nsTArray > inputWrappers; + RefPtr outputWrapper; + nsTArray > inputWrappers; { nsCacheServiceAutoLock lock; @@ -659,7 +659,7 @@ nsCacheEntryDescriptor::nsInputStreamWrapper::Release() { // Holding a reference to descriptor ensures that cache service won't go // away. Do not grab cache service lock if there is no descriptor. - nsRefPtr desc; + RefPtr desc; { mozilla::MutexAutoLock lock(mLock); @@ -851,7 +851,7 @@ nsCacheEntryDescriptor::nsDecompressInputStreamWrapper::Release() { // Holding a reference to descriptor ensures that cache service won't go // away. Do not grab cache service lock if there is no descriptor. - nsRefPtr desc; + RefPtr desc; { mozilla::MutexAutoLock lock(mLock); @@ -1040,7 +1040,7 @@ nsCacheEntryDescriptor::nsOutputStreamWrapper::Release() { // Holding a reference to descriptor ensures that cache service won't go // away. Do not grab cache service lock if there is no descriptor. - nsRefPtr desc; + RefPtr desc; { mozilla::MutexAutoLock lock(mLock); @@ -1270,7 +1270,7 @@ nsCacheEntryDescriptor::nsCompressOutputStreamWrapper::Release() { // Holding a reference to descriptor ensures that cache service won't go // away. Do not grab cache service lock if there is no descriptor. - nsRefPtr desc; + RefPtr desc; { mozilla::MutexAutoLock lock(mLock); diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 4b26a022e3..fda6954d38 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -1170,7 +1170,7 @@ nsCacheService::Init() // static PLDHashOperator nsCacheService::ShutdownCustomCacheDeviceEnum(const nsAString& aProfileDir, - nsRefPtr& aDevice, + RefPtr& aDevice, void* aUserArg) { aDevice->Shutdown(); @@ -1308,7 +1308,7 @@ nsCacheService::CreateSessionInternal(const char * clientID, bool streamBased, nsICacheSession **result) { - nsRefPtr session = + RefPtr session = new nsCacheSession(clientID, storagePolicy, streamBased); session.forget(result); @@ -1358,7 +1358,7 @@ nsresult nsCacheService::EvictEntriesForClient(const char * clientID, nsCacheStoragePolicy storagePolicy) { - nsRefPtr r = + RefPtr r = new EvictionNotifierRunnable(NS_ISUPPORTS_CAST(nsICacheService*, this)); NS_DispatchToMainThread(r); @@ -1966,7 +1966,7 @@ nsCacheService::ProcessRequest(nsCacheRequest * request, // Failsafe check: this is implemented only for offline cache atm. rv = NS_ERROR_FAILURE; } else { - nsRefPtr customCacheDevice; + RefPtr customCacheDevice; rv = GetCustomOfflineDevice(request->mProfileDir, -1, getter_AddRefs(customCacheDevice)); if (NS_SUCCEEDED(rv)) @@ -2913,8 +2913,8 @@ nsCacheService::DoomActiveEntries(DoomCheckFn check) void nsCacheService::CloseAllStreams() { - nsTArray > inputs; - nsTArray > outputs; + nsTArray > inputs; + nsTArray > outputs; { nsCacheServiceAutoLock lock; @@ -2942,7 +2942,7 @@ nsCacheService::CloseAllStreams() for (size_t i = 0; i < entries.Length(); i++) { entry = entries.ElementAt(i); - nsTArray > descs; + nsTArray > descs; entry->GetDescriptors(descs); for (uint32_t j = 0 ; j < descs.Length() ; j++) { diff --git a/netwerk/cache/nsCacheService.h b/netwerk/cache/nsCacheService.h index 88fde3db40..ae871cec80 100644 --- a/netwerk/cache/nsCacheService.h +++ b/netwerk/cache/nsCacheService.h @@ -312,7 +312,7 @@ private: static PLDHashOperator ShutdownCustomCacheDeviceEnum(const nsAString& aProfileDir, - nsRefPtr& aDevice, + RefPtr& aDevice, void* aUserArg); void LogCacheStatistics(); diff --git a/netwerk/cache/nsCacheUtils.cpp b/netwerk/cache/nsCacheUtils.cpp index 536052ada6..d6865f521f 100644 --- a/netwerk/cache/nsCacheUtils.cpp +++ b/netwerk/cache/nsCacheUtils.cpp @@ -39,7 +39,7 @@ nsresult nsShutdownThread::Shutdown(nsIThread *aThread) { nsresult rv; - nsRefPtr ev = new nsDestroyThreadEvent(aThread); + RefPtr ev = new nsDestroyThreadEvent(aThread); rv = NS_DispatchToMainThread(ev); if (NS_FAILED(rv)) { NS_WARNING("Dispatching event in nsShutdownThread::Shutdown failed!"); @@ -52,7 +52,7 @@ nsShutdownThread::BlockingShutdown(nsIThread *aThread) { nsresult rv; - nsRefPtr st = new nsShutdownThread(aThread); + RefPtr st = new nsShutdownThread(aThread); nsCOMPtr workerThread; rv = NS_NewNamedThread("thread shutdown", getter_AddRefs(workerThread)); diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 0e44245712..27dc92df62 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -125,7 +125,7 @@ class EvictionObserver private: mozIStorageConnection *mDB; - nsRefPtr mEvictionFunction; + RefPtr mEvictionFunction; }; #define DCACHE_HASH_MAX INT64_MAX @@ -259,7 +259,7 @@ public: } private: - nsRefPtr mDevice; + RefPtr mDevice; nsCString mGroup; nsCString mClientID; }; @@ -1623,7 +1623,7 @@ nsOfflineCacheDevice::BindEntry(nsCacheEntry *entry) return NS_ERROR_UNEXPECTED; // create binding, pick best generation number - nsRefPtr binding = + RefPtr binding = nsOfflineCacheBinding::Create(mCacheDirectory, entry->Key(), -1); if (!binding) return NS_ERROR_OUT_OF_MEMORY; @@ -1860,7 +1860,7 @@ nsOfflineCacheDevice::Visit(nsICacheVisitor *visitor) // SELECT * from moz_cache; nsOfflineCacheRecord rec; - nsRefPtr info = new nsOfflineCacheEntryInfo; + RefPtr info = new nsOfflineCacheEntryInfo; if (!info) return NS_ERROR_OUT_OF_MEMORY; info->mRec = &rec; @@ -2712,7 +2712,7 @@ nsOfflineCacheDevice::AutoShutdown(nsIApplicationCache * aAppCache) Shutdown(); - nsRefPtr cacheService = nsCacheService::GlobalInstance(); + RefPtr cacheService = nsCacheService::GlobalInstance(); cacheService->RemoveCustomOfflineDevice(this); nsAutoCString clientID; diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.h b/netwerk/cache/nsDiskCacheDeviceSQL.h index 3cdc0dd8c3..68700bb598 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.h +++ b/netwerk/cache/nsDiskCacheDeviceSQL.h @@ -248,7 +248,7 @@ private: char *** values); nsCOMPtr mDB; - nsRefPtr mEvictionFunction; + RefPtr mEvictionFunction; nsCOMPtr mStatement_CacheSize; nsCOMPtr mStatement_ApplicationCacheSize; diff --git a/netwerk/cache2/AppCacheStorage.cpp b/netwerk/cache2/AppCacheStorage.cpp index 73da379172..8a0f95d616 100644 --- a/netwerk/cache2/AppCacheStorage.cpp +++ b/netwerk/cache2/AppCacheStorage.cpp @@ -75,7 +75,7 @@ NS_IMETHODIMP AppCacheStorage::AsyncOpenURI(nsIURI *aURI, rv = noRefURI->GetScheme(scheme); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr<_OldCacheLoad> appCacheLoad = + RefPtr<_OldCacheLoad> appCacheLoad = new _OldCacheLoad(scheme, cacheKey, aCallback, appCache, LoadInfo(), WriteToDisk(), aFlags); rv = appCacheLoad->Start(); @@ -107,7 +107,7 @@ NS_IMETHODIMP AppCacheStorage::AsyncDoomURI(nsIURI *aURI, const nsACString & aId return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr<_OldStorage> old = new _OldStorage( + RefPtr<_OldStorage> old = new _OldStorage( LoadInfo(), WriteToDisk(), LookupAppCache(), true, mAppCache); return old->AsyncDoomURI(aURI, aIdExtension, aCallback); } @@ -144,7 +144,7 @@ NS_IMETHODIMP AppCacheStorage::AsyncEvictStorage(nsICacheEntryDoomCallback* aCal } else { // Discard the group - nsRefPtr<_OldStorage> old = new _OldStorage( + RefPtr<_OldStorage> old = new _OldStorage( LoadInfo(), WriteToDisk(), LookupAppCache(), true, mAppCache); rv = old->AsyncEvictStorage(aCallback); NS_ENSURE_SUCCESS(rv, rv); @@ -172,7 +172,7 @@ NS_IMETHODIMP AppCacheStorage::AsyncVisitStorage(nsICacheStorageVisitor* aVisito do_GetService(NS_CACHESERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr<_OldVisitCallbackWrapper> cb = new _OldVisitCallbackWrapper( + RefPtr<_OldVisitCallbackWrapper> cb = new _OldVisitCallbackWrapper( "offline", aVisitor, aVisitEntries, LoadInfo()); rv = nsCacheService::GlobalInstance()->VisitEntriesInternal(cb); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index 4e0f3f59d1..c4298f8bde 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -442,7 +442,7 @@ NS_IMETHODIMP CacheEntry::OnFileReady(nsresult aResult, bool aIsNew) NS_IMETHODIMP CacheEntry::OnFileDoomed(nsresult aResult) { if (mDoomCallback) { - nsRefPtr event = + RefPtr event = new DoomCallbackRunnable(this, aResult); NS_DispatchToMainThread(event); } @@ -460,8 +460,8 @@ already_AddRefed CacheEntry::ReopenTruncated(bool aMemoryOnly, // Hold callbacks invocation, AddStorageEntry would invoke from doom prematurly mPreventCallbacks = true; - nsRefPtr handle; - nsRefPtr newEntry; + RefPtr handle; + RefPtr newEntry; { mozilla::MutexAutoUnlock unlock(mLock); @@ -497,7 +497,7 @@ already_AddRefed CacheEntry::ReopenTruncated(bool aMemoryOnly, // reference counter and doesn't revert entry state back when write // fails and also doesn't update the entry frecency. Not updating // frecency causes entries to not be purged from our memory pools. - nsRefPtr writeHandle = + RefPtr writeHandle = newEntry->NewWriteHandle(); return writeHandle.forget(); } @@ -580,7 +580,7 @@ bool CacheEntry::InvokeCallbacks(bool aReadOnly) if (NS_SUCCEEDED(rv) && !onCheckThread) { // Redispatch to the target thread - nsRefPtr > event = + RefPtr > event = NS_NewRunnableMethod(this, &CacheEntry::InvokeCallbacksLock); rv = mCallbacks[i].mTargetThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); @@ -747,7 +747,7 @@ void CacheEntry::InvokeAvailableCallback(Callback const & aCallback) if (!onAvailThread) { // Dispatch to the right thread - nsRefPtr event = + RefPtr event = new AvailableCallbackRunnable(this, aCallback); rv = aCallback.mTargetThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); @@ -776,7 +776,7 @@ void CacheEntry::InvokeAvailableCallback(Callback const & aCallback) BackgroundOp(Ops::FRECENCYUPDATE); } - nsRefPtr handle = NewHandle(); + RefPtr handle = NewHandle(); aCallback.mCallback->OnCacheEntryAvailable( handle, false, nullptr, NS_OK); return; @@ -797,7 +797,7 @@ void CacheEntry::InvokeAvailableCallback(Callback const & aCallback) // Consumer will be responsible to fill or validate the entry metadata and data. - nsRefPtr handle = NewWriteHandle(); + RefPtr handle = NewWriteHandle(); rv = aCallback.mCallback->OnCacheEntryAvailable( handle, state == WRITING, nullptr, NS_OK); @@ -1096,7 +1096,7 @@ nsresult CacheEntry::OpenOutputStreamInternal(int64_t offset, nsIOutputStream * NS_ENSURE_SUCCESS(rv, rv); } - nsRefPtr listener = + RefPtr listener = new CacheOutputCloseListener(this); nsCOMPtr stream; @@ -1310,7 +1310,7 @@ NS_IMETHODIMP CacheEntry::Recreate(bool aMemoryOnly, mozilla::MutexAutoLock lock(mLock); - nsRefPtr handle = ReopenTruncated(aMemoryOnly, nullptr); + RefPtr handle = ReopenTruncated(aMemoryOnly, nullptr); if (handle) { handle.forget(_retval); return NS_OK; @@ -1583,7 +1583,7 @@ void CacheEntry::BackgroundOp(uint32_t aOperations, bool aForceAsync) // Because CacheFile::Set*() are not thread-safe to use (uses WeakReference that // is not thread-safe) we must post to the main thread... - nsRefPtr > event = + RefPtr > event = NS_NewRunnableMethodWithArg(this, &CacheEntry::StoreFrecency, mFrecency); NS_DispatchToMainThread(event); } diff --git a/netwerk/cache2/CacheEntry.h b/netwerk/cache2/CacheEntry.h index 9bec9f0c1f..ca6524dd5d 100644 --- a/netwerk/cache2/CacheEntry.h +++ b/netwerk/cache2/CacheEntry.h @@ -125,7 +125,7 @@ private: NS_IMETHOD OnFileDoomed(nsresult aResult) override; // Keep the service alive during life-time of an entry - nsRefPtr mService; + RefPtr mService; // We must monitor when a cache entry whose consumer is responsible // for writing it the first time gets released. We must then invoke @@ -146,7 +146,7 @@ private: // We are raising reference count here to take into account the pending // callback (that virtually holds a ref to this entry before it gets // it's pointer). - nsRefPtr mEntry; + RefPtr mEntry; nsCOMPtr mCallback; nsCOMPtr mTargetThread; bool mReadOnly : 1; @@ -178,7 +178,7 @@ private: return NS_OK; } - nsRefPtr mEntry; + RefPtr mEntry; Callback mCallback; }; @@ -204,7 +204,7 @@ private: return NS_OK; } - nsRefPtr mEntry; + RefPtr mEntry; nsresult mRv; }; @@ -263,7 +263,7 @@ private: nsTArray mCallbacks; nsCOMPtr mDoomCallback; - nsRefPtr mFile; + RefPtr mFile; // Using ReleaseAcquire since we only control access to mFile with this. // When mFileStatus is read and found success it is ensured there is mFile and @@ -366,7 +366,7 @@ public: NS_FORWARD_NSICACHEENTRY(mEntry->) private: virtual ~CacheEntryHandle(); - nsRefPtr mEntry; + RefPtr mEntry; }; @@ -384,7 +384,7 @@ private: explicit CacheOutputCloseListener(CacheEntry* aEntry); private: - nsRefPtr mEntry; + RefPtr mEntry; }; } // namespace net diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index e9c1fdd51e..ea2324db9b 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -101,7 +101,7 @@ protected: nsCOMPtr mCallback; nsresult mRV; uint32_t mChunkIdx; - nsRefPtr mChunk; + RefPtr mChunk; }; @@ -292,7 +292,7 @@ CacheFile::Init(const nsACString &aKey, mReady = true; mDataSize = mMetadata->Offset(); - nsRefPtr ev; + RefPtr ev; ev = new NotifyCacheFileListenerEvent(aCallback, NS_OK, true); rv = NS_DispatchToCurrentThread(ev); NS_ENSURE_SUCCESS(rv, rv); @@ -338,7 +338,7 @@ CacheFile::OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk) // the chunk to the disk again. When the chunk is unused and is dirty simply // addref and release (outside the lock) the chunk which ensures that // CacheFile::DeactivateChunk() will be called again. - nsRefPtr deactivateChunkAgain; + RefPtr deactivateChunkAgain; CacheFileAutoLock lock(this); @@ -1005,7 +1005,7 @@ CacheFile::Unlock() { // move the elements out of mObjsToRelease // so that they can be released after we unlock - nsTArray> objs; + nsTArray> objs; objs.SwapElements(mObjsToRelease); mLock.Unlock(); @@ -1019,7 +1019,7 @@ CacheFile::AssertOwnsLock() const } void -CacheFile::ReleaseOutsideLock(nsRefPtr aObject) +CacheFile::ReleaseOutsideLock(RefPtr aObject) { AssertOwnsLock(); @@ -1056,7 +1056,7 @@ CacheFile::GetChunkLocked(uint32_t aIndex, ECallerType aCaller, nsresult rv; - nsRefPtr chunk; + RefPtr chunk; if (mChunks.Get(aIndex, getter_AddRefs(chunk))) { LOG(("CacheFile::GetChunkLocked() - Found chunk %p in mChunks [this=%p]", chunk.get(), this)); @@ -1268,7 +1268,7 @@ CacheFile::PreloadChunks(uint32_t aIndex) LOG(("CacheFile::PreloadChunks() - Preloading chunk [this=%p, idx=%u]", this, i)); - nsRefPtr chunk; + RefPtr chunk; GetChunkLocked(i, PRELOADER, nullptr, getter_AddRefs(chunk)); // We've checked that we don't have this chunk, so no chunk must be // returned. @@ -1349,7 +1349,7 @@ CacheFile::DeactivateChunk(CacheFileChunk *aChunk) nsresult rv; // Avoid lock reentrancy by increasing the RefCnt - nsRefPtr chunk = aChunk; + RefPtr chunk = aChunk; { CacheFileAutoLock lock(this); @@ -1373,7 +1373,7 @@ CacheFile::DeactivateChunk(CacheFileChunk *aChunk) #ifdef DEBUG { // We can be here iff the chunk is in the hash table - nsRefPtr chunkCheck; + RefPtr chunkCheck; mChunks.Get(chunk->Index(), getter_AddRefs(chunkCheck)); MOZ_ASSERT(chunkCheck == chunk); @@ -1442,7 +1442,7 @@ CacheFile::RemoveChunkInternal(CacheFileChunk *aChunk, bool aCacheChunk) AssertOwnsLock(); aChunk->mActiveChunk = false; - ReleaseOutsideLock(nsRefPtr(aChunk->mFile.forget()).forget()); + ReleaseOutsideLock(RefPtr(aChunk->mFile.forget()).forget()); if (aCacheChunk) { mCachedChunks.Put(aChunk->Index(), aChunk); @@ -1577,7 +1577,7 @@ CacheFile::NotifyChunkListener(CacheFileChunkListener *aCallback, aChunkIdx, aChunk)); nsresult rv; - nsRefPtr ev; + RefPtr ev; ev = new NotifyChunkListenerEvent(aCallback, aResult, aChunkIdx, aChunk); if (aTarget) rv = aTarget->Dispatch(ev, NS_DISPATCH_NORMAL); @@ -1791,7 +1791,7 @@ CacheFile::PostWriteTimer() PLDHashOperator CacheFile::WriteAllCachedChunks(const uint32_t& aIdx, - nsRefPtr& aChunk, + RefPtr& aChunk, void* aClosure) { CacheFile *file = static_cast(aClosure); @@ -1806,8 +1806,8 @@ CacheFile::WriteAllCachedChunks(const uint32_t& aIdx, MOZ_ASSERT(aChunk->IsReady()); // this would be cleaner if we had an nsRefPtr constructor - // that took a nsRefPtr - file->ReleaseOutsideLock(nsRefPtr(aChunk)); + // that took a RefPtr + file->ReleaseOutsideLock(RefPtr(aChunk)); return PL_DHASH_REMOVE; } @@ -1823,7 +1823,7 @@ CacheFile::FailListenersIfNonExistentChunk( LOG(("CacheFile::FailListenersIfNonExistentChunk() [this=%p, idx=%u]", file, aIdx)); - nsRefPtr chunk; + RefPtr chunk; file->mChunks.Get(aIdx, getter_AddRefs(chunk)); if (chunk) { MOZ_ASSERT(!chunk->IsReady()); @@ -1843,7 +1843,7 @@ CacheFile::FailListenersIfNonExistentChunk( PLDHashOperator CacheFile::FailUpdateListeners( const uint32_t& aIdx, - nsRefPtr& aChunk, + RefPtr& aChunk, void* aClosure) { CacheFile *file = static_cast(aClosure); @@ -1859,7 +1859,7 @@ CacheFile::FailUpdateListeners( PLDHashOperator CacheFile::CleanUpCachedChunks(const uint32_t& aIdx, - nsRefPtr& aChunk, + RefPtr& aChunk, void* aClosure) { CacheFile *file = static_cast(aClosure); @@ -1886,7 +1886,7 @@ CacheFile::PadChunkWithZeroes(uint32_t aChunkIdx) MOZ_ASSERT(mDataSize / kChunkSize == aChunkIdx); nsresult rv; - nsRefPtr chunk; + RefPtr chunk; rv = GetChunkLocked(aChunkIdx, WRITER, nullptr, getter_AddRefs(chunk)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/cache2/CacheFile.h b/netwerk/cache2/CacheFile.h index ff7ac1aa2c..80eb206494 100644 --- a/netwerk/cache2/CacheFile.h +++ b/netwerk/cache2/CacheFile.h @@ -122,7 +122,7 @@ private: void Lock(); void Unlock(); void AssertOwnsLock() const; - void ReleaseOutsideLock(nsRefPtr aObject); + void ReleaseOutsideLock(RefPtr aObject); enum ECallerType { READER = 0, @@ -168,7 +168,7 @@ private: void PostWriteTimer(); static PLDHashOperator WriteAllCachedChunks(const uint32_t& aIdx, - nsRefPtr& aChunk, + RefPtr& aChunk, void* aClosure); static PLDHashOperator FailListenersIfNonExistentChunk( @@ -177,11 +177,11 @@ private: void* aClosure); static PLDHashOperator FailUpdateListeners(const uint32_t& aIdx, - nsRefPtr& aChunk, + RefPtr& aChunk, void* aClosure); static PLDHashOperator CleanUpCachedChunks(const uint32_t& aIdx, - nsRefPtr& aChunk, + RefPtr& aChunk, void* aClosure); nsresult PadChunkWithZeroes(uint32_t aChunkIdx); @@ -206,8 +206,8 @@ private: int64_t mDataSize; nsCString mKey; - nsRefPtr mHandle; - nsRefPtr mMetadata; + RefPtr mHandle; + RefPtr mMetadata; nsCOMPtr mListener; nsCOMPtr mDoomAfterOpenListener; @@ -218,7 +218,7 @@ private: nsTArray mInputs; CacheFileOutputStream *mOutput; - nsTArray> mObjsToRelease; + nsTArray> mObjsToRelease; }; class CacheFileAutoLock { @@ -248,7 +248,7 @@ public: } private: - nsRefPtr mFile; + RefPtr mFile; bool mLocked; }; diff --git a/netwerk/cache2/CacheFileChunk.cpp b/netwerk/cache2/CacheFileChunk.cpp index 43423152ec..aaec9a329e 100644 --- a/netwerk/cache2/CacheFileChunk.cpp +++ b/netwerk/cache2/CacheFileChunk.cpp @@ -44,7 +44,7 @@ public: protected: nsCOMPtr mCallback; - nsRefPtr mChunk; + RefPtr mChunk; }; bool @@ -54,7 +54,7 @@ CacheFileChunk::DispatchRelease() return false; } - nsRefPtr > event = + RefPtr > event = NS_NewNonOwningRunnableMethod(this, &CacheFileChunk::Release); NS_DispatchToMainThread(event); @@ -327,7 +327,7 @@ CacheFileChunk::NotifyUpdateListeners() LOG(("CacheFileChunk::NotifyUpdateListeners() - Notifying listener %p " "[this=%p]", item->mCallback.get(), this)); - nsRefPtr ev; + RefPtr ev; ev = new NotifyUpdateListenerEvent(item->mCallback, this); rv2 = item->mTarget->Dispatch(ev, NS_DISPATCH_NORMAL); if (NS_FAILED(rv2) && NS_SUCCEEDED(rv)) diff --git a/netwerk/cache2/CacheFileChunk.h b/netwerk/cache2/CacheFileChunk.h index efa6bd70f7..b81658b6d3 100644 --- a/netwerk/cache2/CacheFileChunk.h +++ b/netwerk/cache2/CacheFileChunk.h @@ -150,7 +150,7 @@ private: uint32_t mRWBufSize; CacheHash::Hash16_t mReadHash; - nsRefPtr mFile; // is null if chunk is cached to + RefPtr mFile; // is null if chunk is cached to // prevent reference cycles nsCOMPtr mListener; nsTArray mUpdateListeners; diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp index 561c7fa76a..dff8c3a744 100644 --- a/netwerk/cache2/CacheFileContextEvictor.cpp +++ b/netwerk/cache2/CacheFileContextEvictor.cpp @@ -482,7 +482,7 @@ CacheFileContextEvictor::StartEvicting() nsCOMPtr ev; ev = NS_NewRunnableMethod(this, &CacheFileContextEvictor::EvictEntries); - nsRefPtr ioThread = CacheFileIOManager::IOThread(); + RefPtr ioThread = CacheFileIOManager::IOThread(); nsresult rv = ioThread->Dispatch(ev, CacheIOThread::EVICT); if (NS_FAILED(rv)) { @@ -546,7 +546,7 @@ CacheFileContextEvictor::EvictEntries() "[hash=%08x%08x%08x%08x%08x, iterator=%p, info=%p]", LOGSHA1(&hash), mEntries[0]->mIterator.get(), mEntries[0]->mInfo.get())); - nsRefPtr handle; + RefPtr handle; CacheFileIOManager::gInstance->mHandles.GetHandle(&hash, getter_AddRefs(handle)); if (handle) { diff --git a/netwerk/cache2/CacheFileContextEvictor.h b/netwerk/cache2/CacheFileContextEvictor.h index bf8111547f..0a595bd830 100644 --- a/netwerk/cache2/CacheFileContextEvictor.h +++ b/netwerk/cache2/CacheFileContextEvictor.h @@ -21,7 +21,7 @@ struct CacheFileContextEvictorEntry { nsCOMPtr mInfo; PRTime mTimeStamp; // in milliseconds - nsRefPtr mIterator; + RefPtr mIterator; }; class CacheFileContextEvictor diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 86a7bb1f61..ab549831c0 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -67,7 +67,7 @@ CacheFileHandle::DispatchRelease() return false; } - nsRefPtr > event = + RefPtr > event = NS_NewNonOwningRunnableMethod(this, &CacheFileHandle::Release); nsresult rv = ioTarget->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); if (NS_FAILED(rv)) { @@ -149,7 +149,7 @@ CacheFileHandle::~CacheFileHandle() MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); - nsRefPtr ioMan = CacheFileIOManager::gInstance; + RefPtr ioMan = CacheFileIOManager::gInstance; if (!IsClosed() && ioMan) { ioMan->CloseHandleInternal(this); } @@ -249,7 +249,7 @@ CacheFileHandles::HandleHashKey::GetNewestHandle() { MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); - nsRefPtr handle; + RefPtr handle; if (mHandles.Length()) { handle = mHandles[0]; } @@ -258,7 +258,7 @@ CacheFileHandles::HandleHashKey::GetNewestHandle() } void -CacheFileHandles::HandleHashKey::GetHandles(nsTArray > &aResult) +CacheFileHandles::HandleHashKey::GetHandles(nsTArray > &aResult) { MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); @@ -336,7 +336,7 @@ CacheFileHandles::GetHandle(const SHA1Sum::Hash *aHash, #endif // Check if the entry is doomed - nsRefPtr handle = entry->GetNewestHandle(); + RefPtr handle = entry->GetNewestHandle(); if (!handle) { LOG(("CacheFileHandles::GetHandle() hash=%08x%08x%08x%08x%08x " "no handle found %p, entry %p", LOGSHA1(aHash), handle.get(), entry)); @@ -380,7 +380,7 @@ CacheFileHandles::NewHandle(const SHA1Sum::Hash *aHash, entry->AssertHandlesState(); #endif - nsRefPtr handle = new CacheFileHandle(entry->Hash(), aPriority); + RefPtr handle = new CacheFileHandle(entry->Hash(), aPriority); entry->AddHandle(handle); LOG(("CacheFileHandles::NewHandle() hash=%08x%08x%08x%08x%08x " @@ -432,7 +432,7 @@ CacheFileHandles::RemoveHandle(CacheFileHandle *aHandle) } void -CacheFileHandles::GetAllHandles(nsTArray > *_retval) +CacheFileHandles::GetAllHandles(nsTArray > *_retval) { MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); for (auto iter = mTable.Iter(); !iter.Done(); iter.Next()) { @@ -442,11 +442,11 @@ CacheFileHandles::GetAllHandles(nsTArray > *_retval) void CacheFileHandles::GetActiveHandles( - nsTArray > *_retval) + nsTArray > *_retval) { MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); for (auto iter = mTable.Iter(); !iter.Done(); iter.Next()) { - nsRefPtr handle = iter.Get()->GetNewestHandle(); + RefPtr handle = iter.Get()->GetNewestHandle(); MOZ_ASSERT(handle); if (!handle->IsDoomed()) { @@ -474,7 +474,7 @@ CacheFileHandles::Log(CacheFileHandlesEntry *entry) { LOG(("CacheFileHandles::Log() BEGIN [entry=%p]", entry)); - nsTArray > array; + nsTArray > array; aEntry->GetHandles(array); for (uint32_t i = 0; i < array.Length(); ++i) { @@ -584,8 +584,8 @@ protected: SHA1Sum::Hash mHash; uint32_t mFlags; nsCOMPtr mCallback; - nsRefPtr mIOMan; - nsRefPtr mHandle; + RefPtr mIOMan; + RefPtr mHandle; nsCString mKey; }; @@ -625,7 +625,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; int64_t mOffset; char *mBuf; int32_t mCount; @@ -684,7 +684,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; int64_t mOffset; const char *mBuf; int32_t mCount; @@ -730,7 +730,7 @@ public: protected: nsCOMPtr mCallback; nsCOMPtr mTarget; - nsRefPtr mHandle; + RefPtr mHandle; }; class DoomFileByKeyEvent : public nsRunnable { @@ -776,7 +776,7 @@ public: protected: SHA1Sum::Hash mHash; nsCOMPtr mCallback; - nsRefPtr mIOMan; + RefPtr mIOMan; }; class ReleaseNSPRHandleEvent : public nsRunnable { @@ -804,7 +804,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; }; class TruncateSeekSetEOFEvent : public nsRunnable { @@ -845,7 +845,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; int64_t mTruncatePos; int64_t mEOFPos; nsCOMPtr mCallback; @@ -888,7 +888,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; nsCString mNewName; nsCOMPtr mCallback; }; @@ -931,7 +931,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; uint32_t mAppId; bool mAnonymous; bool mInBrowser; @@ -977,7 +977,7 @@ public: } protected: - nsRefPtr mHandle; + RefPtr mHandle; bool mHasFrecency; bool mHasExpirationTime; uint32_t mFrecency; @@ -993,8 +993,8 @@ public: SHUTDOWN } mMode; - nsRefPtr mFile; - nsRefPtr mIOMan; + RefPtr mFile; + RefPtr mIOMan; MetadataWriteScheduleEvent(CacheFileIOManager * aManager, CacheFile * aFile, @@ -1008,7 +1008,7 @@ public: NS_IMETHOD Run() { - nsRefPtr ioMan = CacheFileIOManager::gInstance; + RefPtr ioMan = CacheFileIOManager::gInstance; if (!ioMan) { NS_WARNING("CacheFileIOManager already gone in MetadataWriteScheduleEvent::Run()"); return NS_OK; @@ -1063,7 +1063,7 @@ CacheFileIOManager::Init() return NS_ERROR_ALREADY_INITIALIZED; } - nsRefPtr ioMan = new CacheFileIOManager(); + RefPtr ioMan = new CacheFileIOManager(); nsresult rv = ioMan->InitInternal(); NS_ENSURE_SUCCESS(rv, rv); @@ -1109,7 +1109,7 @@ CacheFileIOManager::Shutdown() mozilla::CondVar condVar(lock, "CacheFileIOManager::Shutdown() condVar"); MutexAutoLock autoLock(lock); - nsRefPtr ev = new ShutdownEvent(&lock, &condVar); + RefPtr ev = new ShutdownEvent(&lock, &condVar); DebugOnly rv; rv = gInstance->mIOThread->Dispatch(ev, CacheIOThread::CLOSE); MOZ_ASSERT(NS_SUCCEEDED(rv)); @@ -1129,7 +1129,7 @@ CacheFileIOManager::Shutdown() gInstance->SyncRemoveAllCacheFiles(); } - nsRefPtr ioMan; + RefPtr ioMan; ioMan.swap(gInstance); return NS_OK; @@ -1146,7 +1146,7 @@ CacheFileIOManager::ShutdownInternal() mShuttingDown = true; // close all handles and delete all associated files - nsTArray > handles; + nsTArray > handles; mHandles.GetAllHandles(&handles); handles.AppendElements(mSpecialHandles); @@ -1208,7 +1208,7 @@ CacheFileIOManager::OnProfile() { LOG(("CacheFileIOManager::OnProfile() [gInstance=%p]", gInstance)); - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { // CacheFileIOManager::Init() failed, probably could not create the IO // thread, just go with it... @@ -1302,7 +1302,7 @@ CacheFileIOManager::IOTarget() already_AddRefed CacheFileIOManager::IOThread() { - nsRefPtr thread; + RefPtr thread; if (gInstance) { thread = gInstance->mIOThread; } @@ -1314,7 +1314,7 @@ CacheFileIOManager::IOThread() bool CacheFileIOManager::IsOnIOThread() { - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (ioMan && ioMan->mIOThread) { return ioMan->mIOThread->IsCurrentThread(); } @@ -1326,7 +1326,7 @@ CacheFileIOManager::IsOnIOThread() bool CacheFileIOManager::IsOnIOThreadOrCeased() { - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (ioMan && ioMan->mIOThread) { return ioMan->mIOThread->IsCurrentThread(); } @@ -1349,12 +1349,12 @@ CacheFileIOManager::IsShutdown() nsresult CacheFileIOManager::ScheduleMetadataWrite(CacheFile * aFile) { - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; NS_ENSURE_TRUE(ioMan, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(!ioMan->mShuttingDown, NS_ERROR_NOT_INITIALIZED); - nsRefPtr event = new MetadataWriteScheduleEvent( + RefPtr event = new MetadataWriteScheduleEvent( ioMan, aFile, MetadataWriteScheduleEvent::SCHEDULE); nsCOMPtr target = ioMan->IOTarget(); NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED); @@ -1391,12 +1391,12 @@ CacheFileIOManager::ScheduleMetadataWriteInternal(CacheFile * aFile) nsresult CacheFileIOManager::UnscheduleMetadataWrite(CacheFile * aFile) { - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; NS_ENSURE_TRUE(ioMan, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(!ioMan->mShuttingDown, NS_ERROR_NOT_INITIALIZED); - nsRefPtr event = new MetadataWriteScheduleEvent( + RefPtr event = new MetadataWriteScheduleEvent( ioMan, aFile, MetadataWriteScheduleEvent::UNSCHEDULE); nsCOMPtr target = ioMan->IOTarget(); NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED); @@ -1423,10 +1423,10 @@ CacheFileIOManager::UnscheduleMetadataWriteInternal(CacheFile * aFile) nsresult CacheFileIOManager::ShutdownMetadataWriteScheduling() { - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; NS_ENSURE_TRUE(ioMan, NS_ERROR_NOT_INITIALIZED); - nsRefPtr event = new MetadataWriteScheduleEvent( + RefPtr event = new MetadataWriteScheduleEvent( ioMan, nullptr, MetadataWriteScheduleEvent::SHUTDOWN); nsCOMPtr target = ioMan->IOTarget(); NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED); @@ -1438,7 +1438,7 @@ CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() { MOZ_ASSERT(IsOnIOThreadOrCeased()); - nsTArray > files; + nsTArray > files; files.SwapElements(mScheduledMetadataWrites); for (uint32_t i = 0; i < files.Length(); ++i) { CacheFile * file = files[i]; @@ -1461,7 +1461,7 @@ CacheFileIOManager::Notify(nsITimer * aTimer) mMetadataWritesTimer = nullptr; - nsTArray > files; + nsTArray > files; files.SwapElements(mScheduledMetadataWrites); for (uint32_t i = 0; i < files.Length(); ++i) { CacheFile * file = files[i]; @@ -1480,14 +1480,14 @@ CacheFileIOManager::OpenFile(const nsACString &aKey, PromiseFlatCString(aKey).get(), aFlags, aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return NS_ERROR_NOT_INITIALIZED; } bool priority = aFlags & CacheFileIOManager::PRIORITY; - nsRefPtr ev = new OpenFileEvent(aKey, aFlags, aCallback); + RefPtr ev = new OpenFileEvent(aKey, aFlags, aCallback); rv = ioMan->mIOThread->Dispatch(ev, priority ? CacheIOThread::OPEN_PRIORITY : CacheIOThread::OPEN); @@ -1523,7 +1523,7 @@ CacheFileIOManager::OpenFileInternal(const SHA1Sum::Hash *aHash, rv = GetFile(aHash, getter_AddRefs(file)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr handle; + RefPtr handle; mHandles.GetHandle(aHash, getter_AddRefs(handle)); if ((aFlags & (OPEN | CREATE | CREATE_NEW)) == CREATE_NEW) { @@ -1633,7 +1633,7 @@ CacheFileIOManager::OpenSpecialFileInternal(const nsACString &aKey, rv = GetSpecialFile(aKey, getter_AddRefs(file)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr handle; + RefPtr handle; for (uint32_t i = 0 ; i < mSpecialHandles.Length() ; i++) { if (!mSpecialHandles[i]->IsDoomed() && mSpecialHandles[i]->Key() == aKey) { handle = mSpecialHandles[i]; @@ -1750,13 +1750,13 @@ CacheFileIOManager::Read(CacheFileHandle *aHandle, int64_t aOffset, "listener=%p]", aHandle, aOffset, aCount, aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; } - nsRefPtr ev = new ReadEvent(aHandle, aOffset, aBuf, aCount, + RefPtr ev = new ReadEvent(aHandle, aOffset, aBuf, aCount, aCallback); rv = ioMan->mIOThread->Dispatch(ev, aHandle->IsPriority() ? CacheIOThread::READ_PRIORITY @@ -1817,7 +1817,7 @@ CacheFileIOManager::Write(CacheFileHandle *aHandle, int64_t aOffset, aValidate, aTruncate, aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { if (!aCallback) { @@ -1828,7 +1828,7 @@ CacheFileIOManager::Write(CacheFileHandle *aHandle, int64_t aOffset, return NS_ERROR_NOT_INITIALIZED; } - nsRefPtr ev = new WriteEvent(aHandle, aOffset, aBuf, aCount, + RefPtr ev = new WriteEvent(aHandle, aOffset, aBuf, aCount, aValidate, aTruncate, aCallback); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::WRITE); NS_ENSURE_SUCCESS(rv, rv); @@ -1964,13 +1964,13 @@ CacheFileIOManager::DoomFile(CacheFileHandle *aHandle, aHandle, aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; } - nsRefPtr ev = new DoomFileEvent(aHandle, aCallback); + RefPtr ev = new DoomFileEvent(aHandle, aCallback); rv = ioMan->mIOThread->Dispatch(ev, aHandle->IsPriority() ? CacheIOThread::OPEN_PRIORITY : CacheIOThread::OPEN); @@ -2028,7 +2028,7 @@ CacheFileIOManager::DoomFileInternal(CacheFileHandle *aHandle) aHandle->mIsDoomed = true; if (!aHandle->IsSpecialFile()) { - nsRefPtr storageService = CacheStorageService::Self(); + RefPtr storageService = CacheStorageService::Self(); if (storageService) { nsAutoCString idExtension, url; nsCOMPtr info = @@ -2052,13 +2052,13 @@ CacheFileIOManager::DoomFileByKey(const nsACString &aKey, PromiseFlatCString(aKey).get(), aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return NS_ERROR_NOT_INITIALIZED; } - nsRefPtr ev = new DoomFileByKeyEvent(aKey, aCallback); + RefPtr ev = new DoomFileByKeyEvent(aKey, aCallback); rv = ioMan->mIOThread->DispatchAfterPendingOpens(ev); NS_ENSURE_SUCCESS(rv, rv); @@ -2084,7 +2084,7 @@ CacheFileIOManager::DoomFileByKeyInternal(const SHA1Sum::Hash *aHash) } // Find active handle - nsRefPtr handle; + RefPtr handle; mHandles.GetHandle(aHash, getter_AddRefs(handle)); if (handle) { @@ -2127,13 +2127,13 @@ CacheFileIOManager::ReleaseNSPRHandle(CacheFileHandle *aHandle) LOG(("CacheFileIOManager::ReleaseNSPRHandle() [handle=%p]", aHandle)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; } - nsRefPtr ev = new ReleaseNSPRHandleEvent(aHandle); + RefPtr ev = new ReleaseNSPRHandleEvent(aHandle); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::CLOSE); NS_ENSURE_SUCCESS(rv, rv); @@ -2168,13 +2168,13 @@ CacheFileIOManager::TruncateSeekSetEOF(CacheFileHandle *aHandle, "EOFPos=%lld, listener=%p]", aHandle, aTruncatePos, aEOFPos, aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; } - nsRefPtr ev = new TruncateSeekSetEOFEvent( + RefPtr ev = new TruncateSeekSetEOFEvent( aHandle, aTruncatePos, aEOFPos, aCallback); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::WRITE); @@ -2188,7 +2188,7 @@ void CacheFileIOManager::GetCacheDirectory(nsIFile** result) { *result = nullptr; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return; } @@ -2203,7 +2203,7 @@ void CacheFileIOManager::GetProfilelessCacheDirectory(nsIFile** result) { *result = nullptr; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan || !ioMan->mCacheProfilelessDirectory) { return; } @@ -2222,7 +2222,7 @@ CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash, nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return NS_ERROR_NOT_INITIALIZED; } @@ -2230,10 +2230,10 @@ CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash, nsAutoCString enhanceId; nsAutoCString uriSpec; - nsRefPtr handle; + RefPtr handle; ioMan->mHandles.GetHandle(aHash, getter_AddRefs(handle)); if (handle) { - nsRefPtr info = + RefPtr info = CacheFileUtils::ParseKey(handle->Key(), &enhanceId, &uriSpec); MOZ_ASSERT(info); @@ -2241,7 +2241,7 @@ CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash, return NS_OK; // ignore } - nsRefPtr service = CacheStorageService::Self(); + RefPtr service = CacheStorageService::Self(); if (!service) { return NS_ERROR_NOT_INITIALIZED; } @@ -2260,7 +2260,7 @@ CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash, ioMan->GetFile(aHash, getter_AddRefs(file)); // Read metadata from the file synchronously - nsRefPtr metadata = new CacheFileMetadata(); + RefPtr metadata = new CacheFileMetadata(); rv = metadata->SyncReadMetadata(file); if (NS_FAILED(rv)) { return NS_OK; @@ -2270,7 +2270,7 @@ CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash, nsAutoCString key; metadata->GetKey(key); - nsRefPtr info = + RefPtr info = CacheFileUtils::ParseKey(key, &enhanceId, &uriSpec); MOZ_ASSERT(info); if (!info) { @@ -2381,7 +2381,7 @@ CacheFileIOManager::RenameFile(CacheFileHandle *aHandle, aHandle, PromiseFlatCString(aNewName).get(), aCallback)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; @@ -2391,7 +2391,7 @@ CacheFileIOManager::RenameFile(CacheFileHandle *aHandle, return NS_ERROR_UNEXPECTED; } - nsRefPtr ev = new RenameFileEvent(aHandle, aNewName, + RefPtr ev = new RenameFileEvent(aHandle, aNewName, aCallback); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::WRITE); NS_ENSURE_SUCCESS(rv, rv); @@ -2467,7 +2467,7 @@ CacheFileIOManager::EvictIfOverLimit() LOG(("CacheFileIOManager::EvictIfOverLimit()")); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return NS_ERROR_NOT_INITIALIZED; @@ -2668,7 +2668,7 @@ CacheFileIOManager::EvictAll() LOG(("CacheFileIOManager::EvictAll()")); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return NS_ERROR_NOT_INITIALIZED; @@ -2714,7 +2714,7 @@ CacheFileIOManager::EvictAllInternal() MOZ_ASSERT(mIOThread->IsCurrentThread()); - nsRefPtr r = new EvictionNotifierRunnable(); + RefPtr r = new EvictionNotifierRunnable(); if (!mCacheDirectory) { // This is a kind of hack. Somebody called EvictAll() without a profile. @@ -2736,7 +2736,7 @@ CacheFileIOManager::EvictAllInternal() } // Doom all active handles - nsTArray > handles; + nsTArray > handles; mHandles.GetActiveHandles(&handles); for (uint32_t i = 0; i < handles.Length(); ++i) { @@ -2786,7 +2786,7 @@ CacheFileIOManager::EvictByContext(nsILoadContextInfo *aLoadContextInfo) aLoadContextInfo)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return NS_ERROR_NOT_INITIALIZED; @@ -2837,7 +2837,7 @@ CacheFileIOManager::EvictByContextInternal(nsILoadContextInfo *aLoadContextInfo) } // Doom all active handles that matches the load context - nsTArray > handles; + nsTArray > handles; mHandles.GetActiveHandles(&handles); for (uint32_t i = 0; i < handles.Length(); ++i) { @@ -3002,7 +3002,7 @@ CacheFileIOManager::OnTrashTimer(nsITimer *aTimer, void *aClosure) LOG(("CacheFileIOManager::OnTrashTimer() [timer=%p, closure=%p]", aTimer, aClosure)); - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (!ioMan) { return; @@ -3254,7 +3254,7 @@ CacheFileIOManager::InitIndexEntry(CacheFileHandle *aHandle, ", inBrowser=%d]", aHandle, aAppId, aAnonymous, aInBrowser)); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; @@ -3264,7 +3264,7 @@ CacheFileIOManager::InitIndexEntry(CacheFileHandle *aHandle, return NS_ERROR_UNEXPECTED; } - nsRefPtr ev = + RefPtr ev = new InitIndexEntryEvent(aHandle, aAppId, aAnonymous, aInBrowser); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::WRITE); NS_ENSURE_SUCCESS(rv, rv); @@ -3284,7 +3284,7 @@ CacheFileIOManager::UpdateIndexEntry(CacheFileHandle *aHandle, aExpirationTime ? nsPrintfCString("%u", *aExpirationTime).get() : "")); nsresult rv; - nsRefPtr ioMan = gInstance; + RefPtr ioMan = gInstance; if (aHandle->IsClosed() || !ioMan) { return NS_ERROR_NOT_INITIALIZED; @@ -3294,7 +3294,7 @@ CacheFileIOManager::UpdateIndexEntry(CacheFileHandle *aHandle, return NS_ERROR_UNEXPECTED; } - nsRefPtr ev = + RefPtr ev = new UpdateIndexEntryEvent(aHandle, aFrecency, aExpirationTime); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::WRITE); NS_ENSURE_SUCCESS(rv, rv); @@ -3556,7 +3556,7 @@ CacheFileIOManager::CreateCacheTree() mTreeCreated = true; if (!mContextEvictor) { - nsRefPtr contextEvictor; + RefPtr contextEvictor; contextEvictor = new CacheFileContextEvictor(); // Init() method will try to load unfinished contexts from the disk. Store @@ -3899,7 +3899,7 @@ CacheFileIOManager::SizeOfExcludingThisInternal(mozilla::MallocSizeOf mallocSize // mHandles and mSpecialHandles must be accessed only on the I/O thread, // must sync dispatch. - nsRefPtr sizeOfHandlesRunnable = + RefPtr sizeOfHandlesRunnable = new SizeOfHandlesRunnable(mallocSizeOf, mHandles, mSpecialHandles); n += sizeOfHandlesRunnable->Get(mIOThread); } diff --git a/netwerk/cache2/CacheFileIOManager.h b/netwerk/cache2/CacheFileIOManager.h index 1c378e1f63..96dc91ca1c 100644 --- a/netwerk/cache2/CacheFileIOManager.h +++ b/netwerk/cache2/CacheFileIOManager.h @@ -93,8 +93,8 @@ public: nsresult GetHandle(const SHA1Sum::Hash *aHash, CacheFileHandle **_retval); nsresult NewHandle(const SHA1Sum::Hash *aHash, bool aPriority, CacheFileHandle **_retval); void RemoveHandle(CacheFileHandle *aHandlle); - void GetAllHandles(nsTArray > *_retval); - void GetActiveHandles(nsTArray > *_retval); + void GetAllHandles(nsTArray > *_retval); + void GetActiveHandles(nsTArray > *_retval); void ClearAll(); uint32_t HandleCount(); @@ -143,7 +143,7 @@ public: void AddHandle(CacheFileHandle* aHandle); void RemoveHandle(CacheFileHandle* aHandle); already_AddRefed GetNewestHandle(); - void GetHandles(nsTArray > &aResult); + void GetHandles(nsTArray > &aResult); SHA1Sum::Hash *Hash() const { return mHash; } bool IsEmpty() const { return mHandles.Length() == 0; } @@ -383,7 +383,7 @@ private: static CacheFileIOManager *gInstance; TimeStamp mStartTime; bool mShuttingDown; - nsRefPtr mIOThread; + RefPtr mIOThread; nsCOMPtr mCacheDirectory; #if defined(MOZ_WIDGET_ANDROID) // On Android we add the active profile directory name between the path @@ -396,7 +396,7 @@ private: CacheFileHandles mHandles; nsTArray mHandlesByLastUsed; nsTArray mSpecialHandles; - nsTArray > mScheduledMetadataWrites; + nsTArray > mScheduledMetadataWrites; nsCOMPtr mMetadataWritesTimer; bool mOverLimitEvicting; bool mRemovingTrashDirs; @@ -404,7 +404,7 @@ private: nsCOMPtr mTrashDir; nsCOMPtr mTrashDirEnumerator; nsTArray mFailedTrashDirs; - nsRefPtr mContextEvictor; + RefPtr mContextEvictor; TimeStamp mLastSmartSizeTime; }; diff --git a/netwerk/cache2/CacheFileInputStream.h b/netwerk/cache2/CacheFileInputStream.h index d3781dad05..ab18ea2fd9 100644 --- a/netwerk/cache2/CacheFileInputStream.h +++ b/netwerk/cache2/CacheFileInputStream.h @@ -53,8 +53,8 @@ private: void NotifyListener(); void MaybeNotifyListener(); - nsRefPtr mFile; - nsRefPtr mChunk; + RefPtr mFile; + RefPtr mChunk; int64_t mPos; bool mClosed; nsresult mStatus; diff --git a/netwerk/cache2/CacheFileMetadata.h b/netwerk/cache2/CacheFileMetadata.h index 940625c3ae..b15bca15f2 100644 --- a/netwerk/cache2/CacheFileMetadata.h +++ b/netwerk/cache2/CacheFileMetadata.h @@ -175,7 +175,7 @@ private: nsresult EnsureBuffer(uint32_t aSize); nsresult ParseKey(const nsACString &aKey); - nsRefPtr mHandle; + RefPtr mHandle; nsCString mKey; CacheHash::Hash16_t *mHashArray; uint32_t mHashArraySize; diff --git a/netwerk/cache2/CacheFileOutputStream.cpp b/netwerk/cache2/CacheFileOutputStream.cpp index 385ddda47d..8a40fcc293 100644 --- a/netwerk/cache2/CacheFileOutputStream.cpp +++ b/netwerk/cache2/CacheFileOutputStream.cpp @@ -342,7 +342,7 @@ CacheFileOutputStream::OnChunkUpdated(CacheFileChunk *aChunk) void CacheFileOutputStream::NotifyCloseListener() { - nsRefPtr listener; + RefPtr listener; listener.swap(mCloseListener); if (!listener) return; diff --git a/netwerk/cache2/CacheFileOutputStream.h b/netwerk/cache2/CacheFileOutputStream.h index f8cdcf3bba..3326e5338a 100644 --- a/netwerk/cache2/CacheFileOutputStream.h +++ b/netwerk/cache2/CacheFileOutputStream.h @@ -50,9 +50,9 @@ private: void FillHole(); void NotifyListener(); - nsRefPtr mFile; - nsRefPtr mChunk; - nsRefPtr mCloseListener; + RefPtr mFile; + RefPtr mChunk; + RefPtr mCloseListener; int64_t mPos; bool mClosed; nsresult mStatus; diff --git a/netwerk/cache2/CacheFileUtils.cpp b/netwerk/cache2/CacheFileUtils.cpp index 1c630b4271..026e0a1080 100644 --- a/netwerk/cache2/CacheFileUtils.cpp +++ b/netwerk/cache2/CacheFileUtils.cpp @@ -177,7 +177,7 @@ private: public: already_AddRefed Parse() { - nsRefPtr info; + RefPtr info; if (ParseTags()) info = GetLoadContextInfo(isPrivate, appId, isInBrowser, isAnonymous); @@ -208,7 +208,7 @@ ParseKey(const nsCSubstring &aKey, aKey.EndReading(end); KeyParser parser(caret, end); - nsRefPtr info = parser.Parse(); + RefPtr info = parser.Parse(); if (info) { if (aIdEnhance) diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 5d7974b19f..5556bf6efa 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -146,7 +146,7 @@ private: } const SHA1Sum::Hash *mHash; - nsRefPtr mIndex; + RefPtr mIndex; CacheIndexRecord *mOldRecord; bool mDoNotSearchInIndex; bool mDoNotSearchInUpdates; @@ -194,7 +194,7 @@ private: return NS_ERROR_UNEXPECTED; } - nsRefPtr mIndex; + RefPtr mIndex; bool mCanceled; }; @@ -295,7 +295,7 @@ CacheIndex::Init(nsIFile *aCacheDirectory) return NS_ERROR_ALREADY_INITIALIZED; } - nsRefPtr idx = new CacheIndex(); + RefPtr idx = new CacheIndex(); CacheIndexAutoLock lock(idx); @@ -330,7 +330,7 @@ CacheIndex::PreShutdown() MOZ_ASSERT(NS_IsMainThread()); nsresult rv; - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -424,7 +424,7 @@ CacheIndex::Shutdown() MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr index; + RefPtr index; index.swap(gInstance); if (!index) { @@ -486,7 +486,7 @@ CacheIndex::AddEntry(const SHA1Sum::Hash *aHash) { LOG(("CacheIndex::AddEntry() [hash=%08x%08x%08x%08x%08x]", LOGSHA1(aHash))); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -601,7 +601,7 @@ CacheIndex::EnsureEntryExists(const SHA1Sum::Hash *aHash) LOG(("CacheIndex::EnsureEntryExists() [hash=%08x%08x%08x%08x%08x]", LOGSHA1(aHash))); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -711,7 +711,7 @@ CacheIndex::InitEntry(const SHA1Sum::Hash *aHash, "anonymous=%d, inBrowser=%d]", LOGSHA1(aHash), aAppId, aAnonymous, aInBrowser)); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -820,7 +820,7 @@ CacheIndex::RemoveEntry(const SHA1Sum::Hash *aHash) LOG(("CacheIndex::RemoveEntry() [hash=%08x%08x%08x%08x%08x]", LOGSHA1(aHash))); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -921,7 +921,7 @@ CacheIndex::UpdateEntry(const SHA1Sum::Hash *aHash, aExpirationTime ? nsPrintfCString("%u", *aExpirationTime).get() : "", aSize ? nsPrintfCString("%u", *aSize).get() : "")); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1018,7 +1018,7 @@ CacheIndex::RemoveAll() { LOG(("CacheIndex::RemoveAll()")); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1112,7 +1112,7 @@ CacheIndex::HasEntry(const nsACString &aKey, EntryStatus *_retval) { LOG(("CacheIndex::HasEntry() [key=%s]", PromiseFlatCString(aKey).get())); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1176,7 +1176,7 @@ CacheIndex::GetEntryForEviction(bool aIgnoreEmptyEntries, SHA1Sum::Hash *aHash, { LOG(("CacheIndex::GetEntryForEviction()")); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) return NS_ERROR_NOT_INITIALIZED; @@ -1229,7 +1229,7 @@ CacheIndex::GetEntryForEviction(bool aIgnoreEmptyEntries, SHA1Sum::Hash *aHash, // static bool CacheIndex::IsForcedValidEntry(const SHA1Sum::Hash *aHash) { - nsRefPtr handle; + RefPtr handle; CacheFileIOManager::gInstance->mHandles.GetHandle( aHash, getter_AddRefs(handle)); @@ -1248,7 +1248,7 @@ CacheIndex::GetCacheSize(uint32_t *_retval) { LOG(("CacheIndex::GetCacheSize()")); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) return NS_ERROR_NOT_INITIALIZED; @@ -1270,7 +1270,7 @@ CacheIndex::GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t * { LOG(("CacheIndex::GetCacheStats() [info=%p]", aInfo)); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1307,7 +1307,7 @@ CacheIndex::AsyncGetDiskConsumption(nsICacheStorageConsumptionObserver* aObserve { LOG(("CacheIndex::AsyncGetDiskConsumption()")); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1319,7 +1319,7 @@ CacheIndex::AsyncGetDiskConsumption(nsICacheStorageConsumptionObserver* aObserve return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr observer = + RefPtr observer = DiskConsumptionObserver::Init(aObserver); NS_ENSURE_ARG(observer); @@ -1346,7 +1346,7 @@ CacheIndex::GetIterator(nsILoadContextInfo *aInfo, bool aAddNew, { LOG(("CacheIndex::GetIterator() [info=%p, addNew=%d]", aInfo, aAddNew)); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1358,7 +1358,7 @@ CacheIndex::GetIterator(nsILoadContextInfo *aInfo, bool aAddNew, return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr iter; + RefPtr iter; if (aInfo) { iter = new CacheIndexContextIterator(index, aAddNew, aInfo); } else { @@ -1379,7 +1379,7 @@ CacheIndex::IsUpToDate(bool *_retval) { LOG(("CacheIndex::IsUpToDate()")); - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return NS_ERROR_NOT_INITIALIZED; @@ -1818,7 +1818,7 @@ private: char *mBuf; uint32_t mBufSize; int32_t mBufPos; - nsRefPtr mHash; + RefPtr mHash; }; nsresult @@ -2437,7 +2437,7 @@ CacheIndex::DelayedUpdate(nsITimer *aTimer, void *aClosure) LOG(("CacheIndex::DelayedUpdate()")); nsresult rv; - nsRefPtr index = gInstance; + RefPtr index = gInstance; if (!index) { return; @@ -2464,7 +2464,7 @@ CacheIndex::DelayedUpdate(nsITimer *aTimer, void *aClosure) } // We need to redispatch to run with lower priority - nsRefPtr ioThread = CacheFileIOManager::IOThread(); + RefPtr ioThread = CacheFileIOManager::IOThread(); MOZ_ASSERT(ioThread); index->mUpdateEventPending = true; @@ -2654,7 +2654,7 @@ CacheIndex::BuildIndex() } #ifdef DEBUG - nsRefPtr handle; + RefPtr handle; CacheFileIOManager::gInstance->mHandles.GetHandle(&hash, getter_AddRefs(handle)); #endif @@ -2672,7 +2672,7 @@ CacheIndex::BuildIndex() MOZ_ASSERT(!handle); - nsRefPtr meta = new CacheFileMetadata(); + RefPtr meta = new CacheFileMetadata(); int64_t size = 0; { @@ -2772,7 +2772,7 @@ CacheIndex::StartUpdatingIndex(bool aRebuild) "starting update now.", elapsed)); } - nsRefPtr ioThread = CacheFileIOManager::IOThread(); + RefPtr ioThread = CacheFileIOManager::IOThread(); MOZ_ASSERT(ioThread); // We need to dispatch an event even if we are on IO thread since we need to @@ -2867,7 +2867,7 @@ CacheIndex::UpdateIndex() } #ifdef DEBUG - nsRefPtr handle; + RefPtr handle; CacheFileIOManager::gInstance->mHandles.GetHandle(&hash, getter_AddRefs(handle)); #endif @@ -2912,7 +2912,7 @@ CacheIndex::UpdateIndex() } } - nsRefPtr meta = new CacheFileMetadata(); + RefPtr meta = new CacheFileMetadata(); int64_t size = 0; { diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h index 2cafe7da29..7cff8a8f40 100644 --- a/netwerk/cache2/CacheIndex.h +++ b/netwerk/cache2/CacheIndex.h @@ -964,21 +964,21 @@ private: char *mRWBuf; uint32_t mRWBufSize; uint32_t mRWBufPos; - nsRefPtr mRWHash; + RefPtr mRWHash; // Reading of journal succeeded if true. bool mJournalReadSuccessfully; // Handle used for writing and reading index file. - nsRefPtr mIndexHandle; + RefPtr mIndexHandle; // Handle used for reading journal file. - nsRefPtr mJournalHandle; + RefPtr mJournalHandle; // Used to check the existence of the file during reading process. - nsRefPtr mTmpHandle; + RefPtr mTmpHandle; - nsRefPtr mIndexFileOpener; - nsRefPtr mJournalFileOpener; - nsRefPtr mTmpFileOpener; + RefPtr mIndexFileOpener; + RefPtr mJournalFileOpener; + RefPtr mTmpFileOpener; // Directory enumerator used when building and updating index. nsCOMPtr mDirEnumerator; @@ -1064,7 +1064,7 @@ private: }; // List of async observers that want to get disk consumption information - nsTArray > mDiskConsumptionObservers; + nsTArray > mDiskConsumptionObservers; }; class CacheIndexAutoLock { @@ -1095,7 +1095,7 @@ public: } private: - nsRefPtr mIndex; + RefPtr mIndex; bool mLocked; }; @@ -1127,7 +1127,7 @@ public: } private: - nsRefPtr mIndex; + RefPtr mIndex; bool mLocked; }; diff --git a/netwerk/cache2/CacheIndexIterator.h b/netwerk/cache2/CacheIndexIterator.h index 10c16098b2..7312fa8e8c 100644 --- a/netwerk/cache2/CacheIndexIterator.h +++ b/netwerk/cache2/CacheIndexIterator.h @@ -49,7 +49,7 @@ protected: CacheIndexRecord *aNewRecord); nsresult mStatus; - nsRefPtr mIndex; + RefPtr mIndex; nsTArray mRecords; bool mAddNew; }; diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index ad3dbfadc3..088aeab9ed 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -374,11 +374,11 @@ CacheStorageEvictHelper::ClearStorage(bool const aPrivate, { nsresult rv; - nsRefPtr info = GetLoadContextInfo( + RefPtr info = GetLoadContextInfo( aPrivate, mAppId, aInBrowser, aAnonymous); nsCOMPtr storage; - nsRefPtr service = CacheStorageService::Self(); + RefPtr service = CacheStorageService::Self(); NS_ENSURE_TRUE(service, NS_ERROR_FAILURE); // Clear disk storage @@ -453,7 +453,7 @@ CacheObserver::Observe(nsISupports* aSubject, } if (!strcmp(aTopic, "profile-before-change")) { - nsRefPtr service = CacheStorageService::Self(); + RefPtr service = CacheStorageService::Self(); if (service) service->Shutdown(); @@ -461,7 +461,7 @@ CacheObserver::Observe(nsISupports* aSubject, } if (!strcmp(aTopic, "xpcom-shutdown")) { - nsRefPtr service = CacheStorageService::Self(); + RefPtr service = CacheStorageService::Self(); if (service) service->Shutdown(); @@ -470,7 +470,7 @@ CacheObserver::Observe(nsISupports* aSubject, } if (!strcmp(aTopic, "last-pb-context-exited")) { - nsRefPtr service = CacheStorageService::Self(); + RefPtr service = CacheStorageService::Self(); if (service) service->DropPrivateBrowsingEntries(); @@ -493,7 +493,7 @@ CacheObserver::Observe(nsISupports* aSubject, } if (!strcmp(aTopic, "memory-pressure")) { - nsRefPtr service = CacheStorageService::Self(); + RefPtr service = CacheStorageService::Self(); if (service) service->PurgeFromMemory(nsICacheStorageService::PURGE_EVERYTHING); diff --git a/netwerk/cache2/CacheStorage.cpp b/netwerk/cache2/CacheStorage.cpp index fc1162bf60..8eb6446ec6 100644 --- a/netwerk/cache2/CacheStorage.cpp +++ b/netwerk/cache2/CacheStorage.cpp @@ -87,7 +87,7 @@ NS_IMETHODIMP CacheStorage::AsyncOpenURI(nsIURI *aURI, rv = noRefURI->GetScheme(scheme); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr<_OldCacheLoad> appCacheLoad = + RefPtr<_OldCacheLoad> appCacheLoad = new _OldCacheLoad(scheme, cacheKey, aCallback, appCache, LoadInfo(), WriteToDisk(), aFlags); rv = appCacheLoad->Start(); @@ -97,7 +97,7 @@ NS_IMETHODIMP CacheStorage::AsyncOpenURI(nsIURI *aURI, return NS_OK; } - nsRefPtr entry; + RefPtr entry; rv = CacheStorageService::Self()->AddStorageEntry( this, noRefURI, aIdExtension, true, // create always @@ -124,7 +124,7 @@ NS_IMETHODIMP CacheStorage::OpenTruncate(nsIURI *aURI, const nsACString & aIdExt rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr entry; + RefPtr entry; rv = CacheStorageService::Self()->AddStorageEntry( this, noRefURI, aIdExtension, true, // create always diff --git a/netwerk/cache2/CacheStorage.h b/netwerk/cache2/CacheStorage.h index 44e72fc29a..a916a5858f 100644 --- a/netwerk/cache2/CacheStorage.h +++ b/netwerk/cache2/CacheStorage.h @@ -60,7 +60,7 @@ protected: nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache); - nsRefPtr mLoadContextInfo; + RefPtr mLoadContextInfo; bool mWriteToDisk : 1; bool mLookupAppCache : 1; bool mSkipSizeCheck: 1; diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index 24fcb4bfbb..e689e60a56 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -194,7 +194,7 @@ protected: } } - nsRefPtr mService; + RefPtr mService; nsCOMPtr mCallback; uint64_t mSize; @@ -264,7 +264,7 @@ private: } // Grab the next entry - nsRefPtr entry = mEntryArray[0]; + RefPtr entry = mEntryArray[0]; mEntryArray.RemoveElementAt(0); // Invokes this->OnEntryInfo, that calls the callback with all @@ -323,7 +323,7 @@ private: private: nsCString mContextKey; - nsTArray > mEntryArray; + nsTArray > mEntryArray; }; // WalkDiskCacheRunnable @@ -350,7 +350,7 @@ public: // information gets to the index list before we grab the index iterator // for the first time. This tries to avoid miss of entries that has // been created right before the visit is required. - nsRefPtr thread = CacheFileIOManager::IOThread(); + RefPtr thread = CacheFileIOManager::IOThread(); NS_ENSURE_TRUE(thread, NS_ERROR_NOT_INITIALIZED); return thread->Dispatch(this, CacheIOThread::INDEX); @@ -382,7 +382,7 @@ private: return NS_OK; } - nsRefPtr mWalker; + RefPtr mWalker; nsCString mURISpec; nsCString mIdEnhance; @@ -474,7 +474,7 @@ private: // Called directly from CacheFileIOManager::GetEntryInfo. // Invoke onCacheEntryInfo on the main thread for this entry. - nsRefPtr info = new OnCacheEntryInfoRunnable(this); + RefPtr info = new OnCacheEntryInfoRunnable(this); info->mURISpec = aURISpec; info->mIdEnhance = aIdEnhance; info->mDataSize = aDataSize; @@ -485,7 +485,7 @@ private: NS_DispatchToMainThread(info); } - nsRefPtr mLoadInfo; + RefPtr mLoadInfo; enum { // First, we collect stats for the load context. COLLECT_STATS, @@ -496,7 +496,7 @@ private: ITERATE_METADATA, } mPass; - nsRefPtr mIter; + RefPtr mIter; uint32_t mCount; }; @@ -581,7 +581,7 @@ bool CleaupCacheDirectoriesRunnable::Post(uint32_t aVersion, uint32_t aActive) if (!thread) return false; - nsRefPtr r = + RefPtr r = new CleaupCacheDirectoriesRunnable(aVersion, aActive); thread->Dispatch(r, NS_DISPATCH_NORMAL); return true; @@ -644,7 +644,7 @@ void CacheStorageService::CleaupCacheDirectories(uint32_t aVersion, uint32_t aAc // static bool CacheStorageService::IsOnManagementThread() { - nsRefPtr service = Self(); + RefPtr service = Self(); if (!service) return false; @@ -664,7 +664,7 @@ already_AddRefed CacheStorageService::Thread() const nsresult CacheStorageService::Dispatch(nsIRunnable* aEvent) { - nsRefPtr cacheIOThread = CacheFileIOManager::IOThread(); + RefPtr cacheIOThread = CacheFileIOManager::IOThread(); if (!cacheIOThread) return NS_ERROR_NOT_AVAILABLE; @@ -924,7 +924,7 @@ AddExactEntry(CacheEntryTable* aEntries, CacheEntry* aEntry, bool aOverwrite) { - nsRefPtr existingEntry; + RefPtr existingEntry; if (!aOverwrite && aEntries->Get(aKey, getter_AddRefs(existingEntry))) { bool equals = existingEntry == aEntry; LOG(("AddExactEntry [entry=%p equals=%d]", aEntry, equals)); @@ -942,7 +942,7 @@ RemoveExactEntry(CacheEntryTable* aEntries, CacheEntry* aEntry, bool aOverwrite) { - nsRefPtr existingEntry; + RefPtr existingEntry; if (!aEntries->Get(aKey, getter_AddRefs(existingEntry))) { LOG(("RemoveExactEntry [entry=%p already gone]", aEntry)); return false; // Already removed... @@ -1151,7 +1151,7 @@ CacheStorageService::OnMemoryConsumptionChange(CacheMemoryConsumer* aConsumer, // We don't know if this is called under the service lock or not, // hence rather dispatch. - nsRefPtr cacheIOTarget = Thread(); + RefPtr cacheIOTarget = Thread(); if (!cacheIOTarget) return; @@ -1269,7 +1269,7 @@ CacheStorageService::MemoryPool::PurgeExpired() if (CacheIOThread::YieldAndRerun()) return; - nsRefPtr entry = mExpirationArray[i]; + RefPtr entry = mExpirationArray[i]; uint32_t expirationTime = entry->GetExpirationTime(); if (expirationTime > 0 && expirationTime <= now && @@ -1300,7 +1300,7 @@ CacheStorageService::MemoryPool::PurgeByFrecency(bool &aFrecencyNeedsSort, uint3 if (CacheIOThread::YieldAndRerun()) return; - nsRefPtr entry = mFrecencyArray[i]; + RefPtr entry = mFrecencyArray[i]; if (entry->Purge(aWhat)) { LOG((" abandoned (%d), entry=%p, frecency=%1.10f", @@ -1323,7 +1323,7 @@ CacheStorageService::MemoryPool::PurgeAll(uint32_t aWhat) if (CacheIOThread::YieldAndRerun()) return; - nsRefPtr entry = mFrecencyArray[i]; + RefPtr entry = mFrecencyArray[i]; if (entry->Purge(aWhat)) { LOG((" abandoned entry=%p", entry.get())); @@ -1379,8 +1379,8 @@ CacheStorageService::AddStorageEntry(nsCSubstring const& aContextKey, LOG(("CacheStorageService::AddStorageEntry [entryKey=%s, contextKey=%s]", entryKey.get(), aContextKey.BeginReading())); - nsRefPtr entry; - nsRefPtr handle; + RefPtr entry; + RefPtr handle; { mozilla::MutexAutoLock lock(mLock); @@ -1579,7 +1579,7 @@ CacheStorageService::DoomStorageEntry(CacheStorage const* aStorage, nsresult rv = CacheEntry::HashingKey(EmptyCString(), aIdExtension, aURI, entryKey); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr entry; + RefPtr entry; { mozilla::MutexAutoLock lock(mLock); @@ -1621,7 +1621,7 @@ CacheStorageService::DoomStorageEntry(CacheStorage const* aStorage, LOG((" dooming file only for %s", entryKey.get())); - nsRefPtr callback( + RefPtr callback( new CacheEntryDoomByKeyCallback(aCallback)); rv = CacheFileIOManager::DoomFileByKey(entryKey, callback); NS_ENSURE_SUCCESS(rv, rv); @@ -1642,7 +1642,7 @@ CacheStorageService::DoomStorageEntry(CacheStorage const* aStorage, }; if (aCallback) { - nsRefPtr callback = new Callback(aCallback); + RefPtr callback = new Callback(aCallback); return NS_DispatchToMainThread(callback); } @@ -1739,7 +1739,7 @@ CacheStorageService::DoomStorageEntries(nsCSubstring const& aContextKey, }; if (aCallback) { - nsRefPtr callback = new Callback(aCallback); + RefPtr callback = new Callback(aCallback); return NS_DispatchToMainThread(callback); } @@ -1757,12 +1757,12 @@ CacheStorageService::WalkStorageEntries(CacheStorage const* aStorage, NS_ENSURE_ARG(aStorage); if (aStorage->WriteToDisk()) { - nsRefPtr event = + RefPtr event = new WalkDiskCacheRunnable(aStorage->LoadInfo(), aVisitEntries, aVisitor); return event->Walk(); } - nsRefPtr event = + RefPtr event = new WalkMemoryCacheRunnable(aStorage->LoadInfo(), aVisitEntries, aVisitor); return event->Walk(); } @@ -1787,7 +1787,7 @@ CacheStorageService::CacheFileDoomed(nsILoadContextInfo* aLoadContextInfo, if (!sGlobalEntryTables->Get(contextKey, &entries)) return; - nsRefPtr entry; + RefPtr entry; if (!entries->Get(entryKey, getter_AddRefs(entry))) return; @@ -1815,7 +1815,7 @@ CacheStorageService::GetCacheEntryInfo(nsILoadContextInfo* aLoadContextInfo, nsAutoCString entryKey; CacheEntry::HashingKey(EmptyCString(), aIdExtension, aURISpec, entryKey); - nsRefPtr entry; + RefPtr entry; { mozilla::MutexAutoLock lock(mLock); @@ -1922,7 +1922,7 @@ PLDHashOperator ReportStorageMemory(const nsACString& aKey, // Bypass memory-only entries, those will be reported when iterating // the memory only table. Memory-only entries are stored in both ALL_ENTRIES // and MEMORY_ONLY hashtables. - nsRefPtr const& entry = iter.Data(); + RefPtr const& entry = iter.Data(); if (aTable->Type() == CacheEntryTable::MEMORY_ONLY || entry->IsUsingDisk()) { size += entry->SizeOfIncludingThis(mallocSizeOf); diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index 4d8d8d45a2..3dde0e0b67 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -297,8 +297,8 @@ private: explicit MemoryPool(EType aType); ~MemoryPool(); - nsTArray > mFrecencyArray; - nsTArray > mExpirationArray; + nsTArray > mFrecencyArray; + nsTArray > mExpirationArray; mozilla::Atomic mMemorySize; bool OnMemoryConsumptionChange(uint32_t aSavedMemorySize, @@ -346,7 +346,7 @@ private: return NS_OK; } - nsRefPtr mService; + RefPtr mService; uint32_t mWhat; }; diff --git a/netwerk/cache2/OldWrappers.cpp b/netwerk/cache2/OldWrappers.cpp index 8b877b2d8e..693579902d 100644 --- a/netwerk/cache2/OldWrappers.cpp +++ b/netwerk/cache2/OldWrappers.cpp @@ -284,7 +284,7 @@ nsresult _OldGetDiskConsumption::Get(nsICacheStorageConsumptionObserver* aCallba do_GetService(NS_CACHESERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr<_OldGetDiskConsumption> cb = new _OldGetDiskConsumption(aCallback); + RefPtr<_OldGetDiskConsumption> cb = new _OldGetDiskConsumption(aCallback); // _OldGetDiskConsumption stores the found size value, but until dispatched // to the main thread it doesn't call on the consupmtion observer. See bellow. @@ -381,7 +381,7 @@ NS_IMPL_ISUPPORTS(_OldCacheEntryWrapper, nsICacheEntry) NS_IMETHODIMP _OldCacheEntryWrapper::AsyncDoom(nsICacheEntryDoomCallback* listener) { - nsRefPtr cb = listener + RefPtr cb = listener ? new DoomCallbackWrapper(listener) : nullptr; return AsyncDoom(cb); @@ -516,7 +516,7 @@ MetaDataVisitorWrapper::VisitMetaDataElement(char const * key, NS_IMETHODIMP _OldCacheEntryWrapper::VisitMetaData(nsICacheEntryMetaDataVisitor* cb) { - nsRefPtr w = new MetaDataVisitorWrapper(cb); + RefPtr w = new MetaDataVisitorWrapper(cb); return mOldDesc->VisitMetaData(w); } @@ -927,7 +927,7 @@ NS_IMETHODIMP _OldStorage::AsyncOpenURI(nsIURI *aURI, } } - nsRefPtr<_OldCacheLoad> cacheLoad = + RefPtr<_OldCacheLoad> cacheLoad = new _OldCacheLoad(scheme, cacheKey, aCallback, mAppCache, mLoadInfo, mWriteToDisk, aFlags); @@ -965,7 +965,7 @@ NS_IMETHODIMP _OldStorage::AsyncDoomURI(nsIURI *aURI, const nsACString & aIdExte getter_AddRefs(session)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr cb = aCallback + RefPtr cb = aCallback ? new DoomCallbackWrapper(aCallback) : nullptr; rv = session->DoomEntry(cacheKey, cb); @@ -1046,7 +1046,7 @@ NS_IMETHODIMP _OldStorage::AsyncEvictStorage(nsICacheEntryDoomCallback* aCallbac } if (aCallback) { - nsRefPtr sync = + RefPtr sync = new DoomCallbackSynchronizer(aCallback); rv = sync->Dispatch(); NS_ENSURE_SUCCESS(rv, rv); @@ -1077,7 +1077,7 @@ NS_IMETHODIMP _OldStorage::AsyncVisitStorage(nsICacheStorageVisitor* aVisitor, deviceID = const_cast("disk"); } - nsRefPtr<_OldVisitCallbackWrapper> cb = new _OldVisitCallbackWrapper( + RefPtr<_OldVisitCallbackWrapper> cb = new _OldVisitCallbackWrapper( deviceID, aVisitor, aVisitEntries, mLoadInfo); rv = nsCacheService::GlobalInstance()->VisitEntriesInternal(cb); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/cookie/CookieServiceParent.h b/netwerk/cookie/CookieServiceParent.h index 4204d6b802..43c77d4246 100644 --- a/netwerk/cookie/CookieServiceParent.h +++ b/netwerk/cookie/CookieServiceParent.h @@ -48,7 +48,7 @@ protected: CloneProtocol(Channel* aChannel, mozilla::ipc::ProtocolCloneContext* aCtx) override; - nsRefPtr mCookieService; + RefPtr mCookieService; }; } // namespace net diff --git a/netwerk/cookie/nsCookie.cpp b/netwerk/cookie/nsCookie.cpp index 34d11d156c..d3b2383a32 100644 --- a/netwerk/cookie/nsCookie.cpp +++ b/netwerk/cookie/nsCookie.cpp @@ -83,7 +83,7 @@ nsCookie::Create(const nsACString &aName, { // Ensure mValue contains a valid UTF-8 sequence. Otherwise XPConnect will // truncate the string after the first invalid octet. - nsRefPtr converter = new nsUTF8ConverterService(); + RefPtr converter = new nsUTF8ConverterService(); nsAutoCString aUTF8Value; converter->ConvertStringToUTF8(aValue, "UTF-8", false, true, 1, aUTF8Value); diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 8da42f8ad9..38d0ef2561 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -339,7 +339,7 @@ class DBListenerErrorHandler : public mozIStorageStatementCallback { protected: explicit DBListenerErrorHandler(DBState* dbState) : mDBState(dbState) { } - nsRefPtr mDBState; + RefPtr mDBState; virtual const char *GetOpType() = 0; public: @@ -548,7 +548,7 @@ class CloseCookieDBListener final : public mozIStorageCompletionCallback public: explicit CloseCookieDBListener(DBState* dbState) : mDBState(dbState) { } - nsRefPtr mDBState; + RefPtr mDBState; NS_DECL_ISUPPORTS NS_IMETHOD Complete(nsresult, nsISupports*) override @@ -1988,7 +1988,7 @@ nsCookieService::Add(const nsACString &aHost, int64_t currentTimeInUsec = PR_Now(); - nsRefPtr cookie = + RefPtr cookie = nsCookie::Create(aName, aValue, host, aPath, aExpiry, currentTimeInUsec, @@ -2025,7 +2025,7 @@ nsCookieService::Remove(const nsACString& aHost, uint32_t aAppId, NS_ENSURE_SUCCESS(rv, rv); nsListIter matchIter; - nsRefPtr cookie; + RefPtr cookie; if (FindCookie(nsCookieKey(baseDomain, aAppId, aInBrowserElement), host, PromiseFlatCString(aName), @@ -2295,7 +2295,7 @@ nsCookieService::EnsureReadDomain(const nsCookieKey &aKey) bool hasResult; nsCString name, value, host, path; - nsAutoTArray, kMaxCookiesPerHost> array; + nsAutoTArray, kMaxCookiesPerHost> array; while (1) { rv = mDefaultDBState->stmtReadDomain->ExecuteStep(&hasResult); if (NS_FAILED(rv)) { @@ -2541,7 +2541,7 @@ nsCookieService::ImportCookies(nsIFile *aCookieFile) // Create a new nsCookie and assign the data. We don't know the cookie // creation time, so just use the current time to generate a unique one. - nsRefPtr newCookie = + RefPtr newCookie = nsCookie::Create(Substring(buffer, nameIndex, cookieIndex - nameIndex - 1), Substring(buffer, cookieIndex, buffer.Length() - cookieIndex), host, @@ -2911,7 +2911,7 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI, } // create a new nsCookie and copy attributes - nsRefPtr cookie = + RefPtr cookie = nsCookie::Create(cookieAttributes.name, cookieAttributes.value, cookieAttributes.host, @@ -2979,7 +2979,7 @@ nsCookieService::AddInternal(const nsCookieKey &aKey, bool foundCookie = FindCookie(aKey, aCookie->Host(), aCookie->Name(), aCookie->Path(), matchIter); - nsRefPtr oldCookie; + RefPtr oldCookie; nsCOMPtr purgedList; if (foundCookie) { oldCookie = matchIter.Cookie(); diff --git a/netwerk/cookie/nsCookieService.h b/netwerk/cookie/nsCookieService.h index 50e48bd1ba..b644dadaf9 100644 --- a/netwerk/cookie/nsCookieService.h +++ b/netwerk/cookie/nsCookieService.h @@ -119,7 +119,7 @@ class nsCookieEntry : public nsCookieKey { public: // Hash methods - typedef nsTArray< nsRefPtr > ArrayType; + typedef nsTArray< RefPtr > ArrayType; typedef ArrayType::index_type IndexType; explicit nsCookieEntry(KeyTypePointer aKey) @@ -148,7 +148,7 @@ class nsCookieEntry : public nsCookieKey struct CookieDomainTuple { nsCookieKey key; - nsRefPtr cookie; + RefPtr cookie; size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; @@ -339,8 +339,8 @@ class nsCookieService final : public nsICookieService // note that the private states' dbConn should always be null - we never // want to be dealing with the on-disk DB when in private browsing. DBState *mDBState; - nsRefPtr mDefaultDBState; - nsRefPtr mPrivateDBState; + RefPtr mDefaultDBState; + RefPtr mPrivateDBState; // cached prefs uint8_t mCookieBehavior; // BEHAVIOR_{ACCEPT, REJECTFOREIGN, REJECT, LIMITFOREIGN} diff --git a/netwerk/dns/ChildDNSService.cpp b/netwerk/dns/ChildDNSService.cpp index 84e930d27e..873a4dfc32 100644 --- a/netwerk/dns/ChildDNSService.cpp +++ b/netwerk/dns/ChildDNSService.cpp @@ -123,7 +123,7 @@ ChildDNSService::AsyncResolveExtended(const nsACString &hostname, listener = new DNSListenerProxy(listener, target); } - nsRefPtr childReq = + RefPtr childReq = new DNSRequestChild(nsCString(hostname), flags, nsCString(aNetworkInterface), listener, target); @@ -133,11 +133,11 @@ ChildDNSService::AsyncResolveExtended(const nsACString &hostname, nsCString key; GetDNSRecordHashKey(hostname, originalFlags, aNetworkInterface, originalListener, key); - nsTArray> *hashEntry; + nsTArray> *hashEntry; if (mPendingRequests.Get(key, &hashEntry)) { hashEntry->AppendElement(childReq); } else { - hashEntry = new nsTArray>(); + hashEntry = new nsTArray>(); hashEntry->AppendElement(childReq); mPendingRequests.Put(key, hashEntry); } @@ -171,7 +171,7 @@ ChildDNSService::CancelAsyncResolveExtended(const nsACString &aHostname, } MutexAutoLock lock(mPendingRequestsLock); - nsTArray> *hashEntry; + nsTArray> *hashEntry; nsCString key; GetDNSRecordHashKey(aHostname, aFlags, aNetworkInterface, aListener, key); if (mPendingRequests.Get(key, &hashEntry)) { @@ -228,7 +228,7 @@ ChildDNSService::NotifyRequestDone(DNSRequestChild *aDnsRequest) GetDNSRecordHashKey(aDnsRequest->mHost, originalFlags, aDnsRequest->mNetworkInterface, originalListener, key); - nsTArray> *hashEntry; + nsTArray> *hashEntry; if (mPendingRequests.Get(key, &hashEntry)) { int idx; diff --git a/netwerk/dns/ChildDNSService.h b/netwerk/dns/ChildDNSService.h index bb0f5366e2..b2c3a1dbcc 100644 --- a/netwerk/dns/ChildDNSService.h +++ b/netwerk/dns/ChildDNSService.h @@ -49,7 +49,7 @@ private: bool mDisablePrefetch; // We need to remember pending dns requests to be able to cancel them. - nsClassHashtable>> mPendingRequests; + nsClassHashtable>> mPendingRequests; Mutex mPendingRequestsLock; }; diff --git a/netwerk/dns/DNSListenerProxy.cpp b/netwerk/dns/DNSListenerProxy.cpp index 463040593f..333f0946d3 100644 --- a/netwerk/dns/DNSListenerProxy.cpp +++ b/netwerk/dns/DNSListenerProxy.cpp @@ -20,7 +20,7 @@ DNSListenerProxy::OnLookupComplete(nsICancelable* aRequest, nsIDNSRecord* aRecord, nsresult aStatus) { - nsRefPtr r = + RefPtr r = new OnLookupCompleteRunnable(mListener, aRequest, aRecord, aStatus); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } diff --git a/netwerk/dns/DNSRequestChild.cpp b/netwerk/dns/DNSRequestChild.cpp index 16f83614fd..8437c81670 100644 --- a/netwerk/dns/DNSRequestChild.cpp +++ b/netwerk/dns/DNSRequestChild.cpp @@ -178,7 +178,7 @@ public: return NS_OK; } private: - nsRefPtr mDnsRequest; + RefPtr mDnsRequest; nsresult mReasonForCancel; }; @@ -273,7 +273,7 @@ void DNSRequestChild::ReleaseIPDLReference() { // Request is done or destroyed. Remove it from the hash table. - nsRefPtr dnsServiceChild = + RefPtr dnsServiceChild = dont_AddRef(ChildDNSService::GetSingleton()); dnsServiceChild->NotifyRequestDone(this); diff --git a/netwerk/dns/GetAddrInfo.cpp b/netwerk/dns/GetAddrInfo.cpp index c2182c73f8..918f28a59e 100644 --- a/netwerk/dns/GetAddrInfo.cpp +++ b/netwerk/dns/GetAddrInfo.cpp @@ -209,7 +209,7 @@ _GetTTLData_Windows(const char* aHost, uint16_t* aResult, uint16_t aAddressFamil return NS_ERROR_UNEXPECTED; } - nsRefPtr dnsapi = nullptr; + RefPtr dnsapi = nullptr; { OffTheBooksMutexAutoLock lock(*gDnsapiInfoLock); dnsapi = gDnsapiInfo; diff --git a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp index 9b2bbd773d..cd96a10825 100644 --- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp +++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp @@ -232,7 +232,7 @@ private: return NS_OK; } - nsRefPtr mSts; + RefPtr mSts; DNSServiceRef mService; PRFileDesc* mFD; bool mAttached; @@ -286,7 +286,7 @@ MDNSResponderOperator::ResetService(DNSServiceRef aService) } if (aService) { - nsRefPtr watcher = new ServiceWatcher(aService); + RefPtr watcher = new ServiceWatcher(aService); if (NS_WARN_IF(NS_FAILED(watcher->Init()))) { return rv; } diff --git a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.h b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.h index 368c248f63..2daeb6a303 100644 --- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.h +++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.h @@ -11,7 +11,7 @@ #include "nsCOMPtr.h" #include "nsIDNSServiceDiscovery.h" #include "nsIThread.h" -#include "nsRefPtr.h" +#include "RefPtr.h" #include "nsString.h" namespace mozilla { @@ -37,7 +37,7 @@ private: class ServiceWatcher; DNSServiceRef mService; - nsRefPtr mWatcher; + RefPtr mWatcher; nsCOMPtr mThread; // remember caller thread for callback Atomic mIsCancelled; }; @@ -130,7 +130,7 @@ private: nsCOMPtr mListener; // hold self until callback is made. - nsRefPtr mDeleteProtector; + RefPtr mDeleteProtector; }; } // namespace net diff --git a/netwerk/dns/mdns/libmdns/MDNSResponderReply.h b/netwerk/dns/mdns/libmdns/MDNSResponderReply.h index 47f7695f9d..5ee0614f1d 100644 --- a/netwerk/dns/mdns/libmdns/MDNSResponderReply.h +++ b/netwerk/dns/mdns/libmdns/MDNSResponderReply.h @@ -10,7 +10,7 @@ #include "MDNSResponderOperator.h" #include "mozilla/UniquePtr.h" #include "nsIThread.h" -#include "nsRefPtr.h" +#include "RefPtr.h" #include "nsThreadUtils.h" namespace mozilla { @@ -119,7 +119,7 @@ private: uint16_t mPort; uint16_t mTxtLen; UniquePtr mTxtRecord; - nsRefPtr mContext; + RefPtr mContext; }; } // namespace net diff --git a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp index f6c1d6185b..809523465d 100644 --- a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp +++ b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp @@ -50,7 +50,7 @@ public: private: virtual ~DiscoveryRequest() { Cancel(NS_OK); } - nsRefPtr mService; + RefPtr mService; nsIDNSServiceDiscoveryListener* mListener; }; @@ -86,7 +86,7 @@ public: private: virtual ~RegisterRequest() { Cancel(NS_OK); } - nsRefPtr mService; + RefPtr mService; nsIDNSRegistrationListener* mListener; }; @@ -133,7 +133,7 @@ nsDNSServiceDiscovery::StartDiscovery(const nsACString& aServiceType, return rv; } - nsRefPtr browserOp = new BrowseOperator(aServiceType, + RefPtr browserOp = new BrowseOperator(aServiceType, aListener); if (NS_WARN_IF(NS_FAILED(rv = browserOp->Start()))) { return rv; @@ -152,7 +152,7 @@ nsDNSServiceDiscovery::StopDiscovery(nsIDNSServiceDiscoveryListener* aListener) { nsresult rv; - nsRefPtr browserOp; + RefPtr browserOp; if (!mDiscoveryMap.Get(aListener, getter_AddRefs(browserOp))) { return NS_OK; } @@ -178,7 +178,7 @@ nsDNSServiceDiscovery::RegisterService(nsIDNSServiceInfo* aServiceInfo, return rv; } - nsRefPtr registerOp = new RegisterOperator(aServiceInfo, + RefPtr registerOp = new RegisterOperator(aServiceInfo, aListener); if (NS_WARN_IF(NS_FAILED(rv = registerOp->Start()))) { return rv; @@ -197,7 +197,7 @@ nsDNSServiceDiscovery::UnregisterService(nsIDNSRegistrationListener* aListener) { nsresult rv; - nsRefPtr registerOp; + RefPtr registerOp; if (!mRegisterMap.Get(aListener, getter_AddRefs(registerOp))) { return NS_OK; } @@ -217,7 +217,7 @@ nsDNSServiceDiscovery::ResolveService(nsIDNSServiceInfo* aServiceInfo, { nsresult rv; - nsRefPtr resolveOp = new ResolveOperator(aServiceInfo, + RefPtr resolveOp = new ResolveOperator(aServiceInfo, aListener); if (NS_WARN_IF(NS_FAILED(rv = resolveOp->Start()))) { return rv; diff --git a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.h b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.h index afacf4bd6a..601e51db2d 100644 --- a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.h +++ b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.h @@ -8,7 +8,7 @@ #include "nsIDNSServiceDiscovery.h" #include "nsCOMPtr.h" -#include "nsRefPtr.h" +#include "RefPtr.h" #include "nsRefPtrHashtable.h" namespace mozilla { diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index 49a320a461..b3b80faed1 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -71,7 +71,7 @@ public: private: virtual ~nsDNSRecord() {} - nsRefPtr mHostRecord; + RefPtr mHostRecord; NetAddrElement *mIter; int mIterGenCnt; // the generation count of // mHostRecord->addr_info when we @@ -324,7 +324,7 @@ public: size_t SizeOfIncludingThis(mozilla::MallocSizeOf) const override; - nsRefPtr mResolver; + RefPtr mResolver; nsCString mHost; // hostname we're resolving nsCOMPtr mListener; uint16_t mFlags; @@ -409,7 +409,7 @@ public: bool mDone; nsresult mStatus; - nsRefPtr mHostRecord; + RefPtr mHostRecord; private: PRMonitor *mMonitor; @@ -605,7 +605,7 @@ nsDNSService::Init() nsCOMPtr idn = do_GetService(NS_IDNSERVICE_CONTRACTID); - nsRefPtr res; + RefPtr res; nsresult rv = nsHostResolver::Create(maxCacheEntries, defaultCacheLifetime, defaultGracePeriod, @@ -648,7 +648,7 @@ nsDNSService::Shutdown() UnregisterWeakMemoryReporter(this); #endif // !defined(MOZILLA_XPCOMRT_API) - nsRefPtr res; + RefPtr res; { MutexAutoLock lock(mLock); res = mResolver; @@ -737,7 +737,7 @@ nsDNSService::AsyncResolveExtended(const nsACString &aHostname, { // grab reference to global host resolver and IDN service. beware // simultaneous shutdown!! - nsRefPtr res; + RefPtr res; nsCOMPtr idn; nsCOMPtr target = target_; bool localDomain = false; @@ -820,7 +820,7 @@ nsDNSService::CancelAsyncResolveExtended(const nsACString &aHostname, { // grab reference to global host resolver and IDN service. beware // simultaneous shutdown!! - nsRefPtr res; + RefPtr res; nsCOMPtr idn; bool localDomain = false; { @@ -855,7 +855,7 @@ nsDNSService::Resolve(const nsACString &aHostname, { // grab reference to global host resolver and IDN service. beware // simultaneous shutdown!! - nsRefPtr res; + RefPtr res; nsCOMPtr idn; bool localDomain = false; { diff --git a/netwerk/dns/nsDNSService2.h b/netwerk/dns/nsDNSService2.h index 5085e9b1e0..86156db53f 100644 --- a/netwerk/dns/nsDNSService2.h +++ b/netwerk/dns/nsDNSService2.h @@ -43,7 +43,7 @@ private: uint16_t GetAFForLookup(const nsACString &host, uint32_t flags); - nsRefPtr mResolver; + RefPtr mResolver; nsCOMPtr mIDN; // mLock protects access to mResolver and mIPv4OnlyDomains diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 40997c5649..525001fa51 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -735,7 +735,7 @@ nsHostResolver::ResolveHost(const char *host, // if result is set inside the lock, then we need to issue the // callback before returning. - nsRefPtr result; + RefPtr result; nsresult status = NS_OK, rv = NS_OK; { MutexAutoLock lock(mLock); @@ -952,7 +952,7 @@ nsHostResolver::DetachCallback(const char *host, nsResolveHostCallback *callback, nsresult status) { - nsRefPtr rec; + RefPtr rec; { MutexAutoLock lock(mLock); diff --git a/netwerk/ipc/ChannelEventQueue.cpp b/netwerk/ipc/ChannelEventQueue.cpp index bf4d7529ac..901d78a2ea 100644 --- a/netwerk/ipc/ChannelEventQueue.cpp +++ b/netwerk/ipc/ChannelEventQueue.cpp @@ -52,7 +52,7 @@ ChannelEventQueue::Resume() } if (!--mSuspendCount) { - nsRefPtr > event = + RefPtr > event = NS_NewRunnableMethod(this, &ChannelEventQueue::CompleteResume); if (mTargetThread) { mTargetThread->Dispatch(event, NS_DISPATCH_NORMAL); diff --git a/netwerk/ipc/ChannelEventQueue.h b/netwerk/ipc/ChannelEventQueue.h index be8d99139d..c882e9ba7d 100644 --- a/netwerk/ipc/ChannelEventQueue.h +++ b/netwerk/ipc/ChannelEventQueue.h @@ -51,6 +51,7 @@ class ChannelEventQueue final // Puts IPDL-generated channel event into queue, to be run later // automatically when EndForcedQueueing and/or Resume is called. inline void Enqueue(ChannelEvent* callback); + inline nsresult PrependEvents(nsTArray >& aEvents); // After StartForcedQueueing is called, ShouldEnqueue() will return true and // no events will be run/flushed until EndForcedQueueing is called. @@ -127,6 +128,19 @@ ChannelEventQueue::EndForcedQueueing() MaybeFlushQueue(); } +inline nsresult +ChannelEventQueue::PrependEvents(nsTArray >& aEvents) +{ + if (!mEventQueue.InsertElementsAt(0, aEvents.Length())) { + return NS_ERROR_OUT_OF_MEMORY; + } + + for (uint32_t i = 0; i < aEvents.Length(); i++) { + mEventQueue.ReplaceElementAt(i, aEvents[i].forget()); + } + return NS_OK; +} + inline void ChannelEventQueue::Suspend() { @@ -169,7 +183,7 @@ class MOZ_STACK_CLASS AutoEventEnqueuer mEventQueue->EndForcedQueueing(); } private: - nsRefPtr mEventQueue; + RefPtr mEventQueue; }; } // namespace net diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index e494c363a1..dd76baf880 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -26,17 +26,19 @@ namespace net { struct LoadInfoArgs { - PrincipalInfo requestingPrincipalInfo; - PrincipalInfo triggeringPrincipalInfo; - uint32_t securityFlags; - uint32_t contentPolicyType; - bool upgradeInsecureRequests; - uint64_t innerWindowID; - uint64_t outerWindowID; - uint64_t parentOuterWindowID; - bool enforceSecurity; - bool initialSecurityCheckDone; - PrincipalInfo[] redirectChain; + PrincipalInfo requestingPrincipalInfo; + PrincipalInfo triggeringPrincipalInfo; + uint32_t securityFlags; + uint32_t contentPolicyType; + bool upgradeInsecureRequests; + uint64_t innerWindowID; + uint64_t outerWindowID; + uint64_t parentOuterWindowID; + bool enforceSecurity; + bool initialSecurityCheckDone; + OriginAttributes originAttributes; + PrincipalInfo[] redirectChainIncludingInternalRedirects; + PrincipalInfo[] redirectChain; }; /** diff --git a/netwerk/ipc/NeckoChild.cpp b/netwerk/ipc/NeckoChild.cpp index 3b125aeb98..cd4fff277e 100644 --- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -314,7 +314,7 @@ NeckoChild::RecvAsyncAuthPromptForNestedFrame(const TabId& aNestedFrameId, const nsString& aRealm, const uint64_t& aCallbackId) { - nsRefPtr tabChild = dom::TabChild::FindTabChild(aNestedFrameId); + RefPtr tabChild = dom::TabChild::FindTabChild(aNestedFrameId); if (!tabChild) { MOZ_CRASH(); return false; diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index c894d3c0e5..305e11b05c 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -169,6 +169,9 @@ struct ParamTraits WriteParam(aMsg, aParam.fetchStart); WriteParam(aMsg, aParam.redirectStart); WriteParam(aMsg, aParam.redirectEnd); + + WriteParam(aMsg, aParam.transferSize); + WriteParam(aMsg, aParam.encodedBodySize); } static bool Read(const Message* aMsg, void** aIter, mozilla::net::ResourceTimingStruct* aResult) @@ -182,7 +185,9 @@ struct ParamTraits ReadParam(aMsg, aIter, &aResult->responseEnd) && ReadParam(aMsg, aIter, &aResult->fetchStart) && ReadParam(aMsg, aIter, &aResult->redirectStart) && - ReadParam(aMsg, aIter, &aResult->redirectEnd); + ReadParam(aMsg, aIter, &aResult->redirectEnd) && + ReadParam(aMsg, aIter, &aResult->transferSize) && + ReadParam(aMsg, aIter, &aResult->encodedBodySize); } }; diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index bc7e46e6ec..df951fe850 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -182,7 +182,7 @@ NeckoParent::CreateChannelLoadContext(const PBrowserOrId& aBrowser, switch (aBrowser.type()) { case PBrowserOrId::TPBrowserParent: { - nsRefPtr tabParent = + RefPtr tabParent = TabParent::GetFrom(aBrowser.get_PBrowserParent()); dom::Element* topFrameElement = nullptr; if (tabParent) { @@ -331,7 +331,7 @@ NeckoParent::AllocPWebSocketParent(const PBrowserOrId& browser, return nullptr; } - nsRefPtr tabParent = TabParent::GetFrom(browser.get_PBrowserParent()); + RefPtr tabParent = TabParent::GetFrom(browser.get_PBrowserParent()); PBOverrideStatus overrideStatus = PBOverrideStatusFromLoadContext(serialized); WebSocketChannelParent* p = new WebSocketChannelParent(tabParent, loadContext, overrideStatus); @@ -350,14 +350,14 @@ NeckoParent::DeallocPWebSocketParent(PWebSocketParent* actor) PDataChannelParent* NeckoParent::AllocPDataChannelParent(const uint32_t &channelId) { - nsRefPtr p = new DataChannelParent(); + RefPtr p = new DataChannelParent(); return p.forget().take(); } bool NeckoParent::DeallocPDataChannelParent(PDataChannelParent* actor) { - nsRefPtr p = dont_AddRef(static_cast(actor)); + RefPtr p = dont_AddRef(static_cast(actor)); return true; } @@ -480,7 +480,7 @@ PUDPSocketParent* NeckoParent::AllocPUDPSocketParent(const Principal& /* unused */, const nsCString& /* unused */) { - nsRefPtr p = new UDPSocketParent(this); + RefPtr p = new UDPSocketParent(this); return p.forget().take(); } @@ -827,7 +827,7 @@ NeckoParent::RecvOnAuthAvailable(const uint64_t& aCallbackId, } CallbackMap().erase(aCallbackId); - nsRefPtr holder = + RefPtr holder = new nsAuthInformationHolder(0, EmptyString(), EmptyCString()); holder->SetUsername(aUser); holder->SetPassword(aPassword); diff --git a/netwerk/ipc/NeckoParent.h b/netwerk/ipc/NeckoParent.h index 16d0a3ebee..8b0720b3dd 100644 --- a/netwerk/ipc/NeckoParent.h +++ b/netwerk/ipc/NeckoParent.h @@ -229,7 +229,7 @@ protected: private: nsCString mCoreAppsBasePath; nsCString mWebAppsBasePath; - nsRefPtr mObserver; + RefPtr mObserver; }; /** diff --git a/netwerk/ipc/RemoteOpenFileChild.cpp b/netwerk/ipc/RemoteOpenFileChild.cpp index bd6034fc65..293b08bf3f 100644 --- a/netwerk/ipc/RemoteOpenFileChild.cpp +++ b/netwerk/ipc/RemoteOpenFileChild.cpp @@ -217,7 +217,7 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags, #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) // Windows/OSX desktop builds skip remoting, and just open file in child // process when asked for NSPR handle - nsRefPtr runnable = + RefPtr runnable = new CallsListenerInNewEvent(aListener, NS_OK); runnable->Dispatch(); @@ -296,7 +296,7 @@ RemoteOpenFileChild::HandleFileDescriptorAndNotifyListener( // descriptor callback or through the normal messaging mechanism). Close the // file descriptor if it is valid. if (aFD.IsValid()) { - nsRefPtr runnable = new CloseFileRunnable(aFD); + RefPtr runnable = new CloseFileRunnable(aFD); runnable->Dispatch(); } return; @@ -304,7 +304,7 @@ RemoteOpenFileChild::HandleFileDescriptorAndNotifyListener( MOZ_ASSERT(!mNSPRFileDesc); - nsRefPtr tabChild; + RefPtr tabChild; mTabChild.swap(tabChild); // If RemoteOpenFile reply (Recv__delete__) for app's application.zip comes @@ -338,7 +338,7 @@ RemoteOpenFileChild::NotifyListener(nsresult aResult) mListener->OnRemoteFileOpenComplete(aResult); mListener = nullptr; // release ref to listener - nsRefPtr handler(gJarHandler); + RefPtr handler(gJarHandler); NS_WARN_IF_FALSE(handler, "nsJARProtocolHandler is already gone!"); if (handler) { diff --git a/netwerk/ipc/RemoteOpenFileChild.h b/netwerk/ipc/RemoteOpenFileChild.h index d2fc0c87e7..205ac80a9b 100644 --- a/netwerk/ipc/RemoteOpenFileChild.h +++ b/netwerk/ipc/RemoteOpenFileChild.h @@ -110,7 +110,7 @@ protected: nsCOMPtr mURI; nsCOMPtr mAppURI; nsCOMPtr mListener; - nsRefPtr mTabChild; + RefPtr mTabChild; PRFileDesc* mNSPRFileDesc; bool mAsyncOpenCalled; bool mNSPROpenCalled; diff --git a/netwerk/protocol/about/nsAboutCacheEntry.cpp b/netwerk/protocol/about/nsAboutCacheEntry.cpp index 5a8c612189..9e429e87ea 100644 --- a/netwerk/protocol/about/nsAboutCacheEntry.cpp +++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp @@ -467,7 +467,7 @@ nsAboutCacheEntry::WriteCacheEntryDescription(nsICacheEntry *entry) return NS_OK; } - nsRefPtr pump; + RefPtr pump; rv = nsInputStreamPump::Create(getter_AddRefs(pump), stream); if (NS_FAILED(rv)) { return NS_OK; // just ignore diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.cpp b/netwerk/protocol/about/nsAboutProtocolHandler.cpp index b4e375731a..6e008748b5 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp @@ -169,7 +169,7 @@ nsAboutProtocolHandler::NewChannel2(nsIURI* uri, (*result)->SetOwner(nullptr); } - nsRefPtr aboutURI; + RefPtr aboutURI; nsresult rv2 = uri->QueryInterface(kNestedAboutURICID, getter_AddRefs(aboutURI)); if (NS_SUCCEEDED(rv2) && aboutURI->GetBaseURI()) { diff --git a/netwerk/protocol/app/AppProtocolHandler.cpp b/netwerk/protocol/app/AppProtocolHandler.cpp index 0be12a947b..77d9804708 100644 --- a/netwerk/protocol/app/AppProtocolHandler.cpp +++ b/netwerk/protocol/app/AppProtocolHandler.cpp @@ -399,7 +399,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri, nsIChannel** aResult) { NS_ENSURE_ARG_POINTER(aUri); - nsRefPtr channel = new nsJARChannel(); + RefPtr channel = new nsJARChannel(); nsAutoCString host; nsresult rv = aUri->GetHost(host); @@ -441,7 +441,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri, if (NS_FAILED(rv) || !jsInfo.isObject()) { // Return a DummyChannel. printf_stderr("!! Creating a dummy channel for %s (no appInfo)\n", host.get()); - nsRefPtr dummyChannel = new DummyChannel(); + RefPtr dummyChannel = new DummyChannel(); dummyChannel->SetLoadInfo(aLoadInfo); dummyChannel.forget(aResult); return NS_OK; @@ -452,7 +452,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri, if (!appInfo->Init(cx, jsInfo) || appInfo->mPath.IsEmpty()) { // Return a DummyChannel. printf_stderr("!! Creating a dummy channel for %s (invalid appInfo)\n", host.get()); - nsRefPtr dummyChannel = new DummyChannel(); + RefPtr dummyChannel = new DummyChannel(); dummyChannel->SetLoadInfo(aLoadInfo); dummyChannel.forget(aResult); return NS_OK; diff --git a/netwerk/protocol/data/nsDataHandler.cpp b/netwerk/protocol/data/nsDataHandler.cpp index 059b5d731f..de15b14a44 100644 --- a/netwerk/protocol/data/nsDataHandler.cpp +++ b/netwerk/protocol/data/nsDataHandler.cpp @@ -64,7 +64,7 @@ nsDataHandler::NewURI(const nsACString &aSpec, nsIURI *aBaseURI, nsIURI **result) { nsresult rv; - nsRefPtr uri; + RefPtr uri; nsCString spec(aSpec); diff --git a/netwerk/protocol/device/AndroidCaptureProvider.cpp b/netwerk/protocol/device/AndroidCaptureProvider.cpp index 7bd6846b4b..678cec966f 100644 --- a/netwerk/protocol/device/AndroidCaptureProvider.cpp +++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp @@ -275,7 +275,7 @@ nsresult AndroidCaptureProvider::Init(nsACString& aContentType, NS_ASSERTION(aParams->frameLimit == 0 || aParams->timeLimit == 0, "Cannot set both a frame limit and a time limit!"); - nsRefPtr stream; + RefPtr stream; if (aContentType.EqualsLiteral("video/x-raw-yuv")) { stream = new AndroidCameraInputStream(); @@ -297,6 +297,6 @@ already_AddRefed GetAndroidCaptureProvider() { if (!AndroidCaptureProvider::sInstance) { AndroidCaptureProvider::sInstance = new AndroidCaptureProvider(); } - nsRefPtr ret = AndroidCaptureProvider::sInstance; + RefPtr ret = AndroidCaptureProvider::sInstance; return ret.forget(); } diff --git a/netwerk/protocol/device/nsDeviceChannel.cpp b/netwerk/protocol/device/nsDeviceChannel.cpp index 58c03a33e5..4892cb6fac 100644 --- a/netwerk/protocol/device/nsDeviceChannel.cpp +++ b/netwerk/protocol/device/nsDeviceChannel.cpp @@ -85,7 +85,7 @@ nsDeviceChannel::OpenContentStream(bool aAsync, nsAutoCString type; - nsRefPtr capture; + RefPtr capture; nsCaptureParams captureParams; captureParams.camera = 0; if (kNotFound != spec.Find(NS_LITERAL_CSTRING("type=image/png"), diff --git a/netwerk/protocol/device/nsDeviceProtocolHandler.cpp b/netwerk/protocol/device/nsDeviceProtocolHandler.cpp index 1c7b62c34c..7445ba09f5 100644 --- a/netwerk/protocol/device/nsDeviceProtocolHandler.cpp +++ b/netwerk/protocol/device/nsDeviceProtocolHandler.cpp @@ -45,7 +45,7 @@ nsDeviceProtocolHandler::NewURI(const nsACString &spec, nsIURI *baseURI, nsIURI **result) { - nsRefPtr uri = new nsSimpleURI(); + RefPtr uri = new nsSimpleURI(); nsresult rv = uri->SetSpec(spec); NS_ENSURE_SUCCESS(rv, rv); @@ -59,7 +59,7 @@ nsDeviceProtocolHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** aResult) { - nsRefPtr channel = new nsDeviceChannel(); + RefPtr channel = new nsDeviceChannel(); nsresult rv = channel->Init(aURI); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/protocol/file/nsFileChannel.cpp b/netwerk/protocol/file/nsFileChannel.cpp index 9aecfe88d5..ee9cb67370 100644 --- a/netwerk/protocol/file/nsFileChannel.cpp +++ b/netwerk/protocol/file/nsFileChannel.cpp @@ -193,7 +193,7 @@ private: void OnCopyComplete(); - nsRefPtr mCopyEvent; + RefPtr mCopyEvent; nsCOMPtr mSink; }; @@ -375,7 +375,7 @@ nsFileChannel::OpenContentStream(bool async, nsIInputStream **result, if (NS_FAILED(rv)) return rv; - nsRefPtr uploadStream = + RefPtr uploadStream = new nsFileUploadContentStream(async, fileStream, mUploadStream, mUploadLength, this); if (!uploadStream || !uploadStream->IsInitialized()) { diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp index bee527c9df..d4e495f23f 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.cpp +++ b/netwerk/protocol/ftp/FTPChannelChild.cpp @@ -29,6 +29,7 @@ namespace net { FTPChannelChild::FTPChannelChild(nsIURI* uri) : mIPCOpen(false) +, mUnknownDecoderInvolved(false) , mCanceled(false) , mSuspendCount(0) , mIsPending(false) @@ -392,6 +393,40 @@ FTPChannelChild::RecvOnDataAvailable(const nsresult& channelStatus, return true; } +class MaybeDivertOnDataFTPEvent : public ChannelEvent +{ + public: + MaybeDivertOnDataFTPEvent(FTPChannelChild* child, + const nsCString& data, + const uint64_t& offset, + const uint32_t& count) + : mChild(child) + , mData(data) + , mOffset(offset) + , mCount(count) {} + + void Run() + { + mChild->MaybeDivertOnData(mData, mOffset, mCount); + } + + private: + FTPChannelChild* mChild; + nsCString mData; + uint64_t mOffset; + uint32_t mCount; +}; + +void +FTPChannelChild::MaybeDivertOnData(const nsCString& data, + const uint64_t& offset, + const uint32_t& count) +{ + if (mDivertingToParent) { + SendDivertOnDataAvailable(data, offset, count); + } +} + void FTPChannelChild::DoOnDataAvailable(const nsresult& channelStatus, const nsCString& data, @@ -415,6 +450,11 @@ FTPChannelChild::DoOnDataAvailable(const nsresult& channelStatus, if (mCanceled) return; + if (mUnknownDecoderInvolved) { + mUnknownDecoderEventQ.AppendElement( + new MaybeDivertOnDataFTPEvent(this, data, offset, count)); + } + // NOTE: the OnDataAvailable contract requires the client to read all the data // in the inputstream. This code relies on that ('data' will go away after // this function). Apparently the previous, non-e10s behavior was to actually @@ -474,6 +514,32 @@ FTPChannelChild::RecvOnStopRequest(const nsresult& aChannelStatus) return true; } +class MaybeDivertOnStopFTPEvent : public ChannelEvent +{ + public: + MaybeDivertOnStopFTPEvent(FTPChannelChild* child, + const nsresult& aChannelStatus) + : mChild(child) + , mChannelStatus(aChannelStatus) {} + + void Run() + { + mChild->MaybeDivertOnStop(mChannelStatus); + } + + private: + FTPChannelChild* mChild; + nsresult mChannelStatus; +}; + +void +FTPChannelChild::MaybeDivertOnStop(const nsresult& aChannelStatus) +{ + if (mDivertingToParent) { + SendDivertOnStopRequest(aChannelStatus); + } +} + void FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus) { @@ -491,6 +557,11 @@ FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus) if (!mCanceled) mStatus = aChannelStatus; + if (mUnknownDecoderInvolved) { + mUnknownDecoderEventQ.AppendElement( + new MaybeDivertOnStopFTPEvent(this, aChannelStatus)); + } + { // Ensure that all queued ipdl events are dispatched before // we initiate protocol deletion below. mIsPending = false; @@ -790,6 +861,36 @@ FTPChannelChild::DivertToParent(ChannelDiverterChild **aChild) return NS_OK; } +NS_IMETHODIMP +FTPChannelChild::UnknownDecoderInvolvedKeepData() +{ + mUnknownDecoderInvolved = true; + return NS_OK; +} + +NS_IMETHODIMP +FTPChannelChild::UnknownDecoderInvolvedOnStartRequestCalled() +{ + mUnknownDecoderInvolved = false; + + nsresult rv = NS_OK; + + if (mDivertingToParent) { + rv = mEventQ->PrependEvents(mUnknownDecoderEventQ); + } + mUnknownDecoderEventQ.Clear(); + + return rv; +} + +NS_IMETHODIMP +FTPChannelChild::GetDivertingToParent(bool* aDiverting) +{ + NS_ENSURE_ARG_POINTER(aDiverting); + *aDiverting = mDivertingToParent; + return NS_OK; +} + } // namespace net } // namespace mozilla diff --git a/netwerk/protocol/ftp/FTPChannelChild.h b/netwerk/protocol/ftp/FTPChannelChild.h index 7e22f4b12c..dacde21b53 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.h +++ b/netwerk/protocol/ftp/FTPChannelChild.h @@ -101,13 +101,19 @@ protected: const nsCString& data, const uint64_t& offset, const uint32_t& count); + void MaybeDivertOnData(const nsCString& data, + const uint64_t& offset, + const uint32_t& count); + void MaybeDivertOnStop(const nsresult& statusCode); void DoOnStopRequest(const nsresult& statusCode); void DoFailedAsyncOpen(const nsresult& statusCode); void DoDeleteSelf(); friend class FTPStartRequestEvent; friend class FTPDataAvailableEvent; + friend class MaybeDivertOnDataFTPEvent; friend class FTPStopRequestEvent; + friend class MaybeDivertOnStopFTPEvent; friend class FTPFailedAsyncOpenEvent; friend class FTPDeleteSelfEvent; @@ -115,7 +121,14 @@ private: nsCOMPtr mUploadStream; bool mIPCOpen; - nsRefPtr mEventQ; + RefPtr mEventQ; + + // If nsUnknownDecoder is involved we queue onDataAvailable (and possibly + // OnStopRequest) so that we can divert them if needed when the listener's + // OnStartRequest is finally called + nsTArray> mUnknownDecoderEventQ; + bool mUnknownDecoderInvolved; + bool mCanceled; uint32_t mSuspendCount; bool mIsPending; diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index 365bdc9130..a35e0deb14 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -625,7 +625,7 @@ public: return NS_OK; } private: - nsRefPtr mChannelParent; + RefPtr mChannelParent; nsresult mErrorCode; bool mSkipResume; }; diff --git a/netwerk/protocol/ftp/FTPChannelParent.h b/netwerk/protocol/ftp/FTPChannelParent.h index fcb2511acf..405b36dbcf 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.h +++ b/netwerk/protocol/ftp/FTPChannelParent.h @@ -117,8 +117,8 @@ protected: // Set if we successfully suspended the nsHttpChannel for diversion. Unset // when we call ResumeForDiversion. bool mSuspendedForDiversion; - nsRefPtr mObserver; - nsRefPtr mTabParent; + RefPtr mObserver; + RefPtr mTabParent; }; } // namespace net diff --git a/netwerk/protocol/ftp/nsFTPChannel.cpp b/netwerk/protocol/ftp/nsFTPChannel.cpp index ac3262d487..54b5ebe7ff 100644 --- a/netwerk/protocol/ftp/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/nsFTPChannel.cpp @@ -171,7 +171,7 @@ NS_IMPL_ISUPPORTS(FTPEventSinkProxy, nsIFTPEventSink) NS_IMETHODIMP FTPEventSinkProxy::OnFTPControlLog(bool aServer, const char* aMsg) { - nsRefPtr r = + RefPtr r = new OnFTPControlLogRunnable(mTarget, aServer, aMsg); return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL); } diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index c32963a890..5a7325bebf 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -728,7 +728,7 @@ nsFtpState::S_user() { if (!prompter) return NS_ERROR_NOT_INITIALIZED; - nsRefPtr info = + RefPtr info = new nsAuthInformationHolder(nsIAuthInformation::AUTH_HOST, EmptyString(), EmptyCString()); @@ -817,7 +817,7 @@ nsFtpState::S_pass() { if (!prompter) return NS_ERROR_NOT_INITIALIZED; - nsRefPtr info = + RefPtr info = new nsAuthInformationHolder(nsIAuthInformation::AUTH_HOST | nsIAuthInformation::ONLY_PASSWORD, EmptyString(), @@ -2129,7 +2129,7 @@ nsFtpState::SaveNetworkStats(bool enforce) // Create the event to save the network statistics. // the event is then dispathed to the main thread. - nsRefPtr event = + RefPtr event = new SaveNetworkStatsEvent(appId, isInBrowser, mActiveNetworkInfo, mCountRecv, 0, false); NS_DispatchToMainThread(event); diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.h b/netwerk/protocol/ftp/nsFtpConnectionThread.h index 8cd58a40d6..85bd09be18 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.h @@ -163,7 +163,7 @@ private: nsCString mResponseMsg; // the last command response text // ****** channel/transport/stream vars - nsRefPtr mControlConnection; // cacheable control connection (owns mCPipe) + RefPtr mControlConnection; // cacheable control connection (owns mCPipe) bool mReceivedControlData; bool mTryingCachedControl; // retrying the password bool mRETRFailed; // Did we already try a RETR and it failed? @@ -171,7 +171,7 @@ private: nsCString mModTime; // ****** consumer vars - nsRefPtr mChannel; // our owning FTP channel we pass through our events + RefPtr mChannel; // our owning FTP channel we pass through our events nsCOMPtr mProxyInfo; // ****** connection cache vars diff --git a/netwerk/protocol/ftp/nsFtpControlConnection.cpp b/netwerk/protocol/ftp/nsFtpControlConnection.cpp index 1f158593ba..373fcecb40 100644 --- a/netwerk/protocol/ftp/nsFtpControlConnection.cpp +++ b/netwerk/protocol/ftp/nsFtpControlConnection.cpp @@ -46,7 +46,7 @@ nsFtpControlConnection::OnInputStreamReady(nsIAsyncInputStream *stream) // It's important that we null out mListener before calling one of its // methods as it may call WaitData, which would queue up another read. - nsRefPtr listener; + RefPtr listener; listener.swap(mListener); if (!listener) diff --git a/netwerk/protocol/ftp/nsFtpControlConnection.h b/netwerk/protocol/ftp/nsFtpControlConnection.h index 7e175c15e6..5301bb9cee 100644 --- a/netwerk/protocol/ftp/nsFtpControlConnection.h +++ b/netwerk/protocol/ftp/nsFtpControlConnection.h @@ -79,7 +79,7 @@ private: nsCOMPtr mSocketOutput; nsCOMPtr mSocketInput; - nsRefPtr mListener; + RefPtr mListener; }; #endif diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp index 977fcc4e71..33ae9d5453 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -220,7 +220,7 @@ nsFtpProtocolHandler::NewProxiedChannel2(nsIURI* uri, nsIProxyInfo* proxyInfo, nsIChannel* *result) { NS_ENSURE_ARG_POINTER(uri); - nsRefPtr channel; + RefPtr channel; if (IsNeckoChild()) channel = new FTPChannelChild(uri); else diff --git a/netwerk/protocol/http/AlternateServices.cpp b/netwerk/protocol/http/AlternateServices.cpp index bbb0612a8a..bfe97a8446 100644 --- a/netwerk/protocol/http/AlternateServices.cpp +++ b/netwerk/protocol/http/AlternateServices.cpp @@ -109,7 +109,7 @@ AltSvcMapping::ProcessHeader(const nsCString &buf, const nsCString &originScheme continue; } - nsRefPtr mapping = new AltSvcMapping(originScheme, + RefPtr mapping = new AltSvcMapping(originScheme, originHost, originPort, username, privateBrowsing, NowInSeconds() + maxage, @@ -225,7 +225,7 @@ void AltSvcMapping::GetConnectionInfo(nsHttpConnectionInfo **outCI, nsProxyInfo *pi) { - nsRefPtr ci = + RefPtr ci = new nsHttpConnectionInfo(mOriginHost, mOriginPort, mNPNToken, mUsername, pi, mAlternateHost, mAlternatePort); ci->SetInsecureScheme(!mHttps); @@ -371,7 +371,7 @@ public: } private: - nsRefPtr mMapping; + RefPtr mMapping; uint32_t mRunning : 1; uint32_t mTriedToValidate : 1; uint32_t mTriedToWrite : 1; @@ -417,13 +417,13 @@ AltSvcCache::UpdateAltServiceMapping(AltSvcMapping *map, nsProxyInfo *pi, mHash.Put(map->mHashKey, map); - nsRefPtr ci; + RefPtr ci; map->GetConnectionInfo(getter_AddRefs(ci), pi); caps |= ci->GetAnonymous() ? NS_HTTP_LOAD_ANONYMOUS : 0; nsCOMPtr callbacks = new AltSvcOverride(aCallbacks); - nsRefPtr nullTransaction = + RefPtr nullTransaction = new AltSvcTransaction(map, ci, aCallbacks, caps); nullTransaction->StartTransaction(); gHttpHandler->ConnMgr()->SpeculativeConnect(ci, callbacks, caps, nullTransaction); diff --git a/netwerk/protocol/http/Http2Compression.cpp b/netwerk/protocol/http/Http2Compression.cpp index fe8520124c..d952a5a575 100644 --- a/netwerk/protocol/http/Http2Compression.cpp +++ b/netwerk/protocol/http/Http2Compression.cpp @@ -247,7 +247,7 @@ nvFIFO::VariableLength() const return mTable.GetSize(); } -uint32_t +size_t nvFIFO::StaticLength() const { return gStaticHeaders->GetSize(); @@ -262,7 +262,7 @@ nvFIFO::Clear() } const nvPair * -nvFIFO::operator[] (int32_t index) const +nvFIFO::operator[] (size_t index) const { // NWGH - ensure index > 0 // NWGH - subtract 1 from index here diff --git a/netwerk/protocol/http/Http2Compression.h b/netwerk/protocol/http/Http2Compression.h index c78175d02f..c2a9e350a1 100644 --- a/netwerk/protocol/http/Http2Compression.h +++ b/netwerk/protocol/http/Http2Compression.h @@ -48,9 +48,9 @@ public: uint32_t ByteCount() const; uint32_t Length() const; uint32_t VariableLength() const; - uint32_t StaticLength() const; + size_t StaticLength() const; void Clear(); - const nvPair *operator[] (int32_t index) const; + const nvPair *operator[] (size_t index) const; private: uint32_t mByteCount; @@ -79,7 +79,7 @@ protected: uint32_t mMaxBuffer; private: - nsRefPtr mDynamicReporter; + RefPtr mDynamicReporter; }; class Http2Compressor; diff --git a/netwerk/protocol/http/Http2Push.cpp b/netwerk/protocol/http/Http2Push.cpp index ca08159465..be486a05d1 100644 --- a/netwerk/protocol/http/Http2Push.cpp +++ b/netwerk/protocol/http/Http2Push.cpp @@ -37,7 +37,7 @@ class CallChannelOnPush final : public nsRunnable { NS_IMETHOD Run() { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr channel; + RefPtr channel; CallQueryInterface(mAssociatedChannel, channel.StartAssignment()); MOZ_ASSERT(channel); if (channel && NS_SUCCEEDED(channel->OnPush(mPushedURI, mPushedStream))) { @@ -384,7 +384,7 @@ Http2PushTransactionBuffer::RequestHead() nsresult Http2PushTransactionBuffer::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/netwerk/protocol/http/Http2Session.cpp b/netwerk/protocol/http/Http2Session.cpp index 4d14880d84..86988fd934 100644 --- a/netwerk/protocol/http/Http2Session.cpp +++ b/netwerk/protocol/http/Http2Session.cpp @@ -1110,8 +1110,8 @@ Http2Session::CleanupStream(uint32_t aID, nsresult aResult, errorType aResetCode static void RemoveStreamFromQueue(Http2Stream *aStream, nsDeque &queue) { - uint32_t size = queue.GetSize(); - for (uint32_t count = 0; count < size; ++count) { + size_t size = queue.GetSize(); + for (size_t count = 0; count < size; ++count) { Http2Stream *stream = static_cast(queue.PopFront()); if (stream != aStream) queue.Push(stream); @@ -1675,7 +1675,7 @@ Http2Session::RecvPushPromise(Http2Session *self) } // Create the buffering transaction and push stream - nsRefPtr transactionBuffer = + RefPtr transactionBuffer = new Http2PushTransactionBuffer(); transactionBuffer->SetConnection(self); Http2PushedStream *pushedStream = @@ -1733,7 +1733,7 @@ Http2Session::RecvPushPromise(Http2Session *self) return NS_OK; } - nsRefPtr associatedURL, pushedURL; + RefPtr associatedURL, pushedURL; rv = Http2Stream::MakeOriginURL(associatedStream->Origin(), associatedURL); if (NS_SUCCEEDED(rv)) { rv = Http2Stream::MakeOriginURL(pushedStream->Origin(), pushedURL); @@ -1847,8 +1847,8 @@ Http2Session::RecvGoAway(Http2Session *self) self->mStreamTransactionHash.Enumerate(GoAwayEnumerator, self); // Process the streams marked for deletion and restart. - uint32_t size = self->mGoAwayStreamsToRestart.GetSize(); - for (uint32_t count = 0; count < size; ++count) { + size_t size = self->mGoAwayStreamsToRestart.GetSize(); + for (size_t count = 0; count < size; ++count) { Http2Stream *stream = static_cast(self->mGoAwayStreamsToRestart.PopFront()); @@ -1865,7 +1865,7 @@ Http2Session::RecvGoAway(Http2Session *self) // in another one. (they were never sent on the network so they implicitly // are not covered by the last-good id. size = self->mQueuedStreams.GetSize(); - for (uint32_t count = 0; count < size; ++count) { + for (size_t count = 0; count < size; ++count) { Http2Stream *stream = static_cast(self->mQueuedStreams.PopFront()); MOZ_ASSERT(stream->Queued()); @@ -2068,7 +2068,7 @@ UpdateAltSvcEvent(const nsCString &header, private: nsCString mHeader; nsCString mOrigin; - nsRefPtr mCI; + RefPtr mCI; nsCOMPtr mCallbacks; }; @@ -2163,7 +2163,7 @@ Http2Session::RecvAltSvc(Http2Session *self) return NS_OK; } - nsRefPtr ci(self->ConnectionInfo()); + RefPtr ci(self->ConnectionInfo()); if (!self->mConnection || !ci) { LOG3(("Http2Session::RecvAltSvc %p no connection or conninfo for %d", self, self->mInputFrameID)); @@ -2215,7 +2215,7 @@ Http2Session::RecvAltSvc(Http2Session *self) self->mConnection->GetSecurityInfo(getter_AddRefs(callbacks)); nsCOMPtr irCallbacks = do_QueryInterface(callbacks); - nsRefPtr event = + RefPtr event = new UpdateAltSvcEvent(altSvcFieldValue, origin, ci, irCallbacks); NS_DispatchToMainThread(event); self->ResetDownstreamState(); @@ -3065,7 +3065,7 @@ Http2Session::Close(nsresult aReason) nsHttpConnectionInfo * Http2Session::ConnectionInfo() { - nsRefPtr ci; + RefPtr ci; GetConnectionInfo(getter_AddRefs(ci)); return ci.get(); } @@ -3365,7 +3365,7 @@ Http2Session::CreateTunnel(nsHttpTransaction *trans, // transaction so that an auth created by the connect can be mappped // to the correct security callbacks - nsRefPtr connectTrans = + RefPtr connectTrans = new SpdyConnectTransaction(ci, aCallbacks, trans->Caps(), trans, this); AddStream(connectTrans, nsISupportsPriority::PRIORITY_NORMAL, false, nullptr); Http2Stream *tunnel = mStreamTransactionHash.Get(connectTrans); @@ -3726,8 +3726,8 @@ static PLDHashOperator nsAutoPtr &stream, void *closure) { - nsTArray > *list = - static_cast > *>(closure); + nsTArray > *list = + static_cast > *>(closure); list->AppendElement(key); @@ -3738,7 +3738,7 @@ static PLDHashOperator nsresult Http2Session::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { // Generally this cannot be done with http/2 as transactions are // started right away. diff --git a/netwerk/protocol/http/Http2Session.h b/netwerk/protocol/http/Http2Session.h index 5c3a46dae9..6d8b4f044f 100644 --- a/netwerk/protocol/http/Http2Session.h +++ b/netwerk/protocol/http/Http2Session.h @@ -312,7 +312,7 @@ private: // This is intended to be nsHttpConnectionMgr:nsConnectionHandle taken // from the first transaction on this session. That object contains the // pointer to the real network-level nsHttpConnection object. - nsRefPtr mConnection; + RefPtr mConnection; // The underlying socket transport object is needed to propogate some events nsISocketTransport *mSocketTransport; diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 657c693d4e..9ce9e4b8da 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -341,7 +341,7 @@ Http2Stream::WriteSegments(nsAHttpSegmentWriter *writer, } nsresult -Http2Stream::MakeOriginURL(const nsACString &origin, nsRefPtr &url) +Http2Stream::MakeOriginURL(const nsACString &origin, RefPtr &url) { nsAutoCString scheme; nsresult rv = net_ExtractURLScheme(origin, nullptr, nullptr, &scheme); @@ -351,7 +351,7 @@ Http2Stream::MakeOriginURL(const nsACString &origin, nsRefPtr &ur nsresult Http2Stream::MakeOriginURL(const nsACString &scheme, const nsACString &origin, - nsRefPtr &url) + RefPtr &url) { url = new nsStandardURL(); nsresult rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, @@ -374,7 +374,7 @@ Http2Stream::CreatePushHashKey(const nsCString &scheme, fullOrigin.AppendLiteral("://"); fullOrigin.Append(hostHeader); - nsRefPtr origin; + RefPtr origin; nsresult rv = Http2Stream::MakeOriginURL(scheme, fullOrigin, origin); if (NS_SUCCEEDED(rv)) { @@ -1450,7 +1450,7 @@ Http2Stream::ClearTransactionsBlockedOnTunnel() void Http2Stream::MapStreamToPlainText() { - nsRefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); + RefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); MOZ_ASSERT(qiTrans); mPlainTextTunnel = true; qiTrans->ForcePlainText(); @@ -1459,7 +1459,7 @@ Http2Stream::MapStreamToPlainText() void Http2Stream::MapStreamToHttpConnection() { - nsRefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); + RefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); MOZ_ASSERT(qiTrans); qiTrans->MapStreamToHttpConnection(mSocketTransport, mTransaction->ConnectionInfo()); diff --git a/netwerk/protocol/http/Http2Stream.h b/netwerk/protocol/http/Http2Stream.h index 4ee1935084..a99ce37c28 100644 --- a/netwerk/protocol/http/Http2Stream.h +++ b/netwerk/protocol/http/Http2Stream.h @@ -147,11 +147,11 @@ public: Http2Session *Session() { return mSession; } static nsresult MakeOriginURL(const nsACString &origin, - nsRefPtr &url); + RefPtr &url); static nsresult MakeOriginURL(const nsACString &scheme, const nsACString &origin, - nsRefPtr &url); + RefPtr &url); protected: static void CreatePushHashKey(const nsCString &scheme, @@ -220,7 +220,7 @@ private: // in the Http2Session mStreamTransactionHash so it is important to // keep a reference to it as long as this stream is a member of that hash. // (i.e. don't change it or release it after it is set in the ctor). - nsRefPtr mTransaction; + RefPtr mTransaction; // The underlying socket transport object is needed to propogate some events nsISocketTransport *mSocketTransport; diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 935b526ad7..e68e0959bb 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -42,6 +42,7 @@ #include "nsStreamUtils.h" #include "nsContentSecurityManager.h" #include "nsILoadGroupChild.h" +#include "mozilla/ConsoleReportCollector.h" #include @@ -92,8 +93,12 @@ HttpBaseChannel::HttpBaseChannel() , mCorsMode(nsIHttpChannelInternal::CORS_MODE_NO_CORS) , mRedirectMode(nsIHttpChannelInternal::REDIRECT_MODE_FOLLOW) , mOnStartRequestCalled(false) + , mTransferSize(0) + , mDecodedBodySize(0) + , mEncodedBodySize(0) , mRequireCORSPreflight(false) , mWithCredentials(false) + , mReportCollector(new ConsoleReportCollector()) , mForceMainDocumentChannel(false) { LOG(("Creating HttpBaseChannel @%x\n", this)); @@ -204,6 +209,7 @@ NS_INTERFACE_MAP_BEGIN(HttpBaseChannel) NS_INTERFACE_MAP_ENTRY(nsITraceableChannel) NS_INTERFACE_MAP_ENTRY(nsIPrivateBrowsingChannel) NS_INTERFACE_MAP_ENTRY(nsITimedChannel) + NS_INTERFACE_MAP_ENTRY(nsIConsoleReportCollector) NS_INTERFACE_MAP_END_INHERITING(nsHashPropertyBag) //----------------------------------------------------------------------------- @@ -268,6 +274,21 @@ HttpBaseChannel::GetLoadFlags(nsLoadFlags *aLoadFlags) NS_IMETHODIMP HttpBaseChannel::SetLoadFlags(nsLoadFlags aLoadFlags) { + bool synthesized = false; + nsresult rv = GetResponseSynthesized(&synthesized); + NS_ENSURE_SUCCESS(rv, rv); + + // If this channel is marked as awaiting a synthesized response, + // modifying certain load flags can interfere with the implementation + // of the network interception logic. This takes care of a couple + // known cases that attempt to mark channels as anonymous due + // to cross-origin redirects; since the response is entirely synthesized + // this is an unnecessary precaution. + // This should be removed when bug 1201683 is fixed. + if (synthesized && aLoadFlags != mLoadFlags) { + aLoadFlags &= ~LOAD_ANONYMOUS; + } + mLoadFlags = aLoadFlags; mForceMainDocumentChannel = (aLoadFlags & LOAD_DOCUMENT_URI); return NS_OK; @@ -1067,6 +1088,27 @@ HttpBaseChannel::nsContentEncodings::PrepareForNext(void) // HttpBaseChannel::nsIHttpChannel //----------------------------------------------------------------------------- +NS_IMETHODIMP +HttpBaseChannel::GetTransferSize(uint64_t *aTransferSize) +{ + *aTransferSize = mTransferSize; + return NS_OK; +} + +NS_IMETHODIMP +HttpBaseChannel::GetDecodedBodySize(uint64_t *aDecodedBodySize) +{ + *aDecodedBodySize = mDecodedBodySize; + return NS_OK; +} + +NS_IMETHODIMP +HttpBaseChannel::GetEncodedBodySize(uint64_t *aEncodedBodySize) +{ + *aEncodedBodySize = mEncodedBodySize; + return NS_OK; +} + NS_IMETHODIMP HttpBaseChannel::GetRequestMethod(nsACString& aMethod) { @@ -1752,6 +1794,30 @@ HttpBaseChannel::SetIsMainDocumentChannel(bool aValue) return NS_OK; } +NS_IMETHODIMP +HttpBaseChannel::GetProtocolVersion(nsACString& aProtocolVersion) +{ + nsresult rv; + nsCOMPtr ssl = do_QueryInterface(mSecurityInfo, &rv); + nsAutoCString protocol; + if (NS_SUCCEEDED(rv) && ssl && + NS_SUCCEEDED(ssl->GetNegotiatedNPN(protocol)) && + !protocol.IsEmpty()) { + // The negotiated protocol was not empty so we can use it. + aProtocolVersion = protocol; + return NS_OK; + } + + if (mResponseHead) { + uint32_t version = mResponseHead->Version(); + aProtocolVersion.Assign(nsHttp::GetProtocolVersion(version)); + return NS_OK; + } + + return NS_ERROR_NOT_AVAILABLE; +} + + //----------------------------------------------------------------------------- // HttpBaseChannel::nsIHttpChannelInternal //----------------------------------------------------------------------------- @@ -1853,7 +1919,7 @@ public: } private: - nsRefPtr mChannel; + RefPtr mChannel; NS_ConvertASCIItoUTF16 mCookie; }; @@ -1876,7 +1942,7 @@ HttpBaseChannel::SetCookie(const char *aCookieHeader) cs->SetCookieStringFromHttp(mURI, nullptr, nullptr, aCookieHeader, mResponseHead->PeekHeader(nsHttp::Date), this); if (NS_SUCCEEDED(rv)) { - nsRefPtr r = + RefPtr r = new CookieNotifierRunnable(this, aCookieHeader); NS_DispatchToMainThread(r); } @@ -2285,6 +2351,31 @@ HttpBaseChannel::GetEntityID(nsACString& aEntityID) return NS_OK; } +//----------------------------------------------------------------------------- +// HttpBaseChannel::nsIConsoleReportCollector +//----------------------------------------------------------------------------- + +void +HttpBaseChannel::AddConsoleReport(uint32_t aErrorFlags, + const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, + uint32_t aLineNumber, uint32_t aColumnNumber, + const nsACString& aMessageName, + const nsTArray& aStringParams) +{ + mReportCollector->AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, + aSourceFileURI, aLineNumber, + aColumnNumber, aMessageName, + aStringParams); +} + +void +HttpBaseChannel::FlushConsoleReports(nsIDocument* aDocument) +{ + mReportCollector->FlushConsoleReports(aDocument); +} + nsIPrincipal * HttpBaseChannel::GetURIPrincipal() { @@ -2330,10 +2421,8 @@ HttpBaseChannel::ShouldIntercept() GetCallback(controller); bool shouldIntercept = false; if (controller && !BypassServiceWorker() && mLoadInfo) { - nsContentPolicyType type = mLoadInfo->InternalContentPolicyType(); nsresult rv = controller->ShouldPrepareForIntercept(mURI, - IsNavigation(), - type, + nsContentUtils::IsNonSubresourceRequest(this), &shouldIntercept); if (NS_FAILED(rv)) { return false; @@ -2374,6 +2463,7 @@ HttpBaseChannel::ReleaseListeners() mListenerContext = nullptr; mCallbacks = nullptr; mProgressSink = nullptr; + mCompressListener = nullptr; } void diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 66ea86c554..9f445f8a37 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -15,6 +15,7 @@ #include "nsHttpRequestHead.h" #include "nsHttpResponseHead.h" #include "nsHttpConnectionInfo.h" +#include "nsIConsoleReportCollector.h" #include "nsIEncodedChannel.h" #include "nsIHttpChannel.h" #include "nsHttpHandler.h" @@ -48,6 +49,9 @@ class nsISecurityConsoleMessage; class nsIPrincipal; namespace mozilla { + +class LogCollector; + namespace net { /* @@ -70,6 +74,7 @@ class HttpBaseChannel : public nsHashPropertyBag , public PrivateBrowsingChannel , public nsITimedChannel , public nsIForcePendingChannel + , public nsIConsoleReportCollector { protected: virtual ~HttpBaseChannel(); @@ -159,9 +164,13 @@ public: NS_IMETHOD GetRequestSucceeded(bool *aValue) override; NS_IMETHOD RedirectTo(nsIURI *newURI) override; NS_IMETHOD GetSchedulingContextID(nsID *aSCID) override; + NS_IMETHOD GetTransferSize(uint64_t *aTransferSize) override; + NS_IMETHOD GetDecodedBodySize(uint64_t *aDecodedBodySize) override; + NS_IMETHOD GetEncodedBodySize(uint64_t *aEncodedBodySize) override; NS_IMETHOD SetSchedulingContextID(const nsID aSCID) override; NS_IMETHOD GetIsMainDocumentChannel(bool* aValue) override; NS_IMETHOD SetIsMainDocumentChannel(bool aValue) override; + NS_IMETHOD GetProtocolVersion(nsACString & aProtocolVersion) override; // nsIHttpChannelInternal NS_IMETHOD GetDocumentURI(nsIURI **aDocumentURI) override; @@ -225,6 +234,19 @@ public: // nsIResumableChannel NS_IMETHOD GetEntityID(nsACString& aEntityID) override; + + // nsIConsoleReportCollector + void + AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory, + nsContentUtils::PropertiesFile aPropertiesFile, + const nsACString& aSourceFileURI, + uint32_t aLineNumber, uint32_t aColumnNumber, + const nsACString& aMessageName, + const nsTArray& aStringParams) override; + + void + FlushConsoleReports(nsIDocument* aDocument) override; + class nsContentEncodings : public nsIUTF8StringEnumerator { public: @@ -337,11 +359,14 @@ protected: nsCOMPtr mReferrer; nsCOMPtr mApplicationCache; + // An instance of nsHTTPCompressConv + nsCOMPtr mCompressListener; + nsHttpRequestHead mRequestHead; nsCOMPtr mUploadStream; nsCOMPtr mUploadCloneableCallback; nsAutoPtr mResponseHead; - nsRefPtr mConnectionInfo; + RefPtr mConnectionInfo; nsCOMPtr mProxyInfo; nsCOMPtr mSecurityInfo; @@ -418,7 +443,7 @@ protected: uint32_t mContentDispositionHint; nsAutoPtr mContentDispositionFilename; - nsRefPtr mHttpHandler; // keep gHttpHandler alive + RefPtr mHttpHandler; // keep gHttpHandler alive uint32_t mReferrerPolicy; @@ -457,6 +482,10 @@ protected: // than once. bool mOnStartRequestCalled; + uint64_t mTransferSize; + uint64_t mDecodedBodySize; + uint64_t mEncodedBodySize; + // The network interface id that's associated with this channel. nsCString mNetworkInterfaceId; @@ -468,6 +497,8 @@ protected: nsTArray mUnsafeHeaders; nsCOMPtr mPreflightPrincipal; + nsCOMPtr mReportCollector; + bool mForceMainDocumentChannel; }; @@ -543,7 +574,7 @@ nsresult HttpAsyncAborter::AsyncCall(void (T::*funcPtr)(), { nsresult rv; - nsRefPtr > event = NS_NewRunnableMethod(mThis, funcPtr); + RefPtr > event = NS_NewRunnableMethod(mThis, funcPtr); rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv) && retval) { *retval = event; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 93fba2c920..33dd3b7c6b 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -35,6 +35,7 @@ #include "mozIThirdPartyUtil.h" #include "nsContentSecurityManager.h" #include "nsIDeprecationWarner.h" +#include "nsICompressConvStats.h" #ifdef OS_POSIX #include "chrome/common/file_descriptor_set_posix.h" @@ -67,7 +68,7 @@ static_assert(FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE == 250, class InterceptStreamListener : public nsIStreamListener , public nsIProgressEventSink { - nsRefPtr mOwner; + RefPtr mOwner; nsCOMPtr mContext; virtual ~InterceptStreamListener() {} public: @@ -179,10 +180,13 @@ HttpChannelChild::HttpChannelChild() , mSendResumeAt(false) , mIPCOpen(false) , mKeptAlive(false) + , mUnknownDecoderInvolved(false) , mDivertingToParent(false) , mFlushedForDiversion(false) , mSuspendSent(false) , mSynthesizedResponse(false) + , mShouldInterceptSubsequentRedirect(false) + , mRedirectingForSubsequentSynthesizedResponse(false) , mShouldParentIntercept(false) { LOG(("Creating HttpChannelChild @%x\n", this)); @@ -500,6 +504,7 @@ HttpChannelChild::DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext) if (mDivertingToParent) { mListener = nullptr; mListenerContext = nullptr; + mCompressListener = nullptr; if (mLoadGroup) { mLoadGroup->RemoveRequest(this, nullptr, mStatus); } @@ -513,6 +518,7 @@ HttpChannelChild::DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext) Cancel(rv); } else if (listener) { mListener = listener; + mCompressListener = listener; } } @@ -580,6 +586,42 @@ HttpChannelChild::RecvOnTransportAndData(const nsresult& channelStatus, return true; } +class MaybeDivertOnDataHttpEvent : public ChannelEvent +{ + public: + MaybeDivertOnDataHttpEvent(HttpChannelChild* child, + const nsCString& data, + const uint64_t& offset, + const uint32_t& count) + : mChild(child) + , mData(data) + , mOffset(offset) + , mCount(count) {} + + void Run() + { + mChild->MaybeDivertOnData(mData, mOffset, mCount); + } + + private: + HttpChannelChild* mChild; + nsCString mData; + uint64_t mOffset; + uint32_t mCount; +}; + +void +HttpChannelChild::MaybeDivertOnData(const nsCString& data, + const uint64_t& offset, + const uint32_t& count) +{ + LOG(("HttpChannelChild::MaybeDivertOnData [this=%p]", this)); + + if (mDivertingToParent) { + SendDivertOnDataAvailable(data, offset, count); + } +} + void HttpChannelChild::OnTransportAndData(const nsresult& channelStatus, const nsresult& transportStatus, @@ -607,6 +649,13 @@ HttpChannelChild::OnTransportAndData(const nsresult& channelStatus, if (mCanceled) return; + if (mUnknownDecoderInvolved) { + LOG(("UnknownDecoder is involved queue OnDataAvailable call. [this=%p]", + this)); + mUnknownDecoderEventQ.AppendElement( + new MaybeDivertOnDataHttpEvent(this, data, offset, count)); + } + // Hold queue lock throughout all three calls, else we might process a later // necko msg in between them. AutoEventEnqueuer ensureSerialDispatch(mEventQ); @@ -742,12 +791,42 @@ HttpChannelChild::RecvOnStopRequest(const nsresult& channelStatus, return true; } +class MaybeDivertOnStopHttpEvent : public ChannelEvent +{ + public: + MaybeDivertOnStopHttpEvent(HttpChannelChild* child, + const nsresult& channelStatus) + : mChild(child) + , mChannelStatus(channelStatus) + {} + + void Run() + { + mChild->MaybeDivertOnStop(mChannelStatus); + } + + private: + HttpChannelChild* mChild; + nsresult mChannelStatus; +}; + +void +HttpChannelChild::MaybeDivertOnStop(const nsresult& aChannelStatus) +{ + LOG(("HttpChannelChild::MaybeDivertOnStop [this=%p, " + "mDivertingToParent=%d status=%x]", this, mDivertingToParent, + aChannelStatus)); + if (mDivertingToParent) { + SendDivertOnStopRequest(aChannelStatus); + } +} + void HttpChannelChild::OnStopRequest(const nsresult& channelStatus, const ResourceTimingStruct& timing) { LOG(("HttpChannelChild::OnStopRequest [this=%p status=%x]\n", - this, channelStatus)); + this, channelStatus)); if (mDivertingToParent) { MOZ_RELEASE_ASSERT(!mFlushedForDiversion, @@ -757,6 +836,18 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus, return; } + if (mUnknownDecoderInvolved) { + LOG(("UnknownDecoder is involved queue OnStopRequest call. [this=%p]", + this)); + mUnknownDecoderEventQ.AppendElement( + new MaybeDivertOnStopHttpEvent(this, channelStatus)); + } + + nsCOMPtr conv = do_QueryInterface(mCompressListener); + if (conv) { + conv->GetDecodedDataLength(&mDecodedBodySize); + } + mTransactionTimings.domainLookupStart = timing.domainLookupStart; mTransactionTimings.domainLookupEnd = timing.domainLookupEnd; mTransactionTimings.connectStart = timing.connectStart; @@ -767,6 +858,8 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus, mAsyncOpenTime = timing.fetchStart; mRedirectStartTimeStamp = timing.redirectStart; mRedirectEndTimeStamp = timing.redirectEnd; + mTransferSize = timing.transferSize; + mEncodedBodySize = timing.encodedBodySize; nsPerformance* documentPerformance = GetPerformance(); if (documentPerformance) { @@ -1076,25 +1169,17 @@ HttpChannelChild::RecvRedirect1Begin(const uint32_t& newChannelId, return true; } -void -HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, - const URIParams& newUri, - const uint32_t& redirectFlags, - const nsHttpResponseHead& responseHead, - const nsACString& securityInfoSerialization) +nsresult +HttpChannelChild::SetupRedirect(nsIURI* uri, + const nsHttpResponseHead* responseHead, + nsIChannel** outChannel) { - LOG(("HttpChannelChild::Redirect1Begin [this=%p]\n", this)); + LOG(("HttpChannelChild::SetupRedirect [this=%p]\n", this)); nsresult rv; nsCOMPtr ioService; rv = gHttpHandler->GetIOService(getter_AddRefs(ioService)); - if (NS_FAILED(rv)) { - // Veto redirect. nsHttpChannel decides to cancel or continue. - OnRedirectVerifyCallback(rv); - return; - } - - nsCOMPtr uri = DeserializeURI(newUri); + NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr newChannel; rv = NS_NewChannelInternal(getter_AddRefs(newChannel), @@ -1104,33 +1189,19 @@ HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ioService); - - if (NS_FAILED(rv)) { - // Veto redirect. nsHttpChannel decides to cancel or continue. - OnRedirectVerifyCallback(rv); - return; - } + NS_ENSURE_SUCCESS(rv, rv); // We won't get OnStartRequest, set cookies here. - mResponseHead = new nsHttpResponseHead(responseHead); - - if (!securityInfoSerialization.IsEmpty()) { - NS_DeserializeObject(securityInfoSerialization, - getter_AddRefs(mSecurityInfo)); - } + mResponseHead = new nsHttpResponseHead(*responseHead); bool rewriteToGET = HttpBaseChannel::ShouldRewriteRedirectToGET(mResponseHead->Status(), mRequestHead.ParsedMethod()); rv = SetupReplacementChannel(uri, newChannel, !rewriteToGET); - if (NS_FAILED(rv)) { - // Veto redirect. nsHttpChannel decides to cancel or continue. - OnRedirectVerifyCallback(rv); - return; - } + NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr httpChannelChild = do_QueryInterface(newChannel); - if (mSynthesizedResponse && httpChannelChild) { + if (mShouldInterceptSubsequentRedirect && httpChannelChild) { // In the case where there was a synthesized response that caused a redirection, // we must force the new channel to intercept the request in the parent before a // network transaction is initiated. @@ -1138,15 +1209,64 @@ HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, } mRedirectChannelChild = do_QueryInterface(newChannel); - if (mRedirectChannelChild) { - mRedirectChannelChild->ConnectParent(newChannelId); + newChannel.forget(outChannel); + + return NS_OK; +} + +void +HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, + const URIParams& newUri, + const uint32_t& redirectFlags, + const nsHttpResponseHead& responseHead, + const nsACString& securityInfoSerialization) +{ + LOG(("HttpChannelChild::Redirect1Begin [this=%p]\n", this)); + + nsCOMPtr uri = DeserializeURI(newUri); + + if (!securityInfoSerialization.IsEmpty()) { + NS_DeserializeObject(securityInfoSerialization, + getter_AddRefs(mSecurityInfo)); + } + + nsCOMPtr newChannel; + nsresult rv = SetupRedirect(uri, + &responseHead, + getter_AddRefs(newChannel)); + + if (NS_SUCCEEDED(rv)) { + if (mRedirectChannelChild) { + mRedirectChannelChild->ConnectParent(newChannelId); + rv = gHttpHandler->AsyncOnChannelRedirect(this, + newChannel, + redirectFlags); + } else { + LOG((" redirecting to a protocol that doesn't implement" + " nsIChildChannel")); + rv = NS_ERROR_FAILURE; + } + } + + if (NS_FAILED(rv)) + OnRedirectVerifyCallback(rv); +} + +void +HttpChannelChild::BeginNonIPCRedirect(nsIURI* responseURI, + const nsHttpResponseHead* responseHead) +{ + LOG(("HttpChannelChild::BeginNonIPCRedirect [this=%p]\n", this)); + + nsCOMPtr newChannel; + nsresult rv = SetupRedirect(responseURI, + responseHead, + getter_AddRefs(newChannel)); + + if (NS_SUCCEEDED(rv)) { rv = gHttpHandler->AsyncOnChannelRedirect(this, newChannel, - redirectFlags); - } else { - LOG((" redirecting to a protocol that doesn't implement" - " nsIChildChannel")); - rv = NS_ERROR_FAILURE; + nsIChannelEventSink::REDIRECT_INTERNAL); } if (NS_FAILED(rv)) @@ -1255,7 +1375,7 @@ HttpChannelChild::Redirect3Complete() if (NS_SUCCEEDED(rv)) { if (mLoadInfo) { - mLoadInfo->AppendRedirectedPrincipal(GetURIPrincipal()); + mLoadInfo->AppendRedirectedPrincipal(GetURIPrincipal(), false); } } else { @@ -1354,6 +1474,34 @@ HttpChannelChild::CompleteRedirectSetup(nsIStreamListener *listener, // HttpChannelChild::nsIAsyncVerifyRedirectCallback //----------------------------------------------------------------------------- +class OverrideRunnable : public nsRunnable { + RefPtr mChannel; + RefPtr mNewChannel; + RefPtr mListener; + nsCOMPtr mInput; + nsAutoPtr mHead; + +public: + OverrideRunnable(HttpChannelChild* aChannel, + HttpChannelChild* aNewChannel, + InterceptStreamListener* aListener, + nsIInputStream* aInput, + nsAutoPtr& aHead) + : mChannel(aChannel) + , mNewChannel(aNewChannel) + , mListener(aListener) + , mInput(aInput) + , mHead(aHead) + { + } + + NS_IMETHOD Run() { + mChannel->Redirect3Complete(); + mNewChannel->OverrideWithSynthesizedResponse(mHead, mInput, mListener); + return NS_OK; + } +}; + NS_IMETHODIMP HttpChannelChild::OnRedirectVerifyCallback(nsresult result) { @@ -1367,8 +1515,24 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result) newHttpChannel->SetOriginalURI(mOriginalURI); } + if (mRedirectingForSubsequentSynthesizedResponse) { + nsCOMPtr httpChannelChild = do_QueryInterface(mRedirectChannelChild); + MOZ_ASSERT(httpChannelChild); + RefPtr redirectedChannel = + static_cast(httpChannelChild.get()); + + RefPtr streamListener = + new InterceptStreamListener(redirectedChannel, mListenerContext); + + NS_DispatchToMainThread(new OverrideRunnable(this, redirectedChannel, + streamListener, mSynthesizedInput, + mResponseHead)); + return NS_OK; + } + RequestHeaderTuples emptyHeaders; RequestHeaderTuples* headerTuples = &emptyHeaders; + nsLoadFlags loadFlags = 0; nsCOMPtr newHttpChannelChild = do_QueryInterface(mRedirectChannelChild); @@ -1401,10 +1565,15 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result) SerializeURI(apiRedirectURI, redirectURI); } } + + nsCOMPtr request = do_QueryInterface(mRedirectChannelChild); + if (request) { + request->GetLoadFlags(&loadFlags); + } } if (mIPCOpen) - SendRedirect2Verify(result, *headerTuples, redirectURI); + SendRedirect2Verify(result, *headerTuples, loadFlags, redirectURI); return NS_OK; } @@ -1572,7 +1741,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) mInterceptListener = new InterceptStreamListener(this, mListenerContext); - nsRefPtr intercepted = + RefPtr intercepted = new InterceptedChannelContent(this, controller, mInterceptListener); intercepted->NotifyController(); return NS_OK; @@ -2248,6 +2417,41 @@ HttpChannelChild::DivertToParent(ChannelDiverterChild **aChild) return NS_OK; } +NS_IMETHODIMP +HttpChannelChild::UnknownDecoderInvolvedKeepData() +{ + LOG(("HttpChannelChild::UnknownDecoderInvolvedKeepData [this=%p]", + this)); + mUnknownDecoderInvolved = true; + return NS_OK; +} + +NS_IMETHODIMP +HttpChannelChild::UnknownDecoderInvolvedOnStartRequestCalled() +{ + LOG(("HttpChannelChild::UnknownDecoderInvolvedOnStartRequestCalled " + "[this=%p, mDivertingToParent=%d]", this, mDivertingToParent)); + mUnknownDecoderInvolved = false; + + nsresult rv = NS_OK; + + if (mDivertingToParent) { + rv = mEventQ->PrependEvents(mUnknownDecoderEventQ); + } + mUnknownDecoderEventQ.Clear(); + + return rv; +} + +NS_IMETHODIMP +HttpChannelChild::GetDivertingToParent(bool* aDiverting) +{ + NS_ENSURE_ARG_POINTER(aDiverting); + *aDiverting = mDivertingToParent; + return NS_OK; +} + + void HttpChannelChild::ResetInterception() { @@ -2276,8 +2480,10 @@ HttpChannelChild::GetResponseSynthesized(bool* aSynthesized) void HttpChannelChild::OverrideWithSynthesizedResponse(nsAutoPtr& aResponseHead, nsIInputStream* aSynthesizedInput, - nsIStreamListener* aStreamListener) + InterceptStreamListener* aStreamListener) { + mInterceptListener = aStreamListener; + // Intercepted responses should already be decoded. If its a redirect, // however, we want to respect the encoding of the final result instead. if (!WillRedirect(aResponseHead)) { @@ -2288,6 +2494,7 @@ HttpChannelChild::OverrideWithSynthesizedResponse(nsAutoPtr& mSynthesizedResponse = true; if (WillRedirect(mResponseHead)) { + mShouldInterceptSubsequentRedirect = true; // Continue with the original cross-process request nsresult rv = ContinueAsyncOpen(); NS_ENSURE_SUCCESS_VOID(rv); @@ -2335,6 +2542,20 @@ HttpChannelChild::ForceIntercepted() return NS_OK; } +NS_IMETHODIMP +HttpChannelChild::ForceIntercepted(uint64_t aInterceptionID) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +void +HttpChannelChild::ForceIntercepted(nsIInputStream* aSynthesizedInput) +{ + mSynthesizedInput = aSynthesizedInput; + mSynthesizedResponse = true; + mRedirectingForSubsequentSynthesizedResponse = true; +} + bool HttpChannelChild::RecvIssueDeprecationWarning(const uint32_t& warning, const bool& asError) diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index 541dbec1d9..21809e1862 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -37,6 +37,7 @@ namespace net { class InterceptedChannelContent; class InterceptStreamListener; +class OverrideRunnable; class HttpChannelChild final : public PHttpChannelChild , public HttpBaseChannel @@ -88,6 +89,7 @@ public: NS_IMETHOD GetLocalPort(int32_t* port) override; NS_IMETHOD GetRemoteAddress(nsACString& addr) override; NS_IMETHOD GetRemotePort(int32_t* port) override; + NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override; // nsISupportsPriority NS_IMETHOD SetPriority(int32_t value) override; // nsIClassOfService @@ -174,12 +176,16 @@ private: // asynchronously read from the pump. void OverrideWithSynthesizedResponse(nsAutoPtr& aResponseHead, nsIInputStream* aSynthesizedInput, - nsIStreamListener* aStreamListener); + InterceptStreamListener* aStreamListener); + + void ForceIntercepted(nsIInputStream* aSynthesizedInput); RequestHeaderTuples mClientSetRequestHeaders; nsCOMPtr mRedirectChannelChild; - nsRefPtr mInterceptListener; - nsRefPtr mSynthesizedResponsePump; + RefPtr mInterceptListener; + RefPtr mSynthesizedResponsePump; + nsAutoPtr mSynthesizedResponseHead; + nsCOMPtr mSynthesizedInput; int64_t mSynthesizedStreamLength; bool mIsFromCache; @@ -193,7 +199,13 @@ private: bool mIPCOpen; bool mKeptAlive; // IPC kept open, but only for security info - nsRefPtr mEventQ; + RefPtr mEventQ; + + // If nsUnknownDecoder is involved OnStartRequest call will be delayed and + // this queue keeps OnDataAvailable data until OnStartRequest is finally + // called. + nsTArray> mUnknownDecoderEventQ; + bool mUnknownDecoderInvolved; // Once set, OnData and possibly OnStop will be diverted to the parent. bool mDivertingToParent; @@ -208,6 +220,13 @@ private: // should be intercepted. bool mSynthesizedResponse; + // Set if a synthesized response should cause us to explictly allows intercepting + // an expected forthcoming redirect. + bool mShouldInterceptSubsequentRedirect; + // Set if a redirection is being initiated to facilitate providing a synthesized + // response to a channel using a different principal than the current one. + bool mRedirectingForSubsequentSynthesizedResponse; + // Set if the corresponding parent channel should force an interception to occur // before the network transaction is initiated. bool mShouldParentIntercept; @@ -229,6 +248,9 @@ private: const NetAddr& selfAddr, const NetAddr& peerAddr, const uint32_t& cacheKey); + void MaybeDivertOnData(const nsCString& data, + const uint64_t& offset, + const uint32_t& count); void OnTransportAndData(const nsresult& channelStatus, const nsresult& status, const uint64_t progress, @@ -237,6 +259,7 @@ private: const uint64_t& offset, const uint32_t& count); void OnStopRequest(const nsresult& channelStatus, const ResourceTimingStruct& timing); + void MaybeDivertOnStop(const nsresult& aChannelStatus); void OnProgress(const int64_t& progress, const int64_t& progressMax); void OnStatus(const nsresult& status); void FailedAsyncOpen(const nsresult& status); @@ -249,10 +272,22 @@ private: void Redirect3Complete(); void DeleteSelf(); + // Create a a new channel to be used in a redirection, based on the provided + // response headers. + nsresult SetupRedirect(nsIURI* uri, + const nsHttpResponseHead* responseHead, + nsIChannel** outChannel); + + // Perform a redirection without communicating with the parent process at all. + void BeginNonIPCRedirect(nsIURI* responseURI, + const nsHttpResponseHead* responseHead); + friend class AssociateApplicationCacheEvent; friend class StartRequestEvent; friend class StopRequestEvent; friend class TransportAndDataEvent; + friend class MaybeDivertOnDataHttpEvent; + friend class MaybeDivertOnStopHttpEvent; friend class ProgressEvent; friend class StatusEvent; friend class FailedAsyncOpenEvent; @@ -262,6 +297,7 @@ private: friend class HttpAsyncAborter; friend class InterceptStreamListener; friend class InterceptedChannelContent; + friend class OverrideRunnable; }; //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 59befa62f2..636aa34e64 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -150,6 +150,7 @@ NS_IMPL_ISUPPORTS(HttpChannelParent, nsIProgressEventSink, nsIRequestObserver, nsIStreamListener, + nsIPackagedAppChannelListener, nsIParentChannel, nsIAuthPromptProvider, nsIParentRedirectingChannel, @@ -157,8 +158,8 @@ NS_IMPL_ISUPPORTS(HttpChannelParent, nsIDeprecationWarner) NS_IMETHODIMP -HttpChannelParent::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, - nsContentPolicyType aType, +HttpChannelParent::ShouldPrepareForIntercept(nsIURI* aURI, + bool aIsNonSubresourceRequest, bool* aShouldIntercept) { *aShouldIntercept = mShouldIntercept; @@ -198,7 +199,9 @@ public: NS_IMETHOD Run() { - mChannel->FinishSynthesizedResponse(); + // The URL passed as an argument here doesn't matter, since the child will + // receive a redirection notification as a result of this synthesized response. + mChannel->FinishSynthesizedResponse(EmptyCString()); return NS_OK; } }; @@ -222,7 +225,7 @@ private: } nsCOMPtr mChannel; - nsRefPtr mParentChannel; + RefPtr mParentChannel; }; NS_IMPL_ISUPPORTS(ResponseSynthesizer, nsIFetchEventDispatcher) @@ -239,7 +242,7 @@ NS_IMETHODIMP HttpChannelParent::ChannelIntercepted(nsIInterceptedChannel* aChannel, nsIFetchEventDispatcher** aDispatcher) { - nsRefPtr dispatcher = + RefPtr dispatcher = new ResponseSynthesizer(aChannel, this); dispatcher.forget(aDispatcher); return NS_OK; @@ -690,6 +693,7 @@ HttpChannelParent::RecvUpdateAssociatedContentSecurity(const int32_t& broken, bool HttpChannelParent::RecvRedirect2Verify(const nsresult& result, const RequestHeaderTuples& changedHeaders, + const uint32_t& loadFlags, const OptionalURIParams& aAPIRedirectURI) { LOG(("HttpChannelParent::RecvRedirect2Verify [this=%p result=%x]\n", @@ -713,6 +717,12 @@ HttpChannelParent::RecvRedirect2Verify(const nsresult& result, changedHeaders[i].mMerge); } } + + // A successfully redirected channel must have the LOAD_REPLACE flag. + MOZ_ASSERT(loadFlags & nsIChannel::LOAD_REPLACE); + if (loadFlags & nsIChannel::LOAD_REPLACE) { + newHttpChannel->SetLoadFlags(loadFlags); + } } } @@ -1009,6 +1019,19 @@ HttpChannelParent::RecvRemoveCorsPreflightCacheEntry(const URIParams& uri, return true; } +//----------------------------------------------------------------------------- +// HttpChannelParent::nsIPackagedAppChannelListener +//----------------------------------------------------------------------------- + +NS_IMETHODIMP +HttpChannelParent::OnStartSignedPackageRequest(const nsACString& aPackageId) +{ + if (mTabParent) { + mTabParent->OnStartSignedPackageRequest(mChannel); + } + return NS_OK; +} + //----------------------------------------------------------------------------- // HttpChannelParent::nsIRequestObserver //----------------------------------------------------------------------------- @@ -1121,6 +1144,10 @@ HttpChannelParent::OnStopRequest(nsIRequest *aRequest, mChannel->GetAsyncOpen(&timing.fetchStart); mChannel->GetRedirectStart(&timing.redirectStart); mChannel->GetRedirectEnd(&timing.redirectEnd); + mChannel->GetTransferSize(&timing.transferSize); + mChannel->GetEncodedBodySize(&timing.encodedBodySize); + // decodedBodySize can be computed in the child process so it doesn't need + // to be passed down. if (mIPCClosed || !SendOnStopRequest(aStatusCode, timing)) return NS_ERROR_UNEXPECTED; @@ -1464,7 +1491,7 @@ public: return NS_OK; } private: - nsRefPtr mChannelParent; + RefPtr mChannelParent; nsresult mErrorCode; bool mSkipResume; }; diff --git a/netwerk/protocol/http/HttpChannelParent.h b/netwerk/protocol/http/HttpChannelParent.h index d500c04702..0758a445f1 100644 --- a/netwerk/protocol/http/HttpChannelParent.h +++ b/netwerk/protocol/http/HttpChannelParent.h @@ -22,6 +22,7 @@ #include "mozilla/dom/ipc/IdType.h" #include "nsINetworkInterceptController.h" #include "nsIDeprecationWarner.h" +#include "nsIPackagedAppChannelListener.h" class nsICacheEntry; class nsIAssociatedContentSecurity; @@ -46,6 +47,7 @@ class HttpChannelParent final : public PHttpChannelParent , public nsINetworkInterceptController , public nsIDeprecationWarner , public DisconnectableParent + , public nsIPackagedAppChannelListener , public HttpChannelSecurityWarningReporter { virtual ~HttpChannelParent(); @@ -54,6 +56,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER + NS_DECL_NSIPACKAGEDAPPCHANNELLISTENER NS_DECL_NSIPARENTCHANNEL NS_DECL_NSIPARENTREDIRECTINGCHANNEL NS_DECL_NSIPROGRESSEVENTSINK @@ -136,6 +139,7 @@ protected: virtual bool RecvCancel(const nsresult& status) override; virtual bool RecvRedirect2Verify(const nsresult& result, const RequestHeaderTuples& changedHeaders, + const uint32_t& loadFlags, const OptionalURIParams& apiRedirectUri) override; virtual bool RecvUpdateAssociatedContentSecurity(const int32_t& broken, const int32_t& no) override; @@ -157,7 +161,7 @@ protected: void FailDiversion(nsresult aErrorCode, bool aSkipResume = true); friend class HttpChannelParentListener; - nsRefPtr mTabParent; + RefPtr mTabParent; void OfflineDisconnect() override; uint32_t GetAppId() override; @@ -181,7 +185,7 @@ private: friend class DivertCompleteEvent; friend class ResponseSynthesizer; - nsRefPtr mChannel; + RefPtr mChannel; nsCOMPtr mCacheEntry; nsCOMPtr mAssociatedContentSecurity; Atomic mIPCClosed; // PHttpChannel actor has been Closed() @@ -201,16 +205,16 @@ private: bool mSentRedirect1BeginFailed : 1; bool mReceivedRedirect2Verify : 1; - nsRefPtr mObserver; + RefPtr mObserver; PBOverrideStatus mPBOverride; nsCOMPtr mLoadContext; - nsRefPtr mHttpHandler; + RefPtr mHttpHandler; nsAutoPtr mSynthesizedResponseHead; - nsRefPtr mParentListener; + RefPtr mParentListener; // This is listener we are diverting to. nsCOMPtr mDivertListener; // Set to the canceled status value if the main channel was canceled. @@ -235,7 +239,7 @@ private: // Handle to the channel wrapper if this channel has been intercepted. nsCOMPtr mInterceptedChannel; - nsRefPtr mEventQ; + RefPtr mEventQ; }; } // namespace net diff --git a/netwerk/protocol/http/HttpChannelParentListener.cpp b/netwerk/protocol/http/HttpChannelParentListener.cpp index b0a2573660..e63487ca10 100644 --- a/netwerk/protocol/http/HttpChannelParentListener.cpp +++ b/netwerk/protocol/http/HttpChannelParentListener.cpp @@ -12,6 +12,7 @@ #include "mozilla/unused.h" #include "nsIRedirectChannelRegistrar.h" #include "nsIHttpEventSink.h" +#include "nsIPackagedAppChannelListener.h" using mozilla::unused; @@ -38,6 +39,7 @@ NS_IMPL_ISUPPORTS(HttpChannelParentListener, nsIStreamListener, nsIRequestObserver, nsIChannelEventSink, + nsIPackagedAppChannelListener, nsIRedirectResultListener) //----------------------------------------------------------------------------- @@ -97,6 +99,22 @@ HttpChannelParentListener::OnDataAvailable(nsIRequest *aRequest, return mNextListener->OnDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount); } +//----------------------------------------------------------------------------- +// HttpChannelParentListener::nsIPackagedAppChannelListener +//----------------------------------------------------------------------------- +NS_IMETHODIMP +HttpChannelParentListener::OnStartSignedPackageRequest(const nsACString& aPackageId) +{ + nsCOMPtr listener = do_QueryInterface(mNextListener); + if (listener) { + listener->OnStartSignedPackageRequest(aPackageId); + } else { + NS_WARNING("mNextListener is not nsIPackagedAppChannelListener"); + } + + return NS_OK; +} + //----------------------------------------------------------------------------- // HttpChannelParentListener::nsIInterfaceRequestor //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/HttpChannelParentListener.h b/netwerk/protocol/http/HttpChannelParentListener.h index f7fa16d14c..d73050c49b 100644 --- a/netwerk/protocol/http/HttpChannelParentListener.h +++ b/netwerk/protocol/http/HttpChannelParentListener.h @@ -11,6 +11,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIChannelEventSink.h" #include "nsIRedirectResultListener.h" +#include "nsIPackagedAppChannelListener.h" namespace mozilla { namespace net { @@ -20,12 +21,14 @@ class HttpChannelParent; class HttpChannelParentListener final : public nsIInterfaceRequestor , public nsIChannelEventSink , public nsIRedirectResultListener + , public nsIPackagedAppChannelListener , public nsIStreamListener { public: NS_DECL_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSICHANNELEVENTSINK + NS_DECL_NSIPACKAGEDAPPCHANNELLISTENER NS_DECL_NSIREDIRECTRESULTLISTENER NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER diff --git a/netwerk/protocol/http/InterceptedChannel.cpp b/netwerk/protocol/http/InterceptedChannel.cpp index fd266e5509..dd01c459b0 100644 --- a/netwerk/protocol/http/InterceptedChannel.cpp +++ b/netwerk/protocol/http/InterceptedChannel.cpp @@ -30,10 +30,8 @@ DoAddCacheEntryHeaders(nsHttpChannel *self, NS_IMPL_ISUPPORTS(InterceptedChannelBase, nsIInterceptedChannel) -InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController, - bool aIsNavigation) +InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController) : mController(aController) -, mIsNavigation(aIsNavigation) { } @@ -74,13 +72,6 @@ InterceptedChannelBase::DoNotifyController() mController = nullptr; } -NS_IMETHODIMP -InterceptedChannelBase::GetIsNavigation(bool* aIsNavigation) -{ - *aIsNavigation = mIsNavigation; - return NS_OK; -} - nsresult InterceptedChannelBase::DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason) { @@ -112,7 +103,7 @@ InterceptedChannelBase::DoSynthesizeHeader(const nsACString& aName, const nsACSt InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel, nsINetworkInterceptController* aController, nsICacheEntry* aEntry) -: InterceptedChannelBase(aController, aChannel->IsNavigation()) +: InterceptedChannelBase(aController) , mChannel(aChannel) , mSynthesizedCacheEntry(aEntry) { @@ -186,7 +177,7 @@ InterceptedChannelChrome::SynthesizeHeader(const nsACString& aName, const nsACSt } NS_IMETHODIMP -InterceptedChannelChrome::FinishSynthesizedResponse() +InterceptedChannelChrome::FinishSynthesizedResponse(const nsACString& aFinalURLSpec) { if (!mChannel) { return NS_ERROR_NOT_AVAILABLE; @@ -215,23 +206,38 @@ InterceptedChannelChrome::FinishSynthesizedResponse() mSynthesizedResponseHead.ref(), securityInfo); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr uri; - mChannel->GetURI(getter_AddRefs(uri)); + nsCOMPtr originalURI; + mChannel->GetURI(getter_AddRefs(originalURI)); - bool usingSSL = false; - uri->SchemeIs("https", &usingSSL); - - // Then we open a real cache entry to read the synthesized response from. - rv = mChannel->OpenCacheEntry(usingSSL); - NS_ENSURE_SUCCESS(rv, rv); - - mSynthesizedCacheEntry = nullptr; - - if (!mChannel->AwaitingCacheCallbacks()) { - rv = mChannel->ContinueConnect(); + nsCOMPtr responseURI; + if (!aFinalURLSpec.IsEmpty()) { + nsresult rv = NS_NewURI(getter_AddRefs(responseURI), aFinalURLSpec); NS_ENSURE_SUCCESS(rv, rv); + } else { + responseURI = originalURI; } + bool equal = false; + originalURI->Equals(responseURI, &equal); + if (!equal) { + nsresult rv = + mChannel->StartRedirectChannelToURI(responseURI, nsIChannelEventSink::REDIRECT_INTERNAL); + NS_ENSURE_SUCCESS(rv, rv); + } else { + bool usingSSL = false; + responseURI->SchemeIs("https", &usingSSL); + + // Then we open a real cache entry to read the synthesized response from. + rv = mChannel->OpenCacheEntry(usingSSL); + NS_ENSURE_SUCCESS(rv, rv); + + mSynthesizedCacheEntry = nullptr; + + if (!mChannel->AwaitingCacheCallbacks()) { + rv = mChannel->ContinueConnect(); + NS_ENSURE_SUCCESS(rv, rv); + } + } mChannel = nullptr; return NS_OK; } @@ -276,8 +282,8 @@ InterceptedChannelChrome::GetInternalContentPolicyType(nsContentPolicyType* aPol InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel, nsINetworkInterceptController* aController, - nsIStreamListener* aListener) -: InterceptedChannelBase(aController, aChannel->IsNavigation()) + InterceptStreamListener* aListener) +: InterceptedChannelBase(aController) , mChannel(aChannel) , mStreamListener(aListener) { @@ -337,7 +343,7 @@ InterceptedChannelContent::SynthesizeHeader(const nsACString& aName, const nsACS } NS_IMETHODIMP -InterceptedChannelContent::FinishSynthesizedResponse() +InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURLSpec) { if (NS_WARN_IF(!mChannel)) { return NS_ERROR_NOT_AVAILABLE; @@ -345,9 +351,27 @@ InterceptedChannelContent::FinishSynthesizedResponse() EnsureSynthesizedResponse(); - mChannel->OverrideWithSynthesizedResponse(mSynthesizedResponseHead.ref(), - mSynthesizedInput, - mStreamListener); + nsCOMPtr originalURI; + mChannel->GetURI(getter_AddRefs(originalURI)); + + nsCOMPtr responseURI; + if (!aFinalURLSpec.IsEmpty()) { + nsresult rv = NS_NewURI(getter_AddRefs(responseURI), aFinalURLSpec); + NS_ENSURE_SUCCESS(rv, rv); + } else { + responseURI = originalURI; + } + + bool equal = false; + originalURI->Equals(responseURI, &equal); + if (!equal) { + mChannel->ForceIntercepted(mSynthesizedInput); + mChannel->BeginNonIPCRedirect(responseURI, *mSynthesizedResponseHead.ptr()); + } else { + mChannel->OverrideWithSynthesizedResponse(mSynthesizedResponseHead.ref(), + mSynthesizedInput, + mStreamListener); + } mResponseBody = nullptr; mChannel = nullptr; diff --git a/netwerk/protocol/http/InterceptedChannel.h b/netwerk/protocol/http/InterceptedChannel.h index dfb432efcd..3e134d04a7 100644 --- a/netwerk/protocol/http/InterceptedChannel.h +++ b/netwerk/protocol/http/InterceptedChannel.h @@ -8,7 +8,7 @@ #define InterceptedChannel_h #include "nsINetworkInterceptController.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "mozilla/Maybe.h" class nsICacheEntry; @@ -21,6 +21,7 @@ namespace net { class nsHttpChannel; class HttpChannelChild; class nsHttpResponseHead; +class InterceptStreamListener; // An object representing a channel that has been intercepted. This avoids complicating // the actual channel implementation with the details of synthesizing responses. @@ -35,9 +36,6 @@ protected: // Response head for use when synthesizing Maybe> mSynthesizedResponseHead; - // Whether this intercepted channel was performing a navigation. - bool mIsNavigation; - void EnsureSynthesizedResponse(); void DoNotifyController(); nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason); @@ -45,8 +43,7 @@ protected: virtual ~InterceptedChannelBase(); public: - InterceptedChannelBase(nsINetworkInterceptController* aController, - bool aIsNavigation); + explicit InterceptedChannelBase(nsINetworkInterceptController* aController); // Notify the interception controller that the channel has been intercepted // and prepare the response body output stream. @@ -55,13 +52,12 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override; - NS_IMETHOD GetIsNavigation(bool* aIsNavigation) override; }; class InterceptedChannelChrome : public InterceptedChannelBase { // The actual channel being intercepted. - nsRefPtr mChannel; + RefPtr mChannel; // Writeable cache entry for use when synthesizing a response in a parent process nsCOMPtr mSynthesizedCacheEntry; @@ -77,7 +73,7 @@ public: nsICacheEntry* aEntry); NS_IMETHOD ResetInterception() override; - NS_IMETHOD FinishSynthesizedResponse() override; + NS_IMETHOD FinishSynthesizedResponse(const nsACString& aFinalURLSpec) override; NS_IMETHOD GetChannel(nsIChannel** aChannel) override; NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override; NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override; @@ -91,21 +87,21 @@ public: class InterceptedChannelContent : public InterceptedChannelBase { // The actual channel being intercepted. - nsRefPtr mChannel; + RefPtr mChannel; // Reader-side of the response body when synthesizing in a child proces nsCOMPtr mSynthesizedInput; // Listener for the synthesized response to fix up the notifications before they reach // the actual channel. - nsCOMPtr mStreamListener; + RefPtr mStreamListener; public: InterceptedChannelContent(HttpChannelChild* aChannel, nsINetworkInterceptController* aController, - nsIStreamListener* aListener); + InterceptStreamListener* aListener); NS_IMETHOD ResetInterception() override; - NS_IMETHOD FinishSynthesizedResponse() override; + NS_IMETHOD FinishSynthesizedResponse(const nsACString& aFinalURLSpec) override; NS_IMETHOD GetChannel(nsIChannel** aChannel) override; NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override; NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override; diff --git a/netwerk/protocol/http/NullHttpChannel.cpp b/netwerk/protocol/http/NullHttpChannel.cpp index 90186b48b7..39a9dd76b5 100644 --- a/netwerk/protocol/http/NullHttpChannel.cpp +++ b/netwerk/protocol/http/NullHttpChannel.cpp @@ -56,6 +56,18 @@ NullHttpChannel::Init(nsIURI *aURI, // NullHttpChannel::nsIHttpChannel //----------------------------------------------------------------------------- +NS_IMETHODIMP +NullHttpChannel::GetTransferSize(uint64_t *aTransferSize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +NullHttpChannel::GetDecodedBodySize(uint64_t *aDecodedBodySize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP NullHttpChannel::GetRequestMethod(nsACString & aRequestMethod) { @@ -232,6 +244,18 @@ NullHttpChannel::SetSchedulingContextID(const nsID scID) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +NullHttpChannel::GetProtocolVersion(nsACString& aProtocolVersion) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +NullHttpChannel::GetEncodedBodySize(uint64_t *aEncodedBodySize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + //----------------------------------------------------------------------------- // NullHttpChannel::nsIChannel //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/NullHttpTransaction.cpp b/netwerk/protocol/http/NullHttpTransaction.cpp index 2396044200..73790abbd7 100644 --- a/netwerk/protocol/http/NullHttpTransaction.cpp +++ b/netwerk/protocol/http/NullHttpTransaction.cpp @@ -62,7 +62,7 @@ public: return NS_OK; } - nsRefPtr channel = new NullHttpChannel(); + RefPtr channel = new NullHttpChannel(); channel->Init(uri, 0, nullptr, 0, nullptr); mActivityDistributor->ObserveActivity( nsCOMPtr(do_QueryObject(channel)), @@ -269,7 +269,7 @@ NullHttpTransaction::RequestHead() nsresult NullHttpTransaction::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/netwerk/protocol/http/NullHttpTransaction.h b/netwerk/protocol/http/NullHttpTransaction.h index b3e4be47e1..feba6c977d 100644 --- a/netwerk/protocol/http/NullHttpTransaction.h +++ b/netwerk/protocol/http/NullHttpTransaction.h @@ -70,9 +70,9 @@ private: bool mClaimed; protected: - nsRefPtr mConnection; + RefPtr mConnection; nsCOMPtr mCallbacks; - nsRefPtr mConnectionInfo; + RefPtr mConnectionInfo; nsCOMPtr mActivityDistributor; }; diff --git a/netwerk/protocol/http/PHttpChannel.ipdl b/netwerk/protocol/http/PHttpChannel.ipdl index 04a24579a7..203e65cedd 100644 --- a/netwerk/protocol/http/PHttpChannel.ipdl +++ b/netwerk/protocol/http/PHttpChannel.ipdl @@ -47,7 +47,7 @@ parent: // Reports approval/veto of redirect by child process redirect observers Redirect2Verify(nsresult result, RequestHeaderTuples changedHeaders, - OptionalURIParams apiRedirectTo); + uint32_t loadFlags, OptionalURIParams apiRedirectTo); // For document loads we keep this protocol open after child's // OnStopRequest, and send this msg (instead of __delete__) to allow diff --git a/netwerk/protocol/http/PackagedAppService.cpp b/netwerk/protocol/http/PackagedAppService.cpp index 6a944c16c0..e9faf82582 100644 --- a/netwerk/protocol/http/PackagedAppService.cpp +++ b/netwerk/protocol/http/PackagedAppService.cpp @@ -59,7 +59,7 @@ PackagedAppService::CacheEntryWriter::Create(nsIURI *aURI, nsICacheStorage *aStorage, CacheEntryWriter **aResult) { - nsRefPtr writer = new CacheEntryWriter(); + RefPtr writer = new CacheEntryWriter(); nsresult rv = aStorage->OpenTruncate(aURI, EmptyCString(), getter_AddRefs(writer->mEntry)); if (NS_FAILED(rv)) { @@ -253,7 +253,7 @@ PackagedAppService::CacheEntryWriter::CopyHeadersFromChannel(nsIChannel *aChanne return NS_ERROR_FAILURE; } - nsRefPtr headerCopier = new HeaderCopier(aHead); + RefPtr headerCopier = new HeaderCopier(aHead); return httpChan->VisitResponseHeaders(headerCopier); } @@ -578,14 +578,19 @@ PackagedAppService::PackagedAppDownloader::FinalizeDownload(nsresult aStatusCode aStatusCode = NS_ERROR_FILE_NOT_FOUND; } - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); // NotifyPackageDownloaded removes the ref from the array. Keep a temp ref if (gPackagedAppService) { gPackagedAppService->NotifyPackageDownloaded(mPackageKey); } ClearCallbacks(aStatusCode); - mVerifier = nullptr; + // Explicity remove the downloader from the verifier. The downloader + // will die after exiting this function but the verifier may still be + // alive for a while since some resources maybe being verified. + if (mVerifier) { + mVerifier->ClearListener(); + } } nsCString @@ -634,7 +639,15 @@ PackagedAppService::PackagedAppDownloader::OnStopRequest(nsIRequest *aRequest, // Chances to get here: // 1) Very likely the package has been cached or // 2) Less likely the package is malformed. - FinalizeDownload(aStatusCode); + if (!mVerifier) { + FinalizeDownload(aStatusCode); + } else { + // We've got a broken last part and some resources might be still + // in the verification queue. Send a dummy ResourceCacheInfo to the + // verifier so this broken resource will be processed in the correct + // order. + mVerifier->SetHasBrokenLastPart(aStatusCode); + } } return NS_OK; } @@ -659,7 +672,7 @@ PackagedAppService::PackagedAppDownloader::OnStopRequest(nsIRequest *aRequest, // The downloader only needs to focus on PackagedAppVerifierListener callback. // The PackagedAppVerifier would handle the manifest/resource verification. - nsRefPtr info = + RefPtr info = new ResourceCacheInfo(uri, entry, aStatusCode, lastPart); mVerifier->OnStopRequest(nullptr, info, aStatusCode); @@ -707,7 +720,8 @@ PackagedAppService::PackagedAppDownloader::OnDataAvailable(nsIRequest *aRequest, nsresult PackagedAppService::PackagedAppDownloader::AddCallback(nsIURI *aURI, - nsICacheEntryOpenCallback *aCallback) + nsICacheEntryOpenCallback *aCallback, + nsIChannel* aRequester) { MOZ_RELEASE_ASSERT(NS_IsMainThread(), "mCallbacks hashtable is not thread safe"); nsAutoCString spec; @@ -716,6 +730,8 @@ PackagedAppService::PackagedAppDownloader::AddCallback(nsIURI *aURI, LogURI("PackagedAppDownloader::AddCallback", this, aURI); LOG(("[%p] > callback: %p\n", this, aCallback)); + nsCOMPtr listener = do_QueryInterface(aRequester); + // Check if we already have a resource waiting for this resource nsCOMArray* array = mCallbacks.Get(spec); if (array) { @@ -727,9 +743,12 @@ PackagedAppService::PackagedAppDownloader::AddCallback(nsIURI *aURI, // This is the case where a package downloader is still running and we // peek data from it. - - // TODO: Bug 1186290 to notify that the signed packaged content is ready - // to load. + if (mVerifier && mVerifier->GetIsPackageSigned()) { + // TODO: Bug 1178526 will deal with the package identifier things. + // For now we just use the origin as the identifier. + listener->OnStartSignedPackageRequest(mVerifier->GetPackageOrigin()); + listener = nullptr; // So that the request will not be added to the queue. + } mCacheStorage->AsyncOpenURI(aURI, EmptyCString(), nsICacheStorage::OPEN_READONLY, aCallback); } else { @@ -746,6 +765,12 @@ PackagedAppService::PackagedAppDownloader::AddCallback(nsIURI *aURI, newArray->AppendObject(aCallback); mCallbacks.Put(spec, newArray); } + + // Add the outer channel for notifying OnStartSignedPackageRequest. + if (listener) { + mRequesters.AppendObject(listener); + } + return NS_OK; } @@ -840,9 +865,19 @@ PackagedAppService::PackagedAppDownloader::ClearCallbacks(nsresult aResult) void PackagedAppService::PackagedAppDownloader::NotifyOnStartSignedPackageRequest(const nsACString& aPackageOrigin) { - // TODO: Bug 1186290 to notify whoever wants to know when the signed package is - // about to load. - LOG(("Notifying the signed package is ready to load.")); + MOZ_RELEASE_ASSERT(NS_IsMainThread(), "mRequesters is not thread safe"); + + LOG(("Ready to notify OnStartSignedPackageRequest to all requesters.")); + // Notify all requesters that a signed package is about to download and let + // TabParent to decide if the request needs to be re-made in a new process. + for (uint32_t i = 0; i < mRequesters.Length(); i++) { + nsCOMPtr requester = mRequesters.ObjectAt(i); + LOG(("Notifying %p OnStartSignedPackageRequest. New origin: %s", requester.get(), + nsCString(aPackageOrigin).get())); + requester->OnStartSignedPackageRequest(aPackageOrigin); + } + + mRequesters.Clear(); } void PackagedAppService::PackagedAppDownloader::InstallSignedPackagedApp() @@ -863,6 +898,12 @@ PackagedAppService::PackagedAppDownloader::OnVerified(bool aIsManifest, bool aIsLastPart, bool aVerificationSuccess) { + if (!aUri) { + NS_WARNING("We've got a broken last part."); + FinalizeDownload(aStatusCode); + return NS_OK; + } + RefPtr info = new ResourceCacheInfo(aUri, aCacheEntry, aStatusCode, aIsLastPart); @@ -884,6 +925,12 @@ PackagedAppService::PackagedAppDownloader::OnManifestVerified(const ResourceCach // TODO: If we disallow the request for the manifest file, do NOT callback here. CallCallbacks(aInfo->mURI, aInfo->mCacheEntry, aInfo->mStatusCode); + if (aInfo->mIsLastPart) { + NS_WARNING("This package has manifest only."); + FinalizeDownload(aInfo->mStatusCode); + return; + } + bool isPackagedSigned; mVerifier->GetIsPackageSigned(&isPackagedSigned); if (!isPackagedSigned) { @@ -906,6 +953,15 @@ PackagedAppService::PackagedAppDownloader::OnResourceVerified(const ResourceCach return OnError(ERROR_RESOURCE_VERIFIED_FAILED); } + // If this package is signed and there is any pending requests, we just notify + // right now no matter if this is the requested resource. Doing this can + // have the potential process switch be done as early as possible. + if (mVerifier->GetIsPackageSigned()) { + // TODO: Bug 1178526 will deal with the package identifier things. + // For now we just use the origin as the identifier. + NotifyOnStartSignedPackageRequest(mVerifier->GetPackageOrigin()); + } + // Serve this resource to all listeners. CallCallbacks(aInfo->mURI, aInfo->mCacheEntry, aInfo->mStatusCode); @@ -1031,14 +1087,13 @@ PackagedAppService::GetResource(nsIChannel *aChannel, key += spec; } - nsRefPtr downloader; + RefPtr downloader; if (mDownloadingPackages.Get(key, getter_AddRefs(downloader))) { // We have determined that the file is not in the cache. // If we find that the package that the file belongs to is currently being // downloaded, we will add the callback to the package's queue, and it will // be called once the file is processed and saved in the cache. - - downloader->AddCallback(uri, aCallback); + downloader->AddCallback(uri, aCallback, aChannel); return NS_OK; } @@ -1068,7 +1123,7 @@ PackagedAppService::GetResource(nsIChannel *aChannel, return rv; } - downloader->AddCallback(uri, aCallback); + downloader->AddCallback(uri, aCallback, aChannel); nsCOMPtr streamconv = do_GetService("@mozilla.org/streamConverters;1", &rv); @@ -1086,7 +1141,7 @@ PackagedAppService::GetResource(nsIChannel *aChannel, // Add the package to the hashtable. mDownloadingPackages.Put(key, downloader); - nsRefPtr listener = + RefPtr listener = new PackagedAppChannelListener(downloader, mimeConverter); nsCOMPtr loadContext; diff --git a/netwerk/protocol/http/PackagedAppService.h b/netwerk/protocol/http/PackagedAppService.h index 4dd04dd008..46223c2084 100644 --- a/netwerk/protocol/http/PackagedAppService.h +++ b/netwerk/protocol/http/PackagedAppService.h @@ -13,6 +13,7 @@ #include "PackagedAppVerifier.h" #include "nsIMultiPartChannel.h" #include "PackagedAppVerifier.h" +#include "nsIPackagedAppChannelListener.h" namespace mozilla { namespace net { @@ -122,7 +123,10 @@ private: const nsACString& aPackageOrigin); // Registers a callback which gets called when the given nsIURI is downloaded // aURI is the full URI of a subresource, composed of packageURI + !// + subresourcePath - nsresult AddCallback(nsIURI *aURI, nsICacheEntryOpenCallback *aCallback); + // aRequester is the outer channel who makes the request for aURI. + nsresult AddCallback(nsIURI *aURI, + nsICacheEntryOpenCallback *aCallback, + nsIChannel* aRequester); // Remove the callback from the resource callback list. nsresult RemoveCallbacks(nsICacheEntryOpenCallback* aCallback); @@ -189,7 +193,7 @@ private: static nsresult GetSubresourceURI(nsIRequest * aRequest, nsIURI **aResult); // Used to write data into the cache entry of the resource currently being // downloaded. It is kept alive until the downloader receives OnStopRequest - nsRefPtr mWriter; + RefPtr mWriter; // Cached value of nsICacheStorage nsCOMPtr mCacheStorage; // A hastable containing all the consumers which requested a resource and need @@ -205,7 +209,10 @@ private: bool mIsFromCache; // Deal with verification and delegate callbacks to the downloader. - nsRefPtr mVerifier; + RefPtr mVerifier; + + // The outer channels which have issued the request to the downloader. + nsCOMArray mRequesters; // The package origin without signed package origin identifier. // If you need the origin with the signity taken into account, use @@ -238,7 +245,7 @@ private: private: ~PackagedAppChannelListener() { } - nsRefPtr mDownloader; + RefPtr mDownloader; nsCOMPtr mListener; // nsMultiMixedConv }; diff --git a/netwerk/protocol/http/PackagedAppUtils.js b/netwerk/protocol/http/PackagedAppUtils.js new file mode 100644 index 0000000000..7854260e10 --- /dev/null +++ b/netwerk/protocol/http/PackagedAppUtils.js @@ -0,0 +1,109 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* 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/. */ + +'use strict'; + +const { classes: Cc, interfaces: Ci, utils: Cu } = Components; + +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +const PACKAGEDAPPUTILS_CONTRACTID = "@mozilla.org/network/packaged-app-utils;1"; +const PACKAGEDAPPUTILS_CID = Components.ID("{fe8f1c2e-3c13-11e5-9a3f-bbf47d1e6697}"); + +function PackagedAppUtils() { + +} + +let DEBUG = 0 +function debug(s) { + if (DEBUG) { + dump("-*- PackagedAppUtils: " + s + "\n"); + } +} + +PackagedAppUtils.prototype = { + classID: PACKAGEDAPPUTILS_CID, + contractID: PACKAGEDAPPUTILS_CONTRACTID, + classDescription: "Packaged App Utils", + QueryInterface: XPCOMUtils.generateQI([Ci.nsIPackagedAppUtils]), + + verifyManifest: function(aHeader, aManifest, aCallback) { + debug("Manifest: " + aManifest); + + // parse signature from header + let signature; + const signatureField = "manifest-signature: "; + for (let item of aHeader.split('\r\n')) { + if (item.substr(0, signatureField.length) == signatureField) { + signature = item.substr(signatureField.length); + break; + } + } + if (!signature) { + debug("No signature in header"); + aCallback.fireVerifiedEvent(true, false); + return; + } + debug("Signature: " + signature); + + try { + // Base64 decode + signature = atob(signature); + + // Remove header + let manifestBody = aManifest.substr(aManifest.indexOf('\r\n\r\n') + 4); + debug("manifestBody: " + manifestBody); + + // Parse manifest, store resource hashes + this.resources = JSON.parse(manifestBody)["moz-resources"]; + } catch (e) { + debug("JSON parsing failure"); + aCallback.fireVerifiedEvent(true, false); + return; + } + + let manifestStream = Cc["@mozilla.org/io/string-input-stream;1"] + .createInstance(Ci.nsIStringInputStream); + let signatureStream = Cc["@mozilla.org/io/string-input-stream;1"] + .createInstance(Ci.nsIStringInputStream); + manifestStream.setData(aManifest, aManifest.length); + signatureStream.setData(signature, signature.length); + + let certDb; + try { + certDb = Cc["@mozilla.org/security/x509certdb;1"] + .getService(Ci.nsIX509CertDB); + } catch (e) { + debug("nsIX509CertDB error: " + e); + // unrecoverable error, don't bug the user + throw "CERTDB_ERROR"; + } + + certDb.verifySignedManifestAsync( + Ci.nsIX509CertDB.PrivilegedPackageRoot, manifestStream, signatureStream, + function(aRv, aCert) { + aCallback.fireVerifiedEvent(true, Components.isSuccessCode(aRv)); + }); + }, + + checkIntegrity: function(aFileName, aHashValue, aCallback) { + debug("checkIntegrity() " + aFileName + ": " + aHashValue + "\n"); + if (!this.resources) { + debug("resource hashes not found"); + aCallback.fireVerifiedEvent(false, false); + return; + } + for (let r of this.resources) { + if (r.src === aFileName) { + debug("found integrity = " + r.integrity); + aCallback.fireVerifiedEvent(false, r.integrity === aHashValue); + return; + } + } + aCallback.fireVerifiedEvent(false, false); + }, +}; + +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PackagedAppUtils]); diff --git a/netwerk/protocol/http/PackagedAppUtils.manifest b/netwerk/protocol/http/PackagedAppUtils.manifest new file mode 100644 index 0000000000..584b1a8cdc --- /dev/null +++ b/netwerk/protocol/http/PackagedAppUtils.manifest @@ -0,0 +1,3 @@ +# PackagedAppUtils.js +component {fe8f1c2e-3c13-11e5-9a3f-bbf47d1e6697} PackagedAppUtils.js +contract @mozilla.org/network/packaged-app-utils;1 {fe8f1c2e-3c13-11e5-9a3f-bbf47d1e6697} diff --git a/netwerk/protocol/http/PackagedAppVerifier.cpp b/netwerk/protocol/http/PackagedAppVerifier.cpp index 5a8239a9ac..ab94245272 100644 --- a/netwerk/protocol/http/PackagedAppVerifier.cpp +++ b/netwerk/protocol/http/PackagedAppVerifier.cpp @@ -48,6 +48,16 @@ PackagedAppVerifier::PackagedAppVerifier(nsIPackagedAppVerifierListener* aListen Init(aListener, aPackageOrigin, aSignature, aPackageCacheEntry); } +PackagedAppVerifier::~PackagedAppVerifier() +{ + MOZ_RELEASE_ASSERT(NS_IsMainThread(), "mPendingResourceCacheInfoList is not thread safe."); + while (auto i = mPendingResourceCacheInfoList.popFirst()) { + // This seems to be the only way that we can manually delete a + // nsISupports instance with no warning. + RefPtr deleter(i); + } +} + NS_IMETHODIMP PackagedAppVerifier::Init(nsIPackagedAppVerifierListener* aListener, const nsACString& aPackageOrigin, const nsACString& aSignature, @@ -118,15 +128,26 @@ PackagedAppVerifier::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatusCode) { + MOZ_RELEASE_ASSERT(NS_IsMainThread(), "mHashingResourceURI is not thread safe."); + NS_ENSURE_TRUE(mHasher, NS_ERROR_FAILURE); - nsresult rv = mHasher->Finish(true, mLastComputedResourceHash); + nsAutoCString hash; + nsresult rv = mHasher->Finish(true, hash); NS_ENSURE_SUCCESS(rv, rv); - LOG(("Hash of %s is %s", mHashingResourceURI.get(), - mLastComputedResourceHash.get())); + LOG(("Hash of %s is %s", mHashingResourceURI.get(), hash.get())); - ProcessResourceCache(static_cast(aContext)); + // Store the computated hash associated with the resource URI. + mResourceHashStore.Put(mHashingResourceURI, new nsCString(hash)); + mHashingResourceURI = EmptyCString(); + + // Get a internal copy and take over the life cycle handling + // since the linked list we use only supports pointer-based element. + ResourceCacheInfo* info + = new ResourceCacheInfo(*(static_cast(aContext))); + + ProcessResourceCache(info); return NS_OK; } @@ -136,18 +157,27 @@ PackagedAppVerifier::ProcessResourceCache(const ResourceCacheInfo* aInfo) { MOZ_RELEASE_ASSERT(NS_IsMainThread(), "ProcessResourceCache must be on main thread"); + // Queue this info since we might process it asynchronously. + mPendingResourceCacheInfoList.insertBack(const_cast(aInfo)); + switch (mState) { case STATE_UNKNOWN: // The first resource has to be the manifest. VerifyManifest(aInfo); break; + case STATE_MANIFEST_VERIFYING: + // A resource is cached in the middle of manifest verification. + // Verify it until the manifest is verified. + break; + case STATE_MANIFEST_VERIFIED_OK: VerifyResource(aInfo); break; case STATE_MANIFEST_VERIFIED_FAILED: - OnResourceVerified(aInfo, false); + LOG(("Resource not verified because manifest verification failed.")); + FireVerifiedEvent(false, false); break; default: @@ -156,6 +186,24 @@ PackagedAppVerifier::ProcessResourceCache(const ResourceCacheInfo* aInfo) } } +void +PackagedAppVerifier::FireVerifiedEvent(bool aForManifest, bool aSuccess) +{ + nsCOMPtr r; + + if (aForManifest) { + r = NS_NewRunnableMethodWithArgs(this, + &PackagedAppVerifier::OnManifestVerified, + aSuccess); + } else { + r = NS_NewRunnableMethodWithArgs(this, + &PackagedAppVerifier::OnResourceVerified, + aSuccess); + } + + NS_DispatchToMainThread(r); +} + void PackagedAppVerifier::VerifyManifest(const ResourceCacheInfo* aInfo) { @@ -163,21 +211,29 @@ PackagedAppVerifier::VerifyManifest(const ResourceCacheInfo* aInfo) LOG(("Ready to verify manifest.")); + if (!aInfo->mURI) { // Broken last part. + FireVerifiedEvent(false, false); + mState = STATE_MANIFEST_VERIFIED_FAILED; + return; + } + + mState = STATE_MANIFEST_VERIFYING; + if (gDeveloperMode) { LOG(("Developer mode! Bypass verification.")); - OnManifestVerified(aInfo, true); + FireVerifiedEvent(true, true); return; } if (mSignature.IsEmpty()) { LOG(("No signature. No need to do verification.")); - OnManifestVerified(aInfo, true); + FireVerifiedEvent(true, true); return; } // TODO: Implement manifest verification. LOG(("Manifest verification not implemented yet. See Bug 1178518.")); - OnManifestVerified(aInfo, false); + FireVerifiedEvent(true, false); } void @@ -185,30 +241,51 @@ PackagedAppVerifier::VerifyResource(const ResourceCacheInfo* aInfo) { MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Resource verification must be on main thread"); - LOG(("Checking the resource integrity. '%s'", mLastComputedResourceHash.get())); + if (!aInfo->mURI) { // Broken last part. + FireVerifiedEvent(false, false); + return; + } + + // Look up the resource hash that we computed and stored to + // mResourceHashStore before. + nsAutoCString uriAsAscii; + aInfo->mURI->GetAsciiSpec(uriAsAscii); + nsCString* resourceHash = mResourceHashStore.Get(uriAsAscii); + + if (!resourceHash) { + LOG(("Hash value for %s is not computed. ERROR!", uriAsAscii.get())); + MOZ_CRASH(); + } if (gDeveloperMode) { LOG(("Developer mode! Bypass integrity check.")); - OnResourceVerified(aInfo, true); + FireVerifiedEvent(false, true); return; } if (mSignature.IsEmpty()) { LOG(("No signature. No need to do resource integrity check.")); - OnResourceVerified(aInfo, true); + FireVerifiedEvent(false, true); return; } // TODO: Implement resource integrity check. LOG(("Resource integrity check not implemented yet. See Bug 1178518.")); - OnResourceVerified(aInfo, false); + FireVerifiedEvent(false, false); } void -PackagedAppVerifier::OnManifestVerified(const ResourceCacheInfo* aInfo, bool aSuccess) +PackagedAppVerifier::OnManifestVerified(bool aSuccess) { + MOZ_RELEASE_ASSERT(NS_IsMainThread(), "OnManifestVerified must be on main thread."); + LOG(("PackagedAppVerifier::OnManifestVerified: %d", aSuccess)); + // The listener could have been removed before we verify the resource. + if (!mListener) { + return; + } + // Only when the manifest verified and package has signature would we // regard this package is signed. mIsPackageSigned = aSuccess && !mSignature.IsEmpty(); @@ -228,30 +305,56 @@ PackagedAppVerifier::OnManifestVerified(const ResourceCacheInfo* aInfo, bool aSu } } + RefPtr info(mPendingResourceCacheInfoList.popFirst()); + MOZ_ASSERT(info); + mListener->OnVerified(true, // aIsManifest. - aInfo->mURI, - aInfo->mCacheEntry, - aInfo->mStatusCode, - aInfo->mIsLastPart, + info->mURI, + info->mCacheEntry, + info->mStatusCode, + info->mIsLastPart, aSuccess); - LOG(("PackagedAppVerifier::OnManifestVerified done")); + LOG(("Ready to verify resources that were cached during verification")); + // Verify the resources which were cached during verification accordingly. + for (auto i = mPendingResourceCacheInfoList.getFirst(); i; i = i->getNext()) { + VerifyResource(i); + } } void -PackagedAppVerifier::OnResourceVerified(const ResourceCacheInfo* aInfo, bool aSuccess) +PackagedAppVerifier::OnResourceVerified(bool aSuccess) { MOZ_RELEASE_ASSERT(NS_IsMainThread(), "PackagedAppVerifier::OnResourceVerified must be on main thread"); + // The listener could have been removed before we verify the resource. + if (!mListener) { + return; + } + + RefPtr info(mPendingResourceCacheInfoList.popFirst()); + MOZ_ASSERT(info); + mListener->OnVerified(false, // aIsManifest. - aInfo->mURI, - aInfo->mCacheEntry, - aInfo->mStatusCode, - aInfo->mIsLastPart, + info->mURI, + info->mCacheEntry, + info->mStatusCode, + info->mIsLastPart, aSuccess); } +void +PackagedAppVerifier::SetHasBrokenLastPart(nsresult aStatusCode) +{ + // Append a record with null URI as a broken last part. + + ResourceCacheInfo* info + = new ResourceCacheInfo(nullptr, nullptr, aStatusCode, true); + + mPendingResourceCacheInfoList.insertBack(info); +} + //--------------------------------------------------------------- // nsIPackagedAppVerifier. //--------------------------------------------------------------- diff --git a/netwerk/protocol/http/PackagedAppVerifier.h b/netwerk/protocol/http/PackagedAppVerifier.h index 99d64201b3..36aa974add 100644 --- a/netwerk/protocol/http/PackagedAppVerifier.h +++ b/netwerk/protocol/http/PackagedAppVerifier.h @@ -13,6 +13,7 @@ #include "nsHashKeys.h" #include "nsICryptoHash.h" #include "nsIPackagedAppVerifier.h" +#include "mozilla/LinkedList.h" namespace mozilla { namespace net { @@ -31,6 +32,11 @@ public: // The initial state. STATE_UNKNOWN, + // When we are notified to process the first resource, we will start to + // verify the manifest and go to this state no matter the package has + // signature or not. + STATE_MANIFEST_VERIFYING, + // Either the package has no signature or the manifest is verified // successfully will we be in this state. STATE_MANIFEST_VERIFIED_OK, @@ -45,6 +51,7 @@ public: // The only reason to inherit from nsISupports is it needs to be // passed as the context to PackagedAppVerifier::OnStopRequest. class ResourceCacheInfo : public nsISupports + , public mozilla::LinkedListElement { public: NS_DECL_ISUPPORTS @@ -60,6 +67,16 @@ public: { } + ResourceCacheInfo(const ResourceCacheInfo& aCopyFrom) + : mURI(aCopyFrom.mURI) + , mCacheEntry(aCopyFrom.mCacheEntry) + , mStatusCode(aCopyFrom.mStatusCode) + , mIsLastPart(aCopyFrom.mIsLastPart) + { + } + + // A ResourceCacheInfo must have a URI. If mURI is null, this + // resource is broken. nsCOMPtr mURI; nsCOMPtr mCacheEntry; nsresult mStatusCode; @@ -77,10 +94,27 @@ public: const nsACString& aSignature, nsICacheEntry* aPackageCacheEntry); + // A internal used function to let the verifier know there's a broken + // last part. + void SetHasBrokenLastPart(nsresult aStatusCode); + + // Used to explicitly clear the listener to avoid circula reference. + void ClearListener() { mListener = nullptr; } + + bool GetIsPackageSigned() const + { + return mIsPackageSigned; + } + + const nsACString& GetPackageOrigin() const + { + return mPackageOrigin; + } + static const char* kSignedPakOriginMetadataKey; private: - virtual ~PackagedAppVerifier() { } + virtual ~PackagedAppVerifier(); // Called when a resource is already fully written in the cache. This resource // will be processed and is guaranteed to be called back in either: @@ -100,8 +134,11 @@ private: void VerifyManifest(const ResourceCacheInfo* aInfo); void VerifyResource(const ResourceCacheInfo* aInfo); - void OnManifestVerified(const ResourceCacheInfo* aInfo, bool aSuccess); - void OnResourceVerified(const ResourceCacheInfo* aInfo, bool aSuccess); + void OnManifestVerified(bool aSuccess); + void OnResourceVerified(bool aSuccess); + + // Fire a async event to notify the verification result. + void FireVerifiedEvent(bool aForManifest, bool aSuccess); // To notify that either manifest or resource check is done. nsCOMPtr mListener; @@ -131,6 +168,12 @@ private: // The last computed hash value for a resource. It will be set on every // |EndResourceHash| call. nsCString mLastComputedResourceHash; + + // A list of pending resource that is downloaded but not verified yet. + mozilla::LinkedList mPendingResourceCacheInfoList; + + // A place to store the computed hashes of each resource. + nsClassHashtable mResourceHashStore; }; // class PackagedAppVerifier } // namespace net diff --git a/netwerk/protocol/http/SpdyPush31.cpp b/netwerk/protocol/http/SpdyPush31.cpp index 82cc387c32..c9b920902a 100644 --- a/netwerk/protocol/http/SpdyPush31.cpp +++ b/netwerk/protocol/http/SpdyPush31.cpp @@ -313,7 +313,7 @@ SpdyPush31TransactionBuffer::RequestHead() nsresult SpdyPush31TransactionBuffer::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/netwerk/protocol/http/SpdySession31.cpp b/netwerk/protocol/http/SpdySession31.cpp index 9c279e04a7..955fd06168 100644 --- a/netwerk/protocol/http/SpdySession31.cpp +++ b/netwerk/protocol/http/SpdySession31.cpp @@ -404,8 +404,8 @@ SpdySession31::QueueStream(SpdyStream31 *stream) LOG3(("SpdySession31::QueueStream %p stream %p queued.", this, stream)); #ifdef DEBUG - int32_t qsize = mQueuedStreams.GetSize(); - for (int32_t i = 0; i < qsize; i++) { + size_t qsize = mQueuedStreams.GetSize(); + for (size_t i = 0; i < qsize; i++) { SpdyStream31 *qStream = static_cast(mQueuedStreams.ObjectAt(i)); MOZ_ASSERT(qStream != stream); MOZ_ASSERT(qStream->Queued()); @@ -792,7 +792,7 @@ SpdySession31::GenerateSettings() numberOfEntries++; } - nsRefPtr ci; + RefPtr ci; uint32_t cwnd = 0; GetConnectionInfo(getter_AddRefs(ci)); if (ci) @@ -967,8 +967,8 @@ SpdySession31::CleanupStream(SpdyStream31 *aStream, nsresult aResult, static void RemoveStreamFromQueue(SpdyStream31 *aStream, nsDeque &queue) { - uint32_t size = queue.GetSize(); - for (uint32_t count = 0; count < size; ++count) { + size_t size = queue.GetSize(); + for (size_t count = 0; count < size; ++count) { SpdyStream31 *stream = static_cast(queue.PopFront()); if (stream != aStream) queue.Push(stream); @@ -1107,7 +1107,7 @@ SpdySession31::HandleSynStream(SpdySession31 *self) } // Create the buffering transaction and push stream - nsRefPtr transactionBuffer = + RefPtr transactionBuffer = new SpdyPush31TransactionBuffer(); transactionBuffer->SetConnection(self); SpdyPushedStream31 *pushedStream = @@ -1445,7 +1445,7 @@ SpdySession31::HandleSettings(SpdySession31 *self) case SETTINGS_TYPE_CWND: if (flags & PERSIST_VALUE) { - nsRefPtr ci; + RefPtr ci; self->GetConnectionInfo(getter_AddRefs(ci)); if (ci) gHttpHandler->ConnMgr()->ReportSpdyCWNDSetting(ci, value); @@ -1540,8 +1540,8 @@ SpdySession31::HandleGoAway(SpdySession31 *self) self->mStreamTransactionHash.Enumerate(GoAwayEnumerator, self); // Process the streams marked for deletion and restart. - uint32_t size = self->mGoAwayStreamsToRestart.GetSize(); - for (uint32_t count = 0; count < size; ++count) { + size_t size = self->mGoAwayStreamsToRestart.GetSize(); + for (size_t count = 0; count < size; ++count) { SpdyStream31 *stream = static_cast(self->mGoAwayStreamsToRestart.PopFront()); @@ -1555,7 +1555,7 @@ SpdySession31::HandleGoAway(SpdySession31 *self) // in another one. (they were never sent on the network so they implicitly // are not covered by the last-good id. size = self->mQueuedStreams.GetSize(); - for (uint32_t count = 0; count < size; ++count) { + for (size_t count = 0; count < size; ++count) { SpdyStream31 *stream = static_cast(self->mQueuedStreams.PopFront()); MOZ_ASSERT(stream->Queued()); @@ -2416,7 +2416,7 @@ SpdySession31::Close(nsresult aReason) nsHttpConnectionInfo * SpdySession31::ConnectionInfo() { - nsRefPtr ci; + RefPtr ci; GetConnectionInfo(getter_AddRefs(ci)); return ci.get(); } @@ -2692,7 +2692,7 @@ SpdySession31::CreateTunnel(nsHttpTransaction *trans, // transaction so that an auth created by the connect can be mappped // to the correct security callbacks - nsRefPtr connectTrans = + RefPtr connectTrans = new SpdyConnectTransaction(ci, aCallbacks, trans->Caps(), trans, this); AddStream(connectTrans, nsISupportsPriority::PRIORITY_NORMAL, false, nullptr); SpdyStream31 *tunnel = mStreamTransactionHash.Get(connectTrans); @@ -2943,8 +2943,8 @@ static PLDHashOperator nsAutoPtr &stream, void *closure) { - nsTArray > *list = - static_cast > *>(closure); + nsTArray > *list = + static_cast > *>(closure); list->AppendElement(key); @@ -2955,7 +2955,7 @@ static PLDHashOperator nsresult SpdySession31::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { // Generally this cannot be done with spdy as transactions are // started right away. diff --git a/netwerk/protocol/http/SpdySession31.h b/netwerk/protocol/http/SpdySession31.h index d6b95ff22e..5b2c87fb7a 100644 --- a/netwerk/protocol/http/SpdySession31.h +++ b/netwerk/protocol/http/SpdySession31.h @@ -261,7 +261,7 @@ private: // This is intended to be nsHttpConnectionMgr:nsConnectionHandle taken // from the first transaction on this session. That object contains the // pointer to the real network-level nsHttpConnection object. - nsRefPtr mConnection; + RefPtr mConnection; // The underlying socket transport object is needed to propogate some events nsISocketTransport *mSocketTransport; diff --git a/netwerk/protocol/http/SpdyStream31.cpp b/netwerk/protocol/http/SpdyStream31.cpp index d987ac1b88..afaf0a5bdd 100644 --- a/netwerk/protocol/http/SpdyStream31.cpp +++ b/netwerk/protocol/http/SpdyStream31.cpp @@ -1621,7 +1621,7 @@ SpdyStream31::ClearTransactionsBlockedOnTunnel() void SpdyStream31::MapStreamToPlainText() { - nsRefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); + RefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); MOZ_ASSERT(qiTrans); mPlainTextTunnel = true; qiTrans->ForcePlainText(); @@ -1630,7 +1630,7 @@ SpdyStream31::MapStreamToPlainText() void SpdyStream31::MapStreamToHttpConnection() { - nsRefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); + RefPtr qiTrans(mTransaction->QuerySpdyConnectTransaction()); MOZ_ASSERT(qiTrans); qiTrans->MapStreamToHttpConnection(mSocketTransport, mTransaction->ConnectionInfo()); diff --git a/netwerk/protocol/http/SpdyStream31.h b/netwerk/protocol/http/SpdyStream31.h index 50cd394f30..904b66f9ec 100644 --- a/netwerk/protocol/http/SpdyStream31.h +++ b/netwerk/protocol/http/SpdyStream31.h @@ -165,7 +165,7 @@ private: // in the SpdySession31 mStreamTransactionHash so it is important to // keep a reference to it as long as this stream is a member of that hash. // (i.e. don't change it or release it after it is set in the ctor). - nsRefPtr mTransaction; + RefPtr mTransaction; // The underlying socket transport object is needed to propogate some events nsISocketTransport *mSocketTransport; diff --git a/netwerk/protocol/http/TimingStruct.h b/netwerk/protocol/http/TimingStruct.h index 5d8969b08b..633114d787 100644 --- a/netwerk/protocol/http/TimingStruct.h +++ b/netwerk/protocol/http/TimingStruct.h @@ -24,6 +24,8 @@ struct ResourceTimingStruct : TimingStruct { TimeStamp fetchStart; TimeStamp redirectStart; TimeStamp redirectEnd; + uint64_t transferSize; + uint64_t encodedBodySize; }; } // namespace net diff --git a/netwerk/protocol/http/TunnelUtils.cpp b/netwerk/protocol/http/TunnelUtils.cpp index 6e55e84631..b8cd6dd79b 100644 --- a/netwerk/protocol/http/TunnelUtils.cpp +++ b/netwerk/protocol/http/TunnelUtils.cpp @@ -457,7 +457,7 @@ TLSFilterTransaction::StartTimerCallback() if (mNudgeCallback) { // This class can be called re-entrantly, so cleanup m* before ->on() - nsRefPtr cb(mNudgeCallback); + RefPtr cb(mNudgeCallback); mNudgeCallback = nullptr; cb->OnTunnelNudged(this); } @@ -660,7 +660,7 @@ TLSFilterTransaction::Http1xTransactionCount() nsresult TLSFilterTransaction::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { LOG(("TLSFilterTransaction::TakeSubTransactions [this=%p] mTransaction %p\n", this, mTransaction.get())); @@ -815,7 +815,7 @@ private: virtual ~SocketInWrapper() {}; nsCOMPtr mStream; - nsRefPtr mTLSFilter; + RefPtr mTLSFilter; }; nsresult @@ -887,7 +887,7 @@ private: virtual ~SocketOutWrapper() {}; nsCOMPtr mStream; - nsRefPtr mTLSFilter; + RefPtr mTLSFilter; }; nsresult @@ -1086,7 +1086,7 @@ SpdyConnectTransaction::MapStreamToHttpConnection(nsISocketTransport *aTransport } // make the originating transaction stick to the tunneled conn - nsRefPtr wrappedConn = + RefPtr wrappedConn = gHttpHandler->ConnMgr()->MakeConnectionHandle(mTunneledConn); mDrivingTransaction->SetConnection(wrappedConn); mDrivingTransaction->MakeSticky(); @@ -1303,7 +1303,7 @@ OutputStreamShim::AsyncWait(nsIOutputStreamCallback *callback, LOG(("OutputStreamShim::AsyncWait %p callback %p\n", this, callback)); mCallback = callback; - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } @@ -1321,7 +1321,7 @@ OutputStreamShim::AsyncWait(nsIOutputStreamCallback *callback, NS_IMETHODIMP OutputStreamShim::CloseWithStatus(nsresult reason) { - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } @@ -1344,7 +1344,7 @@ OutputStreamShim::Close() NS_IMETHODIMP OutputStreamShim::Flush() { - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } @@ -1375,7 +1375,7 @@ OutputStreamShim::Write(const char * aBuf, uint32_t aCount, uint32_t *_retval) return mStatus; } - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } @@ -1443,7 +1443,7 @@ InputStreamShim::AsyncWait(nsIInputStreamCallback *callback, NS_IMETHODIMP InputStreamShim::CloseWithStatus(nsresult reason) { - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } @@ -1466,7 +1466,7 @@ InputStreamShim::Close() NS_IMETHODIMP InputStreamShim::Available(uint64_t *_retval) { - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } @@ -1489,7 +1489,7 @@ InputStreamShim::Read(char *aBuf, uint32_t aCount, uint32_t *_retval) return mStatus; } - nsRefPtr baseTrans(do_QueryReferent(mWeakTrans)); + RefPtr baseTrans(do_QueryReferent(mWeakTrans)); if (!baseTrans) { return NS_ERROR_FAILURE; } diff --git a/netwerk/protocol/http/TunnelUtils.h b/netwerk/protocol/http/TunnelUtils.h index ec058dee95..dd7b9f95d4 100644 --- a/netwerk/protocol/http/TunnelUtils.h +++ b/netwerk/protocol/http/TunnelUtils.h @@ -151,10 +151,10 @@ private: static PRStatus FilterClose(PRFileDesc *fd); private: - nsRefPtr mTransaction; + RefPtr mTransaction; nsCOMPtr mSecInfo; nsCOMPtr mTimer; - nsRefPtr mNudgeCallback; + RefPtr mNudgeCallback; // buffered network output, after encryption nsAutoArrayPtr mEncryptedText; @@ -227,17 +227,17 @@ private: bool mForcePlainText; TimeStamp mTimestampSyn; - nsRefPtr mConnInfo; + RefPtr mConnInfo; // mTunneledConn, mTunnelTransport, mTunnelStreamIn, mTunnelStreamOut // are the connectors to the "real" http connection. They are created // together when the tunnel setup is complete and a static reference is held // for the lifetime of the tunnel. - nsRefPtr mTunneledConn; - nsRefPtr mTunnelTransport; - nsRefPtr mTunnelStreamIn; - nsRefPtr mTunnelStreamOut; - nsRefPtr mDrivingTransaction; + RefPtr mTunneledConn; + RefPtr mTunnelTransport; + RefPtr mTunnelStreamIn; + RefPtr mTunnelStreamOut; + RefPtr mDrivingTransaction; }; } // namespace net diff --git a/netwerk/protocol/http/moz.build b/netwerk/protocol/http/moz.build index 5a83a7f1f1..a208f49578 100644 --- a/netwerk/protocol/http/moz.build +++ b/netwerk/protocol/http/moz.build @@ -113,3 +113,8 @@ LOCAL_INCLUDES += [ '/dom/base', '/netwerk/base', ] + +EXTRA_COMPONENTS += [ + 'PackagedAppUtils.js', + 'PackagedAppUtils.manifest', +] diff --git a/netwerk/protocol/http/nsAHttpTransaction.h b/netwerk/protocol/http/nsAHttpTransaction.h index d00d64a0d5..208407dce8 100644 --- a/netwerk/protocol/http/nsAHttpTransaction.h +++ b/netwerk/protocol/http/nsAHttpTransaction.h @@ -100,7 +100,7 @@ public: // at least partially written and cannot be moved. // virtual nsresult TakeSubTransactions( - nsTArray > &outTransactions) = 0; + nsTArray > &outTransactions) = 0; // called to add a sub-transaction in the case of pipelined transactions // classes that do not implement sub transactions @@ -228,7 +228,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpTransaction, NS_AHTTPTRANSACTION_IID) void SetProxyConnectFailed() override; \ virtual nsHttpRequestHead *RequestHead() override; \ uint32_t Http1xTransactionCount() override; \ - nsresult TakeSubTransactions(nsTArray > &outTransactions) override; \ + nsresult TakeSubTransactions(nsTArray > &outTransactions) override; \ nsresult AddTransaction(nsAHttpTransaction *) override; \ uint32_t PipelineDepth() override; \ nsresult SetPipelinePosition(int32_t) override; \ diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index 9b1a472324..0cd80bb14d 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -443,35 +443,10 @@ nsCORSListenerProxy::nsCORSListenerProxy(nsIStreamListener* aOuter, mOriginHeaderPrincipal(aRequestingPrincipal), mWithCredentials(aWithCredentials && !gDisableCORSPrivateData), mRequestApproved(false), - mHasBeenCrossSite(false), - mIsPreflight(false) + mHasBeenCrossSite(false) { } -nsCORSListenerProxy::nsCORSListenerProxy(nsIStreamListener* aOuter, - nsIPrincipal* aRequestingPrincipal, - bool aWithCredentials, - const nsCString& aPreflightMethod, - const nsTArray& aPreflightHeaders) - : mOuterListener(aOuter), - mRequestingPrincipal(aRequestingPrincipal), - mOriginHeaderPrincipal(aRequestingPrincipal), - mWithCredentials(aWithCredentials && !gDisableCORSPrivateData), - mRequestApproved(false), - mHasBeenCrossSite(false), - mIsPreflight(true), -#ifdef DEBUG - mInited(false), -#endif - mPreflightMethod(aPreflightMethod), - mPreflightHeaders(aPreflightHeaders) -{ - for (uint32_t i = 0; i < mPreflightHeaders.Length(); ++i) { - ToLowerCase(mPreflightHeaders[i]); - } - mPreflightHeaders.Sort(); -} - nsCORSListenerProxy::~nsCORSListenerProxy() { } @@ -570,7 +545,6 @@ nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest) // For synthesized responses, we don't need to perform any checks. // Note: This would be unsafe if we ever changed our behavior to allow // service workers to intercept CORS preflights. - MOZ_ASSERT(!mIsPreflight); return NS_OK; } @@ -606,68 +580,6 @@ nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest) } } - if (mIsPreflight) { - bool succeedded; - rv = http->GetRequestSucceeded(&succeedded); - if (NS_FAILED(rv) || !succeedded) { - LogBlockedRequest(aRequest, "CORSPreflightDidNotSucceed", nullptr); - return NS_ERROR_DOM_BAD_URI; - } - - nsAutoCString headerVal; - // The "Access-Control-Allow-Methods" header contains a comma separated - // list of method names. - http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"), - headerVal); - bool foundMethod = mPreflightMethod.EqualsLiteral("GET") || - mPreflightMethod.EqualsLiteral("HEAD") || - mPreflightMethod.EqualsLiteral("POST"); - nsCCharSeparatedTokenizer methodTokens(headerVal, ','); - while(methodTokens.hasMoreTokens()) { - const nsDependentCSubstring& method = methodTokens.nextToken(); - if (method.IsEmpty()) { - continue; - } - if (!NS_IsValidHTTPToken(method)) { - LogBlockedRequest(aRequest, "CORSInvalidAllowMethod", - NS_ConvertUTF8toUTF16(method).get()); - return NS_ERROR_DOM_BAD_URI; - } - foundMethod |= mPreflightMethod.Equals(method); - } - if (!foundMethod) { - LogBlockedRequest(aRequest, "CORSMethodNotFound", nullptr); - return NS_ERROR_DOM_BAD_URI; - } - - // The "Access-Control-Allow-Headers" header contains a comma separated - // list of header names. - http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"), - headerVal); - nsTArray headers; - nsCCharSeparatedTokenizer headerTokens(headerVal, ','); - while(headerTokens.hasMoreTokens()) { - const nsDependentCSubstring& header = headerTokens.nextToken(); - if (header.IsEmpty()) { - continue; - } - if (!NS_IsValidHTTPToken(header)) { - LogBlockedRequest(aRequest, "CORSInvalidAllowHeader", - NS_ConvertUTF8toUTF16(header).get()); - return NS_ERROR_DOM_BAD_URI; - } - headers.AppendElement(header); - } - for (uint32_t i = 0; i < mPreflightHeaders.Length(); ++i) { - if (!headers.Contains(mPreflightHeaders[i], - nsCaseInsensitiveCStringArrayComparator())) { - LogBlockedRequest(aRequest, "CORSMissingAllowHeaderFromPreflight", - NS_ConvertUTF8toUTF16(mPreflightHeaders[i]).get()); - return NS_ERROR_DOM_BAD_URI; - } - } - } - return NS_OK; } @@ -951,6 +863,12 @@ nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel, if (dataScheme) { return NS_OK; } + nsCOMPtr loadInfo; + aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); + if (loadInfo && loadInfo->GetAboutBlankInherits() && + NS_IsAboutBlank(uri)) { + return NS_OK; + } } // Set CORS attributes on channel so that intercepted requests get correct @@ -959,11 +877,7 @@ nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel, // can't return early on failure. nsCOMPtr internal = do_QueryInterface(aChannel); if (internal) { - if (mIsPreflight) { - rv = internal->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_CORS_WITH_FORCED_PREFLIGHT); - } else { - rv = internal->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_CORS); - } + rv = internal->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_CORS); NS_ENSURE_SUCCESS(rv, rv); rv = internal->SetCorsIncludeCredentials(mWithCredentials); NS_ENSURE_SUCCESS(rv, rv); @@ -1019,30 +933,8 @@ nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel, rv = http->SetRequestHeader(NS_LITERAL_CSTRING("Origin"), origin, false); NS_ENSURE_SUCCESS(rv, rv); - // Add preflight headers if this is a preflight request - if (mIsPreflight) { - rv = http-> - SetRequestHeader(NS_LITERAL_CSTRING("Access-Control-Request-Method"), - mPreflightMethod, false); - NS_ENSURE_SUCCESS(rv, rv); - - if (!mPreflightHeaders.IsEmpty()) { - nsAutoCString headers; - for (uint32_t i = 0; i < mPreflightHeaders.Length(); ++i) { - if (i != 0) { - headers += ','; - } - headers += mPreflightHeaders[i]; - } - rv = http-> - SetRequestHeader(NS_LITERAL_CSTRING("Access-Control-Request-Headers"), - headers, false); - NS_ENSURE_SUCCESS(rv, rv); - } - } - // Make cookie-less if needed - if (mIsPreflight || !mWithCredentials) { + if (!mWithCredentials) { nsLoadFlags flags; rv = http->GetLoadFlags(&flags); NS_ENSURE_SUCCESS(rv, rv); @@ -1065,16 +957,18 @@ class nsCORSPreflightListener final : public nsIStreamListener, public nsIChannelEventSink { public: - nsCORSPreflightListener(nsIChannel* aOuterChannel, - nsIStreamListener* aOuterListener, - nsISupports* aOuterContext, - nsIPrincipal* aReferrerPrincipal, + nsCORSPreflightListener(nsIPrincipal* aReferrerPrincipal, nsICorsPreflightCallback* aCallback, - bool aWithCredentials) - : mOuterChannel(aOuterChannel), mOuterListener(aOuterListener), - mOuterContext(aOuterContext), mReferrerPrincipal(aReferrerPrincipal), - mCallback(aCallback), mWithCredentials(aWithCredentials) - { } + bool aWithCredentials, + const nsCString& aPreflightMethod, + const nsTArray& aPreflightHeaders) + : mPreflightMethod(aPreflightMethod), + mPreflightHeaders(aPreflightHeaders), + mReferrerPrincipal(aReferrerPrincipal), + mCallback(aCallback), + mWithCredentials(aWithCredentials) + { + } NS_DECL_ISUPPORTS NS_DECL_NSISTREAMLISTENER @@ -1082,14 +976,15 @@ public: NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSICHANNELEVENTSINK + nsresult CheckPreflightRequestApproved(nsIRequest* aRequest); + private: ~nsCORSPreflightListener() {} void AddResultToCache(nsIRequest* aRequest); - nsCOMPtr mOuterChannel; - nsCOMPtr mOuterListener; - nsCOMPtr mOuterContext; + nsCString mPreflightMethod; + nsTArray mPreflightHeaders; nsCOMPtr mReferrerPrincipal; nsCOMPtr mCallback; bool mWithCredentials; @@ -1216,12 +1111,21 @@ NS_IMETHODIMP nsCORSPreflightListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { - nsresult status; - nsresult rv = aRequest->GetStatus(&status); - - if (NS_SUCCEEDED(rv)) { - rv = status; +#ifdef DEBUG + { + nsCOMPtr internal = do_QueryInterface(aRequest); + bool responseSynthesized = false; + if (internal && + NS_SUCCEEDED(internal->GetResponseSynthesized(&responseSynthesized))) { + // For synthesized responses, we don't need to perform any checks. + // This would be unsafe if we ever changed our behavior to allow + // service workers to intercept CORS preflights. + MOZ_ASSERT(!responseSynthesized); + } } +#endif + + nsresult rv = CheckPreflightRequestApproved(aRequest); if (NS_SUCCEEDED(rv)) { // Everything worked, try to cache and then fire off the actual request. @@ -1240,9 +1144,6 @@ nsCORSPreflightListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatus) { - mOuterChannel = nullptr; - mOuterListener = nullptr; - mOuterContext = nullptr; mCallback = nullptr; return NS_OK; } @@ -1275,6 +1176,82 @@ nsCORSPreflightListener::AsyncOnChannelRedirect(nsIChannel *aOldChannel, return NS_OK; } +nsresult +nsCORSPreflightListener::CheckPreflightRequestApproved(nsIRequest* aRequest) +{ + nsresult status; + nsresult rv = aRequest->GetStatus(&status); + NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(status, status); + + // Test that things worked on a HTTP level + nsCOMPtr http = do_QueryInterface(aRequest); + nsCOMPtr internal = do_QueryInterface(aRequest); + NS_ENSURE_STATE(internal); + + bool succeedded; + rv = http->GetRequestSucceeded(&succeedded); + if (NS_FAILED(rv) || !succeedded) { + LogBlockedRequest(aRequest, "CORSPreflightDidNotSucceed", nullptr); + return NS_ERROR_DOM_BAD_URI; + } + + nsAutoCString headerVal; + // The "Access-Control-Allow-Methods" header contains a comma separated + // list of method names. + http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"), + headerVal); + bool foundMethod = mPreflightMethod.EqualsLiteral("GET") || + mPreflightMethod.EqualsLiteral("HEAD") || + mPreflightMethod.EqualsLiteral("POST"); + nsCCharSeparatedTokenizer methodTokens(headerVal, ','); + while(methodTokens.hasMoreTokens()) { + const nsDependentCSubstring& method = methodTokens.nextToken(); + if (method.IsEmpty()) { + continue; + } + if (!NS_IsValidHTTPToken(method)) { + LogBlockedRequest(aRequest, "CORSInvalidAllowMethod", + NS_ConvertUTF8toUTF16(method).get()); + return NS_ERROR_DOM_BAD_URI; + } + foundMethod |= mPreflightMethod.Equals(method); + } + if (!foundMethod) { + LogBlockedRequest(aRequest, "CORSMethodNotFound", nullptr); + return NS_ERROR_DOM_BAD_URI; + } + + // The "Access-Control-Allow-Headers" header contains a comma separated + // list of header names. + http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"), + headerVal); + nsTArray headers; + nsCCharSeparatedTokenizer headerTokens(headerVal, ','); + while(headerTokens.hasMoreTokens()) { + const nsDependentCSubstring& header = headerTokens.nextToken(); + if (header.IsEmpty()) { + continue; + } + if (!NS_IsValidHTTPToken(header)) { + LogBlockedRequest(aRequest, "CORSInvalidAllowHeader", + NS_ConvertUTF8toUTF16(header).get()); + return NS_ERROR_DOM_BAD_URI; + } + headers.AppendElement(header); + } + for (uint32_t i = 0; i < mPreflightHeaders.Length(); ++i) { + if (!headers.Contains(mPreflightHeaders[i], + nsCaseInsensitiveCStringArrayComparator())) { + LogBlockedRequest(aRequest, "CORSMissingAllowHeaderFromPreflight", + NS_ConvertUTF8toUTF16(mPreflightHeaders[i]).get()); + return NS_ERROR_DOM_BAD_URI; + } + } + + return NS_OK; +} + NS_IMETHODIMP nsCORSPreflightListener::GetInterface(const nsIID & aIID, void **aResult) { @@ -1293,7 +1270,6 @@ nsCORSListenerProxy::RemoveFromCorsPreflightCache(nsIURI* aURI, nsresult nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel, - nsIStreamListener* aListener, nsIPrincipal* aPrincipal, nsICorsPreflightCallback* aCallback, bool aWithCredentials, @@ -1302,6 +1278,11 @@ nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel, { *aPreflightChannel = nullptr; + if (gDisableCORS) { + LogBlockedRequest(aRequestChannel, "CORSDisabled", nullptr); + return NS_ERROR_DOM_BAD_URI; + } + nsAutoCString method; nsCOMPtr httpChannel(do_QueryInterface(aRequestChannel)); NS_ENSURE_TRUE(httpChannel, NS_ERROR_UNEXPECTED); @@ -1347,13 +1328,15 @@ nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel, rv = aRequestChannel->GetLoadFlags(&loadFlags); NS_ENSURE_SUCCESS(rv, rv); - // Preflight requests should never be intercepted by service workers. + // Preflight requests should never be intercepted by service workers and + // are always anonymous. // NOTE: We ignore CORS checks on synthesized responses (see the CORS // preflights, then we need to extend the GetResponseSynthesized() check in // nsCORSListenerProxy::CheckRequestApproved()). If we change our behavior // here and allow service workers to intercept CORS preflights, then that // check won't be safe any more. - loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER; + loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER | + nsIRequest::LOAD_ANONYMOUS; nsCOMPtr preflightChannel; rv = NS_NewChannelInternal(getter_AddRefs(preflightChannel), @@ -1364,27 +1347,54 @@ nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel, loadFlags); NS_ENSURE_SUCCESS(rv, rv); + // Set method and headers nsCOMPtr preHttp = do_QueryInterface(preflightChannel); NS_ASSERTION(preHttp, "Failed to QI to nsIHttpChannel!"); rv = preHttp->SetRequestMethod(NS_LITERAL_CSTRING("OPTIONS")); NS_ENSURE_SUCCESS(rv, rv); + rv = preHttp-> + SetRequestHeader(NS_LITERAL_CSTRING("Access-Control-Request-Method"), + method, false); + NS_ENSURE_SUCCESS(rv, rv); + + nsTArray preflightHeaders; + if (!aUnsafeHeaders.IsEmpty()) { + for (uint32_t i = 0; i < aUnsafeHeaders.Length(); ++i) { + preflightHeaders.AppendElement(); + ToLowerCase(aUnsafeHeaders[i], preflightHeaders[i]); + } + preflightHeaders.Sort(); + nsAutoCString headers; + for (uint32_t i = 0; i < preflightHeaders.Length(); ++i) { + if (i != 0) { + headers += ','; + } + headers += preflightHeaders[i]; + } + rv = preHttp-> + SetRequestHeader(NS_LITERAL_CSTRING("Access-Control-Request-Headers"), + headers, false); + NS_ENSURE_SUCCESS(rv, rv); + } + // Set up listener which will start the original channel - nsCOMPtr preflightListener = - new nsCORSPreflightListener(aRequestChannel, aListener, nullptr, aPrincipal, - aCallback, aWithCredentials); - NS_ENSURE_TRUE(preflightListener, NS_ERROR_OUT_OF_MEMORY); + RefPtr preflightListener = + new nsCORSPreflightListener(aPrincipal, aCallback, aWithCredentials, + method, preflightHeaders); + + rv = preflightChannel->SetNotificationCallbacks(preflightListener); + NS_ENSURE_SUCCESS(rv, rv); // Start preflight if (securityMode == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS) { rv = preflightChannel->AsyncOpen2(preflightListener); } else { - nsRefPtr corsListener = + RefPtr corsListener = new nsCORSListenerProxy(preflightListener, aPrincipal, - aWithCredentials, method, - aUnsafeHeaders); + aWithCredentials); rv = corsListener->Init(preflightChannel, DataURIHandling::Disallow); NS_ENSURE_SUCCESS(rv, rv); rv = preflightChannel->AsyncOpen(corsListener, nullptr); diff --git a/netwerk/protocol/http/nsCORSListenerProxy.h b/netwerk/protocol/http/nsCORSListenerProxy.h index 246cd27e7b..5a0064494a 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.h +++ b/netwerk/protocol/http/nsCORSListenerProxy.h @@ -73,15 +73,7 @@ private: static void RemoveFromCorsPreflightCache(nsIURI* aURI, nsIPrincipal* aRequestingPrincipal); - - nsCORSListenerProxy(nsIStreamListener* aOuter, - nsIPrincipal* aRequestingPrincipal, - bool aWithCredentials, - const nsCString& aPreflightMethod, - const nsTArray& aPreflightHeaders); - static nsresult StartCORSPreflight(nsIChannel* aRequestChannel, - nsIStreamListener* aListener, nsIPrincipal* aPrincipal, nsICorsPreflightCallback* aCallback, bool aWithCredentials, @@ -108,12 +100,9 @@ private: // an http: request to https: in nsHttpChannel::Connect() and hence // a request might not be marked as cross site request based on that promise. bool mHasBeenCrossSite; - bool mIsPreflight; #ifdef DEBUG bool mInited; #endif - nsCString mPreflightMethod; - nsTArray mPreflightHeaders; nsCOMPtr mRedirectCallback; nsCOMPtr mOldRedirectChannel; nsCOMPtr mNewRedirectChannel; diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index a1a58e8c18..c83cbe4b82 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -229,6 +229,26 @@ nsHttp::IsValidToken(const char *start, const char *end) return true; } +const char* +nsHttp::GetProtocolVersion(uint32_t pv) +{ + switch (pv) { + case SPDY_VERSION_31: + return "spdy/3.1"; + case HTTP_VERSION_2: + case NS_HTTP_VERSION_2_0: + return "h2"; + case NS_HTTP_VERSION_1_0: + return "http/1.0"; + case NS_HTTP_VERSION_1_1: + return "http/1.1"; + default: + NS_WARNING(nsPrintfCString("Unkown protocol version: 0x%X. " + "Please file a bug", pv).get()); + return "http/1.1"; + } +} + // static bool nsHttp::IsReasonableHeaderValue(const nsACString &s) diff --git a/netwerk/protocol/http/nsHttp.h b/netwerk/protocol/http/nsHttp.h index e1fd0e08da..65b6af6ea7 100644 --- a/netwerk/protocol/http/nsHttp.h +++ b/netwerk/protocol/http/nsHttp.h @@ -167,6 +167,9 @@ struct nsHttp // Return whether the HTTP status code represents a permanent redirect static bool IsPermanentRedirect(uint32_t httpStatus); + // Returns the APLN token which represents the used protocol version. + static const char* GetProtocolVersion(uint32_t pv); + // Declare all atoms // // The atom names and values are stored in nsHttpAtomList.h and are brought diff --git a/netwerk/protocol/http/nsHttpAuthCache.h b/netwerk/protocol/http/nsHttpAuthCache.h index d6f9475aaa..dfc43e3bae 100644 --- a/netwerk/protocol/http/nsHttpAuthCache.h +++ b/netwerk/protocol/http/nsHttpAuthCache.h @@ -252,7 +252,7 @@ private: private: PLHashTable *mDB; // "host:port" --> nsHttpAuthNode - nsRefPtr mObserver; + RefPtr mObserver; }; } // namespace net diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 525c2eb956..f5b0e160c6 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -89,6 +89,7 @@ #include "nsIDeprecationWarner.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" +#include "nsICompressConvStats.h" namespace mozilla { namespace net { @@ -186,7 +187,7 @@ AutoRedirectVetoNotifier::ReportRedirectResult(bool succeeded) // Append the initial uri of the channel to the redirectChain if (succeeded && mChannel->mLoadInfo) { - mChannel->mLoadInfo->AppendRedirectedPrincipal(mChannel->GetURIPrincipal()); + mChannel->mLoadInfo->AppendRedirectedPrincipal(mChannel->GetURIPrincipal(), false); } mChannel->mRedirectChannel = nullptr; @@ -447,7 +448,7 @@ nsHttpChannel::ContinueConnect() mInterceptCache != INTERCEPTED) { MOZ_ASSERT(!mPreflightChannel); nsresult rv = - nsCORSListenerProxy::StartCORSPreflight(this, mListener, + nsCORSListenerProxy::StartCORSPreflight(this, mPreflightPrincipal, this, mWithCredentials, mUnsafeHeaders, @@ -1053,6 +1054,7 @@ nsHttpChannel::CallOnStartRequest() } if (listener) { mListener = listener; + mCompressListener = listener; } } @@ -2055,14 +2057,23 @@ nsHttpChannel::StartRedirectChannelToURI(nsIURI *upgradedURI, uint32_t flags) // Inform consumers about this fake redirect mRedirectChannel = newChannel; - // Ensure that internally-redirected channels cannot be intercepted, which would look - // like two separate requests to the nsINetworkInterceptController. - nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL; - rv = mRedirectChannel->GetLoadFlags(&loadFlags); - NS_ENSURE_SUCCESS(rv, rv); - loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER; - rv = mRedirectChannel->SetLoadFlags(loadFlags); - NS_ENSURE_SUCCESS(rv, rv); + if (!(flags & nsIChannelEventSink::REDIRECT_STS_UPGRADE)) { + // Ensure that internally-redirected channels cannot be intercepted, which would look + // like two separate requests to the nsINetworkInterceptController. + if (mInterceptCache == INTERCEPTED) { + nsCOMPtr httpRedirect = do_QueryInterface(mRedirectChannel); + if (httpRedirect) { + httpRedirect->ForceIntercepted(mInterceptionID); + } + } else { + nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL; + rv = mRedirectChannel->GetLoadFlags(&loadFlags); + NS_ENSURE_SUCCESS(rv, rv); + loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER; + rv = mRedirectChannel->SetLoadFlags(loadFlags); + NS_ENSURE_SUCCESS(rv, rv); + } + } PushRedirectAsyncFunc( &nsHttpChannel::ContinueAsyncRedirectChannelToURI); @@ -2807,7 +2818,7 @@ nsHttpChannel::ProcessFallback(bool *waitingForRedirectCallback) CloseCacheEntry(true); // Create a new channel to load the fallback entry. - nsRefPtr newChannel; + RefPtr newChannel; rv = gHttpHandler->NewChannel2(mURI, mLoadInfo, getter_AddRefs(newChannel)); @@ -2961,7 +2972,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps) do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr info = GetLoadContextInfo(this); + RefPtr info = GetLoadContextInfo(this); nsCOMPtr cacheStorage; nsCOMPtr openURI; if (!mFallbackKey.IsEmpty() && mFallbackChannel) { @@ -3034,11 +3045,10 @@ nsHttpChannel::OpenCacheEntry(bool isHttps) if (mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY) cacheEntryOpenFlags |= nsICacheStorage::OPEN_BYPASS_IF_BUSY; - if (mPostID) { - extension.Append(nsPrintfCString("%d", mPostID)); - } if (PossiblyIntercepted()) { extension.Append(nsPrintfCString("u%lld", mInterceptionID)); + } else if (mPostID) { + extension.Append(nsPrintfCString("%d", mPostID)); } // If this channel should be intercepted, we do not open a cache entry for this channel @@ -3055,7 +3065,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps) nsCOMPtr controller; GetCallback(controller); - nsRefPtr intercepted = + RefPtr intercepted = new InterceptedChannelChrome(this, controller, entry); intercepted->NotifyController(); } else { @@ -4881,6 +4891,7 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel) NS_INTERFACE_MAP_ENTRY(nsIChannel) NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) NS_INTERFACE_MAP_ENTRY(nsIStreamListener) + NS_INTERFACE_MAP_ENTRY(nsIPackagedAppChannelListener) NS_INTERFACE_MAP_ENTRY(nsIHttpChannel) NS_INTERFACE_MAP_ENTRY(nsICacheInfoChannel) NS_INTERFACE_MAP_ENTRY(nsICachingChannel) @@ -5044,7 +5055,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context) return rv; } - if (ShouldIntercept()) { + if (mInterceptCache != INTERCEPTED && ShouldIntercept()) { mInterceptCache = MAYBE_INTERCEPT; SetCouldBeSynthesized(); } @@ -5147,7 +5158,7 @@ nsHttpChannel::BeginConnect() mRequestHead.SetHTTPS(isHttps); mRequestHead.SetOrigin(scheme, host, port); - nsRefPtr mapping; + RefPtr mapping; if (mAllowAltSvc && // per channel (scheme.Equals(NS_LITERAL_CSTRING("http")) || scheme.Equals(NS_LITERAL_CSTRING("https"))) && @@ -5216,7 +5227,7 @@ nsHttpChannel::BeginConnect() return AsyncCall(&nsHttpChannel::HandleAsyncAPIRedirect); } // Check to see if this principal exists on local blocklists. - nsRefPtr channelClassifier = new nsChannelClassifier(); + RefPtr channelClassifier = new nsChannelClassifier(); if (mLoadFlags & LOAD_CLASSIFY_URI) { nsCOMPtr classifier = do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID); bool tpEnabled = false; @@ -5378,6 +5389,19 @@ nsHttpChannel::BeginConnect() return NS_OK; } +NS_IMETHODIMP +nsHttpChannel::GetEncodedBodySize(uint64_t *aEncodedBodySize) +{ + if (mCacheEntry && !mCacheEntryIsWriteOnly) { + int64_t dataSize = 0; + mCacheEntry->GetDataSize(&dataSize); + *aEncodedBodySize = dataSize; + } else { + *aEncodedBodySize = mLogicalOffset; + } + return NS_OK; +} + //----------------------------------------------------------------------------- // nsHttpChannel::nsIHttpChannelInternal //----------------------------------------------------------------------------- @@ -5395,6 +5419,21 @@ nsHttpChannel::SetupFallbackChannel(const char *aFallbackKey) return NS_OK; } +NS_IMETHODIMP +nsHttpChannel::ForceIntercepted(uint64_t aInterceptionID) +{ + ENSURE_CALLED_BEFORE_ASYNC_OPEN(); + + if (NS_WARN_IF(mLoadFlags & LOAD_BYPASS_SERVICE_WORKER)) { + return NS_ERROR_NOT_AVAILABLE; + } + + MarkIntercepted(); + mResponseCouldBeSynthesized = true; + mInterceptionID = aInterceptionID; + return NS_OK; +} + //----------------------------------------------------------------------------- // nsHttpChannel::nsISupportsPriority //----------------------------------------------------------------------------- @@ -5681,6 +5720,25 @@ nsHttpChannel::GetRequestMethod(nsACString& aMethod) return HttpBaseChannel::GetRequestMethod(aMethod); } +//----------------------------------------------------------------------------- +// nsHttpChannel::nsIPackagedAppChannelListener +//----------------------------------------------------------------------------- + +NS_IMETHODIMP +nsHttpChannel::OnStartSignedPackageRequest(const nsACString& aPackageId) +{ + nsCOMPtr listener; + NS_QueryNotificationCallbacks(this, listener); + + if (listener) { + listener->OnStartSignedPackageRequest(aPackageId); + } else { + LOG(("nsHttpChannel::OnStartSignedPackageRequest [this=%p], no listener on %p", this, mListener.get())); + } + + return NS_OK; +} + //----------------------------------------------------------------------------- // nsHttpChannel::nsIRequestObserver //----------------------------------------------------------------------------- @@ -5837,6 +5895,11 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st gHttpHandler->CancelTransaction(mTransaction, status); } + nsCOMPtr conv = do_QueryInterface(mCompressListener); + if (conv) { + conv->GetDecodedDataLength(&mDecodedBodySize); + } + if (mTransaction) { // determine if we should call DoAuthRetry bool authRetry = mAuthRetryPending && NS_SUCCEEDED(status); @@ -5850,7 +5913,7 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st // tests for NS_HTTP_STICKY_CONNECTION to determine whether or not to // keep the connection around after the transaction is finished. // - nsRefPtr conn; + RefPtr conn; if (authRetry && (mCaps & NS_HTTP_STICKY_CONNECTION)) { conn = mTransaction->GetConnectionReference(); // This is so far a workaround to fix leak when reusing unpersistent @@ -5860,10 +5923,12 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st conn = nullptr; } - nsRefPtr stickyConn; + RefPtr stickyConn; if (mCaps & NS_HTTP_STICKY_CONNECTION) stickyConn = mTransaction->GetConnectionReference(); + mTransferSize = mTransaction->GetTransferSize(); + // at this point, we're done with the transaction mTransactionTimings = mTransaction->Timings(); mTransaction = nullptr; @@ -6880,7 +6945,7 @@ nsHttpChannel::DoInvalidateCacheEntry(nsIURI* aURI) nsCOMPtr cacheStorage; if (NS_SUCCEEDED(rv)) { - nsRefPtr info = GetLoadContextInfo(this); + RefPtr info = GetLoadContextInfo(this); rv = cacheStorageService->DiskCacheStorage(info, false, getter_AddRefs(cacheStorage)); } @@ -7012,7 +7077,7 @@ nsHttpChannel::OnPush(const nsACString &url, Http2PushedStream *pushedStream) return NS_ERROR_UNEXPECTED; } - nsRefPtr channel; + RefPtr channel; CallQueryInterface(pushHttpChannel, channel.StartAssignment()); MOZ_ASSERT(channel); if (!channel) { diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 9ce5049131..99427388dc 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -9,6 +9,7 @@ #include "HttpBaseChannel.h" #include "nsTArray.h" +#include "nsIPackagedAppChannelListener.h" #include "nsICachingChannel.h" #include "nsICacheEntry.h" #include "nsICacheEntryOpenCallback.h" @@ -59,6 +60,7 @@ public: class nsHttpChannel final : public HttpBaseChannel , public HttpAsyncAborter , public nsIStreamListener + , public nsIPackagedAppChannelListener , public nsICachingChannel , public nsICacheEntryOpenCallback , public nsITransportEventSink @@ -76,6 +78,7 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER + NS_DECL_NSIPACKAGEDAPPCHANNELLISTENER NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER NS_DECL_NSICACHEINFOCHANNEL NS_DECL_NSICACHINGCHANNEL @@ -129,8 +132,11 @@ public: NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo) override; NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) override; NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener) override; + // nsIHttpChannel + NS_IMETHOD GetEncodedBodySize(uint64_t *aEncodedBodySize) override; // nsIHttpChannelInternal NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override; + NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override; // nsISupportsPriority NS_IMETHOD SetPriority(int32_t value) override; // nsIClassOfService @@ -403,8 +409,8 @@ private: private: nsCOMPtr mProxyRequest; - nsRefPtr mTransactionPump; - nsRefPtr mTransaction; + RefPtr mTransactionPump; + RefPtr mTransaction; uint64_t mLogicalOffset; @@ -412,7 +418,7 @@ private: nsCOMPtr mCacheEntry; // We must close mCacheInputStream explicitly to avoid leaks. AutoClose mCacheInputStream; - nsRefPtr mCachePump; + RefPtr mCachePump; nsAutoPtr mCachedResponseHead; nsCOMPtr mCachedSecurityInfo; uint32_t mPostID; @@ -431,8 +437,9 @@ private: MAYBE_INTERCEPT, // interception in progress, but can be cancelled INTERCEPTED, // a synthesized response has been provided } mInterceptCache; - // Unique ID of this channel for the interception purposes. - const uint64_t mInterceptionID; + // ID of this channel for the interception purposes. Unique unless this + // channel is replacing an intercepted one via an redirection. + uint64_t mInterceptionID; bool PossiblyIntercepted() { return mInterceptCache != DO_NOT_INTERCEPT; @@ -501,7 +508,7 @@ private: nsTArray mRedirectFuncStack; // Needed for accurate DNS timing - nsRefPtr mDNSPrefetch; + RefPtr mDNSPrefetch; Http2PushedStream *mPushedStream; // True if the channel's principal was found on a phishing, malware, or @@ -516,7 +523,6 @@ private: // If non-null, warnings should be reported to this object. HttpChannelSecurityWarningReporter* mWarningReporter; - protected: virtual void DoNotifyListenerCleanup() override; diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp index 5a97eae677..bca9321a1d 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp @@ -35,6 +35,10 @@ namespace net { #define SUBRESOURCE_AUTH_DIALOG_DISALLOW_CROSS_ORIGIN 1 #define SUBRESOURCE_AUTH_DIALOG_ALLOW_ALL 2 +#define HTTP_AUTH_DIALOG_TOP_LEVEL_DOC 0 +#define HTTP_AUTH_DIALOG_SAME_ORIGIN_SUBRESOURCE 1 +#define HTTP_AUTH_DIALOG_CROSS_ORIGIN_SUBRESOURCE 2 + #define MAX_DISPLAYED_USER_LENGTH 64 #define MAX_DISPLAYED_HOST_LENGTH 64 @@ -820,8 +824,8 @@ nsHttpChannelAuthProvider::BlockPrompt() } // Allow if it is the top-level document or xhr. - if ((loadInfo->InternalContentPolicyType() == nsIContentPolicy::TYPE_DOCUMENT) || - (loadInfo->InternalContentPolicyType() == nsIContentPolicy::TYPE_XMLHTTPREQUEST)) { + if ((loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_DOCUMENT) || + (loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_XMLHTTPREQUEST)) { return false; } @@ -1039,7 +1043,7 @@ nsHttpChannelAuthProvider::PromptForIdentity(uint32_t level, if (authFlags & nsIHttpAuthenticator::IDENTITY_INCLUDES_DOMAIN) promptFlags |= nsIAuthInformation::NEED_DOMAIN; - nsRefPtr holder = + RefPtr holder = new nsHTTPAuthInformation(promptFlags, realmU, nsDependentCString(authType)); if (!holder) diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.h b/netwerk/protocol/http/nsHttpChannelAuthProvider.h index 05b18162dd..c03bfb38ec 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.h +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.h @@ -154,7 +154,7 @@ private: uint32_t mTriedHostAuth : 1; uint32_t mSuppressDefensiveAuth : 1; - nsRefPtr mHttpHandler; // keep gHttpHandler alive + RefPtr mHttpHandler; // keep gHttpHandler alive // A variable holding the preference settings to whether to open HTTP // authentication credentials dialogs for sub-resources and cross-origin diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 898ca1b12a..fdf818db6d 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -171,7 +171,7 @@ nsHttpConnection::StartSpdy(uint8_t spdyVersion) // several requests. If so, we need to unpack that and // pack them all into a new spdy session. - nsTArray > list; + nsTArray > list; nsresult rv = mTransaction->TakeSubTransactions(list); if (rv == NS_ERROR_ALREADY_OPENED) { @@ -208,7 +208,7 @@ nsHttpConnection::StartSpdy(uint8_t spdyVersion) mSpdySession = ASpdySession::NewSpdySession(spdyVersion, mSocketTransport); bool spdyProxy = mConnInfo->UsingHttpsProxy() && !mTLSFilter; if (spdyProxy) { - nsRefPtr wildCardProxyCi; + RefPtr wildCardProxyCi; mConnInfo->CreateWildCard(getter_AddRefs(wildCardProxyCi)); gHttpHandler->ConnMgr()->MoveToWildCardConnEntry(mConnInfo, wildCardProxyCi, this); @@ -1460,7 +1460,7 @@ public: return mConn->OnOutputStreamReady(mConn->mSocketOut); } private: - nsRefPtr mConn; + RefPtr mConn; bool mDoRecv; }; diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h index bf4e0a44df..4d1623ba55 100644 --- a/netwerk/protocol/http/nsHttpConnection.h +++ b/netwerk/protocol/http/nsHttpConnection.h @@ -268,15 +268,15 @@ private: // mTransaction only points to the HTTP Transaction callbacks if the // transaction is open, otherwise it is null. - nsRefPtr mTransaction; - nsRefPtr mTLSFilter; + RefPtr mTransaction; + RefPtr mTLSFilter; - nsRefPtr mHttpHandler; // keep gHttpHandler alive + RefPtr mHttpHandler; // keep gHttpHandler alive Mutex mCallbacksLock; nsMainThreadPtrHandle mCallbacks; - nsRefPtr mConnInfo; + RefPtr mConnInfo; PRIntervalTime mLastReadTime; PRIntervalTime mLastWriteTime; @@ -290,7 +290,7 @@ private: int64_t mTotalBytesWritten; // does not include CONNECT tunnel int64_t mContentBytesWritten; // does not include CONNECT tunnel or TLS - nsRefPtr mInputOverflow; + RefPtr mInputOverflow; PRIntervalTime mRtt; @@ -330,7 +330,7 @@ private: // version level in use, 0 if unused uint8_t mUsingSpdyVersion; - nsRefPtr mSpdySession; + RefPtr mSpdySession; int32_t mPriority; bool mReportedSpdy; diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.cpp b/netwerk/protocol/http/nsHttpConnectionInfo.cpp index 969b4d1891..9fcc98a285 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp +++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp @@ -260,7 +260,7 @@ nsHttpConnectionInfo::CloneAsDirectRoute(nsHttpConnectionInfo **outCI) return; } - nsRefPtr clone = + RefPtr clone = new nsHttpConnectionInfo(mOrigin, mOriginPort, EmptyCString(), mUsername, mProxyInfo, mEndToEndSSL); // Make sure the anonymous, insecure-scheme, and private flags are transferred @@ -285,7 +285,7 @@ nsHttpConnectionInfo::CreateWildCard(nsHttpConnectionInfo **outParam) return NS_ERROR_NOT_IMPLEMENTED; } - nsRefPtr clone; + RefPtr clone; clone = new nsHttpConnectionInfo(NS_LITERAL_CSTRING("*"), 0, mNPNToken, mUsername, mProxyInfo, true); // Make sure the anonymous and private flags are transferred! diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index cd19ea17f0..99ed8faeca 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -351,7 +351,7 @@ nsHttpConnectionMgr::VerifyTraffic() nsresult nsHttpConnectionMgr::DoShiftReloadConnectionCleanup(nsHttpConnectionInfo *aCI) { - nsRefPtr connInfo(aCI); + RefPtr connInfo(aCI); nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup, 0, connInfo); @@ -373,7 +373,7 @@ public: NS_IMETHOD_(MozExternalRefCountType) Release(void); public: // intentional! - nsRefPtr mTrans; + RefPtr mTrans; bool mOverridesOK; uint32_t mParallelSpeculativeConnectLimit; @@ -419,7 +419,7 @@ nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci, return NS_OK; } - nsRefPtr args = new SpeculativeConnectArgs(); + RefPtr args = new SpeculativeConnectArgs(); // Wrap up the callbacks and the target to ensure they're released on the target // thread properly. @@ -479,7 +479,7 @@ nsCompleteUpgradeData(nsAHttpConnection *aConn, nsIHttpUpgradeListener *aListener) : mConn(aConn), mUpgradeListener(aListener) {} - nsRefPtr mConn; + RefPtr mConn; nsCOMPtr mUpgradeListener; }; @@ -526,7 +526,7 @@ nsHttpConnectionMgr::ProcessPendingQ() void nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket(int32_t, void *param) { - nsRefPtr tokenBucket = + RefPtr tokenBucket = dont_AddRef(static_cast(param)); gHttpHandler->SetRequestTokenBucket(tokenBucket); } @@ -534,7 +534,7 @@ nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket(int32_t, void *param) nsresult nsHttpConnectionMgr::UpdateRequestTokenBucket(EventTokenBucket *aBucket) { - nsRefPtr bucket(aBucket); + RefPtr bucket(aBucket); // Call From main thread when a new EventTokenBucket has been made in order // to post the new value to the socket thread. @@ -1099,7 +1099,7 @@ nsHttpConnectionMgr::PruneNoTrafficCB(const nsACString &key, // walk the list backwards to allow us to remove entries easily for (int index = numConns-1; index >= 0; index--) { if (ent->mActiveConns[index]->NoTraffic()) { - nsRefPtr conn = dont_AddRef(ent->mActiveConns[index]); + RefPtr conn = dont_AddRef(ent->mActiveConns[index]); ent->mActiveConns.RemoveElementAt(index); self->DecrementActiveConnCount(conn); conn->Close(NS_ERROR_ABORT); @@ -1269,8 +1269,8 @@ public: { } - nsRefPtr mConnInfo; - nsRefPtr mConn; + RefPtr mConnInfo; + RefPtr mConn; nsHttpConnectionMgr::PipelineFeedbackInfoType mInfo; uint32_t mData; }; @@ -1329,7 +1329,7 @@ nsHttpConnectionMgr::ReportFailedToProcess(nsIURI *uri) // report the event for all the permutations of anonymous and // private versions of this host - nsRefPtr ci = + RefPtr ci = new nsHttpConnectionInfo(host, port, EmptyCString(), username, nullptr, usingSSL); ci->SetAnonymous(false); ci->SetPrivate(false); @@ -1742,14 +1742,14 @@ nsHttpConnectionMgr::TryDispatchTransaction(nsConnectionEntry *ent, // 6 - no connection is available - queue it bool attemptedOptimisticPipeline = !(caps & NS_HTTP_ALLOW_PIPELINING); - nsRefPtr unusedSpdyPersistentConnection; + RefPtr unusedSpdyPersistentConnection; // step 0 // look for existing spdy connection - that's always best because it is // essentially pipelining without head of line blocking if (!(caps & NS_HTTP_DISALLOW_SPDY) && gHttpHandler->IsSpdyEnabled()) { - nsRefPtr conn = GetSpdyPreferredConn(ent); + RefPtr conn = GetSpdyPreferredConn(ent); if (conn) { if ((caps & NS_HTTP_ALLOW_KEEPALIVE) || !conn->IsExperienced()) { LOG((" dispatch to spdy: [conn=%p]\n", conn.get())); @@ -1817,7 +1817,7 @@ nsHttpConnectionMgr::TryDispatchTransaction(nsConnectionEntry *ent, // step 2 // consider an idle persistent connection if (caps & NS_HTTP_ALLOW_KEEPALIVE) { - nsRefPtr conn; + RefPtr conn; while (!conn && (ent->mIdleConns.Length() > 0)) { conn = ent->mIdleConns[0]; ent->mIdleConns.RemoveElementAt(0); @@ -1979,11 +1979,11 @@ nsHttpConnectionMgr::DispatchAbstractTransaction(nsConnectionEntry *ent, for CLASS_SOLO as that connection will never pipeline until it goes quiescent */ - nsRefPtr transaction; + RefPtr transaction; nsresult rv; if (conn->Classification() != nsAHttpTransaction::CLASS_SOLO) { LOG((" using pipeline datastructure.\n")); - nsRefPtr pipeline; + RefPtr pipeline; rv = BuildPipeline(ent, aTrans, getter_AddRefs(pipeline)); if (!NS_SUCCEEDED(rv)) return rv; @@ -1994,7 +1994,7 @@ nsHttpConnectionMgr::DispatchAbstractTransaction(nsConnectionEntry *ent, transaction = aTrans; } - nsRefPtr handle = new nsConnectionHandle(conn); + RefPtr handle = new nsConnectionHandle(conn); // give the transaction the indirect reference to the connection. transaction->SetConnection(handle); @@ -2037,7 +2037,7 @@ nsHttpConnectionMgr::BuildPipeline(nsConnectionEntry *ent, /* the first transaction can go in unconditionally - 1 transaction on a nsHttpPipeline object is not a real HTTP pipeline */ - nsRefPtr pipeline = new nsHttpPipeline(); + RefPtr pipeline = new nsHttpPipeline(); pipeline->AddTransaction(firstTrans); pipeline.forget(result); return NS_OK; @@ -2089,7 +2089,7 @@ nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans) // to the new connection variable instead of searching for a new one nsAHttpConnection *wrappedConnection = trans->Connection(); - nsRefPtr conn; + RefPtr conn; if (wrappedConnection) conn = dont_AddRef(wrappedConnection->TakeHttpConnection()); @@ -2178,7 +2178,7 @@ nsHttpConnectionMgr::CreateTransport(nsConnectionEntry *ent, { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsRefPtr sock = new nsHalfOpenSocket(ent, trans, caps); + RefPtr sock = new nsHalfOpenSocket(ent, trans, caps); if (speculative) { sock->SetSpeculative(true); sock->SetAllow1918(allow1918); @@ -2385,7 +2385,7 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param) LOG(("nsHttpConnectionMgr::OnMsgCancelTransaction [trans=%p]\n", param)); nsresult closeCode = static_cast(reason); - nsRefPtr trans = + RefPtr trans = dont_AddRef(static_cast(param)); // @@ -2393,7 +2393,7 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param) // then ask the connection to close the transaction. otherwise, close the // transaction directly (removing it from the pending queue first). // - nsRefPtr conn(trans->Connection()); + RefPtr conn(trans->Connection()); if (conn && !trans->IsDone()) { conn->CloseTransaction(trans, closeCode); } else { @@ -2476,7 +2476,7 @@ nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, void *param) nsresult nsHttpConnectionMgr::CancelTransactions(nsHttpConnectionInfo *aCI, nsresult code) { - nsRefPtr ci(aCI); + RefPtr ci(aCI); LOG(("nsHttpConnectionMgr::CancelTransactions %s\n",ci->HashKey().get())); int32_t intReason = static_cast(code); @@ -2491,7 +2491,7 @@ void nsHttpConnectionMgr::OnMsgCancelTransactions(int32_t code, void *param) { nsresult reason = static_cast(code); - nsRefPtr ci = + RefPtr ci = dont_AddRef(static_cast(param)); nsConnectionEntry *ent = mCT.Get(ci->HashKey()); LOG(("nsHttpConnectionMgr::OnMsgCancelTransactions %s %p\n", @@ -2500,7 +2500,7 @@ nsHttpConnectionMgr::OnMsgCancelTransactions(int32_t code, void *param) return; } - nsRefPtr trans; + RefPtr trans; for (int32_t i = ent->mPendingQ.Length() - 1; i >= 0; --i) { trans = dont_AddRef(ent->mPendingQ[i]); LOG(("nsHttpConnectionMgr::OnMsgCancelTransactions %s %p %p\n", @@ -2576,7 +2576,7 @@ nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t, void *param) LOG(("nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup\n")); MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsRefPtr ci = + RefPtr ci = dont_AddRef(static_cast(param)); mCT.Enumerate(ClosePersistentConnectionsCB, this); @@ -2899,7 +2899,7 @@ nsHttpConnectionMgr::GetOrCreateConnectionEntry(nsHttpConnectionInfo *specificCI // step 2 if (!prohibitWildCard) { - nsRefPtr wildCardProxyCI; + RefPtr wildCardProxyCI; specificCI->CreateWildCard(getter_AddRefs(wildCardProxyCI)); nsConnectionEntry *wildCardEnt = mCT.Get(wildCardProxyCI->HashKey()); if (wildCardEnt && wildCardEnt->AvailableForDispatchNow()) { @@ -2909,7 +2909,7 @@ nsHttpConnectionMgr::GetOrCreateConnectionEntry(nsHttpConnectionInfo *specificCI // step 3 if (!specificEnt) { - nsRefPtr clone(specificCI->Clone()); + RefPtr clone(specificCI->Clone()); specificEnt = new nsConnectionEntry(clone); mCT.Put(clone->HashKey(), specificEnt); } @@ -2945,7 +2945,7 @@ nsHttpConnectionMgr::OnMsgSpeculativeConnect(int32_t, void *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsRefPtr args = + RefPtr args = dont_AddRef(static_cast(param)); LOG(("nsHttpConnectionMgr::OnMsgSpeculativeConnect [ci=%s]\n", @@ -3279,7 +3279,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::Abandon() MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsRefPtr deleteProtector(this); + RefPtr deleteProtector(this); // Tell socket (and backup socket) to forget the half open socket. if (mSocketTransport) { @@ -3358,7 +3358,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out) CancelBackupTimer(); // assign the new socket to the http connection - nsRefPtr conn = new nsHttpConnection(); + RefPtr conn = new nsHttpConnection(); LOG(("nsHalfOpenSocket::OnOutputStreamReady " "Created new nshttpconnection %p\n", conn.get())); @@ -3419,7 +3419,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out) if (index != -1) { MOZ_ASSERT(!mSpeculative, "Speculative Half Open found mTransaction"); - nsRefPtr temp = dont_AddRef(mEnt->mPendingQ[index]); + RefPtr temp = dont_AddRef(mEnt->mPendingQ[index]); mEnt->mPendingQ.RemoveElementAt(index); gHttpHandler->ConnMgr()->AddActiveConn(conn, mEnt); rv = gHttpHandler->ConnMgr()->DispatchTransaction(mEnt, temp, conn); @@ -3441,7 +3441,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out) !mEnt->mConnInfo->UsingConnect()) { LOG(("nsHalfOpenSocket::OnOutputStreamReady null transaction will " "be used to finish SSL handshake on conn %p\n", conn.get())); - nsRefPtr trans; + RefPtr trans; if (mTransaction->IsNullTransaction() && !mDispatchedMTransaction) { // null transactions cannot be put in the entry queue, so that // explains why it is not present. @@ -3461,7 +3461,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out) // otherwise just put this in the persistent connection pool LOG(("nsHalfOpenSocket::OnOutputStreamReady no transaction match " "returning conn %p to pool\n", conn.get())); - nsRefPtr copy(conn); + RefPtr copy(conn); // forget() to effectively addref because onmsg*() will drop a ref gHttpHandler->ConnMgr()->OnMsgReclaimConnection( 0, conn.forget().take()); diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index 0dc86f1e40..f8679c1302 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -292,7 +292,7 @@ private: explicit nsConnectionEntry(nsHttpConnectionInfo *ci); ~nsConnectionEntry(); - nsRefPtr mConnInfo; + RefPtr mConnInfo; nsTArray mPendingQ; // pending transaction queue nsTArray mActiveConns; // active connections nsTArray mIdleConns; // idle persistent connections @@ -477,7 +477,7 @@ private: void PrintDiagnostics(nsCString &log); private: nsConnectionEntry *mEnt; - nsRefPtr mTransaction; + RefPtr mTransaction; bool mDispatchedMTransaction; nsCOMPtr mSocketTransport; nsCOMPtr mStreamOut; diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 7a7319e161..59faee333b 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -398,7 +398,7 @@ nsHttpHandler::MakeNewRequestTokenBucket() if (!mConnMgr) return; - nsRefPtr tokenBucket = + RefPtr tokenBucket = new EventTokenBucket(RequestTokenBucketHz(), RequestTokenBucketBurst()); mConnMgr->UpdateRequestTokenBucket(tokenBucket); } @@ -508,7 +508,6 @@ nsHttpHandler::IsAcceptableEncoding(const char *enc, bool isSecure) } else { rv = nsHttp::FindToken(mHttpAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr; } - // gzip and deflate are inherently acceptable in modern HTTP - always // process them if a stream converter can also be found. if (!rv && @@ -600,7 +599,7 @@ nsHttpHandler::AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan, uint32_t flags) { // TODO E10S This helper has to be initialized on the other process - nsRefPtr redirectCallbackHelper = + RefPtr redirectCallbackHelper = new nsAsyncRedirectVerifyHelper(); return redirectCallbackHelper->Init(oldChan, newChan, flags); @@ -1602,7 +1601,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) void nsHttpHandler::TimerCallback(nsITimer * aTimer, void * aClosure) { - nsRefPtr thisObject = static_cast(aClosure); + RefPtr thisObject = static_cast(aClosure); if (!thisObject->mPipeliningEnabled) thisObject->mCapabilities &= ~NS_HTTP_ALLOW_PIPELINING; } @@ -1875,7 +1874,7 @@ nsHttpHandler::NewProxiedChannel2(nsIURI *uri, nsILoadInfo* aLoadInfo, nsIChannel** result) { - nsRefPtr httpChannel; + RefPtr httpChannel; LOG(("nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n", givenProxyInfo)); diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 98094ef1cb..2ec453fc4c 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -550,7 +550,7 @@ private: // For Rate Pacing Certain Network Events. Only assign this pointer on // socket thread. void MakeNewRequestTokenBucket(); - nsRefPtr mRequestTokenBucket; + RefPtr mRequestTokenBucket; public: // Socket thread only @@ -569,7 +569,7 @@ public: } private: - nsRefPtr mWifiTickler; + RefPtr mWifiTickler; void TickleWifi(nsIInterfaceRequestor *cb); private: diff --git a/netwerk/protocol/http/nsHttpPipeline.cpp b/netwerk/protocol/http/nsHttpPipeline.cpp index b8371c4062..d21c424e21 100644 --- a/netwerk/protocol/http/nsHttpPipeline.cpp +++ b/netwerk/protocol/http/nsHttpPipeline.cpp @@ -181,7 +181,7 @@ nsHttpPipeline::OnHeadersAvailable(nsAHttpTransaction *trans, MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); MOZ_ASSERT(mConnection, "no connection"); - nsRefPtr ci; + RefPtr ci; GetConnectionInfo(getter_AddRefs(ci)); MOZ_ASSERT(ci); @@ -373,7 +373,7 @@ nsHttpPipeline::Http1xTransactionCount() nsresult nsHttpPipeline::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { LOG(("nsHttpPipeline::TakeSubTransactions [this=%p]\n", this)); @@ -703,7 +703,7 @@ nsHttpPipeline::WriteSegments(nsAHttpSegmentWriter *writer, // ask the connection manager to add additional transactions // to our pipeline. - nsRefPtr ci; + RefPtr ci; GetConnectionInfo(getter_AddRefs(ci)); if (ci) gHttpHandler->ConnMgr()->ProcessPendingQForEntry(ci); @@ -796,7 +796,7 @@ nsHttpPipeline::Close(nsresult reason) mStatus = reason; mClosed = true; - nsRefPtr ci; + RefPtr ci; GetConnectionInfo(getter_AddRefs(ci)); uint32_t numRescheduled = CancelPipeline(reason); diff --git a/netwerk/protocol/http/nsHttpPipeline.h b/netwerk/protocol/http/nsHttpPipeline.h index 053e62d64b..0d81c9f463 100644 --- a/netwerk/protocol/http/nsHttpPipeline.h +++ b/netwerk/protocol/http/nsHttpPipeline.h @@ -59,7 +59,7 @@ private: // overload of nsAHttpTransaction::QueryPipeline() nsHttpPipeline *QueryPipeline() override; - nsRefPtr mConnection; + RefPtr mConnection; nsTArray mRequestQ; // array of transactions nsTArray mResponseQ; // array of transactions nsresult mStatus; diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 0960b9c869..628b6433d8 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -96,6 +96,7 @@ nsHttpTransaction::nsHttpTransaction() , mResponseHead(nullptr) , mContentLength(-1) , mContentRead(0) + , mTransferSize(0) , mInvalidResponseBytesRead(0) , mPushedStream(nullptr) , mInitialRwin(0) @@ -422,7 +423,7 @@ already_AddRefed nsHttpTransaction::GetConnectionReference() { MutexAutoLock lock(mLock); - nsRefPtr connection(mConnection); + RefPtr connection(mConnection); return connection.forget(); } @@ -477,7 +478,7 @@ nsHttpTransaction::Http1xTransactionCount() nsresult nsHttpTransaction::TakeSubTransactions( - nsTArray > &outTransactions) + nsTArray > &outTransactions) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -512,7 +513,7 @@ nsHttpTransaction::SetSecurityCallbacks(nsIInterfaceRequestor* aCallbacks) } if (gSocketTransportService) { - nsRefPtr event = new UpdateSecurityCallbacks(this, aCallbacks); + RefPtr event = new UpdateSecurityCallbacks(this, aCallbacks); gSocketTransportService->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); } } @@ -821,6 +822,7 @@ nsHttpTransaction::WritePipeSegment(nsIOutputStream *stream, MOZ_ASSERT(*countWritten > 0, "bad writer"); trans->CountRecvBytes(*countWritten); trans->mReceivedData = true; + trans->mTransferSize += *countWritten; // Let the transaction "play" with the buffer. It is free to modify // the contents of the buffer and/or modify countWritten. @@ -919,7 +921,7 @@ nsHttpTransaction::SaveNetworkStats(bool enforce) // Create the event to save the network statistics. // the event is then dispathed to the main thread. - nsRefPtr event = + RefPtr event = new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetworkInfo, mCountRecv, mCountSent, false); NS_DispatchToMainThread(event); @@ -1314,7 +1316,7 @@ nsHttpTransaction::Restart() if (!mConnInfo->GetRoutedHost().IsEmpty()) { MutexAutoLock lock(*nsHttp::GetLock()); - nsRefPtr ci; + RefPtr ci; mConnInfo->CloneAsDirectRoute(getter_AddRefs(ci)); mConnInfo = ci; if (mRequestHead) { diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index 6444cd528b..4cb8ecd8a3 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -160,8 +160,11 @@ public: mozilla::TimeStamp GetResponseStart(); mozilla::TimeStamp GetResponseEnd(); + int64_t GetTransferSize() { return mTransferSize; } + bool Do0RTT() override; nsresult Finish0RTT(bool aRestart) override; + private: friend class DeleteHttpTransaction; virtual ~nsHttpTransaction(); @@ -209,7 +212,7 @@ private: return NS_OK; } private: - nsRefPtr mTrans; + RefPtr mTrans; nsCOMPtr mCallbacks; }; @@ -230,8 +233,8 @@ private: nsCOMPtr mRequestStream; int64_t mRequestSize; - nsRefPtr mConnection; - nsRefPtr mConnInfo; + RefPtr mConnection; + RefPtr mConnInfo; nsHttpRequestHead *mRequestHead; // weak ref nsHttpResponseHead *mResponseHead; // owning pointer @@ -242,6 +245,7 @@ private: int64_t mContentLength; // equals -1 if unknown int64_t mContentRead; // count of consumed content bytes + int64_t mTransferSize; // count of received bytes // After a 304/204 or other "no-content" style response we will skip over // up to MAX_INVALID_RESPONSE_BODY_SZ bytes when looking for the next @@ -446,7 +450,7 @@ public: nsIInterfaceRequestor *SecurityCallbacks() { return mCallbacks; } private: - nsRefPtr mTunnelProvider; + RefPtr mTunnelProvider; bool m0RTTInProgress; diff --git a/netwerk/protocol/http/nsIHttpChannel.idl b/netwerk/protocol/http/nsIHttpChannel.idl index 70ebcedfa1..220ff10ed8 100644 --- a/netwerk/protocol/http/nsIHttpChannel.idl +++ b/netwerk/protocol/http/nsIHttpChannel.idl @@ -14,7 +14,7 @@ interface nsIHttpHeaderVisitor; * the inspection of the resulting HTTP response status and headers when they * become available. */ -[builtinclass, scriptable, uuid(e90acf2d-eaf2-41d8-97b2-c8d99f6437a1)] +[builtinclass, scriptable, uuid(b2596105-3d0d-4e6a-824f-0539713bb879)] interface nsIHttpChannel : nsIChannel { /************************************************************************** @@ -84,6 +84,31 @@ interface nsIHttpChannel : nsIChannel */ void setReferrerWithPolicy(in nsIURI referrer, in unsigned long referrerPolicy); + /** + * Returns the network protocol used to fetch the resource as identified + * by the ALPN Protocol ID. + * + * @throws NS_ERROR_NOT_AVAILABLE if called before the response + * has been received (before onStartRequest). + */ + readonly attribute ACString protocolVersion; + + /** + * size consumed by the response header fields and the response payload body + */ + readonly attribute uint64_t transferSize; + + /** + * The size of the message body received by the client, + * after removing any applied content-codings + */ + readonly attribute uint64_t decodedBodySize; + + /** + * The size in octets of the payload body, prior to removing content-codings + */ + readonly attribute uint64_t encodedBodySize; + /** * Get the value of a particular request header. * diff --git a/netwerk/protocol/http/nsIHttpChannelInternal.idl b/netwerk/protocol/http/nsIHttpChannelInternal.idl index 3bc2817ea8..b6779a33f4 100644 --- a/netwerk/protocol/http/nsIHttpChannelInternal.idl +++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl @@ -39,8 +39,7 @@ interface nsIHttpUpgradeListener : nsISupports * using any feature exposed by this interface, be aware that this interface * will change and you will be broken. You have been warned. */ -[scriptable, uuid(5f019a6f-6f6f-4b5c-8994-70cdbc40258e)] - +[scriptable, uuid(9eabaac6-cc7c-4ca1-9430-65f2daaa578f)] interface nsIHttpChannelInternal : nsISupports { /** @@ -223,6 +222,13 @@ interface nsIHttpChannelInternal : nsISupports readonly attribute PRTime lastModifiedTime; + /** + * Force a channel that has not been AsyncOpen'ed to skip any check for possible + * interception and proceed immediately to open a previously-synthesized cache + * entry using the provided ID. + */ + void forceIntercepted(in uint64_t aInterceptionID); + readonly attribute boolean responseSynthesized; /** @@ -235,7 +241,6 @@ interface nsIHttpChannelInternal : nsISupports const unsigned long CORS_MODE_SAME_ORIGIN = 0; const unsigned long CORS_MODE_NO_CORS = 1; const unsigned long CORS_MODE_CORS = 2; - const unsigned long CORS_MODE_CORS_WITH_FORCED_PREFLIGHT = 3; /** * Set by nsCORSListenerProxy to indicate CORS load type. Defaults to CORS_MODE_NO_CORS. */ diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 6fa355dded..5f6e82c077 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -211,7 +211,7 @@ SubstitutingProtocolHandler::NewURI(const nsACString &aSpec, { nsresult rv; - nsRefPtr url = new SubstitutingURL(); + RefPtr url = new SubstitutingURL(); if (!url) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/protocol/rtsp/RtspChannelChild.cpp b/netwerk/protocol/rtsp/RtspChannelChild.cpp index c38ee5f95f..369c89087c 100644 --- a/netwerk/protocol/rtsp/RtspChannelChild.cpp +++ b/netwerk/protocol/rtsp/RtspChannelChild.cpp @@ -99,9 +99,9 @@ public: return NS_OK; } private: - nsRefPtr mListener; - nsRefPtr mRequest; - nsRefPtr mContext; + RefPtr mListener; + RefPtr mRequest; + RefPtr mContext; }; NS_IMETHODIMP @@ -201,9 +201,9 @@ public: return NS_OK; } private: - nsRefPtr mListener; - nsRefPtr mRequest; - nsRefPtr mContext; + RefPtr mListener; + RefPtr mRequest; + RefPtr mContext; nsresult mStatus; }; diff --git a/netwerk/protocol/rtsp/RtspHandler.cpp b/netwerk/protocol/rtsp/RtspHandler.cpp index f633f1ce85..8462d4e9e2 100644 --- a/netwerk/protocol/rtsp/RtspHandler.cpp +++ b/netwerk/protocol/rtsp/RtspHandler.cpp @@ -56,7 +56,7 @@ RtspHandler::NewURI(const nsACString & aSpec, nsresult rv = GetDefaultPort(&port); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr url = new nsStandardURL(); + RefPtr url = new nsStandardURL(); rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, port, aSpec, aOriginCharset, aBaseURI); NS_ENSURE_SUCCESS(rv, rv); @@ -71,7 +71,7 @@ RtspHandler::NewChannel2(nsIURI* aURI, nsIChannel** aResult) { bool isRtsp = false; - nsRefPtr rtspChannel; + RefPtr rtspChannel; nsresult rv = aURI->SchemeIs("rtsp", &isRtsp); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/protocol/rtsp/controller/RtspController.cpp b/netwerk/protocol/rtsp/controller/RtspController.cpp index acdaf73366..a39e3ffbea 100644 --- a/netwerk/protocol/rtsp/controller/RtspController.cpp +++ b/netwerk/protocol/rtsp/controller/RtspController.cpp @@ -226,7 +226,7 @@ private: nsCString mData; uint32_t mLength; uint32_t mOffset; - nsRefPtr mMetaData; + RefPtr mMetaData; nsCOMPtr mListener; }; @@ -238,7 +238,7 @@ RtspController::OnMediaDataAvailable(uint8_t index, nsIStreamingProtocolMetaData *meta) { if (mListener && mState == CONNECTED) { - nsRefPtr task = + RefPtr task = new SendMediaDataTask(mListener, index, data, length, offset, meta); return NS_DispatchToMainThread(task); } @@ -266,7 +266,7 @@ public: private: nsCOMPtr mListener; uint8_t mIndex; - nsRefPtr mMetaData; + RefPtr mMetaData; }; @@ -277,7 +277,7 @@ RtspController::OnConnected(uint8_t index, LOG(("RtspController::OnConnected()")); mState = CONNECTED; if (mListener) { - nsRefPtr task = + RefPtr task = new SendOnConnectedTask(mListener, index, meta); return NS_DispatchToMainThread(task); } @@ -316,7 +316,7 @@ RtspController::OnDisconnected(uint8_t index, mState = DISCONNECTED; if (mListener) { - nsRefPtr task = + RefPtr task = new SendOnDisconnectedTask(mListener, index, reason); // Break the cycle reference between the Listener (RtspControllerParent) and // us. diff --git a/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp b/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp index 649cae9ff5..68c6fad31e 100644 --- a/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp +++ b/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp @@ -135,7 +135,7 @@ RtspControllerChild::RecvOnMediaDataAvailable( const uint32_t& offset, InfallibleTArray&& metaArray) { - nsRefPtr meta = new RtspMetaData(); + RefPtr meta = new RtspMetaData(); nsresult rv = meta->DeserializeRtspMetaData(metaArray); NS_ENSURE_SUCCESS(rv, true); @@ -164,7 +164,7 @@ RtspControllerChild::RecvOnConnected( InfallibleTArray&& metaArray) { // Deserialize meta data. - nsRefPtr meta = new RtspMetaData(); + RefPtr meta = new RtspMetaData(); nsresult rv = meta->DeserializeRtspMetaData(metaArray); NS_ENSURE_SUCCESS(rv, true); meta->GetTotalTracks(&mTotalTracks); @@ -304,7 +304,7 @@ public: return NS_OK; } private: - nsRefPtr mController; + RefPtr mController; IPCEvent mEvent; uint64_t mSeekTime; }; diff --git a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp index 8715979177..aa1923b6ad 100644 --- a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp +++ b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp @@ -42,7 +42,7 @@ RtspControllerParent::Destroy() if (!NS_IsMainThread()) { nsCOMPtr mainThread = do_GetMainThread(); NS_ENSURE_TRUE_VOID(mainThread); - nsRefPtr doomed(this); + RefPtr doomed(this); if (NS_FAILED(NS_ProxyRelease(mainThread, static_cast(doomed), true))) { NS_WARNING("Failed to proxy release to main thread!"); diff --git a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp index c1373be18a..fba00fe8c5 100644 --- a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp +++ b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp @@ -629,7 +629,7 @@ void RTSPSource::onConnected(bool isSeekable) info.mSource = source; } - nsRefPtr meta; + RefPtr meta; int32_t int32Value; int64_t int64Value; @@ -743,7 +743,7 @@ void RTSPSource::onTrackDataAvailable(size_t trackIndex) if (err == -EWOULDBLOCK || err == ERROR_END_OF_STREAM) { return; } else if (err == INFO_DISCONTINUITY) { - nsRefPtr meta; + RefPtr meta; meta = new mozilla::net::RtspMetaData(); meta->SetFrameType(MEDIASTREAM_FRAMETYPE_DISCONTINUITY); @@ -756,7 +756,7 @@ void RTSPSource::onTrackDataAvailable(size_t trackIndex) return; } - nsRefPtr meta; + RefPtr meta; int64_t int64Value; meta = new mozilla::net::RtspMetaData(); @@ -782,7 +782,7 @@ void RTSPSource::onTrackEndOfStream(size_t trackIndex) return; } - nsRefPtr meta; + RefPtr meta; meta = new mozilla::net::RtspMetaData(); meta->SetFrameType(MEDIASTREAM_FRAMETYPE_END_OF_STREAM); diff --git a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp index ebc9e74f79..bb6c3624b5 100644 --- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp @@ -150,6 +150,24 @@ nsViewSourceChannel::GetName(nsACString &result) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsViewSourceChannel::GetTransferSize(uint64_t *aTransferSize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsViewSourceChannel::GetDecodedBodySize(uint64_t *aDecodedBodySize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsViewSourceChannel::GetEncodedBodySize(uint64_t *aEncodedBodySize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsViewSourceChannel::IsPending(bool *result) { @@ -637,6 +655,12 @@ nsViewSourceChannel::SetBaseURI(nsIURI* aBaseURI) return NS_OK; } +NS_IMETHODIMP +nsViewSourceChannel::GetProtocolVersion(nsACString& aProtocolVersion) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + // nsIRequestObserver methods NS_IMETHODIMP nsViewSourceChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) diff --git a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp index a8e24b2d84..5f8932b50e 100644 --- a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp @@ -70,7 +70,7 @@ nsViewSourceHandler::NewURI(const nsACString &aSpec, asciiSpec.Insert(VIEW_SOURCE ":", 0); - // We can't swap() from an nsRefPtr to an nsIURI**, + // We can't swap() from an RefPtr to an nsIURI**, // sadly. nsSimpleNestedURI* ourURI = new nsSimpleNestedURI(innerURI); nsCOMPtr uri = ourURI; diff --git a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp index 6b132176cd..d863a7b2c2 100644 --- a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp +++ b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp @@ -248,7 +248,7 @@ BaseWebSocketChannel::NewURI(const nsACString & aSpec, const char *aOriginCharse if (NS_FAILED(rv)) return rv; - nsRefPtr url = new nsStandardURL(); + RefPtr url = new nsStandardURL(); rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, port, aSpec, aOriginCharset, aBaseURI); if (NS_FAILED(rv)) diff --git a/netwerk/protocol/websocket/BaseWebSocketChannel.h b/netwerk/protocol/websocket/BaseWebSocketChannel.h index 9af00d748e..d9f52864e6 100644 --- a/netwerk/protocol/websocket/BaseWebSocketChannel.h +++ b/netwerk/protocol/websocket/BaseWebSocketChannel.h @@ -78,7 +78,7 @@ class BaseWebSocketChannel : public nsIWebSocketChannel, protected: nsCOMPtr mOriginalURI; nsCOMPtr mURI; - nsRefPtr mListenerMT; + RefPtr mListenerMT; nsCOMPtr mCallbacks; nsCOMPtr mLoadGroup; nsCOMPtr mLoadInfo; diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index 80821b51c1..11953fa6cc 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -604,8 +604,8 @@ public: private: ~CallOnMessageAvailable() {} - nsRefPtr mChannel; - nsRefPtr mListenerMT; + RefPtr mChannel; + RefPtr mListenerMT; nsCString mData; int32_t mLen; }; @@ -642,8 +642,8 @@ public: private: ~CallOnStop() {} - nsRefPtr mChannel; - nsRefPtr mListenerMT; + RefPtr mChannel; + RefPtr mListenerMT; nsresult mReason; }; NS_IMPL_ISUPPORTS(CallOnStop, nsIRunnable) @@ -679,8 +679,8 @@ public: private: ~CallOnServerClose() {} - nsRefPtr mChannel; - nsRefPtr mListenerMT; + RefPtr mChannel; + RefPtr mListenerMT; uint16_t mCode; nsCString mReason; }; @@ -713,8 +713,8 @@ public: private: ~CallAcknowledge() {} - nsRefPtr mChannel; - nsRefPtr mListenerMT; + RefPtr mChannel; + RefPtr mListenerMT; uint32_t mSize; }; @@ -745,7 +745,7 @@ public: private: ~CallOnTransportAvailable() {} - nsRefPtr mChannel; + RefPtr mChannel; nsCOMPtr mTransport; nsCOMPtr mSocketIn; nsCOMPtr mSocketOut; @@ -1111,7 +1111,7 @@ public: private: ~OutboundEnqueuer() {} - nsRefPtr mChannel; + RefPtr mChannel; OutboundMessage *mMessage; }; NS_IMPL_ISUPPORTS(OutboundEnqueuer, nsIRunnable) @@ -2175,7 +2175,7 @@ namespace { class RemoveObserverRunnable : public nsRunnable { - nsRefPtr mChannel; + RefPtr mChannel; public: explicit RemoveObserverRunnable(WebSocketChannel* aChannel) @@ -2359,7 +2359,7 @@ WebSocketChannel::DoStopSession(nsresult reason) nsWSAdmissionManager::OnStopSession(this, reason); - nsRefPtr runnable = new CallOnStop(this, reason); + RefPtr runnable = new CallOnStop(this, reason); mTargetThread->Dispatch(runnable, NS_DISPATCH_NORMAL); } } @@ -3267,6 +3267,8 @@ WebSocketChannel::AsyncOpen(nsIURI *aURI, return rv; } + // Ideally we'd call newChannelFromURIWithLoadInfo here, but that doesn't + // allow setting proxy uri/flags rv = io2->NewChannelFromURIWithProxyFlags2( localURI, mURI, @@ -3887,7 +3889,7 @@ WebSocketChannel::SaveNetworkStats(bool enforce) // Create the event to save the network statistics. // the event is then dispathed to the main thread. - nsRefPtr event = + RefPtr event = new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetworkInfo, countRecv, countSent, false); NS_DispatchToMainThread(event); diff --git a/netwerk/protocol/websocket/WebSocketChannelChild.cpp b/netwerk/protocol/websocket/WebSocketChannelChild.cpp index 51ecf31261..681935a38b 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp @@ -201,7 +201,7 @@ class StartEvent : public ChannelEvent mChild->OnStart(mProtocol, mExtensions, mEffectiveURL, mEncrypted); } private: - nsRefPtr mChild; + RefPtr mChild; nsCString mProtocol; nsCString mExtensions; nsString mEffectiveURL; @@ -260,7 +260,7 @@ class StopEvent : public ChannelEvent mChild->OnStop(mStatusCode); } private: - nsRefPtr mChild; + RefPtr mChild; nsresult mStatusCode; }; @@ -308,7 +308,7 @@ class MessageEvent : public ChannelEvent } } private: - nsRefPtr mChild; + RefPtr mChild; nsCString mMessage; bool mBinary; }; @@ -376,7 +376,7 @@ class AcknowledgeEvent : public ChannelEvent mChild->OnAcknowledge(mSize); } private: - nsRefPtr mChild; + RefPtr mChild; uint32_t mSize; }; @@ -420,7 +420,7 @@ class ServerCloseEvent : public ChannelEvent mChild->OnServerClose(mCode, mReason); } private: - nsRefPtr mChild; + RefPtr mChild; uint16_t mCode; nsCString mReason; }; @@ -524,7 +524,7 @@ public: return NS_OK; } private: - nsRefPtr mChild; + RefPtr mChild; uint16_t mCode; nsCString mReason; }; @@ -576,7 +576,7 @@ public: return NS_OK; } private: - nsRefPtr mChild; + RefPtr mChild; nsCString mMsg; bool mBinaryMsg; }; @@ -647,7 +647,7 @@ public: return NS_OK; } private: - nsRefPtr mChild; + RefPtr mChild; nsAutoPtr mStream; uint32_t mLength; }; diff --git a/netwerk/protocol/websocket/WebSocketChannelChild.h b/netwerk/protocol/websocket/WebSocketChannelChild.h index 0a32ecf3f2..c5761f3db9 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.h +++ b/netwerk/protocol/websocket/WebSocketChannelChild.h @@ -69,7 +69,7 @@ class WebSocketChannelChild final : public BaseWebSocketChannel, void MaybeReleaseIPCObject(); - nsRefPtr mEventQ; + RefPtr mEventQ; nsString mEffectiveURL; // This variable is protected by mutex. diff --git a/netwerk/protocol/websocket/WebSocketChannelParent.cpp b/netwerk/protocol/websocket/WebSocketChannelParent.cpp index dd47919202..7daabab062 100644 --- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp @@ -205,7 +205,7 @@ WebSocketChannelParent::OnStart(nsISupports *aContext) mChannel->GetProtocol(protocol); mChannel->GetExtensions(extensions); - nsRefPtr channel; + RefPtr channel; channel = static_cast(mChannel.get()); MOZ_ASSERT(channel); diff --git a/netwerk/protocol/websocket/WebSocketChannelParent.h b/netwerk/protocol/websocket/WebSocketChannelParent.h index 47c09bb829..065b97e44f 100644 --- a/netwerk/protocol/websocket/WebSocketChannelParent.h +++ b/netwerk/protocol/websocket/WebSocketChannelParent.h @@ -58,7 +58,7 @@ class WebSocketChannelParent : public PWebSocketParent, void OfflineDisconnect() override; uint32_t GetAppId() override; - nsRefPtr mObserver; + RefPtr mObserver; nsCOMPtr mAuthProvider; nsCOMPtr mChannel; diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelChild.h b/netwerk/protocol/wyciwyg/WyciwygChannelChild.h index a89b5c5706..a712c46921 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.h +++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.h @@ -104,7 +104,7 @@ private: bool mIPCOpen; bool mSentAppData; - nsRefPtr mEventQ; + RefPtr mEventQ; friend class WyciwygStartRequestEvent; friend class WyciwygDataAvailableEvent; diff --git a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp index 51d838d870..ce024a264d 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp @@ -47,7 +47,7 @@ public: } } protected: - nsRefPtr mChannel; + RefPtr mChannel; }; class nsWyciwygSetCharsetandSourceEvent : public nsWyciwygAsyncEvent { @@ -795,7 +795,7 @@ nsWyciwygChannel::OpenCacheEntry(nsIURI *aURI, NS_ENSURE_SUCCESS(rv, rv); bool anonymous = mLoadFlags & LOAD_ANONYMOUS; - nsRefPtr loadInfo = mozilla::net::GetLoadContextInfo( + RefPtr loadInfo = mozilla::net::GetLoadContextInfo( mPrivateBrowsing, mAppId, mInBrowser, anonymous); nsCOMPtr cacheStorage; diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index 624046eabb..f33603f145 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -138,7 +138,7 @@ public: MOZ_ASSERT(rv == NS_OK); (void) rv; - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); gDataChannelShutdown = nullptr; } return NS_OK; @@ -261,7 +261,7 @@ DataChannelConnection::Destroy() // Finish Destroy on STS thread to avoid bug 876167 - once that's fixed, // the usrsctp_close() calls can move back here (and just proxy the // disconnect_all()) - RUN_ON_THREAD(mSTS, WrapRunnable(nsRefPtr(this), + RUN_ON_THREAD(mSTS, WrapRunnable(RefPtr(this), &DataChannelConnection::DestroyOnSTS, mSocket, mMasterSocket), NS_DISPATCH_NORMAL); @@ -550,7 +550,7 @@ DataChannelConnection::ConnectViaTransportFlow(TransportFlow *aFlow, uint16_t lo mRemotePort = remoteport; mState = CONNECTING; - RUN_ON_THREAD(mSTS, WrapRunnable(nsRefPtr(this), + RUN_ON_THREAD(mSTS, WrapRunnable(RefPtr(this), &DataChannelConnection::SetSignals), NS_DISPATCH_NORMAL); return true; @@ -663,7 +663,7 @@ DataChannelConnection::ProcessQueuedOpens() temp.Push(static_cast(temp_channel)); } - nsRefPtr channel; + RefPtr channel; // All these entries have an AddRef(); make that explicit now via the dont_AddRef() while (nullptr != (channel = dont_AddRef(static_cast(temp.PopFront())))) { if (channel->mFlags & DATA_CHANNEL_FLAGS_FINISH_OPEN) { @@ -737,7 +737,7 @@ DataChannelConnection::SctpDtlsOutput(void *addr, void *buffer, size_t length, // DISPATCH_SYNC is not fully blocking. This may be tricky, as it // needs to be a per-thread check, not a global. peer->mSTS->Dispatch(WrapRunnable( - nsRefPtr(peer), + RefPtr(peer), &DataChannelConnection::SendPacket, data, length, true), NS_DISPATCH_NORMAL); res = 0; // cheat! Packets can always be dropped later anyways @@ -1054,7 +1054,7 @@ bool DataChannelConnection::SendDeferredMessages() { uint32_t i; - nsRefPtr channel; // we may null out the refs to this + RefPtr channel; // we may null out the refs to this bool still_blocked = false; bool sent = false; @@ -1196,7 +1196,7 @@ DataChannelConnection::HandleOpenRequestMessage(const struct rtcweb_datachannel_ size_t length, uint16_t stream) { - nsRefPtr channel; + RefPtr channel; uint32_t prValue; uint16_t prPolicy; uint32_t flags; @@ -1700,7 +1700,7 @@ DataChannelConnection::ClearResets() } for (uint32_t i = 0; i < mStreamsResetting.Length(); ++i) { - nsRefPtr channel; + RefPtr channel; channel = FindChannelByStream(mStreamsResetting[i]); if (channel) { LOG(("Forgetting channel %u (%p) with pending reset",channel->mStream, channel.get())); @@ -1766,7 +1766,7 @@ void DataChannelConnection::HandleStreamResetEvent(const struct sctp_stream_reset_event *strrst) { uint32_t n, i; - nsRefPtr channel; // since we may null out the ref to the channel + RefPtr channel; // since we may null out the ref to the channel if (!(strrst->strreset_flags & SCTP_STREAM_RESET_DENIED) && !(strrst->strreset_flags & SCTP_STREAM_RESET_FAILED)) { @@ -1825,7 +1825,7 @@ DataChannelConnection::HandleStreamChangeEvent(const struct sctp_stream_change_e { uint16_t stream; uint32_t i; - nsRefPtr channel; + RefPtr channel; if (strchg->strchange_flags == SCTP_STREAM_CHANGE_DENIED) { LOG(("*** Failed increasing number of streams from %u (%u/%u)", @@ -1859,7 +1859,7 @@ DataChannelConnection::HandleStreamChangeEvent(const struct sctp_stream_change_e // Make sure we request enough streams if there's a big jump in streams // Could make a more complex API for OpenXxxFinish() and avoid this loop - int32_t num_needed = mPending.GetSize(); + size_t num_needed = mPending.GetSize(); LOG(("%d of %d new streams already needed", num_needed, new_len - old_len)); num_needed -= (new_len - old_len); // number we added @@ -2030,7 +2030,7 @@ DataChannelConnection::Open(const nsACString& label, const nsACString& protocol, } flags = !inOrder ? DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED : 0; - nsRefPtr channel(new DataChannel(this, + RefPtr channel(new DataChannel(this, aStream, DataChannel::CONNECTING, label, protocol, @@ -2049,7 +2049,7 @@ DataChannelConnection::Open(const nsACString& label, const nsACString& protocol, already_AddRefed DataChannelConnection::OpenFinish(already_AddRefed&& aChannel) { - nsRefPtr channel(aChannel); // takes the reference passed in + RefPtr channel(aChannel); // takes the reference passed in // Normally 1 reference if called from ::Open(), or 2 if called from // ProcessQueuedOpens() unless the DOMDataChannel was gc'd uint16_t stream = channel->mStream; @@ -2354,10 +2354,10 @@ private: // when we send our runnable back to MainThread. Then ~DataChannelConnection // can send the IOThread to MainThread to die in a runnable, avoiding // unsafe event loop recursion. Evil. - nsRefPtr mConnection; + RefPtr mConnection; uint16_t mStream; // Use RefCount for preventing the object is deleted when SendBlob returns. - nsRefPtr mBlob; + RefPtr mBlob; }; int32_t @@ -2409,7 +2409,7 @@ public: private: // Note: we can be destroyed off the target thread, so be careful not to let this // get Released()ed on the temp thread! - nsRefPtr mConnection; + RefPtr mConnection; uint16_t mStream; }; @@ -2434,10 +2434,10 @@ DataChannelConnection::ReadBlob(already_AddRefed aThis, NS_GetMainThread(getter_AddRefs(mainThread)); // Must not let Dispatching it cause the DataChannelConnection to get - // released on the wrong thread. Using WrapRunnable(nsRefPtr(aThis),... + // released on the wrong thread. Using WrapRunnable(RefPtr(aThis),... // will occasionally cause aThis to get released on this thread. Also, an explicit Runnable // lets us avoid copying the blob data an extra time. - nsRefPtr runnable = new DataChannelBlobSendRunnable(aThis, + RefPtr runnable = new DataChannelBlobSendRunnable(aThis, aStream); // avoid copying the blob data by passing the mData from the runnable if (NS_FAILED(aBlob->Available(&len)) || @@ -2501,7 +2501,7 @@ void DataChannelConnection::CloseInt(DataChannel *aChannel) { MOZ_ASSERT(aChannel); - nsRefPtr channel(aChannel); // make sure it doesn't go away on us + RefPtr channel(aChannel); // make sure it doesn't go away on us mLock.AssertCurrentThreadOwns(); LOG(("Connection %p/Channel %p: Closing stream %u", @@ -2558,7 +2558,7 @@ void DataChannelConnection::CloseAll() } // Clean up any pending opens for channels - nsRefPtr channel; + RefPtr channel; while (nullptr != (channel = dont_AddRef(static_cast(mPending.PopFront())))) { LOG(("closing pending channel %p, stream %u", channel.get(), channel->mStream)); channel->Close(); // also releases the ref on each iteration diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h index 4c53983310..d2236723fb 100644 --- a/netwerk/sctp/datachannel/DataChannel.h +++ b/netwerk/sctp/datachannel/DataChannel.h @@ -257,13 +257,13 @@ private: #endif // Exists solely for proxying release of the TransportFlow to the STS thread - static void ReleaseTransportFlow(nsRefPtr aFlow) {} + static void ReleaseTransportFlow(RefPtr aFlow) {} // Data: // NOTE: while this array will auto-expand, increases in the number of // channels available from the stack must be negotiated! bool mAllocateEven; - nsAutoTArray,16> mStreams; + nsAutoTArray,16> mStreams; nsDeque mPending; // Holds addref'ed DataChannel's -- careful! // holds data that's come in before a channel is open nsTArray > mQueuedData; @@ -276,7 +276,7 @@ private: uint16_t mState; // Protected with mLock #ifdef SCTP_DTLS_SUPPORTED - nsRefPtr mTransportFlow; + RefPtr mTransportFlow; nsCOMPtr mSTS; #endif uint16_t mLocalPort; // Accessed from connect thread @@ -424,7 +424,7 @@ private: nsresult AddDataToBinaryMsg(const char *data, uint32_t size); - nsRefPtr mConnection; + RefPtr mConnection; nsCString mLabel; nsCString mProtocol; uint16_t mState; @@ -557,8 +557,8 @@ private: int32_t mType; // XXX should use union - nsRefPtr mChannel; - nsRefPtr mConnection; + RefPtr mChannel; + RefPtr mConnection; nsCString mData; int32_t mLen; }; diff --git a/netwerk/streamconv/converters/moz.build b/netwerk/streamconv/converters/moz.build index 2eba710b5e..b2f0a9f4a2 100644 --- a/netwerk/streamconv/converters/moz.build +++ b/netwerk/streamconv/converters/moz.build @@ -4,6 +4,12 @@ # 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/. +XPIDL_SOURCES += [ + 'nsICompressConvStats.idl' +] + +XPIDL_MODULE = 'necko_http' + UNIFIED_SOURCES += [ 'mozTXTToHTMLConv.cpp', 'nsDirIndex.cpp', diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index 318fec6ff5..ce573ff8fe 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -1,5 +1,5 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:set ts=4 sw=4 sts=4 cindent et: */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=8 et 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/. */ @@ -27,113 +27,120 @@ namespace net { NS_IMPL_ISUPPORTS(nsHTTPCompressConv, nsIStreamConverter, nsIStreamListener, - nsIRequestObserver) + nsIRequestObserver, + nsICompressConvStats) // nsFTPDirListingConv methods nsHTTPCompressConv::nsHTTPCompressConv() - : mListener(nullptr) - , mMode(HTTP_COMPRESS_IDENTITY) - , mOutBuffer(nullptr) - , mInpBuffer(nullptr) - , mOutBufferLen(0) - , mInpBufferLen(0) - , mCheckHeaderDone(false) - , mStreamEnded(false) - , mStreamInitialized(false) - , mLen(0) - , hMode(0) - , mSkipCount(0) - , mFlags(0) + : mMode(HTTP_COMPRESS_IDENTITY) + , mOutBuffer(nullptr) + , mInpBuffer(nullptr) + , mOutBufferLen(0) + , mInpBufferLen(0) + , mCheckHeaderDone(false) + , mStreamEnded(false) + , mStreamInitialized(false) + , mLen(0) + , hMode(0) + , mSkipCount(0) + , mFlags(0) + , mDecodedDataLength(0) { - if (NS_IsMainThread()) { - mFailUncleanStops = - Preferences::GetBool("network.http.enforce-framing.http", false); - } else { - mFailUncleanStops = false; - } + if (NS_IsMainThread()) { + mFailUncleanStops = + Preferences::GetBool("network.http.enforce-framing.http", false); + } else { + mFailUncleanStops = false; + } } nsHTTPCompressConv::~nsHTTPCompressConv() { - NS_IF_RELEASE(mListener); + if (mInpBuffer) { + free(mInpBuffer); + } - if (mInpBuffer) - free(mInpBuffer); + if (mOutBuffer) { + free(mOutBuffer); + } - if (mOutBuffer) - free(mOutBuffer); - - // For some reason we are not getting Z_STREAM_END. But this was also seen - // for mozilla bug 198133. Need to handle this case. - if (mStreamInitialized && !mStreamEnded) - inflateEnd (&d_stream); + // For some reason we are not getting Z_STREAM_END. But this was also seen + // for mozilla bug 198133. Need to handle this case. + if (mStreamInitialized && !mStreamEnded) { + inflateEnd (&d_stream); + } } NS_IMETHODIMP -nsHTTPCompressConv::AsyncConvertData(const char *aFromType, - const char *aToType, - nsIStreamListener *aListener, +nsHTTPCompressConv::GetDecodedDataLength(uint64_t *aDecodedDataLength) +{ + *aDecodedDataLength = mDecodedDataLength; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPCompressConv::AsyncConvertData(const char *aFromType, + const char *aToType, + nsIStreamListener *aListener, nsISupports *aCtxt) { - if (!PL_strncasecmp(aFromType, HTTP_COMPRESS_TYPE, sizeof(HTTP_COMPRESS_TYPE)-1) || - !PL_strncasecmp(aFromType, HTTP_X_COMPRESS_TYPE, sizeof(HTTP_X_COMPRESS_TYPE)-1)) - mMode = HTTP_COMPRESS_COMPRESS; + if (!PL_strncasecmp(aFromType, HTTP_COMPRESS_TYPE, sizeof(HTTP_COMPRESS_TYPE)-1) || + !PL_strncasecmp(aFromType, HTTP_X_COMPRESS_TYPE, sizeof(HTTP_X_COMPRESS_TYPE)-1)) { + mMode = HTTP_COMPRESS_COMPRESS; + } else if (!PL_strncasecmp(aFromType, HTTP_GZIP_TYPE, sizeof(HTTP_GZIP_TYPE)-1) || + !PL_strncasecmp(aFromType, HTTP_X_GZIP_TYPE, sizeof(HTTP_X_GZIP_TYPE)-1)) { + mMode = HTTP_COMPRESS_GZIP; + } else if (!PL_strncasecmp(aFromType, HTTP_DEFLATE_TYPE, sizeof(HTTP_DEFLATE_TYPE)-1)) { + mMode = HTTP_COMPRESS_DEFLATE; + } else if (!PL_strncasecmp(aFromType, HTTP_BROTLI_TYPE, sizeof(HTTP_BROTLI_TYPE)-1)) { + mMode = HTTP_COMPRESS_BROTLI; + } - else if (!PL_strncasecmp(aFromType, HTTP_GZIP_TYPE, sizeof(HTTP_GZIP_TYPE)-1) || - !PL_strncasecmp(aFromType, HTTP_X_GZIP_TYPE, sizeof(HTTP_X_GZIP_TYPE)-1)) - mMode = HTTP_COMPRESS_GZIP; + // hook ourself up with the receiving listener. + mListener = aListener; - else if (!PL_strncasecmp(aFromType, HTTP_DEFLATE_TYPE, sizeof(HTTP_DEFLATE_TYPE)-1)) - mMode = HTTP_COMPRESS_DEFLATE; - - else if (!PL_strncasecmp(aFromType, HTTP_BROTLI_TYPE, sizeof(HTTP_BROTLI_TYPE)-1)) - mMode = HTTP_COMPRESS_BROTLI; - - // hook ourself up with the receiving listener. - mListener = aListener; - NS_ADDREF(mListener); - - mAsyncConvContext = aCtxt; - return NS_OK; -} + mAsyncConvContext = aCtxt; + return NS_OK; +} NS_IMETHODIMP nsHTTPCompressConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { - return mListener->OnStartRequest(request, aContext); -} + return mListener->OnStartRequest(request, aContext); +} NS_IMETHODIMP -nsHTTPCompressConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, +nsHTTPCompressConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus) { - nsresult status = aStatus; - - // Framing integrity is enforced for content-encoding: gzip, but not for - // content-encoding: deflate. Note that gzip vs deflate is NOT determined - // by content sniffing but only via header. - if (!mStreamEnded && NS_SUCCEEDED(status) && - (mFailUncleanStops && (mMode == HTTP_COMPRESS_GZIP)) ) { - // This is not a clean end of gzip stream: the transfer is incomplete. - status = NS_ERROR_NET_PARTIAL_TRANSFER; + nsresult status = aStatus; + + // Framing integrity is enforced for content-encoding: gzip, but not for + // content-encoding: deflate. Note that gzip vs deflate is NOT determined + // by content sniffing but only via header. + if (!mStreamEnded && NS_SUCCEEDED(status) && + (mFailUncleanStops && (mMode == HTTP_COMPRESS_GZIP)) ) { + // This is not a clean end of gzip stream: the transfer is incomplete. + status = NS_ERROR_NET_PARTIAL_TRANSFER; + } + if (NS_SUCCEEDED(status) && mMode == HTTP_COMPRESS_BROTLI) { + uint32_t waste; + nsCOMPtr fpChannel = do_QueryInterface(request); + bool isPending = false; + if (request) { + request->IsPending(&isPending); } - if (NS_SUCCEEDED(status) && mMode == HTTP_COMPRESS_BROTLI) { - uint32_t waste; - nsCOMPtr fpChannel = do_QueryInterface(request); - bool isPending = false; - if (request) { - request->IsPending(&isPending); - } - if (fpChannel && !isPending) { - fpChannel->ForcePending(true); - } - status = BrotliHandler(nullptr, this, nullptr, 0, 0, &waste); - if (fpChannel && !isPending) { - fpChannel->ForcePending(false); - } + if (fpChannel && !isPending) { + fpChannel->ForcePending(true); } - return mListener->OnStopRequest(request, aContext, status); -} + status = BrotliHandler(nullptr, this, nullptr, 0, 0, &waste); + if (fpChannel && !isPending) { + fpChannel->ForcePending(false); + } + } + return mListener->OnStopRequest(request, aContext, status); +} + // static NS_METHOD @@ -165,7 +172,6 @@ nsHTTPCompressConv::BrotliHandler(nsIInputStream *stream, void *closure, const c outPtr = outBuffer; // brotli api is documented in brotli/dec/decode.h and brotli/dec/decode.c - size_t totalOut = self->mBrotli->mTotalOut; res = ::BrotliDecoderDecompressStream( &self->mBrotli->mState, @@ -213,278 +219,267 @@ nsHTTPCompressConv::BrotliHandler(nsIInputStream *stream, void *closure, const c } NS_IMETHODIMP -nsHTTPCompressConv::OnDataAvailable(nsIRequest* request, - nsISupports *aContext, - nsIInputStream *iStr, - uint64_t aSourceOffset, +nsHTTPCompressConv::OnDataAvailable(nsIRequest* request, + nsISupports *aContext, + nsIInputStream *iStr, + uint64_t aSourceOffset, uint32_t aCount) { - nsresult rv = NS_ERROR_INVALID_CONTENT_ENCODING; - uint32_t streamLen = aCount; + nsresult rv = NS_ERROR_INVALID_CONTENT_ENCODING; + uint32_t streamLen = aCount; - if (streamLen == 0) - { - NS_ERROR("count of zero passed to OnDataAvailable"); - return NS_ERROR_UNEXPECTED; + if (streamLen == 0) { + NS_ERROR("count of zero passed to OnDataAvailable"); + return NS_ERROR_UNEXPECTED; + } + + if (mStreamEnded) { + // Hmm... this may just indicate that the data stream is done and that + // what's left is either metadata or padding of some sort.... throwing + // it out is probably the safe thing to do. + uint32_t n; + return iStr->ReadSegments(NS_DiscardSegment, nullptr, streamLen, &n); + } + + switch (mMode) { + case HTTP_COMPRESS_GZIP: + streamLen = check_header(iStr, streamLen, &rv); + + if (rv != NS_OK) { + return rv; } - if (mStreamEnded) - { - // Hmm... this may just indicate that the data stream is done and that - // what's left is either metadata or padding of some sort.... throwing - // it out is probably the safe thing to do. - uint32_t n; - return iStr->ReadSegments(NS_DiscardSegment, nullptr, streamLen, &n); + if (streamLen == 0) { + return NS_OK; } - switch (mMode) - { - case HTTP_COMPRESS_GZIP: - streamLen = check_header(iStr, streamLen, &rv); + // FALLTHROUGH - if (rv != NS_OK) - return rv; + case HTTP_COMPRESS_DEFLATE: - if (streamLen == 0) - return NS_OK; + if (mInpBuffer != nullptr && streamLen > mInpBufferLen) { + mInpBuffer = (unsigned char *) realloc(mInpBuffer, mInpBufferLen = streamLen); - // FALLTHROUGH + if (mOutBufferLen < streamLen * 2) { + mOutBuffer = (unsigned char *) realloc(mOutBuffer, mOutBufferLen = streamLen * 3); + } - case HTTP_COMPRESS_DEFLATE: + if (mInpBuffer == nullptr || mOutBuffer == nullptr) { + return NS_ERROR_OUT_OF_MEMORY; + } + } - if (mInpBuffer != nullptr && streamLen > mInpBufferLen) - { - mInpBuffer = (unsigned char *) moz_realloc(mInpBuffer, mInpBufferLen = streamLen); - - if (mOutBufferLen < streamLen * 2) - mOutBuffer = (unsigned char *) moz_realloc(mOutBuffer, mOutBufferLen = streamLen * 3); + if (mInpBuffer == nullptr) { + mInpBuffer = (unsigned char *) malloc(mInpBufferLen = streamLen); + } - if (mInpBuffer == nullptr || mOutBuffer == nullptr) - return NS_ERROR_OUT_OF_MEMORY; - } + if (mOutBuffer == nullptr) { + mOutBuffer = (unsigned char *) malloc(mOutBufferLen = streamLen * 3); + } - if (mInpBuffer == nullptr) - mInpBuffer = (unsigned char *) moz_malloc(mInpBufferLen = streamLen); + if (mInpBuffer == nullptr || mOutBuffer == nullptr) { + return NS_ERROR_OUT_OF_MEMORY; + } - if (mOutBuffer == nullptr) - mOutBuffer = (unsigned char *) moz_malloc(mOutBufferLen = streamLen * 3); + uint32_t unused; + iStr->Read((char *)mInpBuffer, streamLen, &unused); - if (mInpBuffer == nullptr || mOutBuffer == nullptr) - return NS_ERROR_OUT_OF_MEMORY; + if (mMode == HTTP_COMPRESS_DEFLATE) { + if (!mStreamInitialized) { + memset(&d_stream, 0, sizeof (d_stream)); - uint32_t unused; - iStr->Read((char *)mInpBuffer, streamLen, &unused); - - if (mMode == HTTP_COMPRESS_DEFLATE) - { - if (!mStreamInitialized) - { - memset(&d_stream, 0, sizeof (d_stream)); - - if (inflateInit(&d_stream) != Z_OK) - return NS_ERROR_FAILURE; - - mStreamInitialized = true; - } - d_stream.next_in = mInpBuffer; - d_stream.avail_in = (uInt)streamLen; - - mDummyStreamInitialised = false; - for (;;) - { - d_stream.next_out = mOutBuffer; - d_stream.avail_out = (uInt)mOutBufferLen; - - int code = inflate(&d_stream, Z_NO_FLUSH); - unsigned bytesWritten = (uInt)mOutBufferLen - d_stream.avail_out; - - if (code == Z_STREAM_END) - { - if (bytesWritten) - { - rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); - if (NS_FAILED (rv)) - return rv; - } - - inflateEnd(&d_stream); - mStreamEnded = true; - break; - } - else if (code == Z_OK) - { - if (bytesWritten) - { - rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); - if (NS_FAILED (rv)) - return rv; - } - } - else if (code == Z_BUF_ERROR) - { - if (bytesWritten) - { - rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); - if (NS_FAILED (rv)) - return rv; - } - break; - } - else if (code == Z_DATA_ERROR) - { - // some servers (notably Apache with mod_deflate) don't generate zlib headers - // insert a dummy header and try again - static char dummy_head[2] = - { - 0x8 + 0x7 * 0x10, - (((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF, - }; - inflateReset(&d_stream); - d_stream.next_in = (Bytef*) dummy_head; - d_stream.avail_in = sizeof(dummy_head); - - code = inflate(&d_stream, Z_NO_FLUSH); - if (code != Z_OK) - return NS_ERROR_FAILURE; - - // stop an endless loop caused by non-deflate data being labelled as deflate - if (mDummyStreamInitialised) { - NS_WARNING("endless loop detected" - " - invalid deflate"); - return NS_ERROR_INVALID_CONTENT_ENCODING; - } - mDummyStreamInitialised = true; - // reset stream pointers to our original data - d_stream.next_in = mInpBuffer; - d_stream.avail_in = (uInt)streamLen; - } - else - return NS_ERROR_INVALID_CONTENT_ENCODING; - } /* for */ - } - else - { - if (!mStreamInitialized) - { - memset(&d_stream, 0, sizeof (d_stream)); - - if (inflateInit2(&d_stream, -MAX_WBITS) != Z_OK) - return NS_ERROR_FAILURE; - - mStreamInitialized = true; - } - - d_stream.next_in = mInpBuffer; - d_stream.avail_in = (uInt)streamLen; - - for (;;) - { - d_stream.next_out = mOutBuffer; - d_stream.avail_out = (uInt)mOutBufferLen; - - int code = inflate (&d_stream, Z_NO_FLUSH); - unsigned bytesWritten = (uInt)mOutBufferLen - d_stream.avail_out; - - if (code == Z_STREAM_END) - { - if (bytesWritten) - { - rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); - if (NS_FAILED (rv)) - return rv; - } - - inflateEnd(&d_stream); - mStreamEnded = true; - break; - } - else if (code == Z_OK) - { - if (bytesWritten) - { - rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); - if (NS_FAILED (rv)) - return rv; - } - } - else if (code == Z_BUF_ERROR) - { - if (bytesWritten) - { - rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); - if (NS_FAILED (rv)) - return rv; - } - break; - } - else - return NS_ERROR_INVALID_CONTENT_ENCODING; - } /* for */ - } /* gzip */ - break; - case HTTP_COMPRESS_BROTLI: - { - if (!mBrotli) { - mBrotli = new BrotliWrapper(); - } - - mBrotli->mRequest = request; - mBrotli->mContext = aContext; - mBrotli->mSourceOffset = aSourceOffset; - - uint32_t countRead; - rv = iStr->ReadSegments(BrotliHandler, this, streamLen, &countRead); - if (NS_SUCCEEDED(rv)) { - rv = mBrotli->mStatus; - } - if (NS_FAILED(rv)) { - return rv; - } + if (inflateInit(&d_stream) != Z_OK) { + return NS_ERROR_FAILURE; } - break; - - default: - rv = mListener->OnDataAvailable(request, aContext, iStr, aSourceOffset, aCount); - if (NS_FAILED (rv)) - return rv; - } /* switch */ - return NS_OK; + mStreamInitialized = true; + } + d_stream.next_in = mInpBuffer; + d_stream.avail_in = (uInt)streamLen; + + mDummyStreamInitialised = false; + for (;;) { + d_stream.next_out = mOutBuffer; + d_stream.avail_out = (uInt)mOutBufferLen; + + int code = inflate(&d_stream, Z_NO_FLUSH); + unsigned bytesWritten = (uInt)mOutBufferLen - d_stream.avail_out; + + if (code == Z_STREAM_END) { + if (bytesWritten) { + rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + if (NS_FAILED (rv)) { + return rv; + } + } + + inflateEnd(&d_stream); + mStreamEnded = true; + break; + } else if (code == Z_OK) { + if (bytesWritten) { + rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + if (NS_FAILED (rv)) { + return rv; + } + } + } else if (code == Z_BUF_ERROR) { + if (bytesWritten) { + rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + if (NS_FAILED (rv)) { + return rv; + } + } + break; + } else if (code == Z_DATA_ERROR) { + // some servers (notably Apache with mod_deflate) don't generate zlib headers + // insert a dummy header and try again + static char dummy_head[2] = + { + 0x8 + 0x7 * 0x10, + (((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF, + }; + inflateReset(&d_stream); + d_stream.next_in = (Bytef*) dummy_head; + d_stream.avail_in = sizeof(dummy_head); + + code = inflate(&d_stream, Z_NO_FLUSH); + if (code != Z_OK) { + return NS_ERROR_FAILURE; + } + + // stop an endless loop caused by non-deflate data being labelled as deflate + if (mDummyStreamInitialised) { + NS_WARNING("endless loop detected" + " - invalid deflate"); + return NS_ERROR_INVALID_CONTENT_ENCODING; + } + mDummyStreamInitialised = true; + // reset stream pointers to our original data + d_stream.next_in = mInpBuffer; + d_stream.avail_in = (uInt)streamLen; + } else { + return NS_ERROR_INVALID_CONTENT_ENCODING; + } + } /* for */ + } else { + if (!mStreamInitialized) { + memset(&d_stream, 0, sizeof (d_stream)); + + if (inflateInit2(&d_stream, -MAX_WBITS) != Z_OK) { + return NS_ERROR_FAILURE; + } + + mStreamInitialized = true; + } + + d_stream.next_in = mInpBuffer; + d_stream.avail_in = (uInt)streamLen; + + for (;;) { + d_stream.next_out = mOutBuffer; + d_stream.avail_out = (uInt)mOutBufferLen; + + int code = inflate (&d_stream, Z_NO_FLUSH); + unsigned bytesWritten = (uInt)mOutBufferLen - d_stream.avail_out; + + if (code == Z_STREAM_END) { + if (bytesWritten) { + rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + if (NS_FAILED (rv)) { + return rv; + } + } + + inflateEnd(&d_stream); + mStreamEnded = true; + break; + } else if (code == Z_OK) { + if (bytesWritten) { + rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + if (NS_FAILED (rv)) { + return rv; + } + } + } else if (code == Z_BUF_ERROR) { + if (bytesWritten) { + rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + if (NS_FAILED (rv)) { + return rv; + } + } + break; + } else { + return NS_ERROR_INVALID_CONTENT_ENCODING; + } + } /* for */ + } /* gzip */ + break; + + case HTTP_COMPRESS_BROTLI: + { + if (!mBrotli) { + mBrotli = new BrotliWrapper(); + } + + mBrotli->mRequest = request; + mBrotli->mContext = aContext; + mBrotli->mSourceOffset = aSourceOffset; + + uint32_t countRead; + rv = iStr->ReadSegments(BrotliHandler, this, streamLen, &countRead); + if (NS_SUCCEEDED(rv)) { + rv = mBrotli->mStatus; + } + if (NS_FAILED(rv)) { + return rv; + } + } + break; + + default: + rv = mListener->OnDataAvailable(request, aContext, iStr, aSourceOffset, aCount); + if (NS_FAILED (rv)) { + return rv; + } + } /* switch */ + + return NS_OK; } /* OnDataAvailable */ - // XXX/ruslan: need to implement this too NS_IMETHODIMP -nsHTTPCompressConv::Convert(nsIInputStream *aFromStream, - const char *aFromType, - const char *aToType, - nsISupports *aCtxt, +nsHTTPCompressConv::Convert(nsIInputStream *aFromStream, + const char *aFromType, + const char *aToType, + nsISupports *aCtxt, nsIInputStream **_retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} +{ + return NS_ERROR_NOT_IMPLEMENTED; +} nsresult nsHTTPCompressConv::do_OnDataAvailable(nsIRequest* request, nsISupports *context, uint64_t offset, const char *buffer, uint32_t count) { - if (!mStream) { - mStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID); - NS_ENSURE_STATE(mStream); - } + if (!mStream) { + mStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID); + NS_ENSURE_STATE(mStream); + } - mStream->ShareData(buffer, count); + mStream->ShareData(buffer, count); - nsresult rv = mListener->OnDataAvailable(request, context, mStream, - offset, count); + nsresult rv = mListener->OnDataAvailable(request, context, mStream, + offset, count); - // Make sure the stream no longer references |buffer| in case our listener - // is crazy enough to try to read from |mStream| after ODA. - mStream->ShareData("", 0); + // Make sure the stream no longer references |buffer| in case our listener + // is crazy enough to try to read from |mStream| after ODA. + mStream->ShareData("", 0); + mDecodedDataLength += count; - return rv; + return rv; } #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ @@ -499,146 +494,130 @@ static unsigned gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ uint32_t nsHTTPCompressConv::check_header(nsIInputStream *iStr, uint32_t streamLen, nsresult *rs) { - enum { GZIP_INIT = 0, GZIP_OS, GZIP_EXTRA0, GZIP_EXTRA1, GZIP_EXTRA2, GZIP_ORIG, GZIP_COMMENT, GZIP_CRC }; - char c; + enum { GZIP_INIT = 0, GZIP_OS, GZIP_EXTRA0, GZIP_EXTRA1, GZIP_EXTRA2, GZIP_ORIG, GZIP_COMMENT, GZIP_CRC }; + char c; - *rs = NS_OK; + *rs = NS_OK; - if (mCheckHeaderDone) - return streamLen; - - while (streamLen) - { - switch (hMode) - { - case GZIP_INIT: - uint32_t unused; - iStr->Read(&c, 1, &unused); - streamLen--; - - if (mSkipCount == 0 && ((unsigned)c & 0377) != gz_magic[0]) - { - *rs = NS_ERROR_INVALID_CONTENT_ENCODING; - return 0; - } - - if (mSkipCount == 1 && ((unsigned)c & 0377) != gz_magic[1]) - { - *rs = NS_ERROR_INVALID_CONTENT_ENCODING; - return 0; - } - - if (mSkipCount == 2 && ((unsigned)c & 0377) != Z_DEFLATED) - { - *rs = NS_ERROR_INVALID_CONTENT_ENCODING; - return 0; - } - - mSkipCount++; - if (mSkipCount == 4) - { - mFlags = (unsigned) c & 0377; - if (mFlags & RESERVED) - { - *rs = NS_ERROR_INVALID_CONTENT_ENCODING; - return 0; - } - hMode = GZIP_OS; - mSkipCount = 0; - } - break; - - case GZIP_OS: - iStr->Read(&c, 1, &unused); - streamLen--; - mSkipCount++; - - if (mSkipCount == 6) - hMode = GZIP_EXTRA0; - break; - - case GZIP_EXTRA0: - if (mFlags & EXTRA_FIELD) - { - iStr->Read(&c, 1, &unused); - streamLen--; - mLen = (uInt) c & 0377; - hMode = GZIP_EXTRA1; - } - else - hMode = GZIP_ORIG; - break; - - case GZIP_EXTRA1: - iStr->Read(&c, 1, &unused); - streamLen--; - mLen = ((uInt) c & 0377) << 8; - mSkipCount = 0; - hMode = GZIP_EXTRA2; - break; - - case GZIP_EXTRA2: - if (mSkipCount == mLen) - hMode = GZIP_ORIG; - else - { - iStr->Read(&c, 1, &unused); - streamLen--; - mSkipCount++; - } - break; - - case GZIP_ORIG: - if (mFlags & ORIG_NAME) - { - iStr->Read(&c, 1, &unused); - streamLen--; - if (c == 0) - hMode = GZIP_COMMENT; - } - else - hMode = GZIP_COMMENT; - break; - - case GZIP_COMMENT: - if (mFlags & COMMENT) - { - iStr->Read(&c, 1, &unused); - streamLen--; - if (c == 0) - { - hMode = GZIP_CRC; - mSkipCount = 0; - } - } - else - { - hMode = GZIP_CRC; - mSkipCount = 0; - } - break; - - case GZIP_CRC: - if (mFlags & HEAD_CRC) - { - iStr->Read(&c, 1, &unused); - streamLen--; - mSkipCount++; - if (mSkipCount == 2) - { - mCheckHeaderDone = true; - return streamLen; - } - } - else - { - mCheckHeaderDone = true; - return streamLen; - } - break; - } - } + if (mCheckHeaderDone) { return streamLen; + } + + while (streamLen) { + switch (hMode) { + case GZIP_INIT: + uint32_t unused; + iStr->Read(&c, 1, &unused); + streamLen--; + + if (mSkipCount == 0 && ((unsigned)c & 0377) != gz_magic[0]) { + *rs = NS_ERROR_INVALID_CONTENT_ENCODING; + return 0; + } + + if (mSkipCount == 1 && ((unsigned)c & 0377) != gz_magic[1]) { + *rs = NS_ERROR_INVALID_CONTENT_ENCODING; + return 0; + } + + if (mSkipCount == 2 && ((unsigned)c & 0377) != Z_DEFLATED) { + *rs = NS_ERROR_INVALID_CONTENT_ENCODING; + return 0; + } + + mSkipCount++; + if (mSkipCount == 4) { + mFlags = (unsigned) c & 0377; + if (mFlags & RESERVED) { + *rs = NS_ERROR_INVALID_CONTENT_ENCODING; + return 0; + } + hMode = GZIP_OS; + mSkipCount = 0; + } + break; + + case GZIP_OS: + iStr->Read(&c, 1, &unused); + streamLen--; + mSkipCount++; + + if (mSkipCount == 6) { + hMode = GZIP_EXTRA0; + } + break; + + case GZIP_EXTRA0: + if (mFlags & EXTRA_FIELD) { + iStr->Read(&c, 1, &unused); + streamLen--; + mLen = (uInt) c & 0377; + hMode = GZIP_EXTRA1; + } else { + hMode = GZIP_ORIG; + } + break; + + case GZIP_EXTRA1: + iStr->Read(&c, 1, &unused); + streamLen--; + mLen |= ((uInt) c & 0377) << 8; + mSkipCount = 0; + hMode = GZIP_EXTRA2; + break; + + case GZIP_EXTRA2: + if (mSkipCount == mLen) { + hMode = GZIP_ORIG; + } else { + iStr->Read(&c, 1, &unused); + streamLen--; + mSkipCount++; + } + break; + + case GZIP_ORIG: + if (mFlags & ORIG_NAME) { + iStr->Read(&c, 1, &unused); + streamLen--; + if (c == 0) + hMode = GZIP_COMMENT; + } else { + hMode = GZIP_COMMENT; + } + break; + + case GZIP_COMMENT: + if (mFlags & COMMENT) { + iStr->Read(&c, 1, &unused); + streamLen--; + if (c == 0) { + hMode = GZIP_CRC; + mSkipCount = 0; + } + } else { + hMode = GZIP_CRC; + mSkipCount = 0; + } + break; + + case GZIP_CRC: + if (mFlags & HEAD_CRC) { + iStr->Read(&c, 1, &unused); + streamLen--; + mSkipCount++; + if (mSkipCount == 2) { + mCheckHeaderDone = true; + return streamLen; + } + } else { + mCheckHeaderDone = true; + return streamLen; + } + break; + } + } + return streamLen; } } // namespace net @@ -647,17 +626,16 @@ nsHTTPCompressConv::check_header(nsIInputStream *iStr, uint32_t streamLen, nsres nsresult NS_NewHTTPCompressConv(mozilla::net::nsHTTPCompressConv **aHTTPCompressConv) { - NS_PRECONDITION(aHTTPCompressConv != nullptr, "null ptr"); + NS_PRECONDITION(aHTTPCompressConv != nullptr, "null ptr"); + if (!aHTTPCompressConv) { + return NS_ERROR_NULL_POINTER; + } - if (!aHTTPCompressConv) - return NS_ERROR_NULL_POINTER; - - nsRefPtr outVal = - new mozilla::net::nsHTTPCompressConv(); - if (!outVal) { - return NS_ERROR_OUT_OF_MEMORY; - } - - outVal.forget(aHTTPCompressConv); - return NS_OK; + RefPtr outVal = + new mozilla::net::nsHTTPCompressConv(); + if (!outVal) { + return NS_ERROR_OUT_OF_MEMORY; + } + outVal.forget(aHTTPCompressConv); + return NS_OK; } diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.h b/netwerk/streamconv/converters/nsHTTPCompressConv.h index 85c40494f0..2fed458ffb 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.h +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.h @@ -1,4 +1,5 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=8 et 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/. */ @@ -7,6 +8,7 @@ #define __nsHTTPCompressConv__h__ 1 #include "nsIStreamConverter.h" +#include "nsICompressConvStats.h" #include "nsCOMPtr.h" #include "zlib.h" @@ -18,14 +20,14 @@ class nsIStringInputStream; -#define NS_HTTPCOMPRESSCONVERTER_CID \ -{ \ - /* 66230b2b-17fa-4bd3-abf4-07986151022d */ \ - 0x66230b2b, \ - 0x17fa, \ - 0x4bd3, \ - {0xab, 0xf4, 0x07, 0x98, 0x61, 0x51, 0x02, 0x2d}\ -} +#define NS_HTTPCOMPRESSCONVERTER_CID \ + { \ + /* 66230b2b-17fa-4bd3-abf4-07986151022d */ \ + 0x66230b2b, \ + 0x17fa, \ + 0x4bd3, \ + {0xab, 0xf4, 0x07, 0x98, 0x61, 0x51, 0x02, 0x2d} \ + } #define HTTP_DEFLATE_TYPE "deflate" @@ -39,61 +41,62 @@ class nsIStringInputStream; namespace mozilla { namespace net { - + typedef enum { - HTTP_COMPRESS_GZIP, - HTTP_COMPRESS_DEFLATE, - HTTP_COMPRESS_COMPRESS, - HTTP_COMPRESS_BROTLI, - HTTP_COMPRESS_IDENTITY - } CompressMode; - + HTTP_COMPRESS_GZIP, + HTTP_COMPRESS_DEFLATE, + HTTP_COMPRESS_COMPRESS, + HTTP_COMPRESS_BROTLI, + HTTP_COMPRESS_IDENTITY +} CompressMode; + class BrotliWrapper { public: - BrotliWrapper() - : mTotalOut(0) - , mStatus(NS_OK) + BrotliWrapper() + : mTotalOut(0) + , mStatus(NS_OK) , mRequest(nullptr) , mContext(nullptr) , mSourceOffset(0) - { + { BrotliDecoderStateInit(&mState, 0, 0, 0); - } - ~BrotliWrapper() - { - BrotliDecoderStateCleanup(&mState); - } - - BrotliDecoderState mState; - size_t mTotalOut; - nsresult mStatus; - - nsIRequest *mRequest; - nsISupports *mContext; - uint64_t mSourceOffset; + } + ~BrotliWrapper() + { + BrotliDecoderStateCleanup(&mState); + } + + BrotliDecoderState mState; + size_t mTotalOut; + nsresult mStatus; + + nsIRequest *mRequest; + nsISupports *mContext; + uint64_t mSourceOffset; }; -class nsHTTPCompressConv : public nsIStreamConverter { -public: - // nsISupports methods +class nsHTTPCompressConv + : public nsIStreamConverter + , public nsICompressConvStats +{ + public: + // nsISupports methods NS_DECL_THREADSAFE_ISUPPORTS - - NS_DECL_NSIREQUESTOBSERVER + NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER + NS_DECL_NSICOMPRESSCONVSTATS - // nsIStreamConverter methods + // nsIStreamConverter methods NS_DECL_NSISTREAMCONVERTER - nsHTTPCompressConv (); private: - virtual ~nsHTTPCompressConv (); - nsIStreamListener *mListener; // this guy gets the converted data via his OnDataAvailable () - CompressMode mMode; + nsCOMPtr mListener; // this guy gets the converted data via his OnDataAvailable () + CompressMode mMode; unsigned char *mOutBuffer; unsigned char *mInpBuffer; @@ -102,7 +105,7 @@ private: uint32_t mInpBufferLen; nsAutoPtr mBrotli; - + nsCOMPtr mAsyncConvContext; nsCOMPtr mStream; @@ -124,6 +127,8 @@ private: unsigned mLen, hMode, mSkipCount, mFlags; uint32_t check_header (nsIInputStream *iStr, uint32_t streamLen, nsresult *rv); + + uint32_t mDecodedDataLength; }; } // namespace net diff --git a/netwerk/streamconv/converters/nsICompressConvStats.idl b/netwerk/streamconv/converters/nsICompressConvStats.idl new file mode 100644 index 0000000000..a8837563ed --- /dev/null +++ b/netwerk/streamconv/converters/nsICompressConvStats.idl @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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 "nsISupports.idl" + +/** + * nsICompressConvStats + * + * This interface allows for the observation of decoded resource sizes + */ +[builtinclass, scriptable, uuid(58172ad0-46a9-4893-8fde-cd909c10792a)] +interface nsICompressConvStats : nsISupports +{ + readonly attribute uint64_t decodedDataLength; +}; diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.h b/netwerk/streamconv/converters/nsMultiMixedConv.h index 08be79b992..9d3523b28b 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.h +++ b/netwerk/streamconv/converters/nsMultiMixedConv.h @@ -162,7 +162,7 @@ protected: nsCString mToken; uint32_t mTokenLen; - nsRefPtr mPartChannel; // the channel for the given part we're processing. + RefPtr mPartChannel; // the channel for the given part we're processing. // one channel per part. nsCOMPtr mContext; nsCString mContentType; diff --git a/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/netwerk/streamconv/converters/nsUnknownDecoder.cpp index c424ac79f2..9bbce3bd8a 100644 --- a/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -15,6 +15,7 @@ #include "nsIMIMEService.h" +#include "nsIDivertableChannel.h" #include "nsIViewSourceChannel.h" #include "nsIHttpChannel.h" #include "nsIForcePendingChannel.h" @@ -213,6 +214,15 @@ nsUnknownDecoder::OnDataAvailable(nsIRequest* request, NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); + nsCOMPtr divertable = do_QueryInterface(request); + if (divertable) { + bool diverting; + divertable->GetDivertingToParent(&diverting); + if (diverting) { + // The channel is diverted to the parent do not send any more data here. + return rv; + } + } rv = mNextListener->OnDataAvailable(request, aCtxt, aStream, aSourceOffset, aCount); } @@ -242,6 +252,11 @@ nsUnknownDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt) } } + nsCOMPtr divertable = do_QueryInterface(request); + if (divertable) { + divertable->UnknownDecoderInvolvedKeepData(); + } + // Do not pass the OnStartRequest on to the next listener (yet)... return rv; } @@ -647,6 +662,12 @@ nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request, // mNextListener looks at it. request->Cancel(rv); mNextListener->OnStartRequest(request, aCtxt); + + nsCOMPtr divertable = do_QueryInterface(request); + if (divertable) { + rv = divertable->UnknownDecoderInvolvedOnStartRequestCalled(); + } + return rv; } } @@ -654,6 +675,17 @@ nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request, // Fire the OnStartRequest(...) rv = mNextListener->OnStartRequest(request, aCtxt); + nsCOMPtr divertable = do_QueryInterface(request); + if (divertable) { + rv = divertable->UnknownDecoderInvolvedOnStartRequestCalled(); + bool diverting; + divertable->GetDivertingToParent(&diverting); + if (diverting) { + // The channel is diverted to the parent do not send any more data here. + return rv; + } + } + if (NS_SUCCEEDED(rv)) { // install stream converter if required nsCOMPtr encodedChannel = do_QueryInterface(request); @@ -716,7 +748,7 @@ nsUnknownDecoder::ConvertEncodedData(nsIRequest* request, nsCOMPtr encodedChannel(do_QueryInterface(request)); if (encodedChannel) { - nsRefPtr strListener = + RefPtr strListener = new ConvertedStreamListener(this); nsCOMPtr listener; diff --git a/netwerk/system/win32/nsNotifyAddrListener.cpp b/netwerk/system/win32/nsNotifyAddrListener.cpp index 7646305061..99d24fe7e1 100644 --- a/netwerk/system/win32/nsNotifyAddrListener.cpp +++ b/netwerk/system/win32/nsNotifyAddrListener.cpp @@ -335,7 +335,7 @@ nsNotifyAddrListener::CheckICSStatus(PWCHAR aAdapterName) bool isICSGatewayAdapter = false; HRESULT hr; - nsRefPtr netSharingManager; + RefPtr netSharingManager; hr = CoCreateInstance( CLSID_NetSharingManager, nullptr, @@ -343,16 +343,16 @@ nsNotifyAddrListener::CheckICSStatus(PWCHAR aAdapterName) IID_INetSharingManager, getter_AddRefs(netSharingManager)); - nsRefPtr privateCollection; + RefPtr privateCollection; if (SUCCEEDED(hr)) { hr = netSharingManager->get_EnumPrivateConnections( ICSSC_DEFAULT, getter_AddRefs(privateCollection)); } - nsRefPtr privateEnum; + RefPtr privateEnum; if (SUCCEEDED(hr)) { - nsRefPtr privateEnumUnknown; + RefPtr privateEnumUnknown; hr = privateCollection->get__NewEnum(getter_AddRefs(privateEnumUnknown)); if (SUCCEEDED(hr)) { hr = privateEnumUnknown->QueryInterface( @@ -378,7 +378,7 @@ nsNotifyAddrListener::CheckICSStatus(PWCHAR aAdapterName) continue; } - nsRefPtr connection; + RefPtr connection; if (SUCCEEDED(connectionVariant.punkVal->QueryInterface( IID_INetConnection, getter_AddRefs(connection)))) { diff --git a/netwerk/test/TestBind.cpp b/netwerk/test/TestBind.cpp index 1bd9e42efc..5c59398497 100644 --- a/netwerk/test/TestBind.cpp +++ b/netwerk/test/TestBind.cpp @@ -138,7 +138,7 @@ main(int32_t argc, char *argv[]) } // Listening. - nsRefPtr serverListener = new ServerListener(); + RefPtr serverListener = new ServerListener(); rv = server->AsyncListen(serverListener); if (NS_FAILED(rv)) { fail("Server fail to start listening."); @@ -178,7 +178,7 @@ main(int32_t argc, char *argv[]) } // Open IO streams, to make client SocketTransport connect to server. - nsRefPtr clientCallback = new ClientInputCallback(); + RefPtr clientCallback = new ClientInputCallback(); nsCOMPtr inputStream; rv = client->OpenInputStream(nsITransport::OPEN_UNBUFFERED, 0, 0, getter_AddRefs(inputStream)); diff --git a/netwerk/test/TestUDPSocket.cpp b/netwerk/test/TestUDPSocket.cpp index 3770501997..eb85f5d771 100644 --- a/netwerk/test/TestUDPSocket.cpp +++ b/netwerk/test/TestUDPSocket.cpp @@ -271,7 +271,7 @@ main(int32_t argc, char *argv[]) NS_ENSURE_SUCCESS(rv, -1); // Create UDPServerListener to process UDP packets - nsRefPtr serverListener = new UDPServerListener(); + RefPtr serverListener = new UDPServerListener(); nsCOMPtr secman = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); @@ -289,7 +289,7 @@ main(int32_t argc, char *argv[]) server->AsyncListen(serverListener); // Bind clinet on arbitrary port - nsRefPtr clientListener = new UDPClientListener(); + RefPtr clientListener = new UDPClientListener(); client->Init(0, false, systemPrincipal, true, 0); client->AsyncListen(clientListener); @@ -335,7 +335,7 @@ main(int32_t argc, char *argv[]) if (NS_WARN_IF(!timer)) { return -1; } - nsRefPtr timerCb = new MulticastTimerCallback(); + RefPtr timerCb = new MulticastTimerCallback(); // The following multicast tests using multiple sockets require a firewall // exception on Windows XP before they pass. For now, we'll skip them here. diff --git a/netwerk/test/mochitests/empty.html b/netwerk/test/mochitests/empty.html new file mode 100644 index 0000000000..e60f5abdf4 --- /dev/null +++ b/netwerk/test/mochitests/empty.html @@ -0,0 +1,16 @@ + + + + + + + + + + This page does nothing. If the loading page managed to load this, the test + probably succeeded. + + diff --git a/netwerk/test/mochitests/mochitest.ini b/netwerk/test/mochitests/mochitest.ini index d4047b1edf..552741204d 100644 --- a/netwerk/test/mochitests/mochitest.ini +++ b/netwerk/test/mochitests/mochitest.ini @@ -7,6 +7,11 @@ support-files = rel_preconnect.sjs user_agent.sjs user_agent_update.sjs + redirect_idn.html^headers^ + redirect_idn.html + empty.html + web_packaged_app.sjs + signed_web_packaged_app.sjs [test_arraybufferinputstream.html] [test_partially_cached_content.html] @@ -20,3 +25,7 @@ skip-if = e10s [test_user_agent_updates_reset.html] [test_xhr_method_case.html] skip-if = e10s +[test_idn_redirect.html] +[test_signed_web_packaged_app.html] +skip-if = e10s || buildapp != 'browser' +[test_web_packaged_app.html] diff --git a/netwerk/test/mochitests/redirect_idn.html b/netwerk/test/mochitests/redirect_idn.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/netwerk/test/mochitests/redirect_idn.html^headers^ b/netwerk/test/mochitests/redirect_idn.html^headers^ new file mode 100644 index 0000000000..753f65db87 --- /dev/null +++ b/netwerk/test/mochitests/redirect_idn.html^headers^ @@ -0,0 +1,3 @@ +HTTP 301 Moved Permanently +Location: http://exämple.test/tests/netwerk/test/mochitests/empty.html +X-Comment: Bug 1142083 - This is a redirect to http://exämple.test diff --git a/netwerk/test/mochitests/signed_web_packaged_app.sjs b/netwerk/test/mochitests/signed_web_packaged_app.sjs new file mode 100644 index 0000000000..1b7256be3a --- /dev/null +++ b/netwerk/test/mochitests/signed_web_packaged_app.sjs @@ -0,0 +1,37 @@ +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; + +function handleRequest(request, response) +{ + response.setHeader("Content-Type", "application/package", false); + response.write(octetStreamData.packageHeader + octetStreamData.getData()); + return; +} + +// The package content +// getData formats it as described at http://www.w3.org/TR/web-packaging/#streamable-package-format +var octetStreamData = { + packageHeader: 'manifest-signature: dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\r\n', + + content: [ + { headers: ["Content-Location: /index.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n\r\n Web Packaged App Index\r\n\r\n", type: "text/html" }, + { headers: ["Content-Location: /scripts/app.js", "Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Location: /scripts/helpers/math.js", "Content-Type: text/javascript"], data: "export function sum(nums) { ... }\r\n...\r\n", type: "text/javascript" } + ], + token : "gc0pJq0M:08jU534c0p", + getData: function() { + var str = ""; + for (var i in this.content) { + str += "--" + this.token + "\r\n"; + for (var j in this.content[i].headers) { + str += this.content[i].headers[j] + "\r\n"; + } + str += "\r\n"; + str += this.content[i].data + "\r\n"; + } + + str += "--" + this.token + "--"; + return str; + } +} diff --git a/netwerk/test/mochitests/test_idn_redirect.html b/netwerk/test/mochitests/test_idn_redirect.html new file mode 100644 index 0000000000..b9a594cc56 --- /dev/null +++ b/netwerk/test/mochitests/test_idn_redirect.html @@ -0,0 +1,36 @@ + + + + + Test for URI Manipulation + + + + + +
    +
    +
    +
    +
    +
    diff --git a/netwerk/test/mochitests/test_signed_web_packaged_app.html b/netwerk/test/mochitests/test_signed_web_packaged_app.html
    new file mode 100644
    index 0000000000..7eae7b8956
    --- /dev/null
    +++ b/netwerk/test/mochitests/test_signed_web_packaged_app.html
    @@ -0,0 +1,70 @@
    +
    +
    +
    +   Web packaged app 
    +  
    +  
    +
    +
    +
    +

    + +
    +
    +
    + + diff --git a/netwerk/test/mochitests/test_web_packaged_app.html b/netwerk/test/mochitests/test_web_packaged_app.html new file mode 100644 index 0000000000..b5abaa3dfe --- /dev/null +++ b/netwerk/test/mochitests/test_web_packaged_app.html @@ -0,0 +1,210 @@ + + + + Web packaged app + + + + + + +

    + +
    +
    +
    + + diff --git a/netwerk/test/mochitests/web_packaged_app.sjs b/netwerk/test/mochitests/web_packaged_app.sjs new file mode 100644 index 0000000000..d5587d8d76 --- /dev/null +++ b/netwerk/test/mochitests/web_packaged_app.sjs @@ -0,0 +1,35 @@ +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; + +function handleRequest(request, response) +{ + response.setHeader("Content-Type", "application/package", false); + response.write(octetStreamData.getData()); + return; +} + +// The package content +// getData formats it as described at http://www.w3.org/TR/web-packaging/#streamable-package-format +var octetStreamData = { + content: [ + { headers: ["Content-Location: /index.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n\r\n Web Packaged App Index\r\n\r\n", type: "text/html" }, + { headers: ["Content-Location: /scripts/app.js", "Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Location: /scripts/helpers/math.js", "Content-Type: text/javascript"], data: "export function sum(nums) { ... }\r\n...\r\n", type: "text/javascript" } + ], + token : "gc0pJq0M:08jU534c0p", + getData: function() { + var str = ""; + for (var i in this.content) { + str += "--" + this.token + "\r\n"; + for (var j in this.content[i].headers) { + str += this.content[i].headers[j] + "\r\n"; + } + str += "\r\n"; + str += this.content[i].data + "\r\n"; + } + + str += "--" + this.token + "--"; + return str; + } +} diff --git a/netwerk/test/unit/test_packaged_app_service.js b/netwerk/test/unit/test_packaged_app_service.js index 2e8198e8a5..8a7541bbd7 100644 --- a/netwerk/test/unit/test_packaged_app_service.js +++ b/netwerk/test/unit/test_packaged_app_service.js @@ -30,12 +30,20 @@ // test_bad_package_404 // - tests that a request for a missing subresource doesn't hang if // if the last file in the package is missing some headers +// +// test_worse_package +// - tests that a request for a missing/existing resource doesn't +// break the service and the async verifier. +// Cu.import('resource://gre/modules/LoadContextInfo.jsm'); Cu.import("resource://testing-common/httpd.js"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); +let gPrefs = Cc["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + // The number of times this package has been requested // This number might be reset by tests that use it var packagedAppRequestsMade = 0; @@ -124,8 +132,24 @@ function run_test() httpserver.registerPathHandler("/package", packagedAppContentHandler); httpserver.registerPathHandler("/304Package", packagedAppContentHandler); httpserver.registerPathHandler("/badPackage", packagedAppBadContentHandler); + + let worsePackageNum = 6; + for (let i = 0; i < worsePackageNum; i++) { + httpserver.registerPathHandler("/worsePackage_" + i, + packagedAppWorseContentHandler.bind(null, i)); + } + + httpserver.registerPathHandler("/signedPackage", signedPackagedAppContentHandler); httpserver.start(-1); + // We will enable the developer mode in 'test_signed_package_callback'. + // So restore it after testing. + // + // TODO: To be removed in Bug 1178518. + do_register_cleanup(function() { + gPrefs.clearUserPref("network.http.packaged-apps-developer-mode"); + }); + paservice = Cc["@mozilla.org/network/packaged-app-service;1"] .getService(Ci.nsIPackagedAppService); ok(!!paservice, "test service exists"); @@ -143,6 +167,9 @@ function run_test() add_test(test_bad_package); add_test(test_bad_package_404); + add_test(test_signed_package_callback); + add_test(test_unsigned_package_callback); + // Channels created by addons could have no load info. // In debug mode this triggers an assertion, but we still want to test that // it works in optimized mode. See bug 1196021 comment 17 @@ -152,6 +179,13 @@ function run_test() add_test(test_channel_no_loadinfo); } + add_test(test_worse_package_0); + add_test(test_worse_package_1); + add_test(test_worse_package_2); + add_test(test_worse_package_3); + add_test(test_worse_package_4); + add_test(test_worse_package_5); + // run tests run_next_test(); } @@ -329,3 +363,207 @@ function test_channel_no_loadinfo() { channel.loadInfo = null; paservice.getResource(channel, cacheListener); } + +// ---------------------------------------------------------------------------- + +// Worse package testing to ensure the async PackagedAppVerifier working good. + +function getData(aTestingData) { + var str = ""; + for (var i in aTestingData.content) { + str += "--" + aTestingData.token + "\r\n"; + for (var j in aTestingData.content[i].headers) { + str += aTestingData.content[i].headers[j] + "\r\n"; + } + str += "\r\n"; + str += aTestingData.content[i].data + "\r\n"; + } + + str += "--" + aTestingData.token + "--"; + return str; +} + +var worseTestData = [ + // 0. Only one broken resource. + { content: [ + { headers: ["Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + ], + token : "gc0pJq0M:08jU534c0p", + }, + + // 1. Only one valid resource. + { content: [ + { headers: ["Content-Location: /index.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + ], + token : "gc0pJq0M:08jU534c0p", + }, + + // 2. All broken resources. + { content: [ + { headers: ["Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Type: text/javascript"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + { headers: ["Content-Type: text/javascript"], data: "export function sum(nums) { ... }\r\n...\r\n", type: "text/javascript" } + ], + token : "gc0pJq0M:08jU534c0p", + }, + + // 3. All broken resources except the first one. + { content: [ + { headers: ["Content-Location: /index.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + { headers: ["Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Type: text/javascript"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + { headers: ["Content-Type: text/javascript"], data: "export function sum(nums) { ... }\r\n...\r\n", type: "text/javascript" } + ], + token : "gc0pJq0M:08jU534c0p", + }, + + // 4. All broken resources except the last one. + { content: [ + { headers: ["Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Type: text/javascript"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + { headers: ["Content-Type: text/javascript"], data: "export function sum(nums) { ... }\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Location: /index.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + ], + token : "gc0pJq0M:08jU534c0p", + }, + + // 5. All broken resources except the first and the last one. + { content: [ + { headers: ["Content-Location: /whatever.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + { headers: ["Content-Type: text/javascript"], data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Type: text/javascript"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + { headers: ["Content-Type: text/javascript"], data: "export function sum(nums) { ... }\r\n...\r\n", type: "text/javascript" }, + { headers: ["Content-Location: /index.html", "Content-Type: text/html"], data: "\r\n \r\n \r\n ...\r\n \r\n ...\r\n\r\n", type: "text/html" }, + ], + token : "gc0pJq0M:08jU534c0p", + }, +]; + +function packagedAppWorseContentHandler(index, metadata, response) +{ + response.setHeader("Content-Type", 'application/package'); + var body = getData(worseTestData[index]); + response.bodyOutputStream.write(body, body.length); +} + +function test_worse_package(index, success) { + packagePath = "/worsePackage_" + index; + let url = uri + packagePath + "!//index.html"; + let channel = getChannelForURL(url); + paservice.getResource(channel, { + QueryInterface: function (iid) { + if (iid.equals(Ci.nsICacheEntryOpenCallback) || + iid.equals(Ci.nsISupports)) + return this; + throw Cr.NS_ERROR_NO_INTERFACE; + }, + onCacheEntryCheck: function() { return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; }, + onCacheEntryAvailable: function (entry, isnew, appcache, status) { + let cacheSuccess = (status === Cr.NS_OK); + equal(success, status === Cr.NS_OK, "Check status"); + run_next_test(); + } + }); +} + +function test_worse_package_0() { + test_worse_package(0, false); +} + +function test_worse_package_1() { + test_worse_package(1, true); +} + +function test_worse_package_2() { + test_worse_package(2, false); +} + +function test_worse_package_3() { + test_worse_package(3, true); +} + +function test_worse_package_4() { + test_worse_package(4, true); +} + +function test_worse_package_5() { + test_worse_package(5, true); +} + +//----------------------------------------------------------------------------- + +function signedPackagedAppContentHandler(metadata, response) +{ + response.setHeader("Content-Type", 'application/package'); + var body = testData.packageHeader + testData.getData(); + response.bodyOutputStream.write(body, body.length); +} + +// Used as a stub when the cache listener is not important. +let dummyCacheListener = { + QueryInterface: function (iid) { + if (iid.equals(Ci.nsICacheEntryOpenCallback) || + iid.equals(Ci.nsISupports)) + return this; + throw Cr.NS_ERROR_NO_INTERFACE; + }, + onCacheEntryCheck: function() { return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; }, + onCacheEntryAvailable: function () {} +}; + +function test_signed_package_callback() +{ + // TODO: To be removed in Bug 1178518. + gPrefs.setBoolPref("network.http.packaged-apps-developer-mode", true); + + packagePath = "/signedPackage"; + let url = uri + packagePath + "!//index.html"; + let channel = getChannelForURL(url, { + onStartSignedPackageRequest: function(aPackageId) { + ok(true, "onStartSignedPackageRequest is notifited as expected"); + run_next_test(); + }, + + getInterface: function (iid) { + return this.QueryInterface(iid); + }, + + QueryInterface: function (iid) { + if (iid.equals(Ci.nsISupports) || + iid.equals(Ci.nsIInterfaceRequestor) || + iid.equals(Ci.nsIPackagedAppChannelListener)) { + return this; + } + throw Cr.NS_ERROR_NO_INTERFACE; + }, + }); + + paservice.getResource(channel, dummyCacheListener); +} + +function test_unsigned_package_callback() +{ + packagePath = "/package"; + let url = uri + packagePath + "!//index.html"; + let channel = getChannelForURL(url, { + onStartSignedPackageRequest: function(aPackageId) { + ok(false, "Unsigned package shouldn't be called."); + }, + + getInterface: function (iid) { + return this.QueryInterface(iid); + }, + + QueryInterface: function (iid) { + if (iid.equals(Ci.nsISupports) || + iid.equals(Ci.nsIInterfaceRequestor) || + iid.equals(Ci.nsIPackagedAppChannelListener)) { + return this; + } + throw Cr.NS_ERROR_NO_INTERFACE; + }, + }); + + // Pass cacheListener since we rely on 'run_next_test' in it. + paservice.getResource(channel, cacheListener); +} \ No newline at end of file diff --git a/netwerk/test/unit/test_packaged_app_utils.js b/netwerk/test/unit/test_packaged_app_utils.js new file mode 100644 index 0000000000..ed6f9bbcb7 --- /dev/null +++ b/netwerk/test/unit/test_packaged_app_utils.js @@ -0,0 +1,135 @@ +const header_missing_signature = "header1: content1"; +const header_invalid_signature = "header1: content1\r\nmanifest-signature: invalid-signature\r\n"; +const header = "manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgECMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MDkxMDA4MDQzNVoXDTM1MDkxMDA4MDQzNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGjAYBgNVBAMTEVRydXN0ZWQgQ29ycCBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAts8whjOzEbn/w1xkFJ67af7F/JPujBK91oyJekh2schIMzFau9pY8S1AiJQoJCulOJCJfUc8hBLKBZiGAkii+4Gpx6cVqMLe6C22MdD806Soxn8Dg4dQqbIvPuI4eeVKu5CEk80PW/BaFMmRvRHO62C7PILuH6yZeGHC4P7dTKpsk4CLxh/jRGXLC8jV2BCW0X+3BMbHBg53NoI9s1Gs7KGYnfOHbBP5wEFAa00RjHnubUaCdEBlC8Kl4X7p0S4RGb3rsB08wgFe9EmSZHIgcIm+SuVo7N4qqbI85qo2ulU6J8NN7ZtgMPHzrMhzgAgf/KnqPqwDIxnNmRNJmHTUYwIDAQABozgwNjAMBgNVHRMBAf8EAjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMDMA4GA1UdDwEB/wQEAwIHgDANBgkqhkiG9w0BAQsFAAOCAQEAukH6cJUUj5faa8CuPCqrEa0PoLY4SYNnff9NI+TTAHkB9l+kOcFl5eo2EQOcWmZKYi7QLlWC4jy/KQYattO9FMaxiOQL4FAc6ZIbNyfwWBzZWyr5syYJTTTnkLq8A9pCKarN49+FqhJseycU+8EhJEJyP5pv5hLvDNTTHOQ6SXhASsiX8cjo3AY4bxA5pWeXuTZ459qDxOnQd+GrOe4dIeqflk0hA2xYKe3SfF+QlK8EO370B8Dj8RX230OATM1E3OtYyALe34KW3wM9Qm9rb0eViDnVyDiCWkhhQnw5yPg/XQfloug2itRYuCnfUoRt8xfeHgwz2Ymz8cUADn3KpTGCAf4wggH6AgEBMHgwczELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFRydXN0ZWQgVmFsaWQgQ0ECAQIwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MDkxMDA4MDQ0M1owIwYJKoZIhvcNAQkEMRYEFNg6lGtV9bJbL2hA0c5DdOeuCQ6lMA0GCSqGSIb3DQEBAQUABIIBAKGziwzA5Q38rIvNUDHCjYVTR1FhALGZv677Tc2+pwd82W6O9q5GG9IfkF3ajb1fquUIpGPkf7r0oiO4udC8cSehA+lfhR94A8aCM9UhzvTtRI3tFB+TPSk1UcXlX8tB7dNkx4zC06ujlSaRKkmaZODVXQFEcsF6CKMApsBuUJrwzvbQqVi2KHXUO6oGlMEyt4tY+g2OY/vyxGajfAL49dAYOTtrV0arvJvoTYh+E0iSrsbuiuAxKAVjK/QnLJoV/dTaCqW4t3lzHrpE3+avqMXiewxu84VJSURxoryY89uAZS9+4MKrSOGlGCJy/8xDIAm9pi6lPJBP2pIRjaRt9r0=\r\n"; + +const manifest = "Content-Location: manifest.webapp\r\n" + + "Content-Type: application/x-web-app-manifest+json\r\n\r\n" + +`{ + "name": "My App", + "moz-resources": [ + { + "src": "page2.html", + "integrity": "JREF3JbXGvZ+I1KHtoz3f46ZkeIPrvXtG4VyFQrJ7II=" + }, + { + "src": "index.html", + "integrity": "B5Phw8L1tpyRBkI0gwg/evy1fgtMlMq3BIY3Q8X0rYU=" + }, + { + "src": "scripts/script.js", + "integrity": "6TqtNArQKrrsXEQWu3D9ZD8xvDRIkhyV6zVdTcmsT5Q=" + }, + { + "src": "scripts/library.js", + "integrity": "TN2ByXZiaBiBCvS4MeZ02UyNi44vED+KjdjLInUl4o8=" + } + ], + "moz-permissions": [ + { + "systemXHR": { + "description": "Needed to download stuff" + }, + "devicestorage:pictures": { + "description": "Need to load pictures" + } + } + ], + "moz-uuid": "some-uuid", + "moz-package-location": "https://example.com/myapp/app.pak", + "description": "A great app!" +}`; + +const manifest_missing_moz_resources = "Content-Location: manifest.webapp\r\n" + + "Content-Type: application/x-web-app-manifest+json\r\n\r\n" + +`{ + "name": "My App", + "moz-permissions": [ + { + "systemXHR": { + "description": "Needed to download stuff" + }, + "devicestorage:pictures": { + "description": "Need to load pictures" + } + } + ], + "moz-uuid": "some-uuid", + "moz-package-location": "https://example.com/myapp/app.pak", + "description": "A great app!" +}`; + +const manifest_malformed_json = "}"; + +let packagedAppUtils; + +function run_test() { + add_test(test_verify_manifest(header_missing_signature, manifest, false)); + add_test(test_verify_manifest(header_invalid_signature, manifest, false)); + add_test(test_verify_manifest(header, manifest_malformed_json, false)); + add_test(test_verify_manifest(header, manifest_missing_moz_resources, false)); + add_test(test_verify_manifest(header, manifest, true)); + + // The last verification must succeed, because check_integrity use that object; + add_test(test_check_integrity_success); + add_test(test_check_integrity_filename_not_matched); + add_test(test_check_integrity_hashvalue_not_matched); + + run_next_test(); +} + +function test_verify_manifest(aHeader, aManifest, aShouldSucceed) { + return function() { + do_test_pending(); + packagedAppUtils = Cc["@mozilla.org/network/packaged-app-utils;1"]. + createInstance(Ci.nsIPackagedAppUtils); + let fakeVerifier = { + fireVerifiedEvent: function(aForManifest, aSuccess) { + ok(aForManifest, "aForManifest should be true"); + equal(aSuccess, aShouldSucceed, "Expected verification result: " + aShouldSucceed); + do_test_finished(); + run_next_test(); + } + }; + packagedAppUtils.verifyManifest(aHeader, aManifest, fakeVerifier); + } +} + +function test_check_integrity_success() { + let manifestBody = manifest.substr(manifest.indexOf('\r\n\r\n') + 4); + fakeVerifier = { + fireVerifiedEvent: function(aForManifest, aSuccess) { + ok(!aForManifest && aSuccess, "checkIntegrity should succeed"); + do_test_finished(); + run_next_test(); + } + }; + for (let resource of JSON.parse(manifestBody)["moz-resources"]) { + do_test_pending(); + packagedAppUtils.checkIntegrity(resource.src, resource.integrity, fakeVerifier); + } +} + +function test_check_integrity_filename_not_matched() { + fakeVerifier = { + fireVerifiedEvent: function(aForManifest, aSuccess) { + ok(!aForManifest && !aSuccess, "checkIntegrity should fail"); + do_test_finished(); + run_next_test(); + } + }; + do_test_pending(); + packagedAppUtils.checkIntegrity("/nosuchfile.html", "sha256-kass...eoirW-e", fakeVerifier); + run_next_test(); +} + +function test_check_integrity_hashvalue_not_matched() { + fakeVerifier = { + fireVerifiedEvent: function(aForManifest, aSuccess) { + ok(!aForManifest && !aSuccess, "checkIntegrity should fail"); + do_test_finished(); + run_next_test(); + } + }; + do_test_pending(); + packagedAppUtils.checkIntegrity("/index.html", "kass...eoirW-e", fakeVerifier); +} diff --git a/netwerk/test/unit/test_synthesized_response.js b/netwerk/test/unit/test_synthesized_response.js index 3b313a856f..ae8c3d9e71 100644 --- a/netwerk/test/unit/test_synthesized_response.js +++ b/netwerk/test/unit/test_synthesized_response.js @@ -63,7 +63,7 @@ function make_channel(url, body, cb) { synthesized.data = body; NetUtil.asyncCopy(synthesized, channel.responseBody, function() { - channel.finishSynthesizedResponse(); + channel.finishSynthesizedResponse(''); }); } if (cb) { @@ -150,7 +150,7 @@ add_test(function() { synthesized.data = NON_REMOTE_BODY; NetUtil.asyncCopy(synthesized, channel.responseBody, function() { channel.synthesizeHeader("Content-Length", NON_REMOTE_BODY.length); - channel.finishSynthesizedResponse(); + channel.finishSynthesizedResponse(''); }); }); }); @@ -178,7 +178,7 @@ add_test(function() { // set the content-type to ensure that the stream converter doesn't hold up notifications // and cause the test to fail intercepted.synthesizeHeader("Content-Type", "text/plain"); - intercepted.finishSynthesizedResponse(); + intercepted.finishSynthesizedResponse(''); }); }); chan.asyncOpen(new ChannelListener(handle_synthesized_response, null, @@ -220,7 +220,7 @@ add_test(function() { NetUtil.asyncCopy(synthesized, intercepted.responseBody, function() { let channel = intercepted.channel; - intercepted.finishSynthesizedResponse(); + intercepted.finishSynthesizedResponse(''); channel.cancel(Cr.NS_BINDING_ABORTED); }); }); @@ -237,7 +237,7 @@ add_test(function() { NetUtil.asyncCopy(synthesized, intercepted.responseBody, function() { intercepted.channel.cancel(Cr.NS_BINDING_ABORTED); - intercepted.finishSynthesizedResponse(); + intercepted.finishSynthesizedResponse(''); }); }); chan.asyncOpen(new ChannelListener(run_next_test, null, diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini index 29a0fe55d1..481f9cc6d5 100644 --- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -324,6 +324,7 @@ skip-if = os == "android" [test_safeoutputstream_append.js] [test_packaged_app_service.js] [test_packaged_app_verifier.js] +[test_packaged_app_utils.js] [test_suspend_channel_before_connect.js] [test_inhibit_caching.js] [test_dns_disable_ipv4.js] diff --git a/netwerk/wifi/nsWifiMonitorGonk.cpp b/netwerk/wifi/nsWifiMonitorGonk.cpp index 513f430ca8..0ecbde10c3 100644 --- a/netwerk/wifi/nsWifiMonitorGonk.cpp +++ b/netwerk/wifi/nsWifiMonitorGonk.cpp @@ -124,7 +124,7 @@ nsWifiMonitor::Onready(uint32_t count, nsIWifiScanResult **results) nsCOMArray accessPoints; for (uint32_t i = 0; i < count; i++) { - nsRefPtr ap = new nsWifiAccessPoint(); + RefPtr ap = new nsWifiAccessPoint(); nsString temp; results[i]->GetBssid(temp); diff --git a/netwerk/wifi/nsWifiScannerDBus.cpp b/netwerk/wifi/nsWifiScannerDBus.cpp index 5a30ad9ac7..22823ad341 100644 --- a/netwerk/wifi/nsWifiScannerDBus.cpp +++ b/netwerk/wifi/nsWifiScannerDBus.cpp @@ -194,7 +194,7 @@ nsWifiScannerDBus::IdentifyAPProperties(DBusMessage* aMsg) nsresult rv = GetDBusIterator(aMsg, &arr); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr ap = new nsWifiAccessPoint(); + RefPtr ap = new nsWifiAccessPoint(); do { DBusMessageIter dict; dbus_message_iter_recurse(&arr, &dict); diff --git a/parser/html/nsHtml5Atom.cpp b/parser/html/nsHtml5Atom.cpp index 8166f89cdf..16c65139d8 100644 --- a/parser/html/nsHtml5Atom.cpp +++ b/parser/html/nsHtml5Atom.cpp @@ -9,7 +9,7 @@ nsHtml5Atom::nsHtml5Atom(const nsAString& aString) { mLength = aString.Length(); - nsRefPtr buf = nsStringBuffer::FromString(aString); + RefPtr buf = nsStringBuffer::FromString(aString); if (buf) { mString = static_cast(buf->Data()); } else { diff --git a/parser/html/nsHtml5DependentUTF16Buffer.cpp b/parser/html/nsHtml5DependentUTF16Buffer.cpp index a09add1fed..ed22116114 100644 --- a/parser/html/nsHtml5DependentUTF16Buffer.cpp +++ b/parser/html/nsHtml5DependentUTF16Buffer.cpp @@ -20,7 +20,7 @@ already_AddRefed nsHtml5DependentUTF16Buffer::FalliblyCopyAsOwningBuffer() { int32_t newLength = getEnd() - getStart(); - nsRefPtr newObj = + RefPtr newObj = nsHtml5OwningUTF16Buffer::FalliblyCreate(newLength); if (!newObj) { return nullptr; diff --git a/parser/html/nsHtml5OwningUTF16Buffer.cpp b/parser/html/nsHtml5OwningUTF16Buffer.cpp index 45bbb70dc5..213e402096 100644 --- a/parser/html/nsHtml5OwningUTF16Buffer.cpp +++ b/parser/html/nsHtml5OwningUTF16Buffer.cpp @@ -26,10 +26,10 @@ nsHtml5OwningUTF16Buffer::~nsHtml5OwningUTF16Buffer() DeleteBuffer(); // This is to avoid dtor recursion on 'next', bug 706932. - nsRefPtr tail; + RefPtr tail; tail.swap(next); while (tail && tail->mRefCnt == 1) { - nsRefPtr tmp; + RefPtr tmp; tmp.swap(tail->next); tail.swap(tmp); } @@ -43,7 +43,7 @@ nsHtml5OwningUTF16Buffer::FalliblyCreate(int32_t aLength) if (!newBuf) { return nullptr; } - nsRefPtr newObj = + RefPtr newObj = new (mozilla::fallible) nsHtml5OwningUTF16Buffer(newBuf); if (!newObj) { delete[] newBuf; diff --git a/parser/html/nsHtml5OwningUTF16Buffer.h b/parser/html/nsHtml5OwningUTF16Buffer.h index f4cf0cec85..0d8777464e 100644 --- a/parser/html/nsHtml5OwningUTF16Buffer.h +++ b/parser/html/nsHtml5OwningUTF16Buffer.h @@ -34,7 +34,7 @@ public: /** * The next buffer in a queue. */ - nsRefPtr next; + RefPtr next; /** * A parser key. diff --git a/parser/html/nsHtml5Parser.cpp b/parser/html/nsHtml5Parser.cpp index 6db2c2a558..c28b12c438 100644 --- a/parser/html/nsHtml5Parser.cpp +++ b/parser/html/nsHtml5Parser.cpp @@ -209,8 +209,8 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, // Gripping the other objects just in case, since the other old grip // required grips to these, too. - nsRefPtr streamKungFuDeathGrip(GetStreamParser()); - nsRefPtr treeOpKungFuDeathGrip(mExecutor); + RefPtr streamKungFuDeathGrip(GetStreamParser()); + RefPtr treeOpKungFuDeathGrip(mExecutor); if (!mExecutor->HasStarted()) { NS_ASSERTION(!GetStreamParser(), @@ -313,8 +313,8 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, // and a flaw would lead to worse problems with plain pointers. If this // turns out to be a perf problem, it's worthwhile to consider making // prevSearchbuf a plain pointer again. - nsRefPtr prevSearchBuf; - nsRefPtr firstLevelMarker; + RefPtr prevSearchBuf; + RefPtr firstLevelMarker; if (aKey) { if (mFirstBuffer == mLastBuffer) { @@ -398,7 +398,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, } } - nsRefPtr heapBuffer; + RefPtr heapBuffer; if (stackBuffer.hasMore()) { // The buffer wasn't tokenized to completion. Create a copy of the tail // on the heap. @@ -514,8 +514,8 @@ nsHtml5Parser::Terminate() // XXX - [ until we figure out a way to break parser-sink circularity ] // Hack - Hold a reference until we are completely done... nsCOMPtr kungFuDeathGrip(this); - nsRefPtr streamKungFuDeathGrip(GetStreamParser()); - nsRefPtr treeOpKungFuDeathGrip(mExecutor); + RefPtr streamKungFuDeathGrip(GetStreamParser()); + RefPtr treeOpKungFuDeathGrip(mExecutor); if (GetStreamParser()) { GetStreamParser()->Terminate(); } diff --git a/parser/html/nsHtml5Parser.h b/parser/html/nsHtml5Parser.h index 277143368a..30ae165768 100644 --- a/parser/html/nsHtml5Parser.h +++ b/parser/html/nsHtml5Parser.h @@ -301,7 +301,7 @@ class nsHtml5Parser final : public nsIParser, /** * The first buffer in the pending UTF-16 buffer queue */ - nsRefPtr mFirstBuffer; + RefPtr mFirstBuffer; /** * The last buffer in the pending UTF-16 buffer queue. Always points @@ -312,7 +312,7 @@ class nsHtml5Parser final : public nsIParser, /** * The tree operation executor */ - nsRefPtr mExecutor; + RefPtr mExecutor; /** * The HTML5 tree builder @@ -337,7 +337,7 @@ class nsHtml5Parser final : public nsIParser, /** * The stream listener holding the stream parser. */ - nsRefPtr mStreamListener; + RefPtr mStreamListener; /** * diff --git a/parser/html/nsHtml5SVGLoadDispatcher.cpp b/parser/html/nsHtml5SVGLoadDispatcher.cpp index 1a1b31d594..b5c22d8830 100644 --- a/parser/html/nsHtml5SVGLoadDispatcher.cpp +++ b/parser/html/nsHtml5SVGLoadDispatcher.cpp @@ -27,7 +27,7 @@ nsHtml5SVGLoadDispatcher::Run() // That is, should this code flush or something? Does it really matter? // For that matter, do we really want to try getting the prescontext? // Does this event ever want one? - nsRefPtr ctx; + RefPtr ctx; nsCOMPtr shell = mElement->OwnerDoc()->GetShell(); if (shell) { ctx = shell->GetPresContext(); diff --git a/parser/html/nsHtml5Speculation.h b/parser/html/nsHtml5Speculation.h index 76e2fe0ffa..3104bd7f4b 100644 --- a/parser/html/nsHtml5Speculation.h +++ b/parser/html/nsHtml5Speculation.h @@ -55,7 +55,7 @@ class nsHtml5Speculation final : public nsAHtml5TreeOpSink /** * The first buffer in the pending UTF-16 buffer queue */ - nsRefPtr mBuffer; + RefPtr mBuffer; /** * The start index of this speculation in the first buffer diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index 5af89baaef..c9f117f311 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -116,7 +116,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END class nsHtml5ExecutorFlusher : public nsRunnable { private: - nsRefPtr mExecutor; + RefPtr mExecutor; public: explicit nsHtml5ExecutorFlusher(nsHtml5TreeOpExecutor* aExecutor) : mExecutor(aExecutor) @@ -133,7 +133,7 @@ class nsHtml5ExecutorFlusher : public nsRunnable class nsHtml5LoadFlusher : public nsRunnable { private: - nsRefPtr mExecutor; + RefPtr mExecutor; public: explicit nsHtml5LoadFlusher(nsHtml5TreeOpExecutor* aExecutor) : mExecutor(aExecutor) @@ -809,7 +809,7 @@ nsHtml5StreamParser::WriteStreamBytes(const uint8_t* aFromSegment, return NS_ERROR_NULL_POINTER; } if (mLastBuffer->getEnd() == NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE) { - nsRefPtr newBuf = + RefPtr newBuf = nsHtml5OwningUTF16Buffer::FalliblyCreate( NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE); if (!newBuf) { @@ -840,7 +840,7 @@ nsHtml5StreamParser::WriteStreamBytes(const uint8_t* aFromSegment, NS_ASSERTION(byteCount >= -1, "The decoder consumed fewer than -1 bytes."); if (convResult == NS_PARTIAL_MORE_OUTPUT) { - nsRefPtr newBuf = + RefPtr newBuf = nsHtml5OwningUTF16Buffer::FalliblyCreate( NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE); if (!newBuf) { @@ -917,7 +917,7 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) rv = mExecutor->WillBuildModel(eDTDMode_unknown); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr newBuf = + RefPtr newBuf = nsHtml5OwningUTF16Buffer::FalliblyCreate( NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE); if (!newBuf) { diff --git a/parser/html/nsHtml5StreamParser.h b/parser/html/nsHtml5StreamParser.h index 39800dbd03..2550b9b995 100644 --- a/parser/html/nsHtml5StreamParser.h +++ b/parser/html/nsHtml5StreamParser.h @@ -435,7 +435,7 @@ class nsHtml5StreamParser : public nsICharsetDetectionObserver { /** * The first buffer in the pending UTF-16 buffer queue */ - nsRefPtr mFirstBuffer; + RefPtr mFirstBuffer; /** * The last buffer in the pending UTF-16 buffer queue @@ -472,7 +472,7 @@ class nsHtml5StreamParser : public nsICharsetDetectionObserver { /** * The owner parser. */ - nsRefPtr mOwner; + RefPtr mOwner; /** * Whether the last character tokenized was a carriage return (for CRLF) diff --git a/parser/html/nsHtml5StringParser.h b/parser/html/nsHtml5StringParser.h index 1c258be4e5..3f73224363 100644 --- a/parser/html/nsHtml5StringParser.h +++ b/parser/html/nsHtml5StringParser.h @@ -66,7 +66,7 @@ class nsHtml5StringParser : public nsParserBase /** * The tree operation executor */ - nsRefPtr mBuilder; + RefPtr mBuilder; /** * The HTML5 tree builder diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp index 501c4e42ca..7f489ea90c 100644 --- a/parser/html/nsHtml5TreeOpExecutor.cpp +++ b/parser/html/nsHtml5TreeOpExecutor.cpp @@ -45,7 +45,7 @@ NS_IMPL_RELEASE_INHERITED(nsHtml5TreeOpExecutor, nsContentSink) class nsHtml5ExecutorReflusher : public nsRunnable { private: - nsRefPtr mExecutor; + RefPtr mExecutor; public: explicit nsHtml5ExecutorReflusher(nsHtml5TreeOpExecutor* aExecutor) : mExecutor(aExecutor) @@ -242,7 +242,7 @@ nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason) void FlushTimerCallback(nsITimer* aTimer, void* aClosure) { - nsRefPtr ex = gBackgroundFlushList->popFirst(); + RefPtr ex = gBackgroundFlushList->popFirst(); if (ex) { ex->RunFlushLoop(); } @@ -303,7 +303,7 @@ nsHtml5TreeOpExecutor::FlushSpeculativeLoads() class nsHtml5FlushLoopGuard { private: - nsRefPtr mExecutor; + RefPtr mExecutor; #ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH uint32_t mStartTime; #endif @@ -411,7 +411,7 @@ nsHtml5TreeOpExecutor::RunFlushLoop() } // Not sure if this grip is still needed, but previously, the code // gripped before calling ParseUntilBlocked(); - nsRefPtr streamKungFuDeathGrip = + RefPtr streamKungFuDeathGrip = GetParser()->GetStreamParser(); // Now parse content left in the document.write() buffer queue if any. // This may generate tree ops on its own or dequeue a speculation. @@ -525,8 +525,8 @@ nsHtml5TreeOpExecutor::FlushDocumentWrite() mFlushState = eInFlush; // avoid crashing near EOF - nsRefPtr kungFuDeathGrip(this); - nsRefPtr parserKungFuDeathGrip(mParser); + RefPtr kungFuDeathGrip(this); + RefPtr parserKungFuDeathGrip(mParser); NS_ASSERTION(!mReadingFromStage, "Got doc write flush when reading from stage"); diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index 37f872df14..a252742292 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -159,7 +159,7 @@ nsHtml5TreeOperation::AppendText(const char16_t* aBuffer, } nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager(); - nsRefPtr text = new nsTextNode(nodeInfoManager); + RefPtr text = new nsTextNode(nodeInfoManager); NS_ASSERTION(text, "Infallible malloc failed?"); rv = text->SetText(aBuffer, aLength, false); NS_ENSURE_SUCCESS(rv, rv); @@ -345,7 +345,7 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, } nsCOMPtr newElement; - nsRefPtr nodeInfo = aNodeInfoManager-> + RefPtr nodeInfo = aNodeInfoManager-> GetNodeInfo(aName, nullptr, aNs, nsIDOMNode::ELEMENT_NODE); NS_ASSERTION(nodeInfo, "Got null nodeinfo."); NS_NewElement(getter_AddRefs(newElement), @@ -384,7 +384,7 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, theAttribute, false); - nsRefPtr optionNodeInfo = + RefPtr optionNodeInfo = aNodeInfoManager->GetNodeInfo(nsHtml5Atoms::option, nullptr, kNameSpaceID_XHTML, @@ -392,11 +392,11 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, for (uint32_t i = 0; i < theContent.Length(); ++i) { nsCOMPtr optionElt; - nsRefPtr ni = optionNodeInfo; + RefPtr ni = optionNodeInfo; NS_NewElement(getter_AddRefs(optionElt), ni.forget(), aFromParser); - nsRefPtr optionText = new nsTextNode(aNodeInfoManager); + RefPtr optionText = new nsTextNode(aNodeInfoManager); (void) optionText->SetText(theContent[i], false); optionElt->AppendChildTo(optionText, false); newContent->AppendChildTo(optionElt, false); @@ -464,7 +464,7 @@ nsHtml5TreeOperation::SetFormElement(nsIContent* aNode, nsIContent* aParent) !aNode->HasAttr(kNameSpaceID_None, nsGkAtoms::form)) { formControl->SetForm(formElement); } else if (domImageElement) { - nsRefPtr imageElement = + RefPtr imageElement = static_cast(domImageElement.get()); MOZ_ASSERT(imageElement); imageElement->SetForm(formElement); @@ -516,7 +516,7 @@ nsHtml5TreeOperation::FosterParentText(nsIContent* aStackParent, } nsNodeInfoManager* nodeInfoManager = aStackParent->OwnerDoc()->NodeInfoManager(); - nsRefPtr text = new nsTextNode(nodeInfoManager); + RefPtr text = new nsTextNode(nodeInfoManager); NS_ASSERTION(text, "Infallible malloc failed?"); rv = text->SetText(aBuffer, aLength, false); NS_ENSURE_SUCCESS(rv, rv); @@ -537,7 +537,7 @@ nsHtml5TreeOperation::AppendComment(nsIContent* aParent, nsHtml5DocumentBuilder* aBuilder) { nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager(); - nsRefPtr comment = new dom::Comment(nodeInfoManager); + RefPtr comment = new dom::Comment(nodeInfoManager); NS_ASSERTION(comment, "Infallible malloc failed?"); nsresult rv = comment->SetText(aBuffer, aLength, false); NS_ENSURE_SUCCESS(rv, rv); @@ -550,7 +550,7 @@ nsHtml5TreeOperation::AppendCommentToDocument(char16_t* aBuffer, int32_t aLength, nsHtml5DocumentBuilder* aBuilder) { - nsRefPtr comment = + RefPtr comment = new dom::Comment(aBuilder->GetNodeInfoManager()); NS_ASSERTION(comment, "Infallible malloc failed?"); nsresult rv = comment->SetText(aBuffer, aLength, false); @@ -586,7 +586,7 @@ nsHtml5TreeOperation::GetDocumentFragmentForTemplate(nsIContent* aNode) { dom::HTMLTemplateElement* tempElem = static_cast(aNode); - nsRefPtr frag = tempElem->Content(); + RefPtr frag = tempElem->Content(); return frag; } diff --git a/parser/html/nsParserUtils.cpp b/parser/html/nsParserUtils.cpp index ccd4166618..affdffd950 100644 --- a/parser/html/nsParserUtils.cpp +++ b/parser/html/nsParserUtils.cpp @@ -148,7 +148,7 @@ nsParserUtils::ParseFragment(const nsAString& aFragment, nsAutoScriptBlockerSuppressNodeRemoved autoBlocker; // stop scripts - nsRefPtr loader; + RefPtr loader; bool scripts_enabled = false; if (document) { loader = document->ScriptLoader(); diff --git a/parser/htmlparser/nsParser.cpp b/parser/htmlparser/nsParser.cpp index d2555629a0..306991a90e 100644 --- a/parser/htmlparser/nsParser.cpp +++ b/parser/htmlparser/nsParser.cpp @@ -111,7 +111,7 @@ For more details @see bugzilla bug 76722 class nsParserContinueEvent : public nsRunnable { public: - nsRefPtr mParser; + RefPtr mParser; explicit nsParserContinueEvent(nsParser* aParser) : mParser(aParser) diff --git a/parser/xml/nsSAXXMLReader.cpp b/parser/xml/nsSAXXMLReader.cpp index 891132b2b9..275ffe4d03 100644 --- a/parser/xml/nsSAXXMLReader.cpp +++ b/parser/xml/nsSAXXMLReader.cpp @@ -87,7 +87,7 @@ nsSAXXMLReader::HandleStartElement(const char16_t *aName, if (!mContentHandler) return NS_OK; - nsRefPtr atts = new nsSAXAttributes(); + RefPtr atts = new nsSAXAttributes(); if (!atts) return NS_ERROR_OUT_OF_MEMORY; nsAutoString uri, localName, qName; diff --git a/profile/dirserviceprovider/nsProfileLock.cpp b/profile/dirserviceprovider/nsProfileLock.cpp index 510ee29f3f..0f5cc09e77 100644 --- a/profile/dirserviceprovider/nsProfileLock.cpp +++ b/profile/dirserviceprovider/nsProfileLock.cpp @@ -582,7 +582,7 @@ nsresult nsProfileLock::Lock(nsIFile* aProfileDir, nullptr); if (mLockFileHandle == INVALID_HANDLE_VALUE) { if (aUnlocker) { - nsRefPtr unlocker( + RefPtr unlocker( new mozilla::ProfileUnlockerWin(filePath)); if (NS_SUCCEEDED(unlocker->Init())) { nsCOMPtr unlockerInterface( diff --git a/python/lldbutils/lldbutils/utils.py b/python/lldbutils/lldbutils/utils.py index 1370be5eb8..4e038f6301 100644 --- a/python/lldbutils/lldbutils/utils.py +++ b/python/lldbutils/lldbutils/utils.py @@ -57,13 +57,13 @@ def format_string(lldb_value, length=100): s += "..." return s -# Dereferences a raw pointer, nsCOMPtr, nsRefPtr, nsAutoPtr, already_AddRefed or +# Dereferences a raw pointer, nsCOMPtr, RefPtr, nsAutoPtr, already_AddRefed or # mozilla::RefPtr; otherwise returns the value unchanged. def dereference(lldb_value): if lldb_value.TypeIsPointerType(): return lldb_value.Dereference() name = lldb_value.GetType().GetUnqualifiedType().GetName() - if name.startswith("nsCOMPtr<") or name.startswith("nsRefPtr<") or name.startswith("nsAutoPtr<") or name.startswith("already_AddRefed<"): + if name.startswith("nsCOMPtr<") or name.startswith("RefPtr<") or name.startswith("nsAutoPtr<") or name.startswith("already_AddRefed<"): return lldb_value.GetChildMemberWithName("mRawPtr") if name.startswith("mozilla::RefPtr<"): return lldb_value.GetChildMemberWithName("ptr") diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index b5b436c173..4eb80166f3 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -26,6 +26,7 @@ from mach.mixin.logging import LoggingMixin from mozbuild.base import ( MachCommandBase, + MachCommandConditions as conditions, MozbuildObject, MozconfigFindException, MozconfigLoadException, @@ -273,6 +274,26 @@ class Build(MachCommandBase): help='Verbose output for what commands the build is running.') def build(self, what=None, disable_extra_make_dependencies=None, jobs=0, directory=None, verbose=False): + """Build the source tree. + + With no arguments, this will perform a full build. + + Positional arguments define targets to build. These can be make targets + or patterns like "/" to indicate a make target within a + directory. + + There are a few special targets that can be used to perform a partial + build faster than what `mach build` would perform: + + * binaries - compiles and links all C/C++ sources and produces shared + libraries and executables (binaries). + + * faster - builds JavaScript, XUL, CSS, etc files. + + "binaries" and "faster" almost fully complement each other. However, + there are build actions not captured by either. If things don't appear to + be rebuilding, perform a vanilla `mach build` to rebuild the world. + """ import which from mozbuild.controller.building import BuildMonitor from mozbuild.util import resolve_target_to_make @@ -386,15 +407,20 @@ class Build(MachCommandBase): # For universal builds, we need to run the automation steps in # the first architecture from MOZ_BUILD_PROJECTS projects = make_extra.get('MOZ_BUILD_PROJECTS') + append_env = None if projects: - subdir = os.path.join(self.topobjdir, projects.split()[0]) + project = projects.split()[0] + append_env = {b'MOZ_CURRENT_PROJECT': project.encode('utf-8')} + subdir = os.path.join(self.topobjdir, project) else: subdir = self.topobjdir moz_automation = os.getenv('MOZ_AUTOMATION') or make_extra.get('export MOZ_AUTOMATION', None) if moz_automation and status == 0: status = self._run_make(target='automation/build', directory=subdir, line_handler=output.on_line, log=False, print_directory=False, - ensure_exit_code=False, num_jobs=jobs, silent=not verbose) + ensure_exit_code=False, num_jobs=jobs, silent=not verbose, + append_env=append_env + ) self.log(logging.WARNING, 'warning_summary', {'count': len(monitor.warnings_database)}, @@ -414,9 +440,16 @@ class Build(MachCommandBase): self.log(logging.INFO, 'ccache', {'msg': ccache_diff.hit_rate_message()}, "{msg}") - if monitor.elapsed > 300: + notify_minimum_time = 300 + try: + notify_minimum_time = int(os.environ.get('MACH_NOTIFY_MINTIME', '300')) + except ValueError: + # Just stick with the default + pass + + if monitor.elapsed > notify_minimum_time: # Display a notification when the build completes. - self.notify('Build complete') + self.notify('Build complete' if not status else 'Build failed') if status: return status @@ -446,8 +479,8 @@ class Build(MachCommandBase): print('To take your build for a test drive, run: |mach run|') app = self.substs['MOZ_BUILD_APP'] if app in ('browser', 'mobile/android'): - print('Please remember that you also need to PACKAGE your build ' - 'to have all components properly included and unnecessary files removed.') + print('For more information on what to do now, see ' + 'https://developer.mozilla.org/docs/Developer_Guide/So_You_Just_Built_Firefox') except Exception: # Ignore Exceptions in case we can't find config.status (such # as when doing OSX Universal builds) @@ -504,21 +537,40 @@ class Build(MachCommandBase): print('Hit CTRL+c to stop server.') server.run() + CLOBBER_CHOICES = ['objdir', 'python'] @Command('clobber', category='build', description='Clobber the tree (delete the object directory).') - def clobber(self): - try: - self.remove_objdir() - return 0 - except OSError as e: - if sys.platform.startswith('win'): - if isinstance(e, WindowsError) and e.winerror in (5,32): - self.log(logging.ERROR, 'file_access_error', {'error': e}, - "Could not clobber because a file was in use. If the " - "application is running, try closing it. {error}") - return 1 + @CommandArgument('what', default=['objdir'], nargs='*', + help='Target to clobber, must be one of {{{}}} (default objdir).'.format( + ', '.join(CLOBBER_CHOICES))) + def clobber(self, what): + invalid = set(what) - set(self.CLOBBER_CHOICES) + if invalid: + print('Unknown clobber target(s): {}'.format(', '.join(invalid))) + return 1 - raise + ret = 0 + if 'objdir' in what: + try: + self.remove_objdir() + except OSError as e: + if sys.platform.startswith('win'): + if isinstance(e, WindowsError) and e.winerror in (5,32): + self.log(logging.ERROR, 'file_access_error', {'error': e}, + "Could not clobber because a file was in use. If the " + "application is running, try closing it. {error}") + return 1 + raise + + if 'python' in what: + if os.path.isdir(mozpath.join(self.topsrcdir, '.hg')): + cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[co]'] + elif os.path.isdir(mozpath.join(self.topsrcdir, '.git')): + cmd = ['git', 'clean', '-f', '-x', '*.py[co]'] + else: + cmd = ['find', '.', '-type', 'f', '-name', '*.py[co]', '-delete'] + ret = subprocess.call(cmd, cwd=self.topsrcdir) + return ret @Command('build-backend', category='build', description='Generate a backend used to build the tree.') @@ -742,7 +794,7 @@ class GTestCommands(MachCommandBase): @CommandArgumentGroup('debugging') @CommandArgument('--debug', action='store_true', group='debugging', - help='Enable the debugger. Not specifying a --debugger option will result in the default debugger being used. The following arguments have no effect without this.') + help='Enable the debugger. Not specifying a --debugger option will result in the default debugger being used.') @CommandArgument('--debugger', default=None, type=str, group='debugging', help='Name of debugger to use.') @CommandArgument('--debugger-args', default=None, metavar='params', type=str, @@ -753,12 +805,13 @@ class GTestCommands(MachCommandBase): debugger_args): # We lazy build gtest because it's slow to link - self._run_make(directory="testing/gtest", target='gtest', ensure_exit_code=True) + self._run_make(directory="testing/gtest", target='gtest', + print_directory=False, ensure_exit_code=True) app_path = self.get_binary_path('app') args = [app_path, '-unittest']; - if debug: + if debug or debugger or debugger_args: args = self.prepend_debugger_args(args, debugger, debugger_args) cwd = os.path.join(self.topobjdir, '_tests', 'gtest') @@ -952,6 +1005,9 @@ class Install(MachCommandBase): @Command('install', category='post-build', description='Install the package on the machine, or on a device.') def install(self): + if conditions.is_android(self): + from mozrunner.devices.android_device import verify_android_device + verify_android_device(self) ret = self._run_make(directory=".", target='install', ensure_exit_code=False) if ret == 0: self.notify('Install complete') @@ -977,7 +1033,7 @@ class RunProgram(MachCommandBase): @CommandArgumentGroup('debugging') @CommandArgument('--debug', action='store_true', group='debugging', - help='Enable the debugger. Not specifying a --debugger option will result in the default debugger being used. The following arguments have no effect without this.') + help='Enable the debugger. Not specifying a --debugger option will result in the default debugger being used.') @CommandArgument('--debugger', default=None, type=str, group='debugging', help='Name of debugger to use.') @CommandArgument('--debugparams', default=None, metavar='params', type=str, @@ -994,7 +1050,7 @@ class RunProgram(MachCommandBase): @CommandArgumentGroup('DMD') @CommandArgument('--dmd', action='store_true', group='DMD', help='Enable DMD. The following arguments have no effect without this.') - @CommandArgument('--mode', choices=['live', 'dark-matter', 'cumulative'], group='DMD', + @CommandArgument('--mode', choices=['live', 'dark-matter', 'cumulative', 'scan'], group='DMD', help='Profiling mode. The default is \'dark-matter\'.') @CommandArgument('--sample-below', default=None, type=str, group='DMD', help='Sample blocks smaller than this. Use 1 for no sampling. The default is 4093.') @@ -1036,7 +1092,7 @@ class RunProgram(MachCommandBase): extra_env = {} - if debug: + if debug or debugger or debugparams: import mozdebug if not debugger: # No debugger name was provided. Look for the default ones on diff --git a/rdf/base/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index dd6c29b63d..e977a41e8f 100644 --- a/rdf/base/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -777,7 +777,7 @@ RDFServiceImpl::CreateSingleton(nsISupports* aOuter, return gRDFService->QueryInterface(aIID, aResult); } - nsRefPtr serv = new RDFServiceImpl(); + RefPtr serv = new RDFServiceImpl(); nsresult rv = serv->Init(); if (NS_FAILED(rv)) return rv; diff --git a/rdf/datasource/nsFileSystemDataSource.cpp b/rdf/datasource/nsFileSystemDataSource.cpp index 67e1a11726..512284ccfe 100644 --- a/rdf/datasource/nsFileSystemDataSource.cpp +++ b/rdf/datasource/nsFileSystemDataSource.cpp @@ -200,7 +200,7 @@ FileSystemDataSource::Create(nsISupports* aOuter, const nsIID& aIID, void **aRes { NS_ENSURE_NO_AGGREGATION(aOuter); - nsRefPtr self = new FileSystemDataSource(); + RefPtr self = new FileSystemDataSource(); if (!self) return NS_ERROR_OUT_OF_MEMORY; diff --git a/security/manager/ssl/DataStorage.cpp b/security/manager/ssl/DataStorage.cpp index 516100f1b5..ce81ab879c 100644 --- a/security/manager/ssl/DataStorage.cpp +++ b/security/manager/ssl/DataStorage.cpp @@ -106,7 +106,7 @@ private: static nsresult ParseLine(nsDependentCSubstring& aLine, nsCString& aKeyOut, Entry& aEntryOut); - nsRefPtr mDataStorage; + RefPtr mDataStorage; }; DataStorage::Reader::~Reader() @@ -321,7 +321,7 @@ DataStorage::AsyncReadData(bool& aHaveProfileDir, // Allocate a Reader so that even if it isn't dispatched, // the data-storage-ready notification will be fired and Get // will be able to proceed (this happens in its destructor). - nsRefPtr job(new Reader(this)); + RefPtr job(new Reader(this)); nsresult rv; // If we don't have a profile directory, this will fail. // That's okay - it just means there is no persistent state. @@ -518,7 +518,7 @@ private: NS_DECL_NSIRUNNABLE nsCString mData; - nsRefPtr mDataStorage; + RefPtr mDataStorage; }; NS_IMETHODIMP @@ -600,7 +600,7 @@ DataStorage::AsyncWriteData(const MutexAutoLock& /*aProofOfLock*/) nsCString output; mPersistentDataTable.EnumerateRead(WriteDataCallback, (void*)&output); - nsRefPtr job(new Writer(output, this)); + RefPtr job(new Writer(output, this)); nsresult rv = mWorkerThread->Dispatch(job, NS_DISPATCH_NORMAL); mPendingWrite = false; if (NS_WARN_IF(NS_FAILED(rv))) { @@ -633,7 +633,7 @@ DataStorage::Clear() void DataStorage::TimerCallback(nsITimer* aTimer, void* aClosure) { - nsRefPtr aDataStorage = (DataStorage*)aClosure; + RefPtr aDataStorage = (DataStorage*)aClosure; MutexAutoLock lock(aDataStorage->mMutex); unused << aDataStorage->AsyncWriteData(lock); } diff --git a/security/manager/ssl/TransportSecurityInfo.cpp b/security/manager/ssl/TransportSecurityInfo.cpp index 07cfaef282..f356073207 100644 --- a/security/manager/ssl/TransportSecurityInfo.cpp +++ b/security/manager/ssl/TransportSecurityInfo.cpp @@ -949,7 +949,7 @@ formatOverridableCertErrorMessage(nsISSLStatus & sslStatus, returnedMessage.AppendLiteral("\n\n"); RefPtr ix509; - rv = sslStatus.GetServerCert(byRef(ix509)); + rv = sslStatus.GetServerCert(getter_AddRefs(ix509)); NS_ENSURE_SUCCESS(rv, rv); bool isUntrusted; diff --git a/security/manager/ssl/TransportSecurityInfo.h b/security/manager/ssl/TransportSecurityInfo.h index 637f4d7c86..1f6e1f8416 100644 --- a/security/manager/ssl/TransportSecurityInfo.h +++ b/security/manager/ssl/TransportSecurityInfo.h @@ -102,7 +102,7 @@ private: nsXPIDLCString mHostName; /* SSL Status */ - mozilla::RefPtr mSSLStatus; + RefPtr mSSLStatus; /* Peer cert chain for failed connections (for error reporting) */ nsCOMPtr mFailedCertChain; diff --git a/security/manager/ssl/nsCertPicker.cpp b/security/manager/ssl/nsCertPicker.cpp index 417a3c9e8a..022be17ad8 100644 --- a/security/manager/ssl/nsCertPicker.cpp +++ b/security/manager/ssl/nsCertPicker.cpp @@ -163,7 +163,7 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, ++i, node = CERT_LIST_NEXT(node)) { if (i == selectedIndex) { - nsRefPtr cert = nsNSSCertificate::Create(node->cert); + RefPtr cert = nsNSSCertificate::Create(node->cert); if (!cert) { rv = NS_ERROR_OUT_OF_MEMORY; break; diff --git a/security/manager/ssl/nsCertTree.h b/security/manager/ssl/nsCertTree.h index b869987545..bf17b4efaf 100644 --- a/security/manager/ssl/nsCertTree.h +++ b/security/manager/ssl/nsCertTree.h @@ -46,7 +46,7 @@ public: nsCertAddonInfo() : mUsageCount(0) {} - mozilla::RefPtr mCert; + RefPtr mCert; // how many display entries reference this? // (and therefore depend on the underlying cert) int32_t mUsageCount; @@ -64,7 +64,7 @@ public: nsCertTreeDispInfo(); nsCertTreeDispInfo(nsCertTreeDispInfo &other); - mozilla::RefPtr mAddonInfo; + RefPtr mAddonInfo; enum { direct_db, host_port_override } mTypeOfEntry; @@ -118,7 +118,7 @@ protected: private: static const uint32_t kInitialCacheLength = 64; - nsTArray< mozilla::RefPtr > mDispInfo; + nsTArray< RefPtr > mDispInfo; nsCOMPtr mTree; nsCOMPtr mSelection; treeArrayEl *mTreeArray; @@ -127,7 +127,7 @@ private: PLDHashTable mCompareCache; nsCOMPtr mNSSComponent; nsCOMPtr mOverrideService; - mozilla::RefPtr mOriginalOverrideService; + RefPtr mOriginalOverrideService; treeArrayEl *GetThreadDescAtIndex(int32_t _index); already_AddRefed diff --git a/security/manager/ssl/nsNSSCallbacks.cpp b/security/manager/ssl/nsNSSCallbacks.cpp index 0c8a9f1f35..5db465ba96 100644 --- a/security/manager/ssl/nsNSSCallbacks.cpp +++ b/security/manager/ssl/nsNSSCallbacks.cpp @@ -42,7 +42,7 @@ public: nsNSSHttpRequestSession *mRequestSession; - nsRefPtr mListener; + RefPtr mListener; bool mResponsibleForDoneSignal; TimeStamp mStartTime; }; @@ -162,7 +162,7 @@ nsHTTPDownloadEvent::Run() } struct nsCancelHTTPDownloadEvent : nsRunnable { - nsRefPtr mListener; + RefPtr mListener; NS_IMETHOD Run() { mListener->FreeLoadGroup(true); diff --git a/security/manager/ssl/nsNSSCallbacks.h b/security/manager/ssl/nsNSSCallbacks.h index d77a1d09f8..65735a80f5 100644 --- a/security/manager/ssl/nsNSSCallbacks.h +++ b/security/manager/ssl/nsNSSCallbacks.h @@ -125,7 +125,7 @@ public: PRIntervalTime mTimeoutInterval; - nsRefPtr mListener; + RefPtr mListener; protected: nsNSSHttpRequestSession(); diff --git a/security/manager/ssl/nsNSSCertificate.cpp b/security/manager/ssl/nsNSSCertificate.cpp index 2466eb8b83..e53e10783b 100644 --- a/security/manager/ssl/nsNSSCertificate.cpp +++ b/security/manager/ssl/nsNSSCertificate.cpp @@ -1262,7 +1262,7 @@ nsNSSCertificate::GetValidity(nsIX509CertValidity** aValidity) return NS_ERROR_NOT_AVAILABLE; NS_ENSURE_ARG(aValidity); - nsRefPtr validity = new nsX509CertValidity(mCert.get()); + RefPtr validity = new nsX509CertValidity(mCert.get()); validity.forget(aValidity); return NS_OK; diff --git a/security/manager/ssl/nsNSSCertificateDB.cpp b/security/manager/ssl/nsNSSCertificateDB.cpp index 315258fa66..50d9c6a7f3 100644 --- a/security/manager/ssl/nsNSSCertificateDB.cpp +++ b/security/manager/ssl/nsNSSCertificateDB.cpp @@ -1384,7 +1384,7 @@ nsNSSCertificateDB::FindCertByEmailAddress(nsISupports *aToken, const char *aEma } // node now contains the first valid certificate with correct usage - nsRefPtr nssCert = nsNSSCertificate::Create(node->cert); + RefPtr nssCert = nsNSSCertificate::Create(node->cert); if (!nssCert) return NS_ERROR_OUT_OF_MEMORY; diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index 0bd015732c..defee01460 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -838,7 +838,7 @@ CipherSuiteChangeObserver::StartObserve() { NS_ASSERTION(NS_IsMainThread(), "CipherSuiteChangeObserver::StartObserve() can only be accessed in main thread"); if (!sObserver) { - nsRefPtr observer = new CipherSuiteChangeObserver(); + RefPtr observer = new CipherSuiteChangeObserver(); nsresult rv = Preferences::AddStrongObserver(observer.get(), "security."); if (NS_FAILED(rv)) { sObserver = nullptr; diff --git a/security/manager/ssl/nsNSSComponent.h b/security/manager/ssl/nsNSSComponent.h index 24e4b82df9..08fff0d05b 100644 --- a/security/manager/ssl/nsNSSComponent.h +++ b/security/manager/ssl/nsNSSComponent.h @@ -206,7 +206,7 @@ private: nsCertVerificationThread* mCertVerificationThread; nsNSSHttpInterface mHttpForNSS; - mozilla::RefPtr mDefaultCertVerifier; + RefPtr mDefaultCertVerifier; static PRStatus IdentityInfoInit(void); }; diff --git a/security/manager/ssl/nsProtectedAuthThread.cpp b/security/manager/ssl/nsProtectedAuthThread.cpp index 68f2e59b9c..ea511b24a6 100644 --- a/security/manager/ssl/nsProtectedAuthThread.cpp +++ b/security/manager/ssl/nsProtectedAuthThread.cpp @@ -4,7 +4,7 @@ #include "pk11func.h" #include "mozilla/DebugOnly.h" -#include "mozilla/nsRefPtr.h" +#include "mozilla/RefPtr.h" #include "nsCOMPtr.h" #include "PSMRunnable.h" #include "nsString.h" @@ -84,7 +84,7 @@ NS_IMETHODIMP nsProtectedAuthThread::GetTokenName(nsAString &_retval) NS_IMETHODIMP nsProtectedAuthThread::GetSlot(nsIPKCS11Slot **_retval) { - nsRefPtr slot; + RefPtr slot; { MutexAutoLock lock(mMutex); slot = new nsPKCS11Slot(mSlot); diff --git a/security/manager/ssl/nsSiteSecurityService.h b/security/manager/ssl/nsSiteSecurityService.h index b04747891e..0d4a50e592 100644 --- a/security/manager/ssl/nsSiteSecurityService.h +++ b/security/manager/ssl/nsSiteSecurityService.h @@ -149,7 +149,7 @@ private: bool mUseStsService; int64_t mPreloadListTimeOffset; bool mProcessPKPHeadersFromNonBuiltInRoots; - nsRefPtr mSiteStateStorage; + RefPtr mSiteStateStorage; }; #endif // __nsSiteSecurityService_h__ diff --git a/security/manager/ssl/tests/gtest/DataStorageTest.cpp b/security/manager/ssl/tests/gtest/DataStorageTest.cpp index d3247d5496..b415d7ca9f 100644 --- a/security/manager/ssl/tests/gtest/DataStorageTest.cpp +++ b/security/manager/ssl/tests/gtest/DataStorageTest.cpp @@ -28,7 +28,7 @@ protected: storage->Init(dataWillPersist); } - nsRefPtr storage; + RefPtr storage; bool dataWillPersist; }; diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 24880f9294..c4517a9c41 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -323,7 +323,7 @@ StartupCache::GetBuffer(const char* id, char** outbuf, uint32_t* length) if (NS_SUCCEEDED(rv)) return rv; - nsRefPtr omnijar = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); + RefPtr omnijar = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); // no need to checksum omnijarred entries rv = GetBufferFromZipArchive(omnijar, false, id, outbuf, length); if (NS_SUCCEEDED(rv)) diff --git a/startupcache/StartupCache.h b/startupcache/StartupCache.h index 74cab9a7bc..3705fa7f8d 100644 --- a/startupcache/StartupCache.h +++ b/startupcache/StartupCache.h @@ -161,11 +161,11 @@ private: nsClassHashtable mTable; nsTArray mPendingWrites; - nsRefPtr mArchive; + RefPtr mArchive; nsCOMPtr mFile; nsCOMPtr mObserverService; - nsRefPtr mListener; + RefPtr mListener; nsCOMPtr mTimer; bool mStartupWriteInitiated; diff --git a/storage/StorageBaseStatementInternal.cpp b/storage/StorageBaseStatementInternal.cpp index 7411194485..72ea84fb03 100644 --- a/storage/StorageBaseStatementInternal.cpp +++ b/storage/StorageBaseStatementInternal.cpp @@ -52,8 +52,8 @@ public: return NS_OK; } private: - nsRefPtr mStatement; - nsRefPtr mConnection; + RefPtr mStatement; + RefPtr mConnection; }; /** @@ -78,7 +78,7 @@ public: * responsibility for the instance and all other references to it * should be forgotten. */ - LastDitchSqliteStatementFinalizer(nsRefPtr &aConnection, + LastDitchSqliteStatementFinalizer(RefPtr &aConnection, sqlite3_stmt *aStatement) : mConnection(aConnection) , mAsyncStatement(aStatement) @@ -101,7 +101,7 @@ public: return NS_OK; } private: - nsRefPtr mConnection; + RefPtr mConnection; sqlite3_stmt *mAsyncStatement; }; diff --git a/storage/StorageBaseStatementInternal.h b/storage/StorageBaseStatementInternal.h index 64d3d72eaa..97e68e6b55 100644 --- a/storage/StorageBaseStatementInternal.h +++ b/storage/StorageBaseStatementInternal.h @@ -96,7 +96,7 @@ public: protected: // mix-in bits are protected StorageBaseStatementInternal(); - nsRefPtr mDBConnection; + RefPtr mDBConnection; sqlite3 *mNativeConnection; /** diff --git a/storage/TelemetryVFS.cpp b/storage/TelemetryVFS.cpp index fc4ad5043c..aad4011924 100644 --- a/storage/TelemetryVFS.cpp +++ b/storage/TelemetryVFS.cpp @@ -138,7 +138,7 @@ struct telemetry_file { Histograms *histograms; // quota object for this file - nsRefPtr quotaObject; + RefPtr quotaObject; // The chunk size for this file. See the documentation for // sqlite3_file_control() and FCNTL_CHUNK_SIZE. @@ -706,7 +706,7 @@ xDelete(sqlite3_vfs* vfs, const char *zName, int syncDir) { sqlite3_vfs *orig_vfs = static_cast(vfs->pAppData); int rc; - nsRefPtr quotaObject; + RefPtr quotaObject; if (StringEndsWith(nsDependentCString(zName), NS_LITERAL_CSTRING("-wal"))) { const char *zURIParameterKey = DatabasePathFromWALPath(zName); diff --git a/storage/VacuumManager.cpp b/storage/VacuumManager.cpp index 13fb284de0..bb0c5f5090 100644 --- a/storage/VacuumManager.cpp +++ b/storage/VacuumManager.cpp @@ -204,7 +204,7 @@ Vacuumer::execute() rv = mDBConn->CreateAsyncStatement(pageSizeQuery, getter_AddRefs(pageSizeStmt)); NS_ENSURE_SUCCESS(rv, false); - nsRefPtr callback = new BaseCallback(); + RefPtr callback = new BaseCallback(); nsCOMPtr ps; rv = pageSizeStmt->ExecuteAsync(callback, getter_AddRefs(ps)); NS_ENSURE_SUCCESS(rv, false); @@ -371,7 +371,7 @@ VacuumManager::Observe(nsISupports *aSubject, } int32_t index; for (index = startIndex; index < entries.Count(); ++index) { - nsRefPtr vacuum = new Vacuumer(entries[index]); + RefPtr vacuum = new Vacuumer(entries[index]); // Only vacuum one database per day. if (vacuum->execute()) { break; diff --git a/storage/mozStorageAsyncStatement.cpp b/storage/mozStorageAsyncStatement.cpp index f63ed6a40a..7b4029b55c 100644 --- a/storage/mozStorageAsyncStatement.cpp +++ b/storage/mozStorageAsyncStatement.cpp @@ -182,7 +182,7 @@ AsyncStatement::getParams() // If there isn't already any rows added, we'll have to add one to use. if (mParamsArray->length() == 0) { - nsRefPtr params(new AsyncBindingParams(mParamsArray)); + RefPtr params(new AsyncBindingParams(mParamsArray)); NS_ENSURE_TRUE(params, nullptr); rv = mParamsArray->AddParams(params); diff --git a/storage/mozStorageAsyncStatement.h b/storage/mozStorageAsyncStatement.h index 0873c4de8e..4fac36d307 100644 --- a/storage/mozStorageAsyncStatement.h +++ b/storage/mozStorageAsyncStatement.h @@ -82,7 +82,7 @@ private: * Holds the array of parameters to bind to this statement when we execute * it asynchronously. */ - nsRefPtr mParamsArray; + RefPtr mParamsArray; /** * Caches the JS 'params' helper for this statement. diff --git a/storage/mozStorageAsyncStatementExecution.cpp b/storage/mozStorageAsyncStatementExecution.cpp index 20f7a6b12c..f8c1649b60 100644 --- a/storage/mozStorageAsyncStatementExecution.cpp +++ b/storage/mozStorageAsyncStatementExecution.cpp @@ -82,7 +82,7 @@ public: private: mozIStorageStatementCallback *mCallback; nsCOMPtr mResults; - nsRefPtr mEventStatus; + RefPtr mEventStatus; }; /** @@ -118,7 +118,7 @@ public: private: mozIStorageStatementCallback *mCallback; nsCOMPtr mErrorObj; - nsRefPtr mEventStatus; + RefPtr mEventStatus; }; /** @@ -169,7 +169,7 @@ AsyncExecuteStatements::execute(StatementDataArray &aStatements, mozIStoragePendingStatement **_stmt) { // Create our event to run in the background - nsRefPtr event = + RefPtr event = new AsyncExecuteStatements(aStatements, aConnection, aNativeConnection, aCallback); NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY); @@ -400,7 +400,7 @@ AsyncExecuteStatements::buildAndNotifyResults(sqlite3_stmt *aStatement) mResultSet = new ResultSet(); NS_ENSURE_TRUE(mResultSet, NS_ERROR_OUT_OF_MEMORY); - nsRefPtr row(new Row()); + RefPtr row(new Row()); NS_ENSURE_TRUE(row, NS_ERROR_OUT_OF_MEMORY); nsresult rv = row->initialize(aStatement); @@ -466,7 +466,7 @@ AsyncExecuteStatements::notifyComplete() // Always generate a completion notification; it is what guarantees that our // destruction does not happen here on the async thread. - nsRefPtr completionEvent = + RefPtr completionEvent = new CompletionNotifier(mCallback, mState); // We no longer own mCallback (the CompletionNotifier takes ownership). @@ -502,7 +502,7 @@ AsyncExecuteStatements::notifyError(mozIStorageError *aError) if (!mCallback) return NS_OK; - nsRefPtr notifier = + RefPtr notifier = new ErrorNotifier(mCallback, aError, this); NS_ENSURE_TRUE(notifier, NS_ERROR_OUT_OF_MEMORY); @@ -515,7 +515,7 @@ AsyncExecuteStatements::notifyResults() mMutex.AssertNotCurrentThreadOwns(); NS_ASSERTION(mCallback, "notifyResults called without a callback!"); - nsRefPtr notifier = + RefPtr notifier = new CallbackResultNotifier(mCallback, mResultSet, this); NS_ENSURE_TRUE(notifier, NS_ERROR_OUT_OF_MEMORY); diff --git a/storage/mozStorageAsyncStatementExecution.h b/storage/mozStorageAsyncStatementExecution.h index 4364231e70..c8493fd771 100644 --- a/storage/mozStorageAsyncStatementExecution.h +++ b/storage/mozStorageAsyncStatementExecution.h @@ -183,12 +183,12 @@ private: bool statementsNeedTransaction(); StatementDataArray mStatements; - nsRefPtr mConnection; + RefPtr mConnection; sqlite3 *mNativeConnection; bool mHasTransaction; mozIStorageStatementCallback *mCallback; nsCOMPtr mCallingThread; - nsRefPtr mResultSet; + RefPtr mResultSet; /** * The maximum amount of time we want to wait between results. Defined by diff --git a/storage/mozStorageAsyncStatementJSHelper.cpp b/storage/mozStorageAsyncStatementJSHelper.cpp index 69397db1ff..01fe2647b7 100644 --- a/storage/mozStorageAsyncStatementJSHelper.cpp +++ b/storage/mozStorageAsyncStatementJSHelper.cpp @@ -56,7 +56,7 @@ AsyncStatementJSHelper::getParams(AsyncStatement *aStatement, getter_AddRefs(holder) ); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr paramsHolder = + RefPtr paramsHolder = new AsyncStatementParamsHolder(holder); aStatement->mStatementParamsHolder = new nsMainThreadPtrHolder(paramsHolder); diff --git a/storage/mozStorageBindingParams.cpp b/storage/mozStorageBindingParams.cpp index ee3a1438d3..4de803eaba 100644 --- a/storage/mozStorageBindingParams.cpp +++ b/storage/mozStorageBindingParams.cpp @@ -274,7 +274,7 @@ AsyncBindingParams::BindByName(const nsACString &aName, { NS_ENSURE_FALSE(mLocked, NS_ERROR_UNEXPECTED); - nsRefPtr variant = convertVariantToStorageVariant(aValue); + RefPtr variant = convertVariantToStorageVariant(aValue); if (!variant) return NS_ERROR_UNEXPECTED; @@ -396,7 +396,7 @@ BindingParams::BindByIndex(uint32_t aIndex, ENSURE_INDEX_VALUE(aIndex, mParamCount); // Store the variant for later use. - nsRefPtr variant = convertVariantToStorageVariant(aValue); + RefPtr variant = convertVariantToStorageVariant(aValue); if (!variant) return NS_ERROR_UNEXPECTED; if (mParameters.Length() <= aIndex) { @@ -418,7 +418,7 @@ AsyncBindingParams::BindByIndex(uint32_t aIndex, // In the asynchronous case we do not know how many parameters there are to // bind to, so we cannot check the validity of aIndex. - nsRefPtr variant = convertVariantToStorageVariant(aValue); + RefPtr variant = convertVariantToStorageVariant(aValue); if (!variant) return NS_ERROR_UNEXPECTED; if (mParameters.Length() <= aIndex) { diff --git a/storage/mozStorageBindingParams.h b/storage/mozStorageBindingParams.h index 3d7e9af4c8..fa08ebb2fc 100644 --- a/storage/mozStorageBindingParams.h +++ b/storage/mozStorageBindingParams.h @@ -60,7 +60,7 @@ protected: explicit BindingParams(mozIStorageBindingParamsArray *aOwningArray); // Note that this is managed as a sparse array, so particular caution should // be used for out-of-bounds usage. - nsTArray > mParameters; + nsTArray > mParameters; bool mLocked; private: diff --git a/storage/mozStorageConnection.cpp b/storage/mozStorageConnection.cpp index 791693e627..f5aad00c4e 100644 --- a/storage/mozStorageConnection.cpp +++ b/storage/mozStorageConnection.cpp @@ -245,7 +245,7 @@ basicFunctionHelper(sqlite3_context *aCtx, mozIStorageFunction *func = static_cast(userData); - nsRefPtr arguments(new ArgValueArray(aArgc, aArgv)); + RefPtr arguments(new ArgValueArray(aArgc, aArgv)); if (!arguments) return; @@ -283,7 +283,7 @@ aggregateFunctionStepHelper(sqlite3_context *aCtx, mozIStorageAggregateFunction *func = static_cast(userData); - nsRefPtr arguments(new ArgValueArray(aArgc, aArgv)); + RefPtr arguments(new ArgValueArray(aArgc, aArgv)); if (!arguments) return; @@ -298,7 +298,7 @@ aggregateFunctionFinalHelper(sqlite3_context *aCtx) mozIStorageAggregateFunction *func = static_cast(userData); - nsRefPtr result; + RefPtr result; if (NS_FAILED(func->OnFinal(getter_AddRefs(result)))) { NS_WARNING("User aggregate final function returned error code!"); ::sqlite3_result_error(aCtx, @@ -434,7 +434,7 @@ public: (void)NS_ProxyRelease(thread, mCallbackEvent); } private: - nsRefPtr mConnection; + RefPtr mConnection; sqlite3 *mNativeConnection; nsCOMPtr mCallbackEvent; nsCOMPtr mAsyncExecutionThread; @@ -481,7 +481,7 @@ public: private: nsresult Dispatch(nsresult aResult, nsISupports* aValue) { - nsRefPtr event = new CallbackComplete(aResult, + RefPtr event = new CallbackComplete(aResult, aValue, mCallback.forget()); return mClone->threadOpenedOn->Dispatch(event, NS_DISPATCH_NORMAL); @@ -511,8 +511,8 @@ private: (void)NS_ProxyRelease(thread, rawCallback); } - nsRefPtr mConnection; - nsRefPtr mClone; + RefPtr mConnection; + RefPtr mClone; const bool mReadOnly; nsCOMPtr mCallback; }; @@ -1298,10 +1298,10 @@ Connection::AsyncClone(bool aReadOnly, flags = (~SQLITE_OPEN_CREATE & flags); } - nsRefPtr clone = new Connection(mStorageService, flags, + RefPtr clone = new Connection(mStorageService, flags, mAsyncOnly); - nsRefPtr initEvent = + RefPtr initEvent = new AsyncInitializeClone(this, clone, aReadOnly, aCallback); nsCOMPtr target = clone->getAsyncExecutionTarget(); if (!target) { @@ -1379,7 +1379,7 @@ Connection::Clone(bool aReadOnly, flags = (~SQLITE_OPEN_CREATE & flags); } - nsRefPtr clone = new Connection(mStorageService, flags, + RefPtr clone = new Connection(mStorageService, flags, mAsyncOnly); nsresult rv = initializeClone(clone, aReadOnly); @@ -1493,7 +1493,7 @@ Connection::CreateStatement(const nsACString &aSQLStatement, NS_ENSURE_ARG_POINTER(_stmt); if (!mDBConn) return NS_ERROR_NOT_INITIALIZED; - nsRefPtr statement(new Statement()); + RefPtr statement(new Statement()); NS_ENSURE_TRUE(statement, NS_ERROR_OUT_OF_MEMORY); nsresult rv = statement->initialize(this, mDBConn, aSQLStatement); @@ -1512,7 +1512,7 @@ Connection::CreateAsyncStatement(const nsACString &aSQLStatement, NS_ENSURE_ARG_POINTER(_stmt); if (!mDBConn) return NS_ERROR_NOT_INITIALIZED; - nsRefPtr statement(new AsyncStatement()); + RefPtr statement(new AsyncStatement()); NS_ENSURE_TRUE(statement, NS_ERROR_OUT_OF_MEMORY); nsresult rv = statement->initialize(this, mDBConn, aSQLStatement); diff --git a/storage/mozStorageConnection.h b/storage/mozStorageConnection.h index dd29225895..e5e0649565 100644 --- a/storage/mozStorageConnection.h +++ b/storage/mozStorageConnection.h @@ -357,7 +357,7 @@ private: // This is here for two reasons: 1) It's used to make sure that the // connections do not outlive the service. 2) Our custom collating functions // call its localeCompareStrings() method. - nsRefPtr mStorageService; + RefPtr mStorageService; /** * If |false|, this instance supports synchronous operations @@ -402,10 +402,10 @@ public: private: nsresult mStatus; nsCOMPtr mValue; - // This is a nsRefPtr and not a nsCOMPtr because + // This is a RefPtr and not a nsCOMPtr because // nsCOMP would cause an off-main thread QI, which // is not a good idea (and crashes XPConnect). - nsRefPtr mCallback; + RefPtr mCallback; }; } // namespace storage diff --git a/storage/mozStoragePrivateHelpers.cpp b/storage/mozStoragePrivateHelpers.cpp index 8db8773281..d6819fe8c6 100644 --- a/storage/mozStoragePrivateHelpers.cpp +++ b/storage/mozStoragePrivateHelpers.cpp @@ -161,7 +161,7 @@ convertJSValToVariant( Variant_base * convertVariantToStorageVariant(nsIVariant* aVariant) { - nsRefPtr variant = do_QueryObject(aVariant); + RefPtr variant = do_QueryObject(aVariant); if (variant) { // JS helpers already convert the JS representation to a Storage Variant, // in such a case there's nothing left to do here, so just pass-through. diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp index baa214ef0d..5ebc03ef07 100644 --- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -129,11 +129,11 @@ Service::CollectReports(nsIHandleReportCallback *aHandleReport, nsresult rv; size_t totalConnSize = 0; { - nsTArray > connections; + nsTArray > connections; getConnections(connections); for (uint32_t i = 0; i < connections.Length(); i++) { - nsRefPtr &conn = connections[i]; + RefPtr &conn = connections[i]; // Someone may have closed the Connection, in which case we skip it. bool isReady; @@ -320,7 +320,7 @@ Service::unregisterConnection(Connection *aConnection) // If this is the last Connection it might be the only thing keeping Service // alive. So ensure that Service is destroyed only after the Connection is // cleanly unregistered and destroyed. - nsRefPtr kungFuDeathGrip(this); + RefPtr kungFuDeathGrip(this); { mRegistrationMutex.AssertNotCurrentThreadOwns(); MutexAutoLock mutex(mRegistrationMutex); @@ -345,7 +345,7 @@ Service::unregisterConnection(Connection *aConnection) } void -Service::getConnections(/* inout */ nsTArray >& aConnections) +Service::getConnections(/* inout */ nsTArray >& aConnections) { mRegistrationMutex.AssertNotCurrentThreadOwns(); MutexAutoLock mutex(mRegistrationMutex); @@ -356,11 +356,11 @@ Service::getConnections(/* inout */ nsTArray >& aConnection void Service::minimizeMemory() { - nsTArray > connections; + nsTArray > connections; getConnections(connections); for (uint32_t i = 0; i < connections.Length(); i++) { - nsRefPtr conn = connections[i]; + RefPtr conn = connections[i]; if (!conn->connectionReady()) continue; @@ -669,7 +669,7 @@ Service::OpenSpecialDatabase(const char *aStorageKey, return NS_ERROR_INVALID_ARG; } - nsRefPtr msc = new Connection(this, SQLITE_OPEN_READWRITE, false); + RefPtr msc = new Connection(this, SQLITE_OPEN_READWRITE, false); rv = storageFile ? msc->initialize(storageFile) : msc->initialize(); NS_ENSURE_SUCCESS(rv, rv); @@ -724,7 +724,7 @@ public: private: nsresult DispatchResult(nsresult aStatus, nsISupports* aValue) { - nsRefPtr event = + RefPtr event = new CallbackComplete(aStatus, aValue, mCallback.forget()); @@ -752,10 +752,10 @@ private: (void)NS_ProxyRelease(thread, rawCallback); } - nsRefPtr mConnection; + RefPtr mConnection; nsCOMPtr mStorageFile; int32_t mGrowthIncrement; - nsRefPtr mCallback; + RefPtr mCallback; }; } // namespace @@ -820,11 +820,11 @@ Service::OpenAsyncDatabase(nsIVariant *aDatabaseStore, } // Create connection on this thread, but initialize it on its helper thread. - nsRefPtr msc = new Connection(this, flags, true); + RefPtr msc = new Connection(this, flags, true); nsCOMPtr target = msc->getAsyncExecutionTarget(); MOZ_ASSERT(target, "Cannot initialize a connection that has been closed already"); - nsRefPtr asyncInit = + RefPtr asyncInit = new AsyncInitDatabase(msc, storageFile, growthIncrement, @@ -842,7 +842,7 @@ Service::OpenDatabase(nsIFile *aDatabaseFile, // reasons. int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_CREATE; - nsRefPtr msc = new Connection(this, flags, false); + RefPtr msc = new Connection(this, flags, false); nsresult rv = msc->initialize(aDatabaseFile); NS_ENSURE_SUCCESS(rv, rv); @@ -861,7 +861,7 @@ Service::OpenUnsharedDatabase(nsIFile *aDatabaseFile, // reasons. int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_PRIVATECACHE | SQLITE_OPEN_CREATE; - nsRefPtr msc = new Connection(this, flags, false); + RefPtr msc = new Connection(this, flags, false); nsresult rv = msc->initialize(aDatabaseFile); NS_ENSURE_SUCCESS(rv, rv); @@ -880,7 +880,7 @@ Service::OpenDatabaseWithFileURL(nsIFileURL *aFileURL, // reasons. int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI; - nsRefPtr msc = new Connection(this, flags, false); + RefPtr msc = new Connection(this, flags, false); nsresult rv = msc->initialize(aFileURL); NS_ENSURE_SUCCESS(rv, rv); @@ -946,11 +946,11 @@ Service::Observe(nsISupports *, const char *aTopic, const char16_t *) bool anyOpen = false; do { - nsTArray > connections; + nsTArray > connections; getConnections(connections); anyOpen = false; for (uint32_t i = 0; i < connections.Length(); i++) { - nsRefPtr &conn = connections[i]; + RefPtr &conn = connections[i]; if (conn->isClosing()) { anyOpen = true; break; @@ -963,7 +963,7 @@ Service::Observe(nsISupports *, const char *aTopic, const char16_t *) } while (anyOpen); if (gShutdownChecks == SCM_CRASH) { - nsTArray > connections; + nsTArray > connections; getConnections(connections); for (uint32_t i = 0, n = connections.Length(); i < n; i++) { if (!connections[i]->isClosed()) { diff --git a/storage/mozStorageService.h b/storage/mozStorageService.h index a8f5f5b545..effd330b16 100644 --- a/storage/mozStorageService.h +++ b/storage/mozStorageService.h @@ -124,7 +124,7 @@ public: * it. * @return The open connections. */ - void getConnections(nsTArray >& aConnections); + void getConnections(nsTArray >& aConnections); private: Service(); @@ -148,7 +148,7 @@ private: * The list of connections we have created. Modifications to it are * protected by |mRegistrationMutex|. */ - nsTArray > mConnections; + nsTArray > mConnections; /** * Frees as much heap memory as possible from all of the known open diff --git a/storage/mozStorageStatement.cpp b/storage/mozStorageStatement.cpp index 4456d49a94..1f8636dd4e 100644 --- a/storage/mozStorageStatement.cpp +++ b/storage/mozStorageStatement.cpp @@ -207,7 +207,7 @@ Statement::getParams() // If there isn't already any rows added, we'll have to add one to use. if (mParamsArray->length() == 0) { - nsRefPtr params(new BindingParams(mParamsArray, this)); + RefPtr params(new BindingParams(mParamsArray, this)); NS_ENSURE_TRUE(params, nullptr); rv = mParamsArray->AddParams(params); @@ -317,7 +317,7 @@ MIXIN_IMPL_STORAGEBASESTATEMENTINTERNAL(Statement, (void)0;) NS_IMETHODIMP Statement::Clone(mozIStorageStatement **_statement) { - nsRefPtr statement(new Statement()); + RefPtr statement(new Statement()); NS_ENSURE_TRUE(statement, NS_ERROR_OUT_OF_MEMORY); nsAutoCString sql(::sqlite3_sql(mDBStatement)); diff --git a/storage/mozStorageStatement.h b/storage/mozStorageStatement.h index c6056a12c9..69b69c58de 100644 --- a/storage/mozStorageStatement.h +++ b/storage/mozStorageStatement.h @@ -90,7 +90,7 @@ private: * Holds the array of parameters to bind to this statement when we execute * it asynchronously. */ - nsRefPtr mParamsArray; + RefPtr mParamsArray; /** * The following two members are only used with the JS helper. They cache diff --git a/storage/mozStorageStatementData.h b/storage/mozStorageStatementData.h index a6214b60f4..97c262f011 100644 --- a/storage/mozStorageStatementData.h +++ b/storage/mozStorageStatementData.h @@ -135,7 +135,7 @@ public: private: sqlite3_stmt *mStatement; - nsRefPtr mParamsArray; + RefPtr mParamsArray; /** * We hold onto a reference of the statement's owner so it doesn't get diff --git a/storage/mozStorageStatementJSHelper.cpp b/storage/mozStorageStatementJSHelper.cpp index c05a0a53af..b092b32d32 100644 --- a/storage/mozStorageStatementJSHelper.cpp +++ b/storage/mozStorageStatementJSHelper.cpp @@ -109,7 +109,7 @@ StatementJSHelper::getRow(Statement *aStatement, getter_AddRefs(holder) ); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr rowHolder = new StatementRowHolder(holder); + RefPtr rowHolder = new StatementRowHolder(holder); aStatement->mStatementRowHolder = new nsMainThreadPtrHolder(rowHolder); } @@ -154,7 +154,7 @@ StatementJSHelper::getParams(Statement *aStatement, getter_AddRefs(holder) ); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr paramsHolder = + RefPtr paramsHolder = new StatementParamsHolder(holder); aStatement->mStatementParamsHolder = new nsMainThreadPtrHolder(paramsHolder); diff --git a/storage/test/storage_test_harness.h b/storage/test/storage_test_harness.h index cca7503fbe..bc0fc00abd 100644 --- a/storage/test/storage_test_harness.h +++ b/storage/test/storage_test_harness.h @@ -212,7 +212,7 @@ void AsyncStatementSpinner::SpinUntilCompleted() void blocking_async_execute(mozIStorageBaseStatement *stmt) { - nsRefPtr spinner(new AsyncStatementSpinner()); + RefPtr spinner(new AsyncStatementSpinner()); nsCOMPtr pendy; (void)stmt->ExecuteAsync(spinner, getter_AddRefs(pendy)); @@ -226,7 +226,7 @@ blocking_async_execute(mozIStorageBaseStatement *stmt) void blocking_async_close(mozIStorageConnection *db) { - nsRefPtr spinner(new AsyncStatementSpinner()); + RefPtr spinner(new AsyncStatementSpinner()); db->AsyncClose(spinner); spinner->SpinUntilCompleted(); diff --git a/storage/test/test_AsXXX_helpers.cpp b/storage/test/test_AsXXX_helpers.cpp index 6067bf0ca1..4edf7b93ad 100644 --- a/storage/test/test_AsXXX_helpers.cpp +++ b/storage/test/test_AsXXX_helpers.cpp @@ -110,7 +110,7 @@ test_asyncNULLFallback() do_check_true(NS_SUCCEEDED(stmt->ExecuteAsync(nullptr, getter_AddRefs(pendingStmt)))); do_check_true(pendingStmt); stmt->Finalize(); - nsRefPtr asyncSpin(new Spinner()); + RefPtr asyncSpin(new Spinner()); db->AsyncClose(asyncSpin); asyncSpin->SpinUntilCompleted(); diff --git a/storage/test/test_asyncStatementExecution_transaction.cpp b/storage/test/test_asyncStatementExecution_transaction.cpp index 2bff246bfc..7e94bd80ed 100644 --- a/storage/test/test_asyncStatementExecution_transaction.cpp +++ b/storage/test/test_asyncStatementExecution_transaction.cpp @@ -50,7 +50,7 @@ check_transaction(mozIStorageConnection *aDB, int commit = 0; static_cast(aDB)->setCommitHook(commit_hook, &commit); - nsRefPtr asyncSpin(new AsyncStatementSpinner()); + RefPtr asyncSpin(new AsyncStatementSpinner()); nsCOMPtr asyncPend; do_check_success(aDB->ExecuteAsync(aStmts, aStmtsLen, asyncSpin, getter_AddRefs(asyncPend))); diff --git a/storage/test/test_transaction_helper.cpp b/storage/test/test_transaction_helper.cpp index 5f0a04b918..4277c8f942 100644 --- a/storage/test/test_transaction_helper.cpp +++ b/storage/test/test_transaction_helper.cpp @@ -128,7 +128,7 @@ test_async_Commit() // -- wedge the thread nsCOMPtr target(get_conn_async_thread(db)); do_check_true(target); - nsRefPtr wedger (new ThreadWedger(target)); + RefPtr wedger (new ThreadWedger(target)); { mozStorageTransaction transaction(db, false, diff --git a/storage/test/test_true_async.cpp b/storage/test/test_true_async.cpp index beea9fb0a6..fea00392d6 100644 --- a/storage/test/test_true_async.cpp +++ b/storage/test/test_true_async.cpp @@ -81,7 +81,7 @@ test_AsyncCancellation() // -- wedge the thread nsCOMPtr target(get_conn_async_thread(db)); do_check_true(target); - nsRefPtr wedger (new ThreadWedger(target)); + RefPtr wedger (new ThreadWedger(target)); // -- create statements and cancel them // - async @@ -91,7 +91,7 @@ test_AsyncCancellation() getter_AddRefs(asyncStmt) ); - nsRefPtr asyncSpin(new AsyncStatementSpinner()); + RefPtr asyncSpin(new AsyncStatementSpinner()); nsCOMPtr asyncPend; (void)asyncStmt->ExecuteAsync(asyncSpin, getter_AddRefs(asyncPend)); do_check_true(asyncPend); @@ -104,7 +104,7 @@ test_AsyncCancellation() getter_AddRefs(syncStmt) ); - nsRefPtr syncSpin(new AsyncStatementSpinner()); + RefPtr syncSpin(new AsyncStatementSpinner()); nsCOMPtr syncPend; (void)syncStmt->ExecuteAsync(syncSpin, getter_AddRefs(syncPend)); do_check_true(syncPend); diff --git a/storage/test/test_unlock_notify.cpp b/storage/test/test_unlock_notify.cpp index 2726d0cea7..820ccec5a9 100644 --- a/storage/test/test_unlock_notify.cpp +++ b/storage/test/test_unlock_notify.cpp @@ -163,7 +163,7 @@ test_step_locked_does_not_block_main_thread() ), getter_AddRefs(stmt)); do_check_success(rv); - nsRefPtr locker(new DatabaseLocker("SELECT * FROM test")); + RefPtr locker(new DatabaseLocker("SELECT * FROM test")); do_check_true(locker); mozilla::ReentrantMonitorAutoEnter lock(locker->monitor); locker->RunInBackground(); @@ -191,7 +191,7 @@ test_drop_index_does_not_loop() ), getter_AddRefs(stmt)); do_check_success(rv); - nsRefPtr tester = + RefPtr tester = new DatabaseTester(db, "DROP INDEX unique_data"); do_check_true(tester); mozilla::ReentrantMonitorAutoEnter lock(tester->monitor); @@ -221,7 +221,7 @@ test_drop_table_does_not_loop() ), getter_AddRefs(stmt)); do_check_success(rv); - nsRefPtr tester(new DatabaseTester(db, "DROP TABLE test")); + RefPtr tester(new DatabaseTester(db, "DROP TABLE test")); do_check_true(tester); mozilla::ReentrantMonitorAutoEnter lock(tester->monitor); tester->RunInBackground(); diff --git a/testing/cppunittest.ini b/testing/cppunittest.ini index 8a19df35a1..c7789f39c7 100644 --- a/testing/cppunittest.ini +++ b/testing/cppunittest.ini @@ -28,11 +28,10 @@ skip-if = os == 'b2g' # Bug 1054246 [TestCountPopulation] [TestCountZeroes] [TestDeadlockDetector] -skip-if = os == 'b2g' # Bug 1054249 +skip-if = os == 'b2g' || (os == 'android' && debug) # Bug 1054249 [TestDeadlockDetectorScalability] -[TestDeque] [TestDllInterceptor] -run-if = os == 'win' +skip-if = os != 'win' [TestEndian] [TestEnumSet] [TestFile] diff --git a/testing/mochitest/mach_commands.py b/testing/mochitest/mach_commands.py index 41222e56d5..30f497fc57 100644 --- a/testing/mochitest/mach_commands.py +++ b/testing/mochitest/mach_commands.py @@ -393,6 +393,14 @@ def setup_argument_parser(): from mochitest_options import MochitestArgumentParser + if conditions.is_android(build_obj): + # On Android, check for a connected device (and offer to start an + # emulator if appropriate) before running tests. This check must + # be done in this admittedly awkward place because + # MochitestArgumentParser initialization fails if no device is found. + from mozrunner.devices.android_device import verify_android_device + verify_android_device(build_obj, install=True) + return MochitestArgumentParser() diff --git a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py new file mode 100644 index 0000000000..1a88e52598 --- /dev/null +++ b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py @@ -0,0 +1,522 @@ +# 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/. + +import os +import psutil +import re +import shutil +import signal +import telnetlib +import time +import urllib2 +from distutils.spawn import find_executable + +from mozdevice import DeviceManagerADB, DMError +from mozprocess import ProcessHandler + +EMULATOR_HOME_DIR = os.path.join(os.path.expanduser('~'), '.mozbuild', 'android-device') + +TOOLTOOL_URL = 'https://raw.githubusercontent.com/mozilla/build-tooltool/master/tooltool.py' + +class AvdInfo(object): + """ + Simple class to contain an AVD description. + """ + def __init__(self, description, name, tooltool_manifest, extra_args, + port, uses_sut, sut_port, sut_port2): + self.description = description + self.name = name + self.tooltool_manifest = tooltool_manifest + self.extra_args = extra_args + self.port = port + self.uses_sut = uses_sut + self.sut_port = sut_port + self.sut_port2 = sut_port2 + + +""" + A dictionary to map an AVD type to a description of that type of AVD. + + There is one entry for each type of AVD used in Mozilla automated tests + and the parameters for each reflect those used in mozharness. +""" +AVD_DICT = { + '2.3': AvdInfo('Android 2.3', + 'mozemulator-2.3', + 'testing/config/tooltool-manifests/androidarm/releng.manifest', + ['-debug', + 'init,console,gles,memcheck,adbserver,adbclient,adb,avd_config,socket', + '-qemu', '-m', '1024', '-cpu', 'cortex-a9'], + 5554, + True, + 20701, 20700), + '4.3': AvdInfo('Android 4.3', + 'mozemulator-4.3', + 'testing/config/tooltool-manifests/androidarm_4_3/releng.manifest', + ['-show-kernel', '-debug', + 'init,console,gles,memcheck,adbserver,adbclient,adb,avd_config,socket'], + 5554, + False, + 0, 0), + 'x86': AvdInfo('Android 4.2 x86', + 'mozemulator-x86', + 'testing/config/tooltool-manifests/androidx86/releng.manifest', + ['-debug', + 'init,console,gles,memcheck,adbserver,adbclient,adb,avd_config,socket', + '-qemu', '-m', '1024', '-enable-kvm'], + 5554, + True, + 20701, 20700) +} + +def verify_android_device(build_obj, install=False): + """ + Determine if any Android device is connected via adb. + If no device is found, prompt to start an emulator. + If a device is found or an emulator started and 'install' is + specified, also check whether Firefox is installed on the + device; if not, prompt to install Firefox. + Returns True if the emulator was started or another device was + already connected. + """ + device_verified = False + emulator = AndroidEmulator('*', substs=build_obj.substs) + devices = emulator.dm.devices() + if len(devices) > 0: + device_verified = True + elif emulator.is_available(): + response = raw_input( + "No Android devices connected. Start an emulator? (Y/n) ").strip() + if response.lower().startswith('y') or response == '': + if not emulator.check_avd(): + print("Fetching AVD. This may take a while...") + emulator.update_avd() + print("Starting emulator running %s..." % + emulator.get_avd_description()) + emulator.start() + emulator.wait_for_start() + device_verified = True + + if device_verified and install: + # Determine if Firefox is installed on the device; if not, + # prompt to install. This feature allows a test command to + # launch an emulator, install Firefox, and proceed with testing + # in one operation. It is also a basic safeguard against other + # cases where testing is requested but Firefox installation has + # been forgotten. + # If Firefox is installed, there is no way to determine whether + # the current build is installed, and certainly no way to + # determine if the installed build is the desired build. + # Installing every time is problematic because: + # - it prevents testing against other builds (downloaded apk) + # - installation may take a couple of minutes. + installed = emulator.dm.shellCheckOutput(['pm', 'list', + 'packages', 'org.mozilla.']) + if not 'fennec' in installed and not 'firefox' in installed: + response = raw_input( + "It looks like Firefox is not installed on this device.\n" + "Install Firefox? (Y/n) ").strip() + if response.lower().startswith('y') or response == '': + print("Installing Firefox. This may take a while...") + build_obj._run_make(directory=".", target='install', + ensure_exit_code=False) + return device_verified + + +class AndroidEmulator(object): + + """ + Support running the Android emulator with an AVD from Mozilla + test automation. + + Example usage: + emulator = AndroidEmulator() + if not emulator.is_running() and emulator.is_available(): + if not emulator.check_avd(): + warn("this may take a while...") + emulator.update_avd() + emulator.start() + emulator.wait_for_start() + emulator.wait() + """ + + def __init__(self, avd_type='4.3', verbose=False, substs=None): + self.emulator_log = None + self.emulator_path = 'emulator' + self.verbose = verbose + self.substs = substs + self.avd_type = self._get_avd_type(avd_type) + self.avd_info = AVD_DICT[self.avd_type] + adb_path = self._find_sdk_exe('adb', False) + if not adb_path: + adb_path = 'adb' + self.dm = DeviceManagerADB(autoconnect=False, adbPath=adb_path, retryLimit=1) + self.dm.default_timeout = 10 + self._log_debug("Emulator created with type %s" % self.avd_type) + + def __del__(self): + if self.emulator_log: + self.emulator_log.close() + + def is_running(self): + """ + Returns True if the Android emulator is running. + """ + for proc in psutil.process_iter(): + name = proc.name() + # On some platforms, "emulator" may start an emulator with + # process name "emulator64-arm" or similar. + if name and name.startswith('emulator'): + return True + return False + + def is_available(self): + """ + Returns True if an emulator executable is found. + """ + found = False + emulator_path = self._find_sdk_exe('emulator', True) + if emulator_path: + self.emulator_path = emulator_path + found = True + return found + + def check_avd(self, force=False): + """ + Determine if the AVD is already installed locally. + (This is usually used to determine if update_avd() is likely + to require a download; it is a convenient way of determining + whether a 'this may take a while' warning is warranted.) + + Returns True if the AVD is installed. + """ + avd = os.path.join( + EMULATOR_HOME_DIR, 'avd', self.avd_info.name + '.avd') + if force and os.path.exists(avd): + shutil.rmtree(avd) + if os.path.exists(avd): + self._log_debug("AVD found at %s" % avd) + return True + return False + + def update_avd(self, force=False): + """ + If required, update the AVD via tooltool. + + If the AVD directory is not found, or "force" is requested, + download the tooltool manifest associated with the AVD and then + invoke tooltool.py on the manifest. tooltool.py will download the + required archive (unless already present in the local tooltool + cache) and install the AVD. + """ + avd = os.path.join( + EMULATOR_HOME_DIR, 'avd', self.avd_info.name + '.avd') + if force and os.path.exists(avd): + shutil.rmtree(avd) + if not os.path.exists(avd): + self._fetch_tooltool() + self._fetch_tooltool_manifest() + self._tooltool_fetch() + self._update_avd_paths() + + def start(self): + """ + Launch the emulator. + """ + def outputHandler(line): + self.emulator_log.write("<%s>\n" % line) + env = os.environ + env['ANDROID_AVD_HOME'] = os.path.join(EMULATOR_HOME_DIR, "avd") + command = [self.emulator_path, "-avd", + self.avd_info.name, "-port", "5554"] + if self.avd_info.extra_args: + command += self.avd_info.extra_args + log_path = os.path.join(EMULATOR_HOME_DIR, 'emulator.log') + self.emulator_log = open(log_path, 'w') + self._log_debug("Starting the emulator with this command: %s" % + ' '.join(command)) + self._log_debug("Emulator output will be written to '%s'" % + log_path) + self.proc = ProcessHandler( + command, storeOutput=False, processOutputLine=outputHandler, + env=env) + self.proc.run() + self._log_debug("Emulator started with pid %d" % + int(self.proc.proc.pid)) + + def wait_for_start(self): + """ + Verify that the emulator is running, the emulator device is visible + to adb, and Android has booted. + """ + if not self.proc: + self._log_warning("Emulator not started!") + return False + if self.proc.proc.poll() is not None: + self._log_warning("Emulator has already completed!") + return False + self._log_debug("Waiting for device status...") + while(('emulator-5554', 'device') not in self.dm.devices()): + time.sleep(10) + if self.proc.proc.poll() is not None: + self._log_warning("Emulator has already completed!") + return False + self._log_debug("Device status verified.") + + self._log_debug("Checking that Android has booted...") + complete = False + while(not complete): + output = '' + try: + output = self.dm.shellCheckOutput( + ['getprop', 'sys.boot_completed'], timeout=5) + except DMError: + # adb not yet responding...keep trying + pass + if output.strip() == '1': + complete = True + else: + time.sleep(10) + if self.proc.proc.poll() is not None: + self._log_warning("Emulator has already completed!") + return False + self._log_debug("Android boot status verified.") + + if not self._verify_emulator(): + return False + if self.avd_info.uses_sut: + if not self._verify_sut(): + return False + return True + + def wait(self): + """ + Wait for the emulator to close. If interrupted, close the emulator. + """ + try: + self.proc.wait() + except: + if self.proc.poll() is None: + self.cleanup() + return self.proc.poll() + + def cleanup(self): + """ + Close the emulator. + """ + self.proc.kill(signal.SIGTERM) + + def get_avd_description(self): + """ + Return the human-friendly description of this AVD. + """ + return self.avd_info.description + + def _log_debug(self, text): + if self.verbose: + print "DEBUG: %s" % text + + def _log_warning(self, text): + print "WARNING: %s" % text + + def _fetch_tooltool(self): + self._download_file(TOOLTOOL_URL, 'tooltool.py', EMULATOR_HOME_DIR) + + def _fetch_tooltool_manifest(self): + url = 'https://hg.mozilla.org/%s/raw-file/%s/%s' % ( + "try", "default", self.avd_info.tooltool_manifest) + self._download_file(url, 'releng.manifest', EMULATOR_HOME_DIR) + + def _tooltool_fetch(self): + def outputHandler(line): + self._log_debug(line) + command = ['python', 'tooltool.py', 'fetch', '-m', 'releng.manifest'] + proc = ProcessHandler( + command, processOutputLine=outputHandler, storeOutput=False, + cwd=EMULATOR_HOME_DIR) + proc.run() + try: + proc.wait() + except: + if proc.poll() is None: + proc.kill(signal.SIGTERM) + + def _update_avd_paths(self): + avd_path = os.path.join(EMULATOR_HOME_DIR, "avd") + ini_file = os.path.join(avd_path, "test-1.ini") + ini_file_new = os.path.join(avd_path, self.avd_info.name + ".ini") + os.rename(ini_file, ini_file_new) + avd_dir = os.path.join(avd_path, "test-1.avd") + avd_dir_new = os.path.join(avd_path, self.avd_info.name + ".avd") + os.rename(avd_dir, avd_dir_new) + self._replace_ini_contents(ini_file_new) + + def _download_file(self, url, filename, path): + f = urllib2.urlopen(url) + if not os.path.isdir(path): + try: + os.makedirs(path) + except Exception, e: + self._log_warning(str(e)) + return False + local_file = open(os.path.join(path, filename), 'wb') + local_file.write(f.read()) + local_file.close() + self._log_debug("Downloaded %s to %s/%s" % (url, path, filename)) + return True + + def _replace_ini_contents(self, path): + with open(path, "r") as f: + lines = f.readlines() + with open(path, "w") as f: + for line in lines: + if line.startswith('path='): + avd_path = os.path.join(EMULATOR_HOME_DIR, "avd") + f.write('path=%s/%s.avd\n' % + (avd_path, self.avd_info.name)) + elif line.startswith('path.rel='): + f.write('path.rel=avd/%s.avd\n' % self.avd_info.name) + else: + f.write(line) + + def _telnet_cmd(self, telnet, command): + self._log_debug(">>> " + command) + telnet.write('%s\n' % command) + result = telnet.read_until('OK', 10) + self._log_debug("<<< " + result) + return result + + def _verify_emulator(self): + telnet_ok = False + tn = None + while(not telnet_ok): + try: + tn = telnetlib.Telnet('localhost', self.avd_info.port, 10) + if tn is not None: + res = tn.read_until('OK', 10) + self._telnet_cmd(tn, 'avd status') + if self.avd_info.uses_sut: + cmd = 'redir add tcp:%s:%s' % \ + (str(self.avd_info.sut_port), + str(self.avd_info.sut_port)) + self._telnet_cmd(tn, cmd) + cmd = 'redir add tcp:%s:%s' % \ + (str(self.avd_info.sut_port2), + str(self.avd_info.sut_port2)) + self._telnet_cmd(tn, cmd) + self._telnet_cmd(tn, 'redir list') + self._telnet_cmd(tn, 'network status') + tn.write('quit\n') + tn.read_all() + telnet_ok = True + else: + self._log_warning("Unable to connect to port %d" % port) + except: + self._log_warning("Trying again after unexpected exception") + finally: + if tn is not None: + tn.close() + if not telnet_ok: + time.sleep(10) + if self.proc.proc.poll() is not None: + self._log_warning("Emulator has already completed!") + return False + return telnet_ok + + def _verify_sut(self): + sut_ok = False + while(not sut_ok): + try: + tn = telnetlib.Telnet('localhost', self.avd_info.sut_port, 10) + if tn is not None: + self._log_debug( + "Connected to port %d" % self.avd_info.sut_port) + res = tn.read_until('$>', 10) + if res.find('$>') == -1: + self._log_debug("Unexpected SUT response: %s" % res) + else: + self._log_debug("SUT response: %s" % res) + sut_ok = True + tn.write('quit\n') + tn.read_all() + except: + self._log_debug("Caught exception while verifying sutagent") + finally: + if tn is not None: + tn.close() + if not sut_ok: + time.sleep(10) + if self.proc.proc.poll() is not None: + self._log_warning("Emulator has already completed!") + return False + return sut_ok + + def _get_avd_type(self, requested): + if requested in AVD_DICT.keys(): + return requested + if self.substs: + if not self.substs['TARGET_CPU'].startswith('arm'): + return 'x86' + if self.substs['MOZ_ANDROID_MIN_SDK_VERSION'] == '9': + return '2.3' + return '4.3' + + def _find_sdk_exe(self, exe, tools): + if tools: + subdir = 'tools' + var = 'ANDROID_TOOLS' + else: + subdir = 'platform-tools' + var = 'ANDROID_PLATFORM_TOOLS' + + found = False + # Is exe on PATH? + exe_path = find_executable(exe) + if exe_path: + found = True + else: + self._log_debug("Unable to find executable on PATH") + + if not found: + # Can exe be found in the Android SDK? + try: + android_sdk_root = os.environ['ANDROID_SDK_ROOT'] + exe_path = os.path.join( + android_sdk_root, subdir, exe) + if os.path.exists(exe_path): + found = True + else: + self._log_debug( + "Unable to find executable at %s" % exe_path) + except KeyError: + self._log_debug("ANDROID_SDK_ROOT not set") + + if not found and self.substs: + # Can exe be found in ANDROID_TOOLS/ANDROID_PLATFORM_TOOLS? + try: + exe_path = os.path.join( + self.substs[var], exe) + if os.path.exists(exe_path): + found = True + else: + self._log_debug( + "Unable to find executable at %s" % exe_path) + except KeyError: + self._log_debug("%s not set" % var) + + if not found: + # Can exe be found in the default bootstrap location? + exe_path = os.path.join( + '~', '.mozbuild', 'android-sdk-linux', subdir, exe) + if os.path.exists(exe_path): + found = True + else: + self._log_debug( + "Unable to find executable at %s" % exe_path) + + if found: + self._log_debug("%s found at %s" % (exe, exe_path)) + else: + exe_path = None + return exe_path diff --git a/testing/web-platform/mozilla/meta/MANIFEST.json b/testing/web-platform/mozilla/meta/MANIFEST.json index 57147e6229..f6108e868f 100644 --- a/testing/web-platform/mozilla/meta/MANIFEST.json +++ b/testing/web-platform/mozilla/meta/MANIFEST.json @@ -106,6 +106,12 @@ "url": "/_mozilla/service-workers/service-worker/extendable-event-waituntil.https.html" } ], + "service-workers/service-worker/fetch-canvas-tainting-cache.https.html": [ + { + "path": "service-workers/service-worker/fetch-canvas-tainting-cache.https.html", + "url": "/_mozilla/service-workers/service-worker/fetch-canvas-tainting-cache.https.html" + } + ], "service-workers/service-worker/fetch-canvas-tainting.https.html": [ { "path": "service-workers/service-worker/fetch-canvas-tainting.https.html", diff --git a/testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini b/testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini new file mode 100644 index 0000000000..2f281012cb --- /dev/null +++ b/testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini @@ -0,0 +1,3 @@ +[worker-interception-iframe.https.html] + type: testharness + disabled: not a test diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html new file mode 100644 index 0000000000..fdb64e15d6 --- /dev/null +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html @@ -0,0 +1,38 @@ + +Service Worker: canvas tainting of the fetched image using cached responses + + + + + + + diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html index a6eb4bb491..a1eb62b9e8 100644 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html @@ -64,7 +64,8 @@ function redirect_fetch_test(t, test) { }; frame.contentWindow.postMessage({ url: url, - request_init: test.request_init + request_init: test.request_init, + redirect_dest: test.redirect_dest, }, '*', [channel.port2]); }); diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html index 4232e5d91e..c40c0c7227 100644 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html @@ -3,11 +3,26 @@