mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:37:11 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1207494 - Part 8: Remove use of expression closure from dom/identity/. r=ferjm (34fac889f8) - minor crash thing (13fe2827c2) - Bug 1243359 - initialize mScrollSeriesNumber in all ScrollWheelInput constructors. r=roc (94163d8eca) - fix misspatch (b380a7bbe4) - Bug 1207412 - Make SystemTimeConverter use TimeStamp::Now() when converting times; r=karlt (f408549605) - Bug 1212102 - Drop unnecessary assertion comparing timestamps in SystemTimeConverter; r=karlt (1efaa04b3f) - Bug 1241302 - Slightly modernize this code. r=jst (c1e97bc069) - bug 1216916 clean up when InvokeDragSessionWithImage/Selection() fails r=roc (9cdf71b717) - Bug 1231329 - run ConvertToUnscaledDevPixels if *aPresContext is valid. r=roc (d10f23633b) - Bug 1245927: Innerize before creating DOM files from the file picker. r=baku (8754128362) - Bug 1155214 - Mark nsIBidiKeyboard as builtinclass; r=mrbkap (2d00326d2b) - reorder (c3c1ba92c9) - Bug 1236566 - add override declarations for widget/windows/GfxInfo.h; r=roc (940b40ed91) - Bug 1242659: Part 1. More information on the mismatches. r=jrmuizel (78331ddad2) - Block some Radeon drivers that crash on D3D9. (bug 1213107, r=jrmuizel) (482b66d313) - Bug 1203199 - Blacklist DXVA on some older intel drivers for causing crashes. r=jrmuizel (f1827d4498) - Bug 1203199 - Fix driver range with blacklist to avoid blacklisting other OSes. (2c2d547296) - Bug 1203199 - Bustage fix. CLOSED TREE (3233d407f3) - Bug 1178385. Enable DXVA on the G45 r=ajones (3c59a58a15) - Bug 1188442 IMMHandler::GetSelection() should use static Selection instance when IME doesn't have focus and return its or mSelection's reference r=emk (5cc4b30433) - Bug 1238899 Create hidden native caret for ATOK at composing in windowless plugin r=m_kato (40ef5bb4aa) - Bug 1257919 part 1. Kill off nsIXSLTException. r=khuey (11f37643f2) - Bug 1242072 - Change implementation of BaseProxyHandler::get() to follow ES6 [[Get]] specification. r=jorendorff (094a67f284) - Bug 489636 - Add a GC u-bench test for property tree splitting via deletion; r=sfink (9282fec25f) - Bug 1257919 part 2. Make nsIException and nsIStackFrame builtinclass, so we can start using [implicit_jscontext] on them. r=khuey (0e65fb8554) - Bug 1257919 part 3. Make the various toString methods on exceptions take an explicit JSContext. r=khuey (b342fb4930) - Bug 1257919 part 4. Stop returning StackFrame instances from exceptions::CreateStack. C++ callers of GetCurrentJSStack or exceptions::CreateStack always check for null anyway, and none of them seem to want this non-JS thing. r=khuey (d34036ccf9) - Bug 1257919 part 5. Get rid of the now-unused StackFrame class. r=khuey (aa13af0dfe) - Bug 1141222 - Create ScriptError with stack from Cu.reportError. r=bholley (b83ad26aa0) - Bug 1208641 - Extract stack from DOM/XPC exception. r=bholley (e382b5f48c) - Bug 1254380 part 1. Find the relevant window when the compartment we've got is an addon sandbox compartment in AutoJSAPI exception/warning reporting code. r=bholley (4b1f6c64a9) - Bug 1250630 - remove PBackgroundTest and ifdef ENABLE_TEST blocks. r=khuey (d7b36860a3) - Bug 1250963 part 1. Change NotifyRunnable::Dispatch to not require a JSContext. r=khuey (48e03c2fc2) - Bug 1250963 part 2. Remove the unused JSContext argument of WorkerPrivate::ModifyBusyCount. r=khuey (0f5ca42be1) - Bug 1250291 part 1. Stop pretending to report exceptions in MainThreadStopSyncLoopRunnable::PostDispatch. r=khuey (6e1c81cc06) - Bug 1250291 part 2. Stop pretending to report exceptions in MainThreadWorkerSyncRunnable::PostDispatch. r=khuey (f3d846ea31) - Bug 1250291 part 3. Stop pretending to report exceptions in WorkerDebuggerRunnable::PostDispatch. r=khuey (10bc1710d1) - Bug 1250975. Stop passing a JSContext argument to WorkerRunnable::PreDispatch and its overrides. r=khuey (71ab9046f0) - Bug 1255298. Just pass through the JSContext when passing through the NotificationOptions in notification code. r=wchen (552ae8e33e) - Bug 1250185 part 2. Remove some JSContext stuff that's no longer needed in Notification code. r=khuey (20b99ef28b) - Bug 1251045 part 8. Remove the JSContext argument from some nsINotificationStorageCallback methods. r=khuey (170c4afabc) - Bug 1227015 P7 Supress unused ErrorResult exception if the worker runnable failed to dispatch. r=catalinb (23a3cc6f45) - Bug 1251045 part 3. Remove the JSContext argument of WorkerRunnable::PostDispatch and its overrides. r=khuey (6a666d1a4a) - Bug 1251045 part 2. Remove the JSContext argument of ModifyBusyCountFromWorker. r=khuey (105bc4f59e) - Bug 1252130. Remove unnecessary JSContext argument from NotificationWorkerRunnable::WorkerRunInternal. r=khuey (642727f6f6) - Bug 1252127. Remove unnecessary JSContext argument from PromiseWorkerProxy::CleanUp. r=khuey (339e1157d1) - Bug 1251045 part 1. Make it possible to dispatch a ModifyBusyCountRunnable without a JSContext. r=khuey (665c1f81b4) - Bug 1251045 part 4. Remove the JSContext argument of WorkerRunnable::Dispatch. r=khuey (6c5cdab2b7) - Bug 1250185 part 1. nsIStructuredCloneContainer.initFromBase64 doesn't need a JSContext argument. r=khuey (d63a219209) - fix (773c0393aa) - Bug 1251045 part 5. Remove the JSContext argument from WorkerPrivateParent::Freeze/Thaw. r=khuey (cd419bfd2c) - Bug 1251045 part 6. Remove the JSContext argument from some worker debugger methods that no longer need it. r=khuey (abcc437cb9) - Bug 1251045 part 7. Remove the JSContext argument from some worker methods that no longer need it. r=khuey (3ddcbca08c) - Bug 1249652 part 1. Add a method on ErrorResult to steal an exception, if any, from a JSContext. r=khuey (9c07f5044b) - Bug 1229071 - importScripts should throw the correct error result in case the loading of one of scripts fails, r=bz (cd37645d76) - Bug 1229970 Abort script loading start requests if a load has been canceled. r=khuey (a44d9128ca) - Bug 1233171 Cancel channel when ScriptLoader is aborted during service worker script load. r=khuey (3b6ceafec7) - Bug 1249351 part 1. When doing importScripts of multiple scripts in a service worker, make sure to track the cache streams per-loadinfo, instead of trying to make them all wait on the same stream. r=bkelly (e1ccea9685) - Bug 1157544 - Fix a typo in the test; r=baku (8c0bf8f504) - Bug 1249351 part 2. Clean up test_importscript.html and add multiple-url importScript() case. r=bz (52b0a31032) - Bug 1249652 part 2. ScriptExecutorRunnable::WorkerRun should immediately move JS exceptions to its ErrorResult instead of allowing them to linger on the JSContext. r=baku,khuey (f628d3c8ba) - Bug 1249652 part 3. Simplify way we handle canceling when ScriptLoaderRunnable::RunInternal fails by canceling things with its actual failure code, so we don't have to guess which failed loads are actual failures and which are just canceled via this mechanism. r=baku,khuey (388543fbc3) - Bug 1251369. Use an AutoJSAPI that reports its own exceptions around the main runloop in workers. r=khuey (28b33287cd) - Bug 1251518. Fix js::ErrorReportToString to make a bit more sense, and change worker code to not use it anyway, so it matches the mainthread code. r=bholley,terrence (a48a40de90) - Bug 1254380 part 2. Go ahead and log the stack from our exception in AutoJSAPI::ReportException even if we don't have a window. r=bholley (64532b6017) - Bug 1212328 - Clean up some JSErrorReport-related code. r=Waldo,bz (d5aa611edc) - Bug 1255192 part 1. Remove the JSContext argument of JS::ExceptionStackOrNull. r=bholley (39b631d5ad) - bug 1252687 - make the ctor for CycleCollectorStats constexpr r=mccr8 (9e8168d8ac) - Bug 1254380 part 3. Skip firing error events for mainthread out of memory exceptions via AutoJSAPI::ReportException. r=bholley (d5e4e7dc29) - Bug 1254230 kinda-fix. Make sure to never send script errors with stacks attached to the console service if the associated windows have already had FreeInnerObjects called on them. r=bholley (8c379fe0e0) - Bug 1255192 part 2. Clean up the JSContext usage around xpc::FindExceptionStackForConsoleReport now that it just needs a JSContext for rooting. r=bholley (cade862491) - Bug 1255201. Improve the stack handling in nsXPCComponents_Utils::ReportError for the DOMException case to include the stack from the DOMException. r=bholley (fc6c065284) - Bug 1257919 part 6. Make the filename getter on JSStackFrame take an explicit JSContext. r=khuey (cde115b789) - Bug 1257919 part 7. Make the name getter on JSStackFrame take an explicit JSContext. r=khuey (d7466e9eab) - Bug 1257919 part 8. Make the line/column number getters on JSStackFrame take an explicit JSContext. r=khuey (b8766b98b2) - Bug 1257919 part 9. Make the asyncCause/asyncCaller getters on JSStackFrame take an explicit JSContext. r=khuey (b776ff9c6d) - Bug 1257919 part 10. Make the caller and formattedStack getters on JSStackFrame take an explicit JSContext. r=khuey (dc4d3d9091) - Bug 1252091. Add/RemoveFeature don't need a JSContext argument. r=khuey (5be6253a67) - Bug 1252123. Remove some unnecessary JSContext arguments from worker ScriptLoader methods. r=khuey (1657a35268) - Bug 1255181. Remove AutoJSAPI::InitWithLegacyErrorReporting. r=bholley (5ee7ac506e) - Bug 1254847 part 1. Take ownership of error reporting on the AutoEntryScript in nsXPCWrappedJSClass::DelegatedQueryInterface. r=bholley (62d987b030) - make style wrong again.... (fa4e6cfbc1) - Bug 1254847 part 2. Change nsJSNPRuntime to always use AutoEntryScript and always take ownership of error reporting. r=bholley (d24cb80622) - Bug 1251655 - Remove support for JavaScript-global-constructor-prototype-alias. r=bz. (2b354ea423) - Bug 1251655 - Remove support for JavaScript-DOM-class and JavaScript-DOM-interface. r=bz. (dd6786ea57) - Bug 1251275. Switch to using an AutoEntryScript in WorkerPrivate::RunExpiredTimeouts. r=khuey (f10d1b0dec) - Bug 1072144 part 1. Just release-assert that Promise::Resolve does not fail in service worker code. It can only do that on OOM or overrecursion anyway, and overrecursion is not likely if we're coming right off a runnable. r=khuey (ba4c89a3bc) - Bug 1072144 part 2. When UnregisterWorker tries to ScheduleWorker and that throws, just suppress the exception: there is no good place to report it anyway. r=khuey (ca563ec5cd) - Bug 1072144 part 3. Hoist the exception reporting out of WorkerRunnable::PostRun into WorkerRunnable::Run and make it unconditional. r=khuey (9914acd4a6) - Bug 1252221. When GetOrCreateGlobalScope fails while trying to run a ScriptExecutorRunnable::WorkerRun, just suppress the exception, because there is no way to report it without a compartment to work with. r=khuey (abcc9df148) - Bug 1072144 part 4. Add a WorkerRunnable::PreRun so that we can move worker global creation to it and always have an AutoEntryScript by the time we're evaluating the main worker script. r=khuey (007b528868) - Bug 1251276 part 1. Change WorkerPrivate::CancelAllTimeouts to no longer call RunExpiredTimeouts. r=khuey (6b937370a1) - Bug 1251276 part 2. Remove the JSContext argument of WorkerPrivate::CancelAllTimeouts. r=khuey (336b788e03) - Bug 1251380. Change things so that WorkerPrivate::NotifyInternal (hopefully) never throws. r=khuey (1d4863f83a) - Bug 1254846. Add an AutoEntryScript constructor that takes a JSObject instead of an nsIGlobalObject, for convenience. r=bholley (693857f9b0) - Bug 1255706 part 1. Remove JSContext argument from WorkerPrivate constructor. r=khuey (0486bdb01c) - Bug 1255706 part 2. Remove JSContext argument from WorkerPrivate::Terminate. r=khuey (f0b62de092) - Bug 1257568. Remove the JSContext argument of WorkerPrivate::Kill. r=khuey (ebe7d247b5) - Bug 1252189. Remove the unnecessary JSContext argument from WorkerPrivate::FreezeInternal/ThawInternal. r=khuey (22b137b05e) - Bug 1119490 - Expose the URL constructor to WorkerDebuggerGlobalScope;r=khuey (6f4fc13e1e) - Bug 1241841 - Clear the worker's debugger event queue before destroying its context;r=khuey (a1e8dd4b2d) - Bug 1249950 - Add Performance Markers for MessagePort - patch 1 - remove non-useful 'explicit', r=smaug (8a014b53e6) - Bug 1249950 - Add Performance Markers for MessagePort - patch 2, r=smaug, r=vporof (560caf0ae1) - bug 1250486 - make the ComponentsSH ctor constexpr r=bz (1c441dbb0f) - Bug 1257032: Make files in dom/workers actually build without unification. r=baku (6ab4ae0b65) - Bug 1241522 - handle OOM in nsExpatDriver::HandleCharacterData; r=hsivonen (b652220cdc) - Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in various files.r=benjamin (5fd5e8dbc8) - Bug 1238545 - Remove nsISimpleUnicharStreamFactory; r=froydnj (f0018c5b16) - Bug 1257335. Replace some AutoSafeJSContext uses with AutoJSAPI or AutoJSContext uses. r=bholley (7baf79deb7) - Bug 1247635 - Unify PostMessageRunnable and DispatchEventRunnable in MessagePort.cpp, r=smaug (df2765c215) - Bug 1250572 - Force a parent object in MessagePort/Channel and in StructuredCloneHolder, r=smaug (2a929d59d1) - Bug 1255375 - MessagePort should not leak if DispatchMessage() fails, r=smaug (0a5cdebfb0) - Bug 1251272. Remove the dead code in ReportErrorRunnable::ReportError that could fail, and make it infallible. r=khuey (89e80694d0) - Bug 1072144 part 5. Stop fiddling with compartments on the JSContext before calling PostRun in WorkerRunnable::Run. Add some documentation explaining what's going on. r=khuey (91f4bb6a7c) - Bug 1072144 part 6. Switch WorkerRunnable::Run to calling TakeOwnershipOfErrorReporting on its AutoJSAPI/AutoEntryScript and remove the remaining JS_ReportPendingException callers in worker code. r=khuey (405d9e0282) - Bug 1179548 - Close the windows opened in private browsing worker tests; r=baku (acf3430b69) - Bug 1179753 - Use pushPrefEnv more in worker tests; r=baku (4bfd949c72) - Bug 1134224 - More test for test_bug1132395.html, r=ehsan (626eb100cd) - Bug 1134224 - onerror for test_bug1132395.html, r=ehsan (147195f57e) - Bug 1207635 - get rid of dom.workers.sharedWorkers.enabled pref, r=khuey (22fe2965c6) - Bug 1252592. JS warnings should not trigger error events on shared workers. r=khuey (7f05c2c00d) - Bug 1251308; r=luke (3cbec95738) - Bug 1246838 - Handle const qualifiers and references better in Variant. r=waldo (30da6e3ebf) - Bug 1254565 - Allow passing matchers as rvalues to Variant::match. r=froydnj (1dd799fb0a) - Bug 1246841 - Allow construction of Variant values using type inference. r=waldo (6ba3e6704c) - Bug 1250666 - Forward Variant's move constructor argument correctly to the underlying variant type. r=waldo (7353a53bf0) - Bug 1252185. Remove the dead "target" variable from CloseEventRunnable::WorkerRun. r=khuey (be172da10b) - Bug 1253059: Use fallible allocation in the worker error reporter. r=baku (963222bdd4) - Bug 1253199 - MessagePort should handle the dispatching a message when the parent window is gone, r=smaug (d552e3cd9e) - Bug 1252839 - Remove some if stmt after allocation with 'new' - patch 2, r=bz (3c7eb959bc) - Bug 1252839 - Remove some if stmt after allocation with 'new' - patch 1, r=bz (85067dbfb6) - Bug 1254855. Switch AutoEntryScripts in nsDirectoryViewer to take ownership of error reporting. r=bholley (8c10532323) - Bug 1252565 part 1. Push the script environment preparer bits up from XPCJSRuntime to CycleCollectedJSRuntime, because we need them on workers to do ctypes on workers properly. r=bholley (aecf2595dd) - Bug 1252565 part 2. Make dom::WarningOnlyErrorReporter handle workers. r=bholley (f415b8868b) - Bug 1244222 - Check for function interfaces in DelegatedQueryInterface. r=bz (d213eec83c) - Bug 1254393. Take ownership of error reporting on the AutoEntryScript in nsXPCWrappedJSClass::CallMethod. r=bholley (4765b501c0) - Bug 1251769 - Remove remaining references to MOZILLA_XPCOMRT_API from mfbt. r=froydnj (236adc1d4c) - Bug 1247835 (part 0) - Minor comment and style tweaks in BinarySearch.h. r=luke. (db04793721) - Bug 1244074 - Part 1: Move SheetParsingMode to a separate file. r=dholbert (290adaadea) - Bug 1244074 - Part 2: Add HandleRefPtr for refcounting StyleSheetHandles. r=dholbert r=waldo (8549b24392) - Bug 1244068 - Part 1: Add enum to represent the style system backend type. r=dholbert (c2e53feaf2) - Bug 1244068 - Part 2: Add skeleton ServoStyleSet and a StyleSetHandle smart pointer. r=dholbert (71a5c28629) - Bug 1244068 - Part 3: Factor out nsStyleSet getting in RestyleManager/ElementRestyler. r=dholbert (9e9f4f2e80) - Bug 1245406: In ReflowBlockFrame, use Maybe<> to destroy & reconstruct a stack-allocated object, instead of an explicit call to destructor & placement 'new'. r=dbaron (d36858b818) - Bug 1244068 - Part 4: Use StyleSetHandle instead of concrete style set class in most places. r=dholbert (93f9bcf799) - Bug 1244074 - Part 3: Add skeleton ServoStyleSheet and a StyleSheetHandle smart pointer. r=dholbert (5b4fbdce38) - Bug 1195173 - Apply CSP to preloaded styles within layout/style/Loader.cpp (r=bz) (d1ba920fd3) - Bug 1245681 - Fix addOverrideStyleSheet. r=bz (64099eac73) - Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholberti (867470ac83) - Bug 1246013 (part 1) - Store a copy of the ETLDEntry directly in DomainEntry instead of a pointer to it. r=jduell. (587b3a9fb7) - Bug 1246013 (part 2) - Change "explicit/xpcom/effective-TLD-service" path to the more sensible "explicit/network/effective-TLD-service". r=jduell. (2e0df6f28f) - Bug 1247835 (part 1) - Use binary search instead of a hash table in nsEffectiveTLDService. r=jduell. (685dae01c0) - Bug 1257121 part 1 - Use struct for passing some params of font metrics. r=jfkthame (1dfd7a7429) - Bug 1257121 part 2 - Merge nsFontMetrics::Init to the constructor and remove unused failure handling code. r=jfkthame (0cdc441511) - Bug 1257121 part 3 - Add GetInflatedFontMetricsForFrame function to simplify a common use pattern. r=jfkthame (d9630ebd1b) - Bug 1257121 part 4 - Use return value rather than out param to retur font metrics. r=jfkthame (c9a5b1d1dd) - Bug 1257121 part 5 - Make nsDeviceContext::mFontCache a RefPtr. r=jfkthame (9c53238a6a)
This commit is contained in:
@@ -460,8 +460,8 @@ bool
|
||||
TextAttrsMgr::FontFamilyTextAttr::
|
||||
GetFontFamily(nsIFrame* aFrame, nsString& aFamily)
|
||||
{
|
||||
RefPtr<nsFontMetrics> fm;
|
||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
||||
|
||||
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
|
||||
gfxFont* font = fontGroup->GetFirstValidFont();
|
||||
@@ -618,8 +618,8 @@ 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).
|
||||
RefPtr<nsFontMetrics> fm;
|
||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
||||
|
||||
gfxFontGroup *fontGroup = fm->GetThebesFontGroup();
|
||||
gfxFont *font = fontGroup->GetFirstValidFont();
|
||||
|
||||
@@ -179,8 +179,8 @@ sdnTextAccessible::get_fontFamily(BSTR __RPC_FAR* aFontFamily)
|
||||
if (!frame)
|
||||
return E_FAIL;
|
||||
|
||||
RefPtr<nsFontMetrics> fm;
|
||||
nsLayoutUtils::GetFontMetricsForFrame(frame, getter_AddRefs(fm));
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForFrame(frame, 1.0f);
|
||||
|
||||
const nsString& name =
|
||||
fm->GetThebesFontGroup()->GetFirstValidFont()->GetName();
|
||||
|
||||
@@ -465,7 +465,7 @@ nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
|
||||
unsigned lineNum = 0;
|
||||
NS_NAMED_LITERAL_STRING(scriptSample, "call to eval() or related function blocked by CSP");
|
||||
|
||||
JS::UniqueChars scriptFilename;
|
||||
JS::AutoFilename scriptFilename;
|
||||
if (JS::DescribeScriptedCaller(cx, &scriptFilename, &lineNum)) {
|
||||
if (const char *file = scriptFilename.get()) {
|
||||
CopyUTF8toUTF16(nsDependentCString(file), fileName);
|
||||
|
||||
+14
-14
@@ -17,7 +17,6 @@
|
||||
#include "nsString.h"
|
||||
#include "nsQueryObject.h"
|
||||
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIDocument.h"
|
||||
@@ -30,12 +29,14 @@
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
|
||||
|
||||
// DO NOT use namespace mozilla; it'll break due to a naming conflict between
|
||||
// mozilla::TextRange and a TextRange in OSX headers.
|
||||
using mozilla::CSSStyleSheet;
|
||||
using mozilla::StyleSheetHandle;
|
||||
using mozilla::dom::IsChromeURI;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -414,19 +415,18 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
||||
nsCOMPtr<nsIPresShell> shell = document->GetShell();
|
||||
if (shell) {
|
||||
// Reload only the chrome URL agent style sheets.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
||||
rv = shell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newAgentSheets;
|
||||
for (CSSStyleSheet* sheet : agentSheets) {
|
||||
nsTArray<StyleSheetHandle::RefPtr> newAgentSheets;
|
||||
for (StyleSheetHandle sheet : agentSheets) {
|
||||
nsIURI* uri = sheet->GetSheetURI();
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
RefPtr<CSSStyleSheet> newSheet;
|
||||
rv = document->LoadChromeSheetSync(uri, true,
|
||||
getter_AddRefs(newSheet));
|
||||
StyleSheetHandle::RefPtr newSheet;
|
||||
rv = document->LoadChromeSheetSync(uri, true, &newSheet);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (newSheet) {
|
||||
rv = newAgentSheets.AppendElement(newSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
@@ -446,27 +446,27 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
||||
int32_t count = document->GetNumberOfStyleSheets();
|
||||
|
||||
// Build an array of style sheets we need to reload.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> oldSheets(count);
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newSheets(count);
|
||||
nsTArray<StyleSheetHandle::RefPtr> oldSheets(count);
|
||||
nsTArray<StyleSheetHandle::RefPtr> newSheets(count);
|
||||
|
||||
// Iterate over the style sheets.
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
// Get the style sheet
|
||||
CSSStyleSheet* styleSheet = document->GetStyleSheetAt(i);
|
||||
StyleSheetHandle styleSheet = document->GetStyleSheetAt(i);
|
||||
oldSheets.AppendElement(styleSheet);
|
||||
}
|
||||
|
||||
// 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 (CSSStyleSheet* sheet : oldSheets) {
|
||||
for (StyleSheetHandle sheet : oldSheets) {
|
||||
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
|
||||
|
||||
if (uri && IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
RefPtr<CSSStyleSheet> newSheet;
|
||||
StyleSheetHandle::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));
|
||||
document->LoadChromeSheetSync(uri, false, &newSheet);
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendElement(newSheet);
|
||||
} else {
|
||||
|
||||
@@ -264,9 +264,9 @@ static uint32_t gValidateOrigin = 0xffffffff;
|
||||
#define NS_EVENT_STARVATION_DELAY_HINT 2000
|
||||
|
||||
#ifdef DEBUG
|
||||
static PRLogModuleInfo* gDocShellLog;
|
||||
static mozilla::LazyLogModule gDocShellLog("nsDocShell");
|
||||
#endif
|
||||
static PRLogModuleInfo* gDocShellLeakLog;
|
||||
static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak");;
|
||||
|
||||
const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties";
|
||||
const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties";
|
||||
@@ -816,17 +816,7 @@ nsDocShell::nsDocShell()
|
||||
CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!gDocShellLog) {
|
||||
gDocShellLog = PR_NewLogModule("nsDocShell");
|
||||
}
|
||||
#endif
|
||||
if (!gDocShellLeakLog) {
|
||||
gDocShellLeakLog = PR_NewLogModule("nsDocShellLeak");
|
||||
}
|
||||
if (gDocShellLeakLog) {
|
||||
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this));
|
||||
}
|
||||
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this));
|
||||
|
||||
#ifdef DEBUG
|
||||
// We're counting the number of |nsDocShells| to help find leaks
|
||||
@@ -885,8 +875,6 @@ nsDocShell::Init()
|
||||
NS_ASSERTION(mLoadGroup, "Something went wrong!");
|
||||
|
||||
mContentListener = new nsDSURIContentListener(this);
|
||||
NS_ENSURE_TRUE(mContentListener, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = mContentListener->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -894,7 +882,6 @@ nsDocShell::Init()
|
||||
// ref to us... use an InterfaceRequestorProxy to do this.
|
||||
nsCOMPtr<nsIInterfaceRequestor> proxy =
|
||||
new InterfaceRequestorProxy(static_cast<nsIInterfaceRequestor*>(this));
|
||||
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
|
||||
mLoadGroup->SetNotificationCallbacks(proxy);
|
||||
|
||||
rv = nsDocLoader::AddDocLoaderAsChildOfRoot(this);
|
||||
@@ -1661,7 +1648,6 @@ NS_IMETHODIMP
|
||||
nsDocShell::CreateLoadInfo(nsIDocShellLoadInfo** aLoadInfo)
|
||||
{
|
||||
nsDocShellLoadInfo* loadInfo = new nsDocShellLoadInfo();
|
||||
NS_ENSURE_TRUE(loadInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsCOMPtr<nsIDocShellLoadInfo> localRef(loadInfo);
|
||||
|
||||
localRef.forget(aLoadInfo);
|
||||
@@ -2619,10 +2605,6 @@ nsDocShell::GetDocShellEnumerator(int32_t aItemType, int32_t aDirection,
|
||||
docShellEnum = new nsDocShellBackwardsEnumerator;
|
||||
}
|
||||
|
||||
if (!docShellEnum) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = docShellEnum->SetEnumDocShellType(aItemType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
@@ -6553,7 +6535,6 @@ nsDocShell::RefreshURI(nsIURI* aURI,
|
||||
}
|
||||
|
||||
nsRefreshTimer* refreshTimer = new nsRefreshTimer();
|
||||
NS_ENSURE_TRUE(refreshTimer, NS_ERROR_OUT_OF_MEMORY);
|
||||
uint32_t busyFlags = 0;
|
||||
GetBusyFlags(&busyFlags);
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ private:
|
||||
void operator=(const AbstractTimelineMarker& aOther) = delete;
|
||||
|
||||
public:
|
||||
explicit AbstractTimelineMarker(const char* aName,
|
||||
MarkerTracingType aTracingType);
|
||||
AbstractTimelineMarker(const char* aName,
|
||||
MarkerTracingType aTracingType);
|
||||
|
||||
explicit AbstractTimelineMarker(const char* aName,
|
||||
const TimeStamp& aTime,
|
||||
MarkerTracingType aTracingType);
|
||||
AbstractTimelineMarker(const char* aName,
|
||||
const TimeStamp& aTime,
|
||||
MarkerTracingType aTracingType);
|
||||
|
||||
virtual ~AbstractTimelineMarker();
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ class MOZ_RAII AutoTimelineMarker
|
||||
RefPtr<nsIDocShell> mDocShell;
|
||||
|
||||
public:
|
||||
explicit AutoTimelineMarker(nsIDocShell* aDocShell, const char* aName
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
AutoTimelineMarker(nsIDocShell* aDocShell,
|
||||
const char* aName MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
~AutoTimelineMarker();
|
||||
|
||||
AutoTimelineMarker(const AutoTimelineMarker& aOther) = delete;
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace mozilla {
|
||||
class CompositeTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit CompositeTimelineMarker(const TimeStamp& aTime,
|
||||
MarkerTracingType aTracingType)
|
||||
CompositeTimelineMarker(const TimeStamp& aTime,
|
||||
MarkerTracingType aTracingType)
|
||||
: TimelineMarker("Composite", aTime, aTracingType)
|
||||
{
|
||||
// Even though these markers end up being created on the main thread in the
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace mozilla {
|
||||
class ConsoleTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit ConsoleTimelineMarker(const nsAString& aCause,
|
||||
MarkerTracingType aTracingType)
|
||||
ConsoleTimelineMarker(const nsAString& aCause,
|
||||
MarkerTracingType aTracingType)
|
||||
: TimelineMarker("ConsoleTime", aTracingType)
|
||||
, mCause(aCause)
|
||||
{
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace mozilla {
|
||||
class EventTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit EventTimelineMarker(const nsAString& aType,
|
||||
uint16_t aPhase,
|
||||
MarkerTracingType aTracingType)
|
||||
EventTimelineMarker(const nsAString& aType,
|
||||
uint16_t aPhase,
|
||||
MarkerTracingType aTracingType)
|
||||
: TimelineMarker("DOMEvent", aTracingType)
|
||||
, mType(aType)
|
||||
, mPhase(aPhase)
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace mozilla {
|
||||
class JavascriptTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit JavascriptTimelineMarker(const char* aReason,
|
||||
const char16_t* aFunctionName,
|
||||
const char16_t* aFileName,
|
||||
uint32_t aLineNumber,
|
||||
MarkerTracingType aTracingType,
|
||||
JS::Handle<JS::Value> aAsyncStack,
|
||||
JS::Handle<JS::Value> aAsyncCause)
|
||||
JavascriptTimelineMarker(const char* aReason,
|
||||
const char16_t* aFunctionName,
|
||||
const char16_t* aFileName,
|
||||
uint32_t aLineNumber,
|
||||
MarkerTracingType aTracingType,
|
||||
JS::Handle<JS::Value> aAsyncStack,
|
||||
JS::Handle<JS::Value> aAsyncCause)
|
||||
: TimelineMarker("Javascript", aTracingType, MarkerStackRequest::NO_STACK)
|
||||
, mCause(NS_ConvertUTF8toUTF16(aReason))
|
||||
, mFunctionName(aFunctionName)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/* -*- 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_MessagePortTimelineMarker_h_
|
||||
#define mozilla_MessagePortTimelineMarker_h_
|
||||
|
||||
#include "TimelineMarker.h"
|
||||
#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MessagePortTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
MessagePortTimelineMarker(dom::ProfileTimelineMessagePortOperationType aOperationType,
|
||||
MarkerTracingType aTracingType)
|
||||
: TimelineMarker("MessagePort", aTracingType, MarkerStackRequest::NO_STACK)
|
||||
, mOperationType(aOperationType)
|
||||
{}
|
||||
|
||||
virtual UniquePtr<AbstractTimelineMarker> Clone() override
|
||||
{
|
||||
MessagePortTimelineMarker* clone =
|
||||
new MessagePortTimelineMarker(mOperationType, GetTracingType());
|
||||
clone->SetCustomTime(GetTime());
|
||||
return UniquePtr<AbstractTimelineMarker>(clone);
|
||||
}
|
||||
|
||||
virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override
|
||||
{
|
||||
TimelineMarker::AddDetails(aCx, aMarker);
|
||||
|
||||
if (GetTracingType() == MarkerTracingType::START) {
|
||||
aMarker.mMessagePortOperation.Construct(mOperationType);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
dom::ProfileTimelineMessagePortOperationType mOperationType;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_MessagePortTimelineMarker_h_ */
|
||||
@@ -15,8 +15,8 @@ namespace mozilla {
|
||||
class RestyleTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit RestyleTimelineMarker(nsRestyleHint aRestyleHint,
|
||||
MarkerTracingType aTracingType)
|
||||
RestyleTimelineMarker(nsRestyleHint aRestyleHint,
|
||||
MarkerTracingType aTracingType)
|
||||
: TimelineMarker("Styles", aTracingType)
|
||||
{
|
||||
if (aRestyleHint) {
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace mozilla {
|
||||
class TimelineMarker : public AbstractTimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit TimelineMarker(const char* aName,
|
||||
MarkerTracingType aTracingType,
|
||||
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
|
||||
TimelineMarker(const char* aName,
|
||||
MarkerTracingType aTracingType,
|
||||
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
|
||||
|
||||
explicit TimelineMarker(const char* aName,
|
||||
const TimeStamp& aTime,
|
||||
MarkerTracingType aTracingType,
|
||||
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
|
||||
TimelineMarker(const char* aName,
|
||||
const TimeStamp& aTime,
|
||||
MarkerTracingType aTracingType,
|
||||
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
|
||||
|
||||
virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override;
|
||||
virtual JSObject* GetStack() override;
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace mozilla {
|
||||
class WorkerTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
explicit WorkerTimelineMarker(ProfileTimelineWorkerOperationType aOperationType,
|
||||
MarkerTracingType aTracingType)
|
||||
WorkerTimelineMarker(dom::ProfileTimelineWorkerOperationType aOperationType,
|
||||
MarkerTracingType aTracingType)
|
||||
: TimelineMarker("Worker", aTracingType, MarkerStackRequest::NO_STACK)
|
||||
, mOperationType(aOperationType)
|
||||
{}
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
ProfileTimelineWorkerOperationType mOperationType;
|
||||
dom::ProfileTimelineWorkerOperationType mOperationType;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -14,6 +14,7 @@ EXPORTS.mozilla += [
|
||||
'JavascriptTimelineMarker.h',
|
||||
'LayerTimelineMarker.h',
|
||||
'MarkersStorage.h',
|
||||
'MessagePortTimelineMarker.h',
|
||||
'ObservedDocShell.h',
|
||||
'RestyleTimelineMarker.h',
|
||||
'TimelineConsumers.h',
|
||||
|
||||
+31
-59
@@ -298,7 +298,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!mWorkerPrivate->AddFeature(cx, this))) {
|
||||
if (NS_WARN_IF(!mWorkerPrivate->AddFeature(this))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ private:
|
||||
mRunnable->ReleaseData();
|
||||
mRunnable->mConsole = nullptr;
|
||||
|
||||
aWorkerPrivate->RemoveFeature(aCx, mRunnable);
|
||||
aWorkerPrivate->RemoveFeature(mRunnable);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ private:
|
||||
|
||||
RefPtr<WorkerControlRunnable> runnable =
|
||||
new ConsoleReleaseRunnable(mWorkerPrivate, this);
|
||||
runnable->Dispatch(nullptr);
|
||||
runnable->Dispatch();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1033,64 +1033,58 @@ Console::NoopMethod()
|
||||
|
||||
static
|
||||
nsresult
|
||||
StackFrameToStackEntry(nsIStackFrame* aStackFrame,
|
||||
ConsoleStackEntry& aStackEntry,
|
||||
uint32_t aLanguage)
|
||||
StackFrameToStackEntry(JSContext* aCx, nsIStackFrame* aStackFrame,
|
||||
ConsoleStackEntry& aStackEntry)
|
||||
{
|
||||
MOZ_ASSERT(aStackFrame);
|
||||
|
||||
nsresult rv = aStackFrame->GetFilename(aStackEntry.mFilename);
|
||||
nsresult rv = aStackFrame->GetFilename(aCx, aStackEntry.mFilename);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
int32_t lineNumber;
|
||||
rv = aStackFrame->GetLineNumber(&lineNumber);
|
||||
rv = aStackFrame->GetLineNumber(aCx, &lineNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mLineNumber = lineNumber;
|
||||
|
||||
int32_t columnNumber;
|
||||
rv = aStackFrame->GetColumnNumber(&columnNumber);
|
||||
rv = aStackFrame->GetColumnNumber(aCx, &columnNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mColumnNumber = columnNumber;
|
||||
|
||||
rv = aStackFrame->GetName(aStackEntry.mFunctionName);
|
||||
rv = aStackFrame->GetName(aCx, aStackEntry.mFunctionName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsString cause;
|
||||
rv = aStackFrame->GetAsyncCause(cause);
|
||||
rv = aStackFrame->GetAsyncCause(aCx, cause);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!cause.IsEmpty()) {
|
||||
aStackEntry.mAsyncCause.Construct(cause);
|
||||
}
|
||||
|
||||
aStackEntry.mLanguage = aLanguage;
|
||||
aStackEntry.mLanguage = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static
|
||||
nsresult
|
||||
ReifyStack(nsIStackFrame* aStack, nsTArray<ConsoleStackEntry>& aRefiedStack)
|
||||
ReifyStack(JSContext* aCx, nsIStackFrame* aStack,
|
||||
nsTArray<ConsoleStackEntry>& aRefiedStack)
|
||||
{
|
||||
nsCOMPtr<nsIStackFrame> stack(aStack);
|
||||
|
||||
while (stack) {
|
||||
uint32_t language;
|
||||
nsresult rv = stack->GetLanguage(&language);
|
||||
ConsoleStackEntry& data = *aRefiedStack.AppendElement();
|
||||
nsresult rv = StackFrameToStackEntry(aCx, stack, data);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
|
||||
ConsoleStackEntry& data = *aRefiedStack.AppendElement();
|
||||
rv = StackFrameToStackEntry(stack, data, language);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> caller;
|
||||
rv = stack->GetCaller(getter_AddRefs(caller));
|
||||
rv = stack->GetCaller(aCx, getter_AddRefs(caller));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!caller) {
|
||||
rv = stack->GetAsyncCaller(getter_AddRefs(caller));
|
||||
rv = stack->GetAsyncCaller(aCx, getter_AddRefs(caller));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
stack.swap(caller);
|
||||
@@ -1129,46 +1123,22 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
|
||||
DEFAULT_MAX_STACKTRACE_DEPTH : 1;
|
||||
nsCOMPtr<nsIStackFrame> stack = CreateStack(aCx, maxDepth);
|
||||
|
||||
if (!stack) {
|
||||
return;
|
||||
if (stack) {
|
||||
callData->mTopStackFrame.emplace();
|
||||
nsresult rv = StackFrameToStackEntry(aCx, stack,
|
||||
*callData->mTopStackFrame);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Walk up to the first JS stack frame and save it if we find it.
|
||||
do {
|
||||
uint32_t language;
|
||||
nsresult rv = stack->GetLanguage(&language);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
|
||||
callData->mTopStackFrame.emplace();
|
||||
nsresult rv = StackFrameToStackEntry(stack,
|
||||
*callData->mTopStackFrame,
|
||||
language);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> caller;
|
||||
rv = stack->GetCaller(getter_AddRefs(caller));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
stack.swap(caller);
|
||||
} while (stack);
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
callData->mStack = stack;
|
||||
} else {
|
||||
// nsIStackFrame is not threadsafe, so we need to snapshot it now,
|
||||
// before we post our runnable to the main thread.
|
||||
callData->mReifiedStack.emplace();
|
||||
nsresult rv = ReifyStack(stack, *callData->mReifiedStack);
|
||||
nsresult rv = ReifyStack(aCx, stack, *callData->mReifiedStack);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
@@ -1301,7 +1271,7 @@ LazyStackGetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp)
|
||||
|
||||
nsIStackFrame* stack = reinterpret_cast<nsIStackFrame*>(v.toPrivate());
|
||||
nsTArray<ConsoleStackEntry> reifiedStack;
|
||||
nsresult rv = ReifyStack(stack, reifiedStack);
|
||||
nsresult rv = ReifyStack(aCx, stack, reifiedStack);
|
||||
if (NS_FAILED(rv)) {
|
||||
Throw(aCx, rv);
|
||||
return false;
|
||||
@@ -1333,12 +1303,14 @@ Console::ProcessCallData(ConsoleCallData* aData, JS::Handle<JSObject*> aGlobal,
|
||||
frame = *aData->mTopStackFrame;
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(aGlobal)) {
|
||||
return;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
ClearException ce(cx);
|
||||
RootedDictionary<ConsoleEvent> event(cx);
|
||||
|
||||
JSAutoCompartment ac(cx, aGlobal);
|
||||
|
||||
event.mID.Construct();
|
||||
event.mInnerID.Construct();
|
||||
|
||||
|
||||
+19
-50
@@ -216,37 +216,7 @@ Exception::Exception(const nsACString& aMessage,
|
||||
sEverMadeOneFromFactory = true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> location;
|
||||
if (aLocation) {
|
||||
location = aLocation;
|
||||
} else {
|
||||
location = GetCurrentJSStack();
|
||||
// it is legal for there to be no active JS stack, if C++ code
|
||||
// is operating on a JS-implemented interface pointer without
|
||||
// having been called in turn by JS. This happens in the JS
|
||||
// component loader, and will become more common as additional
|
||||
// components are implemented in JS.
|
||||
}
|
||||
// We want to trim off any leading native 'dataless' frames
|
||||
if (location) {
|
||||
while (1) {
|
||||
uint32_t language;
|
||||
int32_t lineNumber;
|
||||
if (NS_FAILED(location->GetLanguage(&language)) ||
|
||||
language == nsIProgrammingLanguage::JAVASCRIPT ||
|
||||
NS_FAILED(location->GetLineNumber(&lineNumber)) ||
|
||||
lineNumber) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIStackFrame> caller;
|
||||
if (NS_FAILED(location->GetCaller(getter_AddRefs(caller))) || !caller) {
|
||||
break;
|
||||
}
|
||||
location = caller;
|
||||
}
|
||||
}
|
||||
|
||||
Initialize(aMessage, aResult, aName, location, aData);
|
||||
Initialize(aMessage, aResult, aName, aLocation, aData);
|
||||
}
|
||||
|
||||
Exception::Exception()
|
||||
@@ -336,12 +306,12 @@ Exception::GetName(nsACString& aName)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Exception::GetFilename(nsAString& aFilename)
|
||||
Exception::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (mLocation) {
|
||||
return mLocation->GetFilename(aFilename);
|
||||
return mLocation->GetFilename(aCx, aFilename);
|
||||
}
|
||||
|
||||
aFilename.Assign(mFilename);
|
||||
@@ -349,14 +319,14 @@ Exception::GetFilename(nsAString& aFilename)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Exception::GetLineNumber(uint32_t *aLineNumber)
|
||||
Exception::GetLineNumber(JSContext* aCx, uint32_t *aLineNumber)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLineNumber);
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (mLocation) {
|
||||
int32_t lineno;
|
||||
nsresult rv = mLocation->GetLineNumber(&lineno);
|
||||
nsresult rv = mLocation->GetLineNumber(aCx, &lineno);
|
||||
*aLineNumber = lineno;
|
||||
return rv;
|
||||
}
|
||||
@@ -398,7 +368,7 @@ Exception::GetData(nsISupports** aData)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Exception::ToString(nsACString& _retval)
|
||||
Exception::ToString(JSContext* aCx, nsACString& _retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@@ -411,7 +381,7 @@ Exception::ToString(nsACString& _retval)
|
||||
|
||||
if (mLocation) {
|
||||
// we need to free this if it does not fail
|
||||
nsresult rv = mLocation->ToString(location);
|
||||
nsresult rv = mLocation->ToString(aCx, location);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@@ -452,12 +422,11 @@ Exception::Initialize(const nsACString& aMessage, nsresult aResult,
|
||||
if (aLocation) {
|
||||
mLocation = aLocation;
|
||||
} else {
|
||||
nsresult rv;
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
rv = xpc->GetCurrentJSStack(getter_AddRefs(mLocation));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mLocation = GetCurrentJSStack();
|
||||
// it is legal for there to be no active JS stack, if C++ code
|
||||
// is operating on a JS-implemented interface pointer without
|
||||
// having been called in turn by JS. This happens in the JS
|
||||
// component loader.
|
||||
}
|
||||
|
||||
mData = aData;
|
||||
@@ -503,11 +472,11 @@ Exception::GetName(nsString& retval)
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Exception::LineNumber() const
|
||||
Exception::LineNumber(JSContext* aCx) const
|
||||
{
|
||||
if (mLocation) {
|
||||
int32_t lineno;
|
||||
if (NS_SUCCEEDED(mLocation->GetLineNumber(&lineno))) {
|
||||
if (NS_SUCCEEDED(mLocation->GetLineNumber(aCx, &lineno))) {
|
||||
return lineno;
|
||||
}
|
||||
return 0;
|
||||
@@ -537,21 +506,21 @@ Exception::GetData() const
|
||||
}
|
||||
|
||||
void
|
||||
Exception::GetStack(nsAString& aStack, ErrorResult& aRv) const
|
||||
Exception::GetStack(JSContext* aCx, nsAString& aStack, ErrorResult& aRv) const
|
||||
{
|
||||
if (mLocation) {
|
||||
aRv = mLocation->GetFormattedStack(aStack);
|
||||
aRv = mLocation->GetFormattedStack(aCx, aStack);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Exception::Stringify(nsString& retval)
|
||||
Exception::Stringify(JSContext* aCx, nsString& retval)
|
||||
{
|
||||
nsCString str;
|
||||
#ifdef DEBUG
|
||||
DebugOnly<nsresult> rv =
|
||||
#endif
|
||||
ToString(str);
|
||||
ToString(aCx, str);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
CopyUTF8toUTF16(str, retval);
|
||||
}
|
||||
@@ -590,7 +559,7 @@ DOMException::GetCode(uint16_t* aCode)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMException::ToString(nsACString& aReturn)
|
||||
DOMException::ToString(JSContext* aCx, nsACString& aReturn)
|
||||
{
|
||||
aReturn.Truncate();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
// The XPCOM GetFilename does the right thing. It might throw, but we want to
|
||||
// return an empty filename in that case anyway, instead of throwing.
|
||||
|
||||
uint32_t LineNumber() const;
|
||||
uint32_t LineNumber(JSContext* aCx) const;
|
||||
|
||||
uint32_t ColumnNumber() const;
|
||||
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
|
||||
already_AddRefed<nsISupports> GetData() const;
|
||||
|
||||
void GetStack(nsAString& aStack, ErrorResult& aRv) const;
|
||||
void GetStack(JSContext* aCx, nsAString& aStack, ErrorResult& aRv) const;
|
||||
|
||||
void Stringify(nsString& retval);
|
||||
void Stringify(JSContext* aCx, nsString& retval);
|
||||
|
||||
// XPCOM factory ctor.
|
||||
Exception();
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
NS_DECL_NSIDOMDOMEXCEPTION
|
||||
|
||||
// nsIException overrides
|
||||
NS_IMETHOD ToString(nsACString& aReturn) override;
|
||||
NS_IMETHOD ToString(JSContext* aCx, nsACString& aReturn) override;
|
||||
|
||||
// nsWrapperCache overrides
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
|
||||
@@ -701,7 +701,7 @@ nsresult
|
||||
FileReader::IncreaseBusyCounter()
|
||||
{
|
||||
if (mWorkerPrivate && mBusyCount++ == 0 &&
|
||||
!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), this)) {
|
||||
!mWorkerPrivate->AddFeature(this)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ FileReader::DecreaseBusyCounter()
|
||||
{
|
||||
MOZ_ASSERT_IF(mWorkerPrivate, mBusyCount);
|
||||
if (mWorkerPrivate && --mBusyCount == 0) {
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
|
||||
mWorkerPrivate->RemoveFeature(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,7 +742,7 @@ FileReader::Shutdown()
|
||||
}
|
||||
|
||||
if (mWorkerPrivate && mBusyCount != 0) {
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
|
||||
mWorkerPrivate->RemoveFeature(this);
|
||||
mWorkerPrivate = nullptr;
|
||||
mBusyCount = 0;
|
||||
}
|
||||
|
||||
+44
-33
@@ -347,9 +347,10 @@ AutoJSAPI::InitInternal(JSObject* aGlobal, JSContext* aCx, bool aIsMainThread)
|
||||
mAutoNullableCompartment.emplace(mCx, aGlobal);
|
||||
}
|
||||
|
||||
JSRuntime* rt = JS_GetRuntime(aCx);
|
||||
mOldErrorReporter.emplace(JS_GetErrorReporter(rt));
|
||||
|
||||
if (aIsMainThread) {
|
||||
JSRuntime* rt = JS_GetRuntime(aCx);
|
||||
mOldErrorReporter.emplace(JS_GetErrorReporter(rt));
|
||||
JS_SetErrorReporter(rt, xpc::SystemErrorReporter);
|
||||
}
|
||||
}
|
||||
@@ -410,14 +411,6 @@ AutoJSAPI::Init(JSObject* aObject)
|
||||
return Init(xpc::NativeGlobal(aObject));
|
||||
}
|
||||
|
||||
bool
|
||||
AutoJSAPI::InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
return Init(aGlobalObject, FindJSContext(aGlobalObject));
|
||||
}
|
||||
|
||||
bool
|
||||
AutoJSAPI::Init(nsPIDOMWindow* aWindow, JSContext* aCx)
|
||||
{
|
||||
@@ -442,18 +435,6 @@ AutoJSAPI::Init(nsGlobalWindow* aWindow)
|
||||
return Init(static_cast<nsIGlobalObject*>(aWindow));
|
||||
}
|
||||
|
||||
bool
|
||||
AutoJSAPI::InitWithLegacyErrorReporting(nsPIDOMWindow* aWindow)
|
||||
{
|
||||
return InitWithLegacyErrorReporting(static_cast<nsGlobalWindow*>(aWindow));
|
||||
}
|
||||
|
||||
bool
|
||||
AutoJSAPI::InitWithLegacyErrorReporting(nsGlobalWindow* aWindow)
|
||||
{
|
||||
return InitWithLegacyErrorReporting(static_cast<nsIGlobalObject*>(aWindow));
|
||||
}
|
||||
|
||||
// Even with autoJSAPIOwnsErrorReporting, the JS engine still sends warning
|
||||
// reports to the JSErrorReporter as soon as they are generated. These go
|
||||
// directly to the console, so we can handle them easily here.
|
||||
@@ -463,11 +444,30 @@ AutoJSAPI::InitWithLegacyErrorReporting(nsGlobalWindow* aWindow)
|
||||
void
|
||||
WarningOnlyErrorReporter(JSContext* aCx, const char* aMessage, JSErrorReport* aRep)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(JSREPORT_IS_WARNING(aRep->flags));
|
||||
if (!NS_IsMainThread()) {
|
||||
// Reporting a warning on workers is a bit complicated because we have to
|
||||
// climb our parent chain until we get to the main thread. So go ahead and
|
||||
// just go through the worker ReportError codepath here.
|
||||
//
|
||||
// That said, it feels like we should be able to short-circuit things a bit
|
||||
// here by posting an appropriate runnable to the main thread directly...
|
||||
// Worth looking into sometime.
|
||||
workers::WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx);
|
||||
MOZ_ASSERT(worker);
|
||||
|
||||
worker->ReportError(aCx, aMessage, aRep);
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
nsPIDOMWindow* win = xpc::CurrentWindowOrNull(aCx);
|
||||
nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
|
||||
if (!win) {
|
||||
// We run addons in a separate privileged compartment, but if we're in an
|
||||
// addon compartment we should log warnings to the console of the associated
|
||||
// DOM Window.
|
||||
win = xpc::AddonWindowOrNull(JS::CurrentGlobalOrNull(aCx));
|
||||
}
|
||||
xpcReport->Init(aRep, aMessage, nsContentUtils::IsCallerChrome(),
|
||||
win ? win->WindowID() : 0);
|
||||
xpcReport->LogToConsole();
|
||||
@@ -482,13 +482,7 @@ AutoJSAPI::TakeOwnershipOfErrorReporting()
|
||||
JSRuntime *rt = JS_GetRuntime(cx());
|
||||
mOldAutoJSAPIOwnsErrorReporting = JS::ContextOptionsRef(cx()).autoJSAPIOwnsErrorReporting();
|
||||
JS::ContextOptionsRef(cx()).setAutoJSAPIOwnsErrorReporting(true);
|
||||
// Workers have their own error reporting mechanism which deals with warnings
|
||||
// as well, so don't change the worker error reporter for now. Once we switch
|
||||
// all of workers to TakeOwnershipOfErrorReporting(), we will just make the
|
||||
// default worker error reporter assert that it only sees warnings.
|
||||
if (mIsMainThread) {
|
||||
JS_SetErrorReporter(rt, WarningOnlyErrorReporter);
|
||||
}
|
||||
JS_SetErrorReporter(rt, WarningOnlyErrorReporter);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -518,14 +512,22 @@ AutoJSAPI::ReportException()
|
||||
if (StealException(&exn) && jsReport.init(cx(), exn)) {
|
||||
if (mIsMainThread) {
|
||||
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win = xpc::WindowGlobalOrNull(errorGlobal);
|
||||
if (!win) {
|
||||
// We run addons in a separate privileged compartment, but they still
|
||||
// expect to trigger the onerror handler of their associated DOM Window.
|
||||
win = xpc::AddonWindowOrNull(errorGlobal);
|
||||
}
|
||||
xpcReport->Init(jsReport.report(), jsReport.message(),
|
||||
nsContentUtils::IsCallerChrome(),
|
||||
win ? win->WindowID() : 0);
|
||||
if (win) {
|
||||
if (win && jsReport.report()->errorNumber != JSMSG_OUT_OF_MEMORY) {
|
||||
DispatchScriptErrorEvent(win, JS_GetRuntime(cx()), xpcReport, exn);
|
||||
} else {
|
||||
xpcReport->LogToConsole();
|
||||
JS::Rooted<JSObject*> stack(cx(),
|
||||
xpc::FindExceptionStackForConsoleReport(win, exn));
|
||||
xpcReport->LogToConsoleWithStack(stack);
|
||||
}
|
||||
} else {
|
||||
// On a worker, we just use the worker error reporting mechanism and don't
|
||||
@@ -545,6 +547,7 @@ AutoJSAPI::ReportException()
|
||||
}
|
||||
} else {
|
||||
NS_WARNING("OOMed while acquiring uncaught exception from JSAPI");
|
||||
ClearException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,6 +591,14 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
}
|
||||
}
|
||||
|
||||
AutoEntryScript::AutoEntryScript(JSObject* aObject,
|
||||
const char *aReason,
|
||||
bool aIsMainThread,
|
||||
JSContext* aCx)
|
||||
: AutoEntryScript(xpc::NativeGlobal(aObject), aReason, aIsMainThread, aCx)
|
||||
{
|
||||
}
|
||||
|
||||
AutoEntryScript::~AutoEntryScript()
|
||||
{
|
||||
// GC when we pop a script entry point. This is a useful heuristic that helps
|
||||
|
||||
+18
-13
@@ -221,12 +221,20 @@ public:
|
||||
// This uses the SafeJSContext (or worker equivalent), and enters a null
|
||||
// compartment, so that the consumer is forced to select a compartment to
|
||||
// enter before manipulating objects.
|
||||
//
|
||||
// This variant will ensure that any errors reported by this AutoJSAPI as it
|
||||
// comes off the stack will not fire error events or be associated with any
|
||||
// particular web-visible global.
|
||||
void Init();
|
||||
|
||||
// This uses the SafeJSContext (or worker equivalent), and enters the
|
||||
// compartment of aGlobalObject.
|
||||
// If aGlobalObject or its associated JS global are null then it returns
|
||||
// false and use of cx() will cause an assertion.
|
||||
//
|
||||
// If aGlobalObject represents a web-visible global, errors reported by this
|
||||
// AutoJSAPI as it comes off the stack will fire the relevant error events and
|
||||
// show up in the corresponding web console.
|
||||
bool Init(nsIGlobalObject* aGlobalObject);
|
||||
|
||||
// This is a helper that grabs the native global associated with aObject and
|
||||
@@ -237,18 +245,12 @@ public:
|
||||
// If aGlobalObject or its associated JS global are null then it returns
|
||||
// false and use of cx() will cause an assertion.
|
||||
// If aCx is null it will cause an assertion.
|
||||
//
|
||||
// If aGlobalObject represents a web-visible global, errors reported by this
|
||||
// AutoJSAPI as it comes off the stack will fire the relevant error events and
|
||||
// show up in the corresponding web console.
|
||||
bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx);
|
||||
|
||||
// This may only be used on the main thread.
|
||||
// This attempts to use the JSContext associated with aGlobalObject, otherwise
|
||||
// it uses the SafeJSContext. It then enters the compartment of aGlobalObject.
|
||||
// This means that existing error reporting mechanisms that use the JSContext
|
||||
// to find the JSErrorReporter should still work as before.
|
||||
// We should be able to remove this around bug 981198.
|
||||
// If aGlobalObject or its associated JS global are null then it returns
|
||||
// false and use of cx() will cause an assertion.
|
||||
bool InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject);
|
||||
|
||||
// Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*,
|
||||
// when it is more easily available than an nsIGlobalObject.
|
||||
bool Init(nsPIDOMWindow* aWindow);
|
||||
@@ -257,9 +259,6 @@ public:
|
||||
bool Init(nsGlobalWindow* aWindow);
|
||||
bool Init(nsGlobalWindow* aWindow, JSContext* aCx);
|
||||
|
||||
bool InitWithLegacyErrorReporting(nsPIDOMWindow* aWindow);
|
||||
bool InitWithLegacyErrorReporting(nsGlobalWindow* aWindow);
|
||||
|
||||
JSContext* cx() const {
|
||||
MOZ_ASSERT(mCx, "Must call Init before using an AutoJSAPI");
|
||||
MOZ_ASSERT_IF(mIsMainThread, CxPusherIsStackTop());
|
||||
@@ -346,6 +345,12 @@ public:
|
||||
// Note: aCx is mandatory off-main-thread.
|
||||
JSContext* aCx = nullptr);
|
||||
|
||||
AutoEntryScript(JSObject* aObject, // Any object from the relevant global
|
||||
const char *aReason,
|
||||
bool aIsMainThread = NS_IsMainThread(),
|
||||
// Note: aCx is mandatory off-main-thread.
|
||||
JSContext* aCx = nullptr);
|
||||
|
||||
~AutoEntryScript();
|
||||
|
||||
void SetWebIDLCallerPrincipal(nsIPrincipal *aPrincipal) {
|
||||
|
||||
+14
-5
@@ -17,6 +17,8 @@
|
||||
#include "mozilla/dom/HTMLContentElement.h"
|
||||
#include "mozilla/dom/HTMLShadowElement.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@@ -130,7 +132,7 @@ ShadowRoot::StyleSheetChanged()
|
||||
}
|
||||
|
||||
void
|
||||
ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
|
||||
ShadowRoot::InsertSheet(StyleSheetHandle aSheet,
|
||||
nsIContent* aLinkingContent)
|
||||
{
|
||||
nsCOMPtr<nsIStyleSheetLinkingElement>
|
||||
@@ -148,8 +150,8 @@ ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
|
||||
break;
|
||||
}
|
||||
|
||||
nsINode* sheetOwnerNode = mProtoBinding->StyleSheetAt(i)->GetOwnerNode();
|
||||
if (nsContentUtils::PositionIsBefore(aLinkingContent, sheetOwnerNode)) {
|
||||
nsINode* sheetOwningNode = mProtoBinding->StyleSheetAt(i)->GetOwnerNode();
|
||||
if (nsContentUtils::PositionIsBefore(aLinkingContent, sheetOwningNode)) {
|
||||
mProtoBinding->InsertStyleSheetAt(i, aSheet);
|
||||
break;
|
||||
}
|
||||
@@ -161,7 +163,7 @@ ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
|
||||
}
|
||||
|
||||
void
|
||||
ShadowRoot::RemoveSheet(CSSStyleSheet* aSheet)
|
||||
ShadowRoot::RemoveSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
mProtoBinding->RemoveStyleSheet(aSheet);
|
||||
|
||||
@@ -752,7 +754,14 @@ ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
|
||||
// XXXheycam Return null until ServoStyleSheet implements the right
|
||||
// DOM interfaces.
|
||||
StyleSheetHandle sheet = mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't return ServoStyleSheets to script yet");
|
||||
return nullptr;
|
||||
}
|
||||
return sheet->AsGecko();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsTHashtable.h"
|
||||
@@ -45,8 +46,8 @@ public:
|
||||
|
||||
void AddToIdTable(Element* aElement, nsIAtom* aId);
|
||||
void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
|
||||
void InsertSheet(CSSStyleSheet* aSheet, nsIContent* aLinkingContent);
|
||||
void RemoveSheet(CSSStyleSheet* aSheet);
|
||||
void InsertSheet(StyleSheetHandle aSheet, nsIContent* aLinkingContent);
|
||||
void RemoveSheet(StyleSheetHandle aSheet);
|
||||
bool ApplyAuthorStyles();
|
||||
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
|
||||
StyleSheetList* StyleSheets();
|
||||
|
||||
@@ -295,6 +295,7 @@ StructuredCloneHolder::Read(nsISupports* aParent,
|
||||
{
|
||||
MOZ_ASSERT_IF(mSupportedContext == SameProcessSameThread,
|
||||
mCreationThread == NS_GetCurrentThread());
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
mozilla::AutoRestore<nsISupports*> guard(mParent);
|
||||
mParent = aParent;
|
||||
@@ -1044,9 +1045,11 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
|
||||
MOZ_ASSERT(aExtraData < mPortIdentifiers.Length());
|
||||
const MessagePortIdentifier& portIdentifier = mPortIdentifiers[aExtraData];
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mParent);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<MessagePort> port =
|
||||
MessagePort::Create(mParent, portIdentifier, rv);
|
||||
MessagePort::Create(global, portIdentifier, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+20
-22
@@ -1258,7 +1258,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
|
||||
}
|
||||
|
||||
unsigned lineno, column;
|
||||
JS::UniqueChars file;
|
||||
JS::AutoFilename file;
|
||||
if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno,
|
||||
&column)) {
|
||||
NS_WARNING("Failed to get line number and filename in workers.");
|
||||
@@ -1493,7 +1493,7 @@ WebSocketImpl::Init(JSContext* aCx,
|
||||
MOZ_ASSERT(aCx);
|
||||
|
||||
unsigned lineno, column;
|
||||
JS::UniqueChars file;
|
||||
JS::AutoFilename file;
|
||||
if (JS::DescribeScriptedCaller(aCx, &file, &lineno, &column)) {
|
||||
mScriptFile = file.get();
|
||||
mScriptLine = lineno;
|
||||
@@ -2148,8 +2148,7 @@ WebSocketImpl::RegisterFeature()
|
||||
MOZ_ASSERT(!mWorkerFeature);
|
||||
mWorkerFeature = new WebSocketWorkerFeature(this);
|
||||
|
||||
JSContext* cx = GetCurrentThreadJSContext();
|
||||
if (!mWorkerPrivate->AddFeature(cx, mWorkerFeature)) {
|
||||
if (!mWorkerPrivate->AddFeature(mWorkerFeature)) {
|
||||
NS_WARNING("Failed to register a feature.");
|
||||
mWorkerFeature = nullptr;
|
||||
return false;
|
||||
@@ -2170,8 +2169,7 @@ WebSocketImpl::UnregisterFeature()
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
MOZ_ASSERT(mWorkerFeature);
|
||||
|
||||
JSContext* cx = GetCurrentThreadJSContext();
|
||||
mWorkerPrivate->RemoveFeature(cx, mWorkerFeature);
|
||||
mWorkerPrivate->RemoveFeature(mWorkerFeature);
|
||||
mWorkerFeature = nullptr;
|
||||
mWorkerPrivate = nullptr;
|
||||
|
||||
@@ -2525,20 +2523,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(aCx, true);
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(true);
|
||||
return !NS_FAILED(mImpl->CancelInternal());
|
||||
}
|
||||
|
||||
void PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aRunResult)
|
||||
void PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
bool aRunResult) override
|
||||
{
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false);
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(false);
|
||||
}
|
||||
|
||||
bool
|
||||
PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
PreDispatch(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
// We don't call WorkerRunnable::PreDispatch because it would assert the
|
||||
// wrong thing about which thread we're on.
|
||||
@@ -2547,8 +2546,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
bool aDispatchResult)
|
||||
PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
|
||||
{
|
||||
// We don't call WorkerRunnable::PostDispatch because it would assert the
|
||||
// wrong thing about which thread we're on.
|
||||
@@ -2571,7 +2569,7 @@ WebSocketImpl::Cancel(nsresult aStatus)
|
||||
MOZ_ASSERT(mWorkerPrivate);
|
||||
RefPtr<CancelRunnable> runnable =
|
||||
new CancelRunnable(mWorkerPrivate, this);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -2695,10 +2693,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(aCx, true);
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(true);
|
||||
|
||||
// No messages when disconnected.
|
||||
if (mWebSocketImpl->mDisconnectingOrDisconnected) {
|
||||
@@ -2709,13 +2707,14 @@ public:
|
||||
return !NS_FAILED(mEvent->Run());
|
||||
}
|
||||
|
||||
void PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aRunResult)
|
||||
void PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
bool aRunResult) override
|
||||
{
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false);
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(false);
|
||||
}
|
||||
|
||||
bool
|
||||
PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
PreDispatch(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
// We don't call WorkerRunnable::PreDispatch because it would assert the
|
||||
// wrong thing about which thread we're on. We're on whichever thread the
|
||||
@@ -2725,8 +2724,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
bool aDispatchResult)
|
||||
PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
|
||||
{
|
||||
// We don't call WorkerRunnable::PreDispatch because it would assert the
|
||||
// wrong thing about which thread we're on. We're on whichever thread the
|
||||
@@ -2772,7 +2770,7 @@ WebSocketImpl::Dispatch(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags)
|
||||
RefPtr<WorkerRunnableDispatcher> event =
|
||||
new WorkerRunnableDispatcher(this, mWorkerPrivate, event_ref.forget());
|
||||
|
||||
if (!event->Dispatch(nullptr)) {
|
||||
if (!event->Dispatch()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ EXPORTS += [
|
||||
'nsIDocumentInlines.h',
|
||||
'nsIDocumentObserver.h',
|
||||
'nsIDOMClassInfo.h',
|
||||
'nsIDOMScriptObjectFactory.h',
|
||||
'nsIGlobalObject.h',
|
||||
'nsImageLoadingContent.h',
|
||||
'nsIMutationObserver.h',
|
||||
@@ -276,7 +275,6 @@ UNIFIED_SOURCES += [
|
||||
'nsDOMClassInfo.cpp',
|
||||
'nsDOMMutationObserver.cpp',
|
||||
'nsDOMNavigationTiming.cpp',
|
||||
'nsDOMScriptObjectFactory.cpp',
|
||||
'nsDOMSerializer.cpp',
|
||||
'nsDOMTokenList.cpp',
|
||||
'nsDOMWindowList.cpp',
|
||||
|
||||
@@ -213,7 +213,7 @@ nsContentSink::Init(nsIDocument* aDoc,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
nsContentSink::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ class nsContentSink : public nsICSSLoaderObserver,
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIDOMWindowUtils.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
#include "nsIDragService.h"
|
||||
|
||||
+36
-319
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsICategoryManager.h"
|
||||
@@ -117,8 +118,6 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
// NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
|
||||
// are defined in nsIDOMClassInfo.h.
|
||||
|
||||
@@ -149,7 +148,7 @@ static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
_chromeOnly, _allowXBL) \
|
||||
{ #_class, \
|
||||
nullptr, \
|
||||
{ _helper::doCreate }, \
|
||||
_helper::doCreate, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
nullptr, \
|
||||
@@ -335,9 +334,13 @@ nsDOMClassInfo::GetNative(nsIXPConnectWrappedNative *wrapper, JSObject *obj)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
|
||||
nsDOMClassInfo::DefineStaticJSVals()
|
||||
{
|
||||
#define SET_JSID_TO_STRING(_id, _cx, _str) \
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init(xpc::UnprivilegedJunkScope());
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
#define SET_JSID_TO_STRING(_id, _cx, _str) \
|
||||
if (JSString *str = ::JS_AtomizeAndPinString(_cx, _str)) \
|
||||
_id = INTERNED_STRING_TO_JSID(_cx, str); \
|
||||
else \
|
||||
@@ -361,15 +364,6 @@ nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
|
||||
{
|
||||
}
|
||||
|
||||
nsDOMClassInfo::~nsDOMClassInfo()
|
||||
{
|
||||
if (IS_EXTERNAL(mData->mCachedClassInfo)) {
|
||||
// Some compilers don't like delete'ing a const nsDOMClassInfo*
|
||||
nsDOMClassInfoData* data = const_cast<nsDOMClassInfoData*>(mData);
|
||||
delete static_cast<nsExternalDOMClassInfoData*>(data);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMClassInfo)
|
||||
NS_IMPL_RELEASE(nsDOMClassInfo)
|
||||
|
||||
@@ -457,58 +451,6 @@ nsDOMClassInfo::RegisterClassProtos(int32_t aClassInfoID)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsDOMClassInfo::RegisterExternalClasses()
|
||||
{
|
||||
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
|
||||
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsCOMPtr<nsIComponentRegistrar> registrar;
|
||||
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString contractId;
|
||||
nsAutoCString categoryEntry;
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
|
||||
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
|
||||
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
|
||||
|
||||
if (!category) {
|
||||
NS_WARNING("Category entry not an nsISupportsCString!");
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = category->GetData(categoryEntry);
|
||||
|
||||
cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(),
|
||||
getter_Copies(contractId));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCID *cid;
|
||||
rv = registrar->ContractIDToCID(contractId, &cid);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Bad contract id registered with the script namespace manager");
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid);
|
||||
free(cid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return nameSpaceManager->RegisterExternalInterfaces(true);
|
||||
}
|
||||
|
||||
#define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if) \
|
||||
{ \
|
||||
nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
|
||||
@@ -571,8 +513,6 @@ nsDOMClassInfo::Init()
|
||||
nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
|
||||
sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener), elt);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@@ -719,7 +659,7 @@ nsDOMClassInfo::Init()
|
||||
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
|
||||
if (!sClassInfoData[i].u.mConstructorFptr ||
|
||||
if (!sClassInfoData[i].mConstructorFptr ||
|
||||
sClassInfoData[i].mDebugID != i) {
|
||||
MOZ_CRASH("Class info data out of sync, you forgot to update "
|
||||
"nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
|
||||
@@ -736,7 +676,7 @@ nsDOMClassInfo::Init()
|
||||
#endif
|
||||
|
||||
// Initialize static JSString's
|
||||
DefineStaticJSVals(cx);
|
||||
DefineStaticJSVals();
|
||||
|
||||
int32_t i;
|
||||
|
||||
@@ -754,8 +694,6 @@ nsDOMClassInfo::Init()
|
||||
RegisterClassProtos(i);
|
||||
}
|
||||
|
||||
RegisterExternalClasses();
|
||||
|
||||
sIsInitialized = true;
|
||||
|
||||
return NS_OK;
|
||||
@@ -987,41 +925,6 @@ nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
|
||||
const nsAString &aName,
|
||||
const nsGlobalNameStruct *aStruct,
|
||||
const nsGlobalNameStruct **aResult)
|
||||
{
|
||||
NS_ASSERTION(aStruct->mType ==
|
||||
nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
||||
"Wrong type!");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->mCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
||||
NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
|
||||
|
||||
rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), sof);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
const nsGlobalNameStruct *name_struct = aNameSpaceManager->LookupName(aName);
|
||||
if (name_struct &&
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
*aResult = name_struct;
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Couldn't get the DOM ClassInfo data.");
|
||||
|
||||
*aResult = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static nsresult
|
||||
ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||
JS::Handle<JSObject*> obj, const char16_t *name,
|
||||
@@ -1155,48 +1058,20 @@ NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
|
||||
if (!sClassInfoData[aID].mCachedClassInfo) {
|
||||
nsDOMClassInfoData& data = sClassInfoData[aID];
|
||||
|
||||
data.mCachedClassInfo = data.u.mConstructorFptr(&data);
|
||||
data.mCachedClassInfo = data.mConstructorFptr(&data);
|
||||
NS_ENSURE_TRUE(data.mCachedClassInfo, nullptr);
|
||||
|
||||
NS_ADDREF(data.mCachedClassInfo);
|
||||
}
|
||||
|
||||
NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
|
||||
"This is bad, internal class marked as external!");
|
||||
|
||||
return sClassInfoData[aID].mCachedClassInfo;
|
||||
}
|
||||
|
||||
// static
|
||||
nsIClassInfo *
|
||||
nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
|
||||
{
|
||||
NS_ASSERTION(IS_EXTERNAL(aData->mCachedClassInfo)
|
||||
|| !aData->mCachedClassInfo,
|
||||
"This is bad, external class marked as internal!");
|
||||
|
||||
if (!aData->mCachedClassInfo) {
|
||||
if (aData->u.mExternalConstructorFptr) {
|
||||
aData->mCachedClassInfo =
|
||||
aData->u.mExternalConstructorFptr(aData->mName);
|
||||
} else {
|
||||
aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
|
||||
}
|
||||
NS_ENSURE_TRUE(aData->mCachedClassInfo, nullptr);
|
||||
|
||||
NS_ADDREF(aData->mCachedClassInfo);
|
||||
aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
|
||||
}
|
||||
|
||||
return GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
void
|
||||
nsDOMClassInfo::ShutDown()
|
||||
{
|
||||
if (sClassInfoData[0].u.mConstructorFptr) {
|
||||
if (sClassInfoData[0].mConstructorFptr) {
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < eDOMClassInfoIDCount; i++) {
|
||||
@@ -1223,12 +1098,10 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
||||
nsCOMPtr<nsISupports> native;
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
native = do_CreateInstance(name_struct->mCID, &rv);
|
||||
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||
native = do_CreateInstance(name_struct->mAlias->mCID, &rv);
|
||||
} else {
|
||||
native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
|
||||
MOZ_ASSERT(name_struct->mType ==
|
||||
nsGlobalNameStruct::eTypeExternalConstructor);
|
||||
native = do_CreateInstance(name_struct->mCID, &rv);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Failed to create the object");
|
||||
@@ -1300,7 +1173,6 @@ protected:
|
||||
public:
|
||||
|
||||
static nsresult Create(const char16_t* aName,
|
||||
const nsDOMClassInfoData* aData,
|
||||
const nsGlobalNameStruct* aNameStruct,
|
||||
nsPIDOMWindow* aOwner,
|
||||
nsDOMConstructor** aResult);
|
||||
@@ -1356,25 +1228,9 @@ private:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool IsConstructable(const nsDOMClassInfoData *aData)
|
||||
{
|
||||
if (IS_EXTERNAL(aData->mCachedClassInfo)) {
|
||||
const nsExternalDOMClassInfoData* data =
|
||||
static_cast<const nsExternalDOMClassInfoData*>(aData);
|
||||
return data->mConstructorCID != nullptr;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static bool IsConstructable(const nsGlobalNameStruct *aNameStruct)
|
||||
{
|
||||
return
|
||||
(aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
||||
IsConstructable(&sClassInfoData[aNameStruct->mDOMClassInfoID])) ||
|
||||
(aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
|
||||
IsConstructable(aNameStruct->mData)) ||
|
||||
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor ||
|
||||
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias;
|
||||
return aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor;
|
||||
}
|
||||
|
||||
const char16_t* mClassName;
|
||||
@@ -1385,7 +1241,6 @@ private:
|
||||
//static
|
||||
nsresult
|
||||
nsDOMConstructor::Create(const char16_t* aName,
|
||||
const nsDOMClassInfoData* aData,
|
||||
const nsGlobalNameStruct* aNameStruct,
|
||||
nsPIDOMWindow* aOwner,
|
||||
nsDOMConstructor** aResult)
|
||||
@@ -1406,9 +1261,7 @@ nsDOMConstructor::Create(const char16_t* aName,
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
bool constructable = aNameStruct ?
|
||||
IsConstructable(aNameStruct) :
|
||||
IsConstructable(aData);
|
||||
bool constructable = aNameStruct && IsConstructable(aNameStruct);
|
||||
|
||||
*aResult = new nsDOMConstructor(aName, constructable, currentInner);
|
||||
NS_ADDREF(*aResult);
|
||||
@@ -1540,9 +1393,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo &&
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||
if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
// Doesn't have DOM interfaces.
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1556,59 +1407,27 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
|
||||
NS_ASSERTION(nameSpaceManager, "Can't get namespace manager?");
|
||||
|
||||
const nsIID *class_iid;
|
||||
if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
|
||||
class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
||||
if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
||||
class_iid = &class_name_struct->mIID;
|
||||
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
class_iid =
|
||||
sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
|
||||
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
class_iid = class_name_struct->mData->mProtoChainInterface;
|
||||
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||
const nsGlobalNameStruct* alias_struct =
|
||||
nameSpaceManager->GetConstructorProto(class_name_struct);
|
||||
if (!alias_struct) {
|
||||
NS_ERROR("Couldn't get constructor prototype.");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
class_iid =
|
||||
sClassInfoData[alias_struct->mDOMClassInfoID].mProtoChainInterface;
|
||||
} else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
class_iid = alias_struct->mData->mProtoChainInterface;
|
||||
} else {
|
||||
NS_ERROR("Expected eTypeClassConstructor or eTypeExternalClassInfo.");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
} else {
|
||||
*bp = false;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||
name_struct = nameSpaceManager->GetConstructorProto(name_struct);
|
||||
if (!name_struct) {
|
||||
NS_ERROR("Couldn't get constructor prototype.");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
|
||||
NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor,
|
||||
"The constructor was set up with a struct of the wrong type.");
|
||||
|
||||
const nsDOMClassInfoData *ci_data = nullptr;
|
||||
const nsDOMClassInfoData *ci_data;
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
||||
name_struct->mDOMClassInfoID >= 0) {
|
||||
ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
|
||||
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
ci_data = name_struct->mData;
|
||||
} else {
|
||||
ci_data = nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager>
|
||||
@@ -1652,14 +1471,11 @@ nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*>
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
const nsIID *class_iid;
|
||||
if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
|
||||
class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
||||
if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
||||
class_iid = &class_name_struct->mIID;
|
||||
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
class_iid =
|
||||
sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
|
||||
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
class_iid = class_name_struct->mData->mProtoChainInterface;
|
||||
} else {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1686,23 +1502,15 @@ GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
|
||||
const nsGlobalNameStruct *aNameStruct,
|
||||
JS::MutableHandle<JSObject*> aProto)
|
||||
{
|
||||
NS_ASSERTION(aNameStruct->mType ==
|
||||
nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
|
||||
NS_ASSERTION(aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor,
|
||||
"Wrong type!");
|
||||
|
||||
nsCOMPtr<nsIClassInfo> ci;
|
||||
if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
int32_t id = aNameStruct->mDOMClassInfoID;
|
||||
MOZ_ASSERT(id >= 0, "Negative DOM classinfo?!?");
|
||||
int32_t id = aNameStruct->mDOMClassInfoID;
|
||||
MOZ_ASSERT(id >= 0, "Negative DOM classinfo?!?");
|
||||
|
||||
nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
|
||||
nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
|
||||
|
||||
ci = NS_GetDOMClassInfoInstance(ci_id);
|
||||
}
|
||||
else {
|
||||
ci = nsDOMClassInfo::GetClassInfoInstance(aNameStruct->mData);
|
||||
}
|
||||
nsCOMPtr<nsIClassInfo> ci = NS_GetDOMClassInfoInstance(ci_id);
|
||||
NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsresult rv =
|
||||
@@ -1730,7 +1538,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||
"Wrong type or missing ci_data!");
|
||||
|
||||
RefPtr<nsDOMConstructor> constructor;
|
||||
nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct, aWin,
|
||||
nsresult rv = nsDOMConstructor::Create(name, name_struct, aWin,
|
||||
getter_AddRefs(constructor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -1883,8 +1691,7 @@ OldBindingConstructorEnabled(const nsGlobalNameStruct *aStruct,
|
||||
nsGlobalWindow *aWin, JSContext *cx)
|
||||
{
|
||||
MOZ_ASSERT(aStruct->mType == nsGlobalNameStruct::eTypeProperty ||
|
||||
aStruct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
aStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo);
|
||||
aStruct->mType == nsGlobalNameStruct::eTypeClassConstructor);
|
||||
|
||||
// Don't expose chrome only constructors to content windows.
|
||||
if (aStruct->mChromeOnly) {
|
||||
@@ -1915,17 +1722,8 @@ nsWindowSH::NameStructEnabled(JSContext* aCx, nsGlobalWindow *aWin,
|
||||
const nsGlobalNameStruct& aNameStruct)
|
||||
{
|
||||
const nsGlobalNameStruct* nameStruct = &aNameStruct;
|
||||
if (nameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||
nsresult rv = GetExternalClassInfo(GetNameSpaceManager(), aName, nameStruct,
|
||||
&nameStruct);
|
||||
if (NS_FAILED(rv) || !nameStruct) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return (nameStruct->mType != nsGlobalNameStruct::eTypeProperty &&
|
||||
nameStruct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
|
||||
nameStruct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) ||
|
||||
nameStruct->mType != nsGlobalNameStruct::eTypeClassConstructor) ||
|
||||
OldBindingConstructorEnabled(nameStruct, aWin, aCx);
|
||||
}
|
||||
|
||||
@@ -1995,16 +1793,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||
rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
|
||||
&name_struct);
|
||||
if (NS_FAILED(rv) || !name_struct) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeClassProto ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
// Lookup new DOM bindings.
|
||||
@@ -2096,45 +1885,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...
|
||||
RefPtr<nsDOMConstructor> constructor;
|
||||
rv = nsDOMConstructor::Create(class_name,
|
||||
nullptr,
|
||||
name_struct,
|
||||
static_cast<nsPIDOMWindow*>(aWin),
|
||||
getter_AddRefs(constructor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
js::AssertSameCompartment(cx, obj);
|
||||
rv = nsContentUtils::WrapNative(cx, constructor,
|
||||
&NS_GET_IID(nsIDOMDOMConstructor), &v,
|
||||
false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> class_obj(cx, &v.toObject());
|
||||
|
||||
// ... and define the constants from the DOM interface on that
|
||||
// constructor object.
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, class_obj);
|
||||
rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!JS_WrapValue(cx, &v)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
FillPropertyDescriptor(desc, obj, 0, v);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
if (!OldBindingConstructorEnabled(name_struct, aWin, cx)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -2158,15 +1909,9 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
|
||||
// This is the Xray case. Look up the constructor object for this
|
||||
// prototype.
|
||||
const nsDOMClassInfoData *ci_data;
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
|
||||
} else {
|
||||
ci_data = name_struct->mData;
|
||||
}
|
||||
|
||||
return ResolvePrototype(nsDOMClassInfo::sXPConnect, aWin, cx, obj,
|
||||
class_name, ci_data,
|
||||
class_name,
|
||||
&sClassInfoData[name_struct->mDOMClassInfoID],
|
||||
name_struct, nameSpaceManager, dot_prototype,
|
||||
desc);
|
||||
}
|
||||
@@ -2179,37 +1924,9 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
name_struct, nameSpaceManager, nullptr, desc);
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||
const nsGlobalNameStruct *alias_struct =
|
||||
nameSpaceManager->GetConstructorProto(name_struct);
|
||||
NS_ENSURE_TRUE(alias_struct, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// We need to use the XPConnect prototype for the DOM class that this
|
||||
// constructor is an alias for (for example for Image we need the prototype
|
||||
// for HTMLImageElement).
|
||||
JS::Rooted<JSObject*> dot_prototype(cx);
|
||||
rv = GetXPCProto(nsDOMClassInfo::sXPConnect, cx, aWin, alias_struct,
|
||||
&dot_prototype);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(dot_prototype);
|
||||
|
||||
const nsDOMClassInfoData *ci_data;
|
||||
if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
ci_data = &sClassInfoData[alias_struct->mDOMClassInfoID];
|
||||
} else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
ci_data = alias_struct->mData;
|
||||
} else {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return ResolvePrototype(nsDOMClassInfo::sXPConnect, aWin, cx, obj,
|
||||
class_name, ci_data,
|
||||
name_struct, nameSpaceManager, nullptr, desc);
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
RefPtr<nsDOMConstructor> constructor;
|
||||
rv = nsDOMConstructor::Create(class_name, nullptr, name_struct,
|
||||
rv = nsDOMConstructor::Create(class_name, name_struct,
|
||||
static_cast<nsPIDOMWindow*>(aWin),
|
||||
getter_AddRefs(constructor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#define nsDOMClassInfo_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIXPCScriptable.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "js/Id.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
||||
@@ -32,13 +32,9 @@ struct nsDOMClassInfoData
|
||||
{
|
||||
const char *mName;
|
||||
const char16_t *mNameUTF16;
|
||||
union {
|
||||
nsDOMClassInfoConstructorFnc mConstructorFptr;
|
||||
nsDOMClassInfoExternalConstructorFnc mExternalConstructorFptr;
|
||||
} u;
|
||||
nsDOMClassInfoConstructorFnc mConstructorFptr;
|
||||
|
||||
nsIClassInfo *mCachedClassInfo; // low bit is set to 1 if external,
|
||||
// so be sure to mask if necessary!
|
||||
nsIClassInfo *mCachedClassInfo;
|
||||
const nsIID *mProtoChainInterface;
|
||||
const nsIID **mInterfaces;
|
||||
uint32_t mScriptableFlags : 31; // flags must not use more than 31 bits!
|
||||
@@ -51,19 +47,6 @@ struct nsDOMClassInfoData
|
||||
#endif
|
||||
};
|
||||
|
||||
struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
|
||||
{
|
||||
const nsCID *mConstructorCID;
|
||||
};
|
||||
|
||||
|
||||
// To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
|
||||
// The low bit is set when we created a generic helper for an external
|
||||
// (which holds on to the nsDOMClassInfoData).
|
||||
#define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) & ~0x1)
|
||||
#define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) | 0x1)
|
||||
#define IS_EXTERNAL(_ptr) (uintptr_t(_ptr) & 0x1)
|
||||
|
||||
class nsWindowSH;
|
||||
|
||||
class nsDOMClassInfo : public nsXPCClassInfo
|
||||
@@ -71,7 +54,7 @@ class nsDOMClassInfo : public nsXPCClassInfo
|
||||
friend class nsWindowSH;
|
||||
|
||||
protected:
|
||||
virtual ~nsDOMClassInfo();
|
||||
virtual ~nsDOMClassInfo() {};
|
||||
|
||||
public:
|
||||
explicit nsDOMClassInfo(nsDOMClassInfoData* aData);
|
||||
@@ -82,17 +65,6 @@ public:
|
||||
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
// Helper method that returns a *non* refcounted pointer to a
|
||||
// helper. So please note, don't release this pointer, if you do,
|
||||
// you better make sure you've addreffed before release.
|
||||
//
|
||||
// Whaaaaa! I wanted to name this method GetClassInfo, but nooo,
|
||||
// some of Microsoft devstudio's headers #defines GetClassInfo to
|
||||
// GetClassInfoA so I can't, those $%#@^! bastards!!! What gives
|
||||
// them the right to do that?
|
||||
|
||||
static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoData* aData);
|
||||
|
||||
static nsresult Init();
|
||||
static void ShutDown();
|
||||
|
||||
@@ -134,12 +106,11 @@ protected:
|
||||
}
|
||||
|
||||
static nsresult RegisterClassProtos(int32_t aDOMClassInfoID);
|
||||
static nsresult RegisterExternalClasses();
|
||||
|
||||
static nsIXPConnect *sXPConnect;
|
||||
|
||||
// nsIXPCScriptable code
|
||||
static nsresult DefineStaticJSVals(JSContext *cx);
|
||||
static nsresult DefineStaticJSVals();
|
||||
|
||||
static bool sIsInitialized;
|
||||
|
||||
|
||||
@@ -60,10 +60,6 @@ NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
|
||||
} \
|
||||
} else
|
||||
|
||||
#else
|
||||
|
||||
// See nsIDOMClassInfo.h
|
||||
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
|
||||
#endif // nsDOMClassInfoID_h__
|
||||
|
||||
@@ -1,127 +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/.
|
||||
*
|
||||
*
|
||||
* This Original Code has been modified by IBM Corporation.
|
||||
* Modifications made by IBM described herein are
|
||||
* Copyright (c) International Business Machines
|
||||
* Corporation, 2000
|
||||
*
|
||||
* Modifications to Mozilla code or documentation
|
||||
* identified per MPL Section 3.3
|
||||
*
|
||||
* Date Modified by Description of modification
|
||||
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
|
||||
* use in OS2
|
||||
*/
|
||||
|
||||
#include "nsDOMScriptObjectFactory.h"
|
||||
#include "nsScriptNameSpaceManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsCRT.h"
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPrototypeCache.h"
|
||||
#endif
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
using mozilla::dom::GetNameSpaceManager;
|
||||
|
||||
nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMScriptObjectFactory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMScriptObjectFactory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScriptObjectFactory)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMScriptObjectFactory)
|
||||
NS_IMPL_RELEASE(nsDOMScriptObjectFactory)
|
||||
|
||||
NS_IMETHODIMP_(nsISupports *)
|
||||
nsDOMScriptObjectFactory::GetClassInfoInstance(nsDOMClassInfoID aID)
|
||||
{
|
||||
return NS_GetDOMClassInfoInstance(aID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsISupports *)
|
||||
nsDOMScriptObjectFactory::GetExternalClassInfoInstance(const nsAString& aName)
|
||||
{
|
||||
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
|
||||
NS_ENSURE_TRUE(nameSpaceManager, nullptr);
|
||||
|
||||
const nsGlobalNameStruct *globalStruct = nameSpaceManager->LookupName(aName);
|
||||
if (globalStruct) {
|
||||
if (globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(globalStruct->mCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), this);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
globalStruct = nameSpaceManager->LookupName(aName);
|
||||
NS_ENSURE_TRUE(globalStruct, nullptr);
|
||||
|
||||
NS_ASSERTION(globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
|
||||
"The classinfo data for this class didn't get registered.");
|
||||
}
|
||||
if (globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
return nsDOMClassInfo::GetClassInfoInstance(globalStruct->mData);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScriptObjectFactory::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const char16_t *someData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
#ifdef MOZ_XUL
|
||||
// Flush the XUL cache since it holds JS roots, and we're about to
|
||||
// start the final GC.
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
|
||||
if (cache)
|
||||
cache->Flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
{
|
||||
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
|
||||
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return nameSpaceManager->RegisterDOMCIData(aName,
|
||||
aConstructorFptr,
|
||||
aProtoChainInterface,
|
||||
aInterfaces,
|
||||
aScriptableFlags,
|
||||
aHasClassInterface,
|
||||
aConstructorCID);
|
||||
}
|
||||
@@ -1,50 +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/.
|
||||
*
|
||||
*
|
||||
* This Original Code has been modified by IBM Corporation.
|
||||
* Modifications made by IBM described herein are
|
||||
* Copyright (c) International Business Machines
|
||||
* Corporation, 2000
|
||||
*
|
||||
* Modifications to Mozilla code or documentation
|
||||
* identified per MPL Section 3.3
|
||||
*
|
||||
* Date Modified by Description of modification
|
||||
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
|
||||
* use in OS2
|
||||
*/
|
||||
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsDOMScriptObjectFactory final : public nsIDOMScriptObjectFactory,
|
||||
public nsIObserver
|
||||
{
|
||||
~nsDOMScriptObjectFactory() {}
|
||||
|
||||
public:
|
||||
nsDOMScriptObjectFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIObserver
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// nsIDOMScriptObjectFactory
|
||||
NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) override;
|
||||
NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName) override;
|
||||
|
||||
NS_IMETHOD RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID) override;
|
||||
};
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
#include "mozilla/css/ImageLoader.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#undef GetClassName
|
||||
|
||||
+136
-76
@@ -243,6 +243,10 @@
|
||||
#include "gfxVR.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#include "nsISpeculativeConnect.h"
|
||||
|
||||
@@ -729,10 +733,16 @@ nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
}
|
||||
|
||||
aFound = true;
|
||||
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
StyleSheetHandle sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
NS_ASSERTION(sheet, "Must have a sheet");
|
||||
|
||||
return static_cast<CSSStyleSheet*>(sheet);
|
||||
// XXXheycam Return null until ServoStyleSheet implements the right DOM
|
||||
// interfaces.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't return a ServoStyleSheet to the DOM yet");
|
||||
return nullptr;
|
||||
}
|
||||
return sheet->AsGecko();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -742,7 +752,7 @@ nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMStyleSheetList::StyleSheetAdded(CSSStyleSheet* aStyleSheet,
|
||||
nsDOMStyleSheetList::StyleSheetAdded(StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
if (aDocumentSheet && -1 != mLength) {
|
||||
@@ -751,7 +761,7 @@ nsDOMStyleSheetList::StyleSheetAdded(CSSStyleSheet* aStyleSheet,
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMStyleSheetList::StyleSheetRemoved(CSSStyleSheet* aStyleSheet,
|
||||
nsDOMStyleSheetList::StyleSheetRemoved(StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
if (aDocumentSheet && -1 != mLength) {
|
||||
@@ -1318,9 +1328,14 @@ nsDOMStyleSheetSetList::EnsureFresh()
|
||||
int32_t count = mDocument->GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
|
||||
StyleSheetHandle sheet = mDocument->GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
// XXXheycam ServoStyleSheets don't expose their title yet.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: ServoStyleSets don't expose their title yet");
|
||||
continue;
|
||||
}
|
||||
sheet->AsGecko()->GetTitle(title);
|
||||
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
|
||||
return;
|
||||
}
|
||||
@@ -1600,7 +1615,7 @@ nsDocument::~nsDocument()
|
||||
mCachedRootElement = nullptr;
|
||||
|
||||
// Let the stylesheets know we're going away
|
||||
for (CSSStyleSheet* sheet : mStyleSheets) {
|
||||
for (StyleSheetHandle sheet : mStyleSheets) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
}
|
||||
if (mAttrStyleSheet) {
|
||||
@@ -2279,7 +2294,7 @@ void
|
||||
nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
||||
{
|
||||
// The stylesheets should forget us
|
||||
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(mStyleSheets)) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (sheet->IsApplicable()) {
|
||||
@@ -2294,11 +2309,11 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheetsFromStyleSets(
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
SheetType aType)
|
||||
{
|
||||
// The stylesheets should forget us
|
||||
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(aSheets)) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (sheet->IsApplicable()) {
|
||||
@@ -2364,24 +2379,24 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
||||
}
|
||||
|
||||
static void
|
||||
AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
AppendSheetsToStyleSet(StyleSetHandle aStyleSet,
|
||||
const nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
SheetType aType)
|
||||
{
|
||||
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(aSheets)) {
|
||||
aStyleSet->AppendStyleSheet(aType, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
||||
nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
|
||||
{
|
||||
NS_PRECONDITION(aStyleSet, "Must have a style set");
|
||||
NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
|
||||
"Style set already has document sheets?");
|
||||
|
||||
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(mStyleSheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->AddDocStyleSheet(sheet, this);
|
||||
}
|
||||
@@ -2389,13 +2404,13 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AuthorStyleSheets()) {
|
||||
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate backwards to maintain order
|
||||
for (CSSStyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
@@ -3721,7 +3736,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel,
|
||||
|
||||
already_AddRefed<nsIPresShell>
|
||||
nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet)
|
||||
StyleSetHandle aStyleSet)
|
||||
{
|
||||
// Don't add anything here. Add it to |doCreateShell| instead.
|
||||
// This exists so that subclasses can pass other values for the 4th
|
||||
@@ -3731,7 +3746,7 @@ nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager,
|
||||
|
||||
already_AddRefed<nsIPresShell>
|
||||
nsDocument::doCreateShell(nsPresContext* aContext,
|
||||
nsViewManager* aViewManager, nsStyleSet* aStyleSet)
|
||||
nsViewManager* aViewManager, StyleSetHandle aStyleSet)
|
||||
{
|
||||
NS_ASSERTION(!mPresShell, "We have a presshell already!");
|
||||
|
||||
@@ -4048,7 +4063,7 @@ nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::EnsureOnDemandBuiltInUASheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
if (mOnDemandBuiltInUASheets.Contains(aSheet)) {
|
||||
return;
|
||||
@@ -4059,7 +4074,7 @@ nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::AddOnDemandBuiltInUASheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(aSheet));
|
||||
|
||||
@@ -4088,20 +4103,20 @@ nsDocument::GetNumberOfStyleSheets() const
|
||||
return mStyleSheets.Length();
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsDocument::GetStyleSheetAt(int32_t aIndex) const
|
||||
{
|
||||
return mStyleSheets.SafeElementAt(aIndex, nullptr);
|
||||
return mStyleSheets.SafeElementAt(aIndex, StyleSheetHandle());
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsDocument::GetIndexOfStyleSheet(CSSStyleSheet* aSheet) const
|
||||
nsDocument::GetIndexOfStyleSheet(StyleSheetHandle aSheet) const
|
||||
{
|
||||
return mStyleSheets.IndexOf(aSheet);
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
nsDocument::AddStyleSheetToStyleSets(StyleSheetHandle aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
@@ -4114,7 +4129,11 @@ nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
className##Init init; \
|
||||
init.mBubbles = true; \
|
||||
init.mCancelable = true; \
|
||||
init.mStylesheet = aSheet; \
|
||||
/* XXXheycam ServoStyleSheet doesn't implement DOM interfaces yet */ \
|
||||
if (aSheet->IsServo()) { \
|
||||
NS_ERROR("stylo: can't dispatch events for ServoStyleSheets yet"); \
|
||||
} \
|
||||
init.mStylesheet = aSheet->IsGecko() ? aSheet->AsGecko() : nullptr; \
|
||||
init.memberName = argName; \
|
||||
\
|
||||
RefPtr<className> event = \
|
||||
@@ -4128,7 +4147,7 @@ nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
} while (0);
|
||||
|
||||
void
|
||||
nsDocument::NotifyStyleSheetAdded(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
nsDocument::NotifyStyleSheetAdded(StyleSheetHandle aSheet, bool aDocumentSheet)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetAdded, (aSheet, aDocumentSheet));
|
||||
|
||||
@@ -4141,7 +4160,7 @@ nsDocument::NotifyStyleSheetAdded(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::NotifyStyleSheetRemoved(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
nsDocument::NotifyStyleSheetRemoved(StyleSheetHandle aSheet, bool aDocumentSheet)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetRemoved, (aSheet, aDocumentSheet));
|
||||
|
||||
@@ -4154,7 +4173,7 @@ nsDocument::NotifyStyleSheetRemoved(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::AddStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
mStyleSheets.AppendElement(aSheet);
|
||||
@@ -4168,7 +4187,7 @@ nsDocument::AddStyleSheet(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheetFromStyleSets(CSSStyleSheet* aSheet)
|
||||
nsDocument::RemoveStyleSheetFromStyleSets(StyleSheetHandle aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
@@ -4177,10 +4196,10 @@ nsDocument::RemoveStyleSheetFromStyleSets(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::RemoveStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
RefPtr<CSSStyleSheet> sheet = aSheet; // hold ref so it won't die too soon
|
||||
StyleSheetHandle::RefPtr sheet = aSheet; // hold ref so it won't die too soon
|
||||
|
||||
if (!mStyleSheets.RemoveElement(aSheet)) {
|
||||
NS_ASSERTION(mInUnlinkOrDeletion, "stylesheet not found");
|
||||
@@ -4199,8 +4218,8 @@ nsDocument::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
||||
nsDocument::UpdateStyleSheets(nsTArray<StyleSheetHandle::RefPtr>& aOldSheets,
|
||||
nsTArray<StyleSheetHandle::RefPtr>& aNewSheets)
|
||||
{
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
|
||||
@@ -4209,7 +4228,7 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
"The lists must be the same length!");
|
||||
int32_t count = aOldSheets.Length();
|
||||
|
||||
RefPtr<CSSStyleSheet> oldSheet;
|
||||
StyleSheetHandle::RefPtr oldSheet;
|
||||
int32_t i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
oldSheet = aOldSheets[i];
|
||||
@@ -4220,7 +4239,7 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
RemoveStyleSheet(oldSheet); // This does the right notifications
|
||||
|
||||
// Now put the new one in its place. If it's null, just ignore it.
|
||||
CSSStyleSheet* newSheet = aNewSheets[i];
|
||||
StyleSheetHandle newSheet = aNewSheets[i];
|
||||
if (newSheet) {
|
||||
mStyleSheets.InsertElementAt(oldIndex, newSheet);
|
||||
newSheet->SetOwningDocument(this);
|
||||
@@ -4236,7 +4255,7 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
|
||||
nsDocument::InsertStyleSheetAt(StyleSheetHandle aSheet, int32_t aIndex)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null ptr");
|
||||
|
||||
@@ -4253,7 +4272,7 @@ nsDocument::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
|
||||
|
||||
|
||||
void
|
||||
nsDocument::SetStyleSheetApplicableState(CSSStyleSheet* aSheet,
|
||||
nsDocument::SetStyleSheetApplicableState(StyleSheetHandle aSheet,
|
||||
bool aApplicable)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
@@ -4319,7 +4338,7 @@ ConvertAdditionalSheetType(nsIDocument::additionalSheetType aType)
|
||||
}
|
||||
|
||||
static int32_t
|
||||
FindSheet(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets, nsIURI* aSheetURI)
|
||||
FindSheet(const nsTArray<StyleSheetHandle::RefPtr>& aSheets, nsIURI* aSheetURI)
|
||||
{
|
||||
for (int32_t i = aSheets.Length() - 1; i >= 0; i-- ) {
|
||||
bool bEqual;
|
||||
@@ -4363,9 +4382,8 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
MOZ_CRASH("impossible value for aType");
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
sheet->SetOwningDocument(this);
|
||||
@@ -4375,7 +4393,7 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, CSSStyleSheet* aSheet)
|
||||
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, StyleSheetHandle aSheet)
|
||||
{
|
||||
if (mAdditionalSheets[aType].Contains(aSheet))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@@ -4404,11 +4422,11 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
||||
{
|
||||
MOZ_ASSERT(aSheetURI);
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& sheets = mAdditionalSheets[aType];
|
||||
nsTArray<StyleSheetHandle::RefPtr>& sheets = mAdditionalSheets[aType];
|
||||
|
||||
int32_t i = FindSheet(mAdditionalSheets[aType], aSheetURI);
|
||||
if (i >= 0) {
|
||||
RefPtr<CSSStyleSheet> sheetRef = sheets[i];
|
||||
StyleSheetHandle::RefPtr sheetRef = sheets[i];
|
||||
sheets.RemoveElementAt(i);
|
||||
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
@@ -4430,10 +4448,10 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
||||
}
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsDocument::FirstAdditionalAuthorSheet()
|
||||
{
|
||||
return mAdditionalSheets[eAuthorSheet].SafeElementAt(0, nullptr);
|
||||
return mAdditionalSheets[eAuthorSheet].SafeElementAt(0, StyleSheetHandle());
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
@@ -5173,7 +5191,7 @@ nsDocument::DocumentStatesChanged(EventStates aStateMask)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleChanged(CSSStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleChanged(StyleSheetHandle aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleChanged, (aSheet));
|
||||
@@ -5187,7 +5205,7 @@ nsDocument::StyleRuleChanged(CSSStyleSheet* aSheet,
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleAdded(CSSStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleAdded(StyleSheetHandle aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleAdded, (aSheet));
|
||||
@@ -5202,7 +5220,7 @@ nsDocument::StyleRuleAdded(CSSStyleSheet* aSheet,
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleRemoved(CSSStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleRemoved(StyleSheetHandle aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleRemoved, (aSheet));
|
||||
@@ -6443,17 +6461,23 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
|
||||
int32_t count = GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
CSSStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
StyleSheetHandle sheet = GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
|
||||
// XXXheycam Make this work with ServoStyleSheets.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
|
||||
continue;
|
||||
}
|
||||
|
||||
bool disabled;
|
||||
sheet->GetDisabled(&disabled);
|
||||
sheet->AsGecko()->GetDisabled(&disabled);
|
||||
if (disabled) {
|
||||
// Disabled sheets don't affect the currently selected set
|
||||
continue;
|
||||
}
|
||||
|
||||
sheet->GetTitle(title);
|
||||
sheet->AsGecko()->GetTitle(title);
|
||||
|
||||
if (aSheetSet.IsEmpty()) {
|
||||
aSheetSet = title;
|
||||
@@ -6557,11 +6581,18 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
|
||||
int32_t count = GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
CSSStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
StyleSheetHandle sheet = GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
|
||||
// XXXheycam Make this work with ServoStyleSheets.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
|
||||
continue;
|
||||
}
|
||||
|
||||
sheet->AsGecko()->GetTitle(title);
|
||||
if (!title.IsEmpty()) {
|
||||
sheet->SetEnabled(title.Equals(aSheetSet));
|
||||
sheet->AsGecko()->SetEnabled(title.Equals(aSheetSet));
|
||||
}
|
||||
}
|
||||
if (aUpdateCSSLoader) {
|
||||
@@ -9804,7 +9835,7 @@ class StubCSSLoaderObserver final : public nsICSSLoaderObserver {
|
||||
~StubCSSLoaderObserver() {}
|
||||
public:
|
||||
NS_IMETHOD
|
||||
StyleSheetLoaded(CSSStyleSheet*, bool, nsresult) override
|
||||
StyleSheetLoaded(StyleSheetHandle, bool, nsresult) override
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -9833,12 +9864,12 @@ nsDocument::PreloadStyle(nsIURI* uri, const nsAString& charset,
|
||||
|
||||
nsresult
|
||||
nsDocument::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
|
||||
CSSStyleSheet** sheet)
|
||||
mozilla::StyleSheetHandle::RefPtr* aSheet)
|
||||
{
|
||||
css::SheetParsingMode mode =
|
||||
isAgentSheet ? css::eAgentSheetFeatures
|
||||
: css::eAuthorSheetFeatures;
|
||||
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, sheet);
|
||||
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, aSheet);
|
||||
}
|
||||
|
||||
class nsDelayedEventDispatcher : public nsRunnable
|
||||
@@ -10164,28 +10195,38 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
||||
|
||||
int32_t sheetsCount = GetNumberOfStyleSheets();
|
||||
for (int32_t i = 0; i < sheetsCount; ++i) {
|
||||
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetAt(i);
|
||||
if (sheet) {
|
||||
if (sheet->IsApplicable()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddStyleSheet(clonedSheet);
|
||||
// XXXheycam Need to make ServoStyleSheet cloning work.
|
||||
if (sheet->IsGecko()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddStyleSheet(clonedSheet);
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate backwards to maintain order
|
||||
for (CSSStyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
|
||||
if (sheet) {
|
||||
if (sheet->IsApplicable()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
|
||||
// XXXheycam Need to make ServoStyleSheet cloning work.
|
||||
if (sheet->IsGecko()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12316,7 +12357,7 @@ nsDocument::OnAppThemeChanged()
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GetNumberOfStyleSheets(); i++) {
|
||||
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetAt(i);
|
||||
if (!sheet) {
|
||||
continue;
|
||||
}
|
||||
@@ -12683,12 +12724,12 @@ nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
|
||||
}
|
||||
|
||||
static size_t
|
||||
SizeOfOwnedSheetArrayExcludingThis(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
SizeOfOwnedSheetArrayExcludingThis(const nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
size_t n = 0;
|
||||
n += aSheets.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (CSSStyleSheet* sheet : aSheets) {
|
||||
for (StyleSheetHandle sheet : aSheets) {
|
||||
if (!sheet->GetOwningDocument()) {
|
||||
// Avoid over-reporting shared sheets.
|
||||
continue;
|
||||
@@ -13269,8 +13310,15 @@ nsIDocument::FlushUserFontSet()
|
||||
if (gfxPlatform::GetPlatform()->DownloadableFontsEnabled()) {
|
||||
nsTArray<nsFontFaceRuleContainer> rules;
|
||||
nsIPresShell* shell = GetShell();
|
||||
if (shell && !shell->StyleSet()->AppendFontFaceRules(rules)) {
|
||||
return;
|
||||
if (shell) {
|
||||
// XXXheycam ServoStyleSets don't support exposing @font-face rules yet.
|
||||
if (shell->StyleSet()->IsGecko()) {
|
||||
if (!shell->StyleSet()->AsGecko()->AppendFontFaceRules(rules)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: ServoStyleSets cannot handle @font-face rules yet");
|
||||
}
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
@@ -13353,6 +13401,18 @@ nsIDocument::ReportHasScrollLinkedEffect()
|
||||
"ScrollLinkedEffectFound2");
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType
|
||||
nsIDocument::GetStyleBackendType() const
|
||||
{
|
||||
if (!mPresShell) {
|
||||
#ifdef MOZ_STYLO
|
||||
NS_WARNING("GetStyleBackendType() called on document without a pres shell");
|
||||
#endif
|
||||
return StyleBackendType::Gecko;
|
||||
}
|
||||
return mPresShell->StyleSet()->BackendType();
|
||||
}
|
||||
|
||||
Selection*
|
||||
nsIDocument::GetSelection(ErrorResult& aRv)
|
||||
{
|
||||
|
||||
+31
-30
@@ -44,7 +44,7 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIApplicationCache.h"
|
||||
#include "nsIApplicationCacheContainer.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "PLDHashTable.h"
|
||||
#include "nsAttrAndChildArray.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
@@ -748,9 +748,10 @@ public:
|
||||
* its presentation context (presentation contexts <b>must not</b> be
|
||||
* shared among multiple presentation shells).
|
||||
*/
|
||||
virtual already_AddRefed<nsIPresShell> CreateShell(nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet) override;
|
||||
virtual already_AddRefed<nsIPresShell> CreateShell(
|
||||
nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
mozilla::StyleSetHandle aStyleSet) override;
|
||||
virtual void DeleteShell() override;
|
||||
|
||||
virtual nsresult GetAllowPlugins(bool* aAllowPlugins) override;
|
||||
@@ -768,36 +769,36 @@ public:
|
||||
virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const override;
|
||||
virtual Element* GetRootElementInternal() const override;
|
||||
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
|
||||
/**
|
||||
* Get the (document) style sheets owned by this document.
|
||||
* These are ordered, highest priority last
|
||||
*/
|
||||
virtual int32_t GetNumberOfStyleSheets() const override;
|
||||
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const override;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const override;
|
||||
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual mozilla::StyleSheetHandle GetStyleSheetAt(int32_t aIndex) const override;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::StyleSheetHandle aSheet) const override;
|
||||
virtual void AddStyleSheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
virtual void RemoveStyleSheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
|
||||
virtual void UpdateStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) override;
|
||||
virtual void AddStyleSheetToStyleSets(mozilla::CSSStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(mozilla::CSSStyleSheet* aSheet);
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aOldSheets,
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aNewSheets) override;
|
||||
virtual void AddStyleSheetToStyleSets(mozilla::StyleSheetHandle aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(mozilla::StyleSheetHandle aSheet);
|
||||
|
||||
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void InsertStyleSheetAt(mozilla::StyleSheetHandle aSheet,
|
||||
int32_t aIndex) override;
|
||||
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void SetStyleSheetApplicableState(mozilla::StyleSheetHandle aSheet,
|
||||
bool aApplicable) override;
|
||||
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI) override;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet) override;
|
||||
mozilla::StyleSheetHandle aSheet) override;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* sheetURI) override;
|
||||
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() override;
|
||||
virtual mozilla::StyleSheetHandle FirstAdditionalAuthorSheet() override;
|
||||
|
||||
virtual nsIChannel* GetChannel() const override {
|
||||
return mChannel;
|
||||
@@ -857,11 +858,11 @@ public:
|
||||
virtual void DocumentStatesChanged(
|
||||
mozilla::EventStates aStateMask) override;
|
||||
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
|
||||
virtual void FlushPendingNotifications(mozFlushType aType) override;
|
||||
@@ -933,7 +934,7 @@ public:
|
||||
void ReportUseCounters();
|
||||
|
||||
private:
|
||||
void AddOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet);
|
||||
void AddOnDemandBuiltInUASheet(mozilla::StyleSheetHandle aSheet);
|
||||
nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const;
|
||||
void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages);
|
||||
|
||||
@@ -1115,7 +1116,7 @@ public:
|
||||
const nsAString& aIntegrity) override;
|
||||
|
||||
virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
|
||||
mozilla::CSSStyleSheet** sheet) override;
|
||||
mozilla::StyleSheetHandle::RefPtr* aSheet) override;
|
||||
|
||||
virtual nsISupports* GetCurrentContentSink() override;
|
||||
|
||||
@@ -1485,14 +1486,14 @@ public:
|
||||
protected:
|
||||
already_AddRefed<nsIPresShell> doCreateShell(nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet);
|
||||
mozilla::StyleSetHandle aStyleSet);
|
||||
|
||||
void RemoveDocStyleSheetsFromStyleSets();
|
||||
void RemoveStyleSheetsFromStyleSets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets,
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets,
|
||||
mozilla::SheetType aType);
|
||||
void ResetStylesheetsToURI(nsIURI* aURI);
|
||||
void FillStyleSet(nsStyleSet* aStyleSet);
|
||||
void FillStyleSet(mozilla::StyleSetHandle aStyleSet);
|
||||
|
||||
// Return whether all the presshells for this document are safe to flush
|
||||
bool IsSafeToFlush() const;
|
||||
@@ -1538,9 +1539,9 @@ protected:
|
||||
// EndLoad() has already happened.
|
||||
nsWeakPtr mWeakSink;
|
||||
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mOnDemandBuiltInUASheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mStyleSheets;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mOnDemandBuiltInUASheets;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||
|
||||
// Array of observers
|
||||
nsTObserverArray<nsIDocumentObserver*> mObservers;
|
||||
@@ -1719,8 +1720,8 @@ private:
|
||||
friend class nsUnblockOnloadEvent;
|
||||
// Recomputes the visibility state but doesn't set the new value.
|
||||
mozilla::dom::VisibilityState GetVisibilityState() const;
|
||||
void NotifyStyleSheetAdded(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetRemoved(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetAdded(mozilla::StyleSheetHandle aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetRemoved(mozilla::StyleSheetHandle aSheet, bool aDocumentSheet);
|
||||
|
||||
void PostUnblockOnloadEvent();
|
||||
void DoUnblockOnload();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "AppProcessChecker.h"
|
||||
#include "ContentChild.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
@@ -1102,16 +1103,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
continue;
|
||||
}
|
||||
|
||||
// Note - The ergonomics here will get a lot better with bug 971673:
|
||||
//
|
||||
// AutoEntryScript aes;
|
||||
// if (!aes.Init(wrappedJS->GetJSObject())) {
|
||||
// continue;
|
||||
// }
|
||||
// JSContext* cx = aes.cx();
|
||||
nsIGlobalObject* nativeGlobal =
|
||||
xpc::NativeGlobal(js::GetGlobalForObjectCrossCompartment(wrappedJS->GetJSObject()));
|
||||
AutoEntryScript aes(nativeGlobal, "message manager handler");
|
||||
AutoEntryScript aes(wrappedJS->GetJSObject(), "message manager handler");
|
||||
aes.TakeOwnershipOfErrorReporting();
|
||||
JSContext* cx = aes.cx();
|
||||
JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());
|
||||
@@ -1655,7 +1647,6 @@ void
|
||||
nsMessageManagerScriptExecutor::Shutdown()
|
||||
{
|
||||
if (sCachedScripts) {
|
||||
AutoSafeJSContext cx;
|
||||
NS_ASSERTION(sCachedScripts != nullptr, "Need cached scripts");
|
||||
for (auto iter = sCachedScripts->Iter(); !iter.Done(); iter.Next()) {
|
||||
delete iter.Data();
|
||||
@@ -1694,8 +1685,7 @@ nsMessageManagerScriptExecutor::LoadScriptInternal(const nsAString& aURL,
|
||||
|
||||
JS::Rooted<JSObject*> global(rt, mGlobal->GetJSObject());
|
||||
if (global) {
|
||||
AutoEntryScript aes(xpc::NativeGlobal(global),
|
||||
"message manager script load");
|
||||
AutoEntryScript aes(global, "message manager script load");
|
||||
aes.TakeOwnershipOfErrorReporting();
|
||||
JSContext* cx = aes.cx();
|
||||
if (script) {
|
||||
@@ -1772,12 +1762,13 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
JS::SourceBufferHolder::GiveOwnership);
|
||||
|
||||
if (dataStringBuf && dataStringLength > 0) {
|
||||
AutoSafeJSContext cx;
|
||||
// Compile the script in the compilation scope instead of the current global
|
||||
// to avoid keeping the current compartment alive.
|
||||
JS::Rooted<JSObject*> global(cx, xpc::CompilationScope());
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(xpc::CompilationScope())) {
|
||||
return;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::CompileOptions options(cx, JSVERSION_LATEST);
|
||||
options.setFileAndLine(url.get(), 1);
|
||||
options.setNoScriptRval(true);
|
||||
@@ -1816,8 +1807,7 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
const nsAString& aURL,
|
||||
bool aRunInGlobalScope)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JSScript*> script(cx);
|
||||
JS::Rooted<JSScript*> script(nsContentUtils::RootingCx());
|
||||
TryCacheLoadAndCompileScript(aURL, aRunInGlobalScope, true, &script);
|
||||
}
|
||||
|
||||
|
||||
@@ -615,6 +615,7 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
||||
mMayHavePaintEventListener(false), mMayHaveTouchEventListener(false),
|
||||
mMayHaveMouseEnterLeaveEventListener(false),
|
||||
mMayHavePointerEnterLeaveEventListener(false),
|
||||
mInnerObjectsFreed(false),
|
||||
mIsModalContentWindow(false),
|
||||
mIsActive(false), mIsBackground(false),
|
||||
mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false),
|
||||
@@ -1155,7 +1156,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
|
||||
#endif
|
||||
mShowFocusRingForContent(false),
|
||||
mFocusByKeyOccurred(false),
|
||||
mInnerObjectsFreed(false),
|
||||
mHasGamepad(false),
|
||||
#ifdef MOZ_GAMEPAD
|
||||
mHasSeenGamepadInput(false),
|
||||
@@ -3413,9 +3413,9 @@ nsGlobalWindow::DefineArgumentsProperty(nsIArray *aArguments)
|
||||
|
||||
nsIScriptContext *ctx = GetOuterWindowInternal()->mContext;
|
||||
NS_ENSURE_TRUE(aArguments && ctx, NS_ERROR_NOT_INITIALIZED);
|
||||
AutoJSContext cx;
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, GetWrapperPreserveColor());
|
||||
JS::Rooted<JSObject*> obj(nsContentUtils::RootingCx(),
|
||||
GetWrapperPreserveColor());
|
||||
return ctx->SetProperty(obj, "arguments", aArguments);
|
||||
}
|
||||
|
||||
@@ -4057,7 +4057,9 @@ nsGlobalWindow::GetMozSelfSupport(ErrorResult& aError)
|
||||
return mMozSelfSupport;
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
// We're called from JS and want to use out existing JSContext (and,
|
||||
// importantly, its compartment!) here.
|
||||
AutoJSContext cx;
|
||||
GlobalObject global(cx, FastGetGlobalJSObject());
|
||||
mMozSelfSupport = MozSelfSupport::Constructor(global, cx, aError);
|
||||
return mMozSelfSupport;
|
||||
@@ -6214,8 +6216,13 @@ nsGlobalWindow::DispatchResizeEvent(const CSSIntSize& aSize)
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
// We don't init the AutoJSAPI with ourselves because we don't want it
|
||||
// reporting errors to our onerror handlers.
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoCompartment ac(cx, GetWrapperPreserveColor());
|
||||
|
||||
DOMWindowResizeEventDetail detail;
|
||||
detail.mWidth = aSize.width;
|
||||
detail.mHeight = aSize.height;
|
||||
@@ -9130,8 +9137,7 @@ nsGlobalWindow::NotifyDOMWindowThawed(nsGlobalWindow* aWindow) {
|
||||
JSObject*
|
||||
nsGlobalWindow::GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JSObject*> handler(cx);
|
||||
JS::Rooted<JSObject*> handler(nsContentUtils::RootingCx());
|
||||
if (mCachedXBLPrototypeHandlers) {
|
||||
mCachedXBLPrototypeHandlers->Get(aKey, handler.address());
|
||||
}
|
||||
@@ -11242,7 +11248,7 @@ nsGlobalWindow::ShowSlowScriptDialog()
|
||||
}
|
||||
|
||||
// Check if we should offer the option to debug
|
||||
JS::UniqueChars filename;
|
||||
JS::AutoFilename filename;
|
||||
unsigned lineno;
|
||||
bool hasFrame = JS::DescribeScriptedCaller(cx, &filename, &lineno);
|
||||
|
||||
|
||||
@@ -1680,10 +1680,6 @@ protected:
|
||||
// should be displayed.
|
||||
bool mFocusByKeyOccurred : 1;
|
||||
|
||||
// Ensure that a call to ResumeTimeouts() after FreeInnerObjects() does nothing.
|
||||
// This member is only used by inner windows.
|
||||
bool mInnerObjectsFreed : 1;
|
||||
|
||||
// Inner windows only.
|
||||
// Indicates whether this window wants gamepad input events
|
||||
bool mHasGamepad : 1;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "nsHostObjectProtocolHandler.h"
|
||||
|
||||
#include "DOMMediaStream.h"
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/MediaSource.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
@@ -200,11 +201,7 @@ class BlobURLsReporter final : public nsIMemoryReporter
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
nsCOMPtr<nsIStackFrame> frame;
|
||||
rv = xpc->GetCurrentJSStack(getter_AddRefs(frame));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
nsCOMPtr<nsIStackFrame> frame = dom::GetCurrentJSStack(maxFrames);
|
||||
|
||||
nsAutoCString origin;
|
||||
nsCOMPtr<nsIURI> principalURI;
|
||||
@@ -213,12 +210,17 @@ class BlobURLsReporter final : public nsIMemoryReporter
|
||||
principalURI->GetPrePath(origin);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < maxFrames && frame; ++i) {
|
||||
// If we got a frame, we better have a current JSContext. This is cheating
|
||||
// a bit; ideally we'd have our caller pass in a JSContext, or have
|
||||
// GetCurrentJSStack() hand out the JSContext it found.
|
||||
JSContext* cx = frame ? nsContentUtils::GetCurrentJSContext() : nullptr;
|
||||
|
||||
for (uint32_t i = 0; frame; ++i) {
|
||||
nsString fileNameUTF16;
|
||||
int32_t lineNumber = 0;
|
||||
|
||||
frame->GetFilename(fileNameUTF16);
|
||||
frame->GetLineNumber(&lineNumber);
|
||||
frame->GetFilename(cx, fileNameUTF16);
|
||||
frame->GetLineNumber(cx, &lineNumber);
|
||||
|
||||
if (!fileNameUTF16.IsEmpty()) {
|
||||
NS_ConvertUTF16toUTF8 fileName(fileNameUTF16);
|
||||
@@ -245,8 +247,10 @@ class BlobURLsReporter final : public nsIMemoryReporter
|
||||
stack += ")/";
|
||||
}
|
||||
|
||||
rv = frame->GetCaller(getter_AddRefs(frame));
|
||||
nsCOMPtr<nsIStackFrame> caller;
|
||||
nsresult rv = frame->GetCaller(cx, getter_AddRefs(caller));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
caller.swap(frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,7 @@
|
||||
#ifndef nsIDOMClassInfo_h___
|
||||
#define nsIDOMClassInfo_h___
|
||||
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIXPCScriptable.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
#define DOM_BASE_SCRIPTABLE_FLAGS \
|
||||
(nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
|
||||
@@ -32,153 +27,4 @@
|
||||
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
|
||||
nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY)
|
||||
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
|
||||
// See nsDOMClassInfoID.h
|
||||
|
||||
#else
|
||||
|
||||
#define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
|
||||
aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
|
||||
\
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
|
||||
&rv)); \
|
||||
if (NS_FAILED(rv)) { \
|
||||
*aInstancePtr = nullptr; \
|
||||
return rv; \
|
||||
} \
|
||||
\
|
||||
foundInterface = \
|
||||
sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
||||
} else
|
||||
|
||||
#endif /* MOZILLA_INTERNAL_API */
|
||||
|
||||
// Looks up the nsIClassInfo for a class name registered with the
|
||||
// nsScriptNamespaceManager. Remember to release NS_CLASSINFO_NAME(_class)
|
||||
// (eg. when your module unloads).
|
||||
#define NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
|
||||
aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
|
||||
extern nsISupports *NS_CLASSINFO_NAME(_class); \
|
||||
if (NS_CLASSINFO_NAME(_class)) { \
|
||||
foundInterface = NS_CLASSINFO_NAME(_class); \
|
||||
} else { \
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
|
||||
\
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
|
||||
&rv)); \
|
||||
if (NS_FAILED(rv)) { \
|
||||
*aInstancePtr = nullptr; \
|
||||
return rv; \
|
||||
} \
|
||||
\
|
||||
foundInterface = \
|
||||
sof->GetExternalClassInfoInstance(NS_LITERAL_STRING(#_class)); \
|
||||
\
|
||||
if (foundInterface) { \
|
||||
NS_CLASSINFO_NAME(_class) = foundInterface; \
|
||||
NS_CLASSINFO_NAME(_class)->AddRef(); \
|
||||
} \
|
||||
} \
|
||||
} else
|
||||
|
||||
|
||||
#define NS_DECL_DOM_CLASSINFO(_class) \
|
||||
nsISupports *NS_CLASSINFO_NAME(_class) = nullptr;
|
||||
|
||||
// {891a7b01-1b61-11d6-a7f2-f690b638899c}
|
||||
#define NS_IDOMCI_EXTENSION_IID \
|
||||
{ 0x891a7b01, 0x1b61, 0x11d6, \
|
||||
{ 0xa7, 0xf2, 0xf6, 0x90, 0xb6, 0x38, 0x89, 0x9c } }
|
||||
|
||||
class nsIDOMScriptObjectFactory;
|
||||
|
||||
class nsIDOMCIExtension : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCI_EXTENSION_IID)
|
||||
|
||||
NS_IMETHOD RegisterDOMCI(const char* aName,
|
||||
nsIDOMScriptObjectFactory* aDOMSOFactory) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMCIExtension, NS_IDOMCI_EXTENSION_IID)
|
||||
|
||||
#define NS_DOMCI_EXTENSION_NAME(_module) ns##_module##DOMCIExtension
|
||||
#define NS_DOMCI_EXTENSION_CONSTRUCTOR(_module) \
|
||||
ns##_module##DOMCIExtensionConstructor
|
||||
#define NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(_extension) \
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(_extension)
|
||||
|
||||
#define NS_DOMCI_EXTENSION(_module) \
|
||||
class NS_DOMCI_EXTENSION_NAME(_module) : public nsIDOMCIExtension \
|
||||
{ \
|
||||
public: \
|
||||
NS_DOMCI_EXTENSION_NAME(_module)(); \
|
||||
virtual ~NS_DOMCI_EXTENSION_NAME(_module)(); \
|
||||
\
|
||||
NS_DECL_ISUPPORTS \
|
||||
\
|
||||
NS_IMETHOD RegisterDOMCI(const char* aName, \
|
||||
nsIDOMScriptObjectFactory* aDOMSOFactory); \
|
||||
}; \
|
||||
\
|
||||
NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(NS_DOMCI_EXTENSION_NAME(_module)) \
|
||||
\
|
||||
NS_DOMCI_EXTENSION_NAME(_module)::NS_DOMCI_EXTENSION_NAME(_module)() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
NS_DOMCI_EXTENSION_NAME(_module)::~NS_DOMCI_EXTENSION_NAME(_module)() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
NS_IMPL_ISUPPORTS(NS_DOMCI_EXTENSION_NAME(_module), nsIDOMCIExtension) \
|
||||
\
|
||||
NS_IMETHODIMP \
|
||||
NS_DOMCI_EXTENSION_NAME(_module)::RegisterDOMCI(const char* aName, \
|
||||
nsIDOMScriptObjectFactory* aDOMSOFactory) \
|
||||
{
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_BEGIN(_class) \
|
||||
if (nsCRT::strcmp(aName, #_class) == 0) { \
|
||||
static const nsIID* interfaces[] = {
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_INTERFACE(_interface) \
|
||||
&NS_GET_IID(_interface),
|
||||
|
||||
// Don't forget to register the primary interface (_proto) in the
|
||||
// JAVASCRIPT_DOM_INTERFACE category, or prototypes for this class
|
||||
// won't work (except if the interface name starts with nsIDOM).
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, _proto, _hasclassif, \
|
||||
_constructorcid) \
|
||||
nullptr \
|
||||
}; \
|
||||
aDOMSOFactory->RegisterDOMClassInfo(#_class, nullptr, _proto, \
|
||||
interfaces, \
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS, \
|
||||
_hasclassif, _constructorcid); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_END(_class, _proto, _hasclassif, \
|
||||
_constructorcid) \
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, &NS_GET_IID(_proto), \
|
||||
_hasclassif, _constructorcid)
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(_class, _hasclassif, \
|
||||
_constructorcid) \
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, nullptr, _hasclassif, \
|
||||
_constructorcid)
|
||||
|
||||
#define NS_DOMCI_EXTENSION_END \
|
||||
return NS_ERROR_FAILURE; \
|
||||
}
|
||||
|
||||
|
||||
#endif /* nsIDOMClassInfo_h___ */
|
||||
|
||||
@@ -1,45 +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 nsIDOMScriptObjectFactory_h__
|
||||
#define nsIDOMScriptObjectFactory_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
|
||||
{ 0x2a50e17c, 0x46ff, 0x4150, \
|
||||
{ 0xbb, 0x46, 0xd8, 0x07, 0xb3, 0x36, 0xde, 0xab } }
|
||||
|
||||
typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
|
||||
(const char* aName);
|
||||
|
||||
class nsIDOMScriptObjectFactory : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
|
||||
|
||||
NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) = 0;
|
||||
NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName) = 0;
|
||||
|
||||
// Register the info for an external class. aName must be static
|
||||
// data, it will not be deleted by the DOM code. aProtoChainInterface
|
||||
// must be registered in the JAVASCRIPT_DOM_INTERFACE category, or
|
||||
// prototypes for this class won't work (except if the interface
|
||||
// name starts with nsIDOM).
|
||||
NS_IMETHOD RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,
|
||||
NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
|
||||
|
||||
#endif /* nsIDOMScriptObjectFactory_h__ */
|
||||
+24
-19
@@ -35,6 +35,8 @@
|
||||
#include "nsClassHashtable.h"
|
||||
#include "prclist.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include <bitset> // for member
|
||||
|
||||
class gfxUserFontSet;
|
||||
@@ -81,7 +83,6 @@ class nsPresContext;
|
||||
class nsRange;
|
||||
class nsScriptLoader;
|
||||
class nsSMILAnimationController;
|
||||
class nsStyleSet;
|
||||
class nsTextNode;
|
||||
class nsWindowSizes;
|
||||
class nsDOMCaretPosition;
|
||||
@@ -94,6 +95,7 @@ class CSSStyleSheet;
|
||||
class ErrorResult;
|
||||
class EventStates;
|
||||
class PendingAnimationTracker;
|
||||
class StyleSetHandle;
|
||||
class SVGAttrAnimationRuleProcessor;
|
||||
template<typename> class OwningNonNull;
|
||||
|
||||
@@ -682,9 +684,10 @@ public:
|
||||
* method is responsible for calling BeginObservingDocument() on the
|
||||
* presshell if the presshell should observe document mutations.
|
||||
*/
|
||||
virtual already_AddRefed<nsIPresShell> CreateShell(nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet) = 0;
|
||||
virtual already_AddRefed<nsIPresShell> CreateShell(
|
||||
nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
mozilla::StyleSetHandle aStyleSet) = 0;
|
||||
virtual void DeleteShell() = 0;
|
||||
|
||||
nsIPresShell* GetShell() const
|
||||
@@ -929,7 +932,7 @@ public:
|
||||
* TODO We can get rid of the whole concept of delayed loading if we fix
|
||||
* bug 77999.
|
||||
*/
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Get the number of (document) stylesheets
|
||||
@@ -945,7 +948,7 @@ public:
|
||||
* @return the stylesheet at aIndex. Null if aIndex is out of range.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
|
||||
virtual mozilla::StyleSheetHandle GetStyleSheetAt(int32_t aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
|
||||
@@ -954,7 +957,7 @@ public:
|
||||
* adjusted for the "special" sheets.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void InsertStyleSheetAt(mozilla::StyleSheetHandle aSheet,
|
||||
int32_t aIndex) = 0;
|
||||
|
||||
/**
|
||||
@@ -963,7 +966,7 @@ public:
|
||||
* @param aSheet the sheet to get the index of
|
||||
* @return aIndex the index of the sheet in the full list
|
||||
*/
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const = 0;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::StyleSheetHandle aSheet) const = 0;
|
||||
|
||||
/**
|
||||
* Replace the stylesheets in aOldSheets with the stylesheets in
|
||||
@@ -974,24 +977,24 @@ public:
|
||||
* will simply be removed.
|
||||
*/
|
||||
virtual void UpdateStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) = 0;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aOldSheets,
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aNewSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add a stylesheet to the document
|
||||
*/
|
||||
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void AddStyleSheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Remove a stylesheet from the document
|
||||
*/
|
||||
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void RemoveStyleSheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the applicable state of the sheet changed
|
||||
* and that observers should be notified and style sets updated
|
||||
*/
|
||||
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void SetStyleSheetApplicableState(mozilla::StyleSheetHandle aSheet,
|
||||
bool aApplicable) = 0;
|
||||
|
||||
enum additionalSheetType {
|
||||
@@ -1004,10 +1007,10 @@ public:
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI) = 0;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
mozilla::StyleSheetHandle aSheet) = 0;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* sheetURI) = 0;
|
||||
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() = 0;
|
||||
virtual mozilla::StyleSheetHandle FirstAdditionalAuthorSheet() = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. This is guaranteed to not return null.
|
||||
@@ -1016,6 +1019,8 @@ public:
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType GetStyleBackendType() const;
|
||||
|
||||
/**
|
||||
* Get this document's StyleImageLoader. This is guaranteed to not return null.
|
||||
*/
|
||||
@@ -1310,11 +1315,11 @@ public:
|
||||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
@@ -2137,7 +2142,7 @@ public:
|
||||
* DO NOT USE FOR UNTRUSTED CONTENT.
|
||||
*/
|
||||
virtual nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet,
|
||||
mozilla::CSSStyleSheet** aSheet) = 0;
|
||||
mozilla::StyleSheetHandle::RefPtr* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the locale used for the document specifies a direction of
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define nsIDocumentObserver_h___
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIMutationObserver.h"
|
||||
|
||||
@@ -14,7 +15,6 @@ class nsIContent;
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
namespace css {
|
||||
class Rule;
|
||||
} // namespace css
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
||||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleSheetAdded(mozilla::StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
||||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleSheetRemoved(mozilla::StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that has changed state
|
||||
*/
|
||||
virtual void StyleSheetApplicableStateChanged(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleSheetApplicableStateChanged(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been modified within a style sheet.
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that contians the rule
|
||||
*/
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been added to a style sheet.
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
*/
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been removed from a style sheet.
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
*/
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
||||
@@ -186,25 +186,25 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
||||
mozilla::EventStates aStateMask) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
|
||||
virtual void StyleSheetAdded(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
virtual void StyleSheetAdded(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
|
||||
virtual void StyleSheetRemoved(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
virtual void StyleSheetRemoved(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
|
||||
virtual void StyleSheetApplicableStateChanged( \
|
||||
mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
|
||||
@@ -262,29 +262,29 @@ NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
|
||||
void \
|
||||
_class::StyleSheetAdded(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
_class::StyleSheetAdded(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetRemoved(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
_class::StyleSheetRemoved(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetApplicableStateChanged(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleSheetApplicableStateChanged(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
#define JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY \
|
||||
"JavaScript-global-constructor"
|
||||
|
||||
#define JAVASCRIPT_GLOBAL_CONSTRUCTOR_PROTO_ALIAS_CATEGORY \
|
||||
"JavaScript-global-constructor-prototype-alias"
|
||||
|
||||
#define JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY \
|
||||
"JavaScript-global-property"
|
||||
|
||||
@@ -23,10 +20,4 @@
|
||||
#define JAVASCRIPT_NAVIGATOR_PROPERTY_CATEGORY \
|
||||
"JavaScript-navigator-property"
|
||||
|
||||
#define JAVASCRIPT_DOM_CLASS \
|
||||
"JavaScript-DOM-class"
|
||||
|
||||
#define JAVASCRIPT_DOM_INTERFACE \
|
||||
"JavaScript-DOM-interface"
|
||||
|
||||
#endif /* nsIScriptNameSpaceManager_h__ */
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
class nsICSSLoaderObserver;
|
||||
class nsIURI;
|
||||
@@ -16,10 +17,6 @@ class nsIURI;
|
||||
{ 0xa8b79f3b, 0x9d18, 0x4f9c, \
|
||||
{ 0xb1, 0xaa, 0x8c, 0x9b, 0x1b, 0xaa, 0xac, 0xad } }
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsIStyleSheetLinkingElement : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLESHEETLINKINGELEMENT_IID)
|
||||
@@ -31,14 +28,14 @@ public:
|
||||
* @param aStyleSheet the style sheet associated with this
|
||||
* element.
|
||||
*/
|
||||
NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
NS_IMETHOD SetStyleSheet(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* Used to obtain the style sheet linked in by this element.
|
||||
*
|
||||
* @return the style sheet associated with this element.
|
||||
*/
|
||||
NS_IMETHOD_(mozilla::CSSStyleSheet*) GetStyleSheet() = 0;
|
||||
NS_IMETHOD_(mozilla::StyleSheetHandle) GetStyleSheet() = 0;
|
||||
|
||||
/**
|
||||
* Initialize the stylesheet linking element. If aDontLoadStyle is
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsScriptNameSpaceManager.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/DOMExceptionBinding.h"
|
||||
#include "mozilla/dom/ErrorEvent.h"
|
||||
#include "nsAXPCNativeCallContext.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
@@ -223,6 +225,59 @@ ProcessNameForCollectorLog()
|
||||
"default" : "content";
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
|
||||
// This handles JS Exceptions (via ExceptionStackOrNull), as well as DOM and XPC
|
||||
// Exceptions.
|
||||
//
|
||||
// Note that the returned object is _not_ wrapped into the compartment of
|
||||
// exceptionValue.
|
||||
JSObject*
|
||||
FindExceptionStackForConsoleReport(nsPIDOMWindow* win,
|
||||
JS::HandleValue exceptionValue)
|
||||
{
|
||||
if (!exceptionValue.isObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (win && win->InnerObjectsFreed()) {
|
||||
// Pretend like we have no stack, so we don't end up keeping the global
|
||||
// alive via the stack.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSContext* cx = nsContentUtils::RootingCxForThread();
|
||||
JS::RootedObject exceptionObject(cx, &exceptionValue.toObject());
|
||||
JSObject* stackObject = ExceptionStackOrNull(exceptionObject);
|
||||
if (stackObject) {
|
||||
return stackObject;
|
||||
}
|
||||
|
||||
// It is not a JS Exception, try DOM Exception.
|
||||
RefPtr<Exception> exception;
|
||||
UNWRAP_OBJECT(DOMException, exceptionObject, exception);
|
||||
if (!exception) {
|
||||
// Not a DOM Exception, try XPC Exception.
|
||||
UNWRAP_OBJECT(Exception, exceptionObject, exception);
|
||||
if (!exception) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> stack = exception->GetLocation();
|
||||
if (!stack) {
|
||||
return nullptr;
|
||||
}
|
||||
JS::RootedValue value(cx);
|
||||
stack->GetNativeSavedFrame(&value);
|
||||
if (value.isObject()) {
|
||||
return &value.toObject();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} /* namespace xpc */
|
||||
|
||||
static PRTime
|
||||
GetCollectionTimeDelta()
|
||||
{
|
||||
@@ -381,8 +436,10 @@ public:
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsPIDOMWindow* win = mWindow;
|
||||
MOZ_ASSERT(win);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// First, notify the DOM that we have a script error, but only if
|
||||
// our window is still the current inner.
|
||||
JSContext* rootingCx = nsContentUtils::RootingCx();
|
||||
if (win->IsCurrentInnerWindow() && win->GetDocShell() && !sHandlingScriptError) {
|
||||
AutoRestore<bool> recursionGuard(sHandlingScriptError);
|
||||
sHandlingScriptError = true;
|
||||
@@ -390,8 +447,7 @@ public:
|
||||
RefPtr<nsPresContext> presContext;
|
||||
win->GetDocShell()->GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
RootedDictionary<ErrorEventInit> init(cx);
|
||||
RootedDictionary<ErrorEventInit> init(rootingCx);
|
||||
init.mCancelable = true;
|
||||
init.mFilename = mReport->mFileName;
|
||||
init.mBubbles = true;
|
||||
@@ -418,20 +474,9 @@ public:
|
||||
}
|
||||
|
||||
if (status != nsEventStatus_eConsumeNoDefault) {
|
||||
if (mError.isObject()) {
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(mError.toObjectOrNull()))) {
|
||||
mReport->LogToConsole();
|
||||
return NS_OK;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JSObject*> exObj(cx, mError.toObjectOrNull());
|
||||
JS::RootedObject stack(cx, ExceptionStackOrNull(cx, exObj));
|
||||
mReport->LogToConsoleWithStack(stack);
|
||||
} else {
|
||||
mReport->LogToConsole();
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> stack(rootingCx,
|
||||
xpc::FindExceptionStackForConsoleReport(win, mError));
|
||||
mReport->LogToConsoleWithStack(stack);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -509,14 +554,9 @@ SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
if (!win || JSREPORT_IS_WARNING(xpcReport->mFlags) ||
|
||||
report->errorNumber == JSMSG_OUT_OF_MEMORY)
|
||||
{
|
||||
if (exception.isObject()) {
|
||||
JS::RootedObject exObj(cx, exception.toObjectOrNull());
|
||||
JSAutoCompartment ac(cx, exObj);
|
||||
JS::RootedObject stackVal(cx, ExceptionStackOrNull(cx, exObj));
|
||||
xpcReport->LogToConsoleWithStack(stackVal);
|
||||
} else {
|
||||
xpcReport->LogToConsole();
|
||||
}
|
||||
JS::Rooted<JSObject*> stack(cx,
|
||||
xpc::FindExceptionStackForConsoleReport(win, exception));
|
||||
xpcReport->LogToConsoleWithStack(stack);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -799,15 +839,15 @@ nsresult
|
||||
nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, nsISupports* aArgs)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetGlobalObject()))) {
|
||||
if (NS_WARN_IF(!jsapi.Init(GetGlobalObject()))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
MOZ_ASSERT(jsapi.cx() == mContext,
|
||||
"AutoJSAPI should have found our own JSContext*");
|
||||
jsapi.TakeOwnershipOfErrorReporting();
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::AutoValueVector args(mContext);
|
||||
JS::AutoValueVector args(cx);
|
||||
|
||||
JS::Rooted<JSObject*> global(mContext, GetWindowProxy());
|
||||
JS::Rooted<JSObject*> global(cx, GetWindowProxy());
|
||||
nsresult rv =
|
||||
ConvertSupportsTojsvals(aArgs, global, args);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -815,17 +855,17 @@ nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, n
|
||||
// got the arguments, now attach them.
|
||||
|
||||
for (uint32_t i = 0; i < args.length(); ++i) {
|
||||
if (!JS_WrapValue(mContext, args[i])) {
|
||||
if (!JS_WrapValue(cx, args[i])) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> array(mContext, ::JS_NewArrayObject(mContext, args));
|
||||
JS::Rooted<JSObject*> array(cx, ::JS_NewArrayObject(cx, args));
|
||||
if (!array) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return JS_DefineProperty(mContext, aTarget, aPropName, array, 0) ? NS_OK : NS_ERROR_FAILURE;
|
||||
return JS_DefineProperty(cx, aTarget, aPropName, array, 0) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -1400,6 +1440,11 @@ TimeUntilNow(TimeStamp start)
|
||||
|
||||
struct CycleCollectorStats
|
||||
{
|
||||
MOZ_CONSTEXPR CycleCollectorStats() :
|
||||
mMaxGCDuration(0), mRanSyncForgetSkippable(false), mSuspected(0),
|
||||
mMaxSkippableDuration(0), mMaxSliceTime(0), mMaxSliceTimeSinceClear(0),
|
||||
mTotalSliceTime(0), mAnyLockedOut(false), mExtraForgetSkippableCalls(0) {}
|
||||
|
||||
void Init()
|
||||
{
|
||||
Clear();
|
||||
@@ -2527,8 +2572,6 @@ AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
|
||||
aSize, aMemory, aHandle);
|
||||
}
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
void
|
||||
nsJSContext::EnsureStatics()
|
||||
{
|
||||
@@ -2663,15 +2706,6 @@ nsJSContext::EnsureStatics()
|
||||
obs->AddObserver(observer, "quit-application", false);
|
||||
obs->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
|
||||
// Bug 907848 - We need to explicitly get the nsIDOMScriptObjectFactory
|
||||
// service in order to force its constructor to run, which registers a
|
||||
// shutdown observer. It would be nice to make this more explicit and less
|
||||
// side-effect-y.
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
|
||||
if (!factory) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
sIsInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
+4
-15
@@ -37,7 +37,7 @@ bool
|
||||
nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
|
||||
uint32_t* aLineno, uint32_t* aColumn)
|
||||
{
|
||||
JS::UniqueChars filename;
|
||||
JS::AutoFilename filename;
|
||||
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, aColumn)) {
|
||||
return false;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ bool
|
||||
nsJSUtils::GetCallingLocation(JSContext* aContext, nsAString& aFilename,
|
||||
uint32_t* aLineno, uint32_t* aColumn)
|
||||
{
|
||||
JS::UniqueChars filename;
|
||||
JS::AutoFilename filename;
|
||||
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, aColumn)) {
|
||||
return false;
|
||||
}
|
||||
@@ -83,19 +83,8 @@ nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext)
|
||||
if (!aContext)
|
||||
return 0;
|
||||
|
||||
uint64_t innerWindowID = 0;
|
||||
|
||||
JSObject *jsGlobal = JS::CurrentGlobalOrNull(aContext);
|
||||
if (jsGlobal) {
|
||||
nsIScriptGlobalObject *scriptGlobal = GetStaticScriptGlobal(jsGlobal);
|
||||
if (scriptGlobal) {
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(scriptGlobal);
|
||||
if (win)
|
||||
innerWindowID = win->WindowID();
|
||||
}
|
||||
}
|
||||
|
||||
return innerWindowID;
|
||||
nsGlobalWindow* win = xpc::CurrentWindowOrNull(aContext);
|
||||
return win ? win->WindowID() : 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -3581,11 +3581,15 @@ nsObjectLoadingContent::TeardownProtoChain()
|
||||
nsCOMPtr<nsIContent> thisContent =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
|
||||
// Use the safe JSContext here as we're not always able to find the
|
||||
// JSContext associated with the NPP any more.
|
||||
AutoSafeJSContext cx;
|
||||
NS_ENSURE_TRUE_VOID(thisContent->GetWrapper());
|
||||
|
||||
// We don't init the AutoJSAPI with our wrapper because we don't want it
|
||||
// reporting errors to our window's onerror listeners.
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JSObject*> obj(cx, thisContent->GetWrapper());
|
||||
NS_ENSURE_TRUE(obj, /* void */);
|
||||
MOZ_ASSERT(obj);
|
||||
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
@@ -539,6 +539,14 @@ public:
|
||||
mMayHavePointerEnterLeaveEventListener = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this has had inner objects freed.
|
||||
*/
|
||||
bool InnerObjectsFreed() const
|
||||
{
|
||||
return mInnerObjectsFreed;
|
||||
}
|
||||
|
||||
|
||||
virtual JSObject* GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) = 0;
|
||||
virtual void CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
|
||||
@@ -829,6 +837,12 @@ protected:
|
||||
bool mMayHaveMouseEnterLeaveEventListener;
|
||||
bool mMayHavePointerEnterLeaveEventListener;
|
||||
|
||||
// Used to detect whether we have called FreeInnerObjects() (e.g. to ensure
|
||||
// that a call to ResumeTimeouts() after FreeInnerObjects() does nothing).
|
||||
// This member is only used by inner windows.
|
||||
bool mInnerObjectsFreed;
|
||||
|
||||
|
||||
// This variable is used on both inner and outer windows (and they
|
||||
// should match).
|
||||
bool mIsModalContentWindow;
|
||||
|
||||
@@ -849,9 +849,10 @@ nsScriptLoader::AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest)
|
||||
}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.InitWithLegacyErrorReporting(globalObject)) {
|
||||
if (!jsapi.Init(globalObject)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
jsapi.TakeOwnershipOfErrorReporting();
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JSObject*> global(cx, globalObject->GetGlobalJSObject());
|
||||
|
||||
@@ -61,21 +61,6 @@ GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
// An entry is being cleared, let the key (nsString) do its own
|
||||
// cleanup.
|
||||
e->mKey.~nsString();
|
||||
if (e->mGlobalName.mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
nsIClassInfo* ci = GET_CLEAN_CI_PTR(e->mGlobalName.mData->mCachedClassInfo);
|
||||
|
||||
// If we constructed an internal helper, we'll let the helper delete
|
||||
// the nsDOMClassInfoData structure, if not we do it here.
|
||||
if (!ci || e->mGlobalName.mData->u.mExternalConstructorFptr) {
|
||||
delete e->mGlobalName.mData;
|
||||
}
|
||||
|
||||
// Release our pointer to the helper.
|
||||
NS_IF_RELEASE(ci);
|
||||
}
|
||||
else if (e->mGlobalName.mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||
delete e->mGlobalName.mAlias;
|
||||
}
|
||||
|
||||
// This will set e->mGlobalName.mType to
|
||||
// nsGlobalNameStruct::eTypeNotInitialized
|
||||
@@ -151,21 +136,6 @@ nsScriptNameSpaceManager::RemoveFromHash(PLDHashTable *aTable,
|
||||
aTable->Remove(aKey);
|
||||
}
|
||||
|
||||
nsGlobalNameStruct*
|
||||
nsScriptNameSpaceManager::GetConstructorProto(const nsGlobalNameStruct* aStruct)
|
||||
{
|
||||
NS_ASSERTION(aStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias,
|
||||
"This function only works on constructor aliases!");
|
||||
if (!aStruct->mAlias->mProto) {
|
||||
auto proto = static_cast<GlobalNameMapEntry*>
|
||||
(mGlobalNames.Search(&aStruct->mAlias->mProtoName));
|
||||
if (proto) {
|
||||
aStruct->mAlias->mProto = &proto->mGlobalName;
|
||||
}
|
||||
}
|
||||
return aStruct->mAlias->mProto;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
|
||||
const char *aCategory)
|
||||
@@ -187,116 +157,6 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterExternalInterfaces(bool aAsProto)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager>
|
||||
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_INTERFACE,
|
||||
getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString IID_string;
|
||||
nsAutoCString category_entry;
|
||||
const char* if_name;
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||
bool found_old, dom_prefix;
|
||||
|
||||
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
|
||||
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
|
||||
|
||||
if (!category) {
|
||||
NS_WARNING("Category entry not an nsISupportsCString!");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = category->GetData(category_entry);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry.get(),
|
||||
getter_Copies(IID_string));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIID primary_IID;
|
||||
if (!primary_IID.Parse(IID_string) ||
|
||||
primary_IID.Equals(NS_GET_IID(nsISupports))) {
|
||||
NS_ERROR("Invalid IID registered with the script namespace manager!");
|
||||
continue;
|
||||
}
|
||||
|
||||
iim->GetInfoForIID(&primary_IID, getter_AddRefs(if_info));
|
||||
|
||||
while (if_info) {
|
||||
const nsIID *iid;
|
||||
if_info->GetIIDShared(&iid);
|
||||
NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (iid->Equals(NS_GET_IID(nsISupports))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if_info->GetNameShared(&if_name);
|
||||
dom_prefix = (strncmp(if_name, NS_DOM_INTERFACE_PREFIX,
|
||||
sizeof(NS_DOM_INTERFACE_PREFIX) - 1) == 0);
|
||||
|
||||
const char* name;
|
||||
if (dom_prefix) {
|
||||
name = if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1;
|
||||
} else {
|
||||
name = if_name + sizeof(NS_INTERFACE_PREFIX) - 1;
|
||||
}
|
||||
|
||||
if (aAsProto) {
|
||||
RegisterClassProto(name, iid, &found_old);
|
||||
} else {
|
||||
RegisterInterface(name, iid, &found_old);
|
||||
}
|
||||
|
||||
if (found_old) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
|
||||
tmp->GetParent(getter_AddRefs(if_info));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterInterface(const char* aIfName,
|
||||
const nsIID *aIfIID,
|
||||
bool* aFoundOld)
|
||||
{
|
||||
*aFoundOld = false;
|
||||
|
||||
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, aIfName);
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
||||
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) {
|
||||
*aFoundOld = true;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeInterface;
|
||||
s->mIID = *aIfIID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::Init()
|
||||
{
|
||||
@@ -304,9 +164,6 @@ nsScriptNameSpaceManager::Init()
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = RegisterExternalInterfaces(false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -389,8 +246,7 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
||||
}
|
||||
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
|
||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
||||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding,
|
||||
"Whaaa, JS environment name clash!");
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
|
||||
@@ -414,8 +270,7 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
||||
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding &&
|
||||
s->mType != nsGlobalNameStruct::eTypeInterface) {
|
||||
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) {
|
||||
*aFoundOld = true;
|
||||
|
||||
return NS_OK;
|
||||
@@ -427,77 +282,6 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
|
||||
nsCID& aCID)
|
||||
{
|
||||
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, aClassName);
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// If an external constructor is already defined with aClassName we
|
||||
// won't overwrite it.
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
|
||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
||||
"Whaaa, JS environment name clash!");
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfoCreator;
|
||||
s->mCID = aCID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterDOMCIData(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
{
|
||||
const char16_t* className;
|
||||
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, aName, &className);
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// If an external constructor is already defined with aClassName we
|
||||
// won't overwrite it.
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX Should we bail out here?
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
|
||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
||||
"Someone tries to register classinfo data for a class that isn't new or external!");
|
||||
|
||||
s->mData = new nsExternalDOMClassInfoData;
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfo;
|
||||
s->mData->mName = aName;
|
||||
s->mData->mNameUTF16 = className;
|
||||
if (aConstructorFptr)
|
||||
s->mData->u.mExternalConstructorFptr = aConstructorFptr;
|
||||
else
|
||||
// null constructor will cause us to use nsDOMGenericSH::doCreate
|
||||
s->mData->u.mExternalConstructorFptr = nullptr;
|
||||
s->mData->mCachedClassInfo = nullptr;
|
||||
s->mData->mProtoChainInterface = aProtoChainInterface;
|
||||
s->mData->mInterfaces = aInterfaces;
|
||||
s->mData->mScriptableFlags = aScriptableFlags;
|
||||
s->mData->mHasClassInterface = aHasClassInterface;
|
||||
s->mData->mConstructorCID = aConstructorCID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategoryManager,
|
||||
const char* aCategory,
|
||||
@@ -591,31 +375,6 @@ nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategory
|
||||
nsCID cid = *cidPtr;
|
||||
free(cidPtr);
|
||||
|
||||
if (type == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
nsXPIDLCString constructorProto;
|
||||
rv = aCategoryManager->GetCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_PROTO_ALIAS_CATEGORY,
|
||||
categoryEntry.get(),
|
||||
getter_Copies(constructorProto));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, categoryEntry.get());
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding) {
|
||||
s->mAlias = new nsGlobalNameStruct::ConstructorAlias;
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalConstructorAlias;
|
||||
s->mChromeOnly = false;
|
||||
s->mAlias->mCID = cid;
|
||||
AppendASCIItoUTF16(constructorProto, s->mAlias->mProtoName);
|
||||
s->mAlias->mProto = nullptr;
|
||||
} else {
|
||||
NS_WARNING("Global script name not overwritten!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsGlobalNameStruct *s = AddToHash(table, categoryEntry.get());
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
||||
@@ -36,25 +36,14 @@
|
||||
|
||||
struct nsGlobalNameStruct
|
||||
{
|
||||
struct ConstructorAlias
|
||||
{
|
||||
nsCID mCID;
|
||||
nsString mProtoName;
|
||||
nsGlobalNameStruct* mProto;
|
||||
};
|
||||
|
||||
enum nametype {
|
||||
eTypeNotInitialized,
|
||||
eTypeNewDOMBinding,
|
||||
eTypeInterface,
|
||||
eTypeProperty,
|
||||
eTypeNavigatorProperty,
|
||||
eTypeExternalConstructor,
|
||||
eTypeClassConstructor,
|
||||
eTypeClassProto,
|
||||
eTypeExternalClassInfoCreator,
|
||||
eTypeExternalClassInfo,
|
||||
eTypeExternalConstructorAlias
|
||||
} mType;
|
||||
|
||||
// mChromeOnly is only used for structs that define non-WebIDL things
|
||||
@@ -65,9 +54,7 @@ struct nsGlobalNameStruct
|
||||
|
||||
union {
|
||||
int32_t mDOMClassInfoID; // eTypeClassConstructor
|
||||
nsIID mIID; // eTypeInterface, eTypeClassProto
|
||||
nsExternalDOMClassInfoData* mData; // eTypeExternalClassInfo
|
||||
ConstructorAlias* mAlias; // eTypeExternalConstructorAlias
|
||||
nsIID mIID; // eTypeClassProto
|
||||
nsCID mCID; // All other types except eTypeNewDOMBinding
|
||||
};
|
||||
|
||||
@@ -137,23 +124,6 @@ public:
|
||||
const nsIID *aConstructorProtoIID,
|
||||
bool *aFoundOld);
|
||||
|
||||
nsresult RegisterExternalInterfaces(bool aAsProto);
|
||||
|
||||
nsresult RegisterExternalClassName(const char *aClassName,
|
||||
nsCID& aCID);
|
||||
|
||||
// Register the info for an external class. aName must be static
|
||||
// data, it will not be deleted by the DOM code.
|
||||
nsresult RegisterDOMCIData(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID);
|
||||
|
||||
nsGlobalNameStruct* GetConstructorProto(const nsGlobalNameStruct* aStruct);
|
||||
|
||||
void RegisterDefineDOMInterface(const nsAFlatString& aName,
|
||||
mozilla::dom::DefineInterface aDefineDOMInterface,
|
||||
mozilla::dom::ConstructorEnabled* aConstructorEnabled);
|
||||
|
||||
@@ -58,8 +58,7 @@ nsStructuredCloneContainer::InitFromJSVal(JS::Handle<JS::Value> aData,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStructuredCloneContainer::InitFromBase64(const nsAString &aData,
|
||||
uint32_t aFormatVersion,
|
||||
JSContext* aCx)
|
||||
uint32_t aFormatVersion)
|
||||
{
|
||||
if (DataLength()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
#include "nsStyleLinkElement.h"
|
||||
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/FragmentOrElement.h"
|
||||
@@ -67,7 +68,7 @@ nsStyleLinkElement::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStyleLinkElement::SetStyleSheet(CSSStyleSheet* aStyleSheet)
|
||||
nsStyleLinkElement::SetStyleSheet(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
if (mStyleSheet) {
|
||||
mStyleSheet->SetOwningNode(nullptr);
|
||||
@@ -84,7 +85,7 @@ nsStyleLinkElement::SetStyleSheet(CSSStyleSheet* aStyleSheet)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(CSSStyleSheet*)
|
||||
NS_IMETHODIMP_(StyleSheetHandle)
|
||||
nsStyleLinkElement::GetStyleSheet()
|
||||
{
|
||||
return mStyleSheet;
|
||||
@@ -316,8 +317,15 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element* oldScopeElement =
|
||||
mStyleSheet ? mStyleSheet->GetScopeElement() : nullptr;
|
||||
// XXXheycam ServoStyleSheets do not support <style scoped>.
|
||||
Element* oldScopeElement = nullptr;
|
||||
if (mStyleSheet) {
|
||||
if (mStyleSheet->IsServo()) {
|
||||
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
|
||||
} else {
|
||||
oldScopeElement = mStyleSheet->AsGecko()->GetScopeElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
|
||||
MOZ_ASSERT(!(aOldDocument && aOldShadowRoot),
|
||||
@@ -465,10 +473,18 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStyleSheet->IsServo()) {
|
||||
// XXXheycam ServoStyleSheets don't support <style scoped>.
|
||||
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
|
||||
return;
|
||||
}
|
||||
|
||||
CSSStyleSheet* sheet = mStyleSheet->AsGecko();
|
||||
|
||||
nsCOMPtr<nsIContent> thisContent;
|
||||
CallQueryInterface(this, getter_AddRefs(thisContent));
|
||||
|
||||
Element* oldScopeElement = mStyleSheet->GetScopeElement();
|
||||
Element* oldScopeElement = sheet->GetScopeElement();
|
||||
Element* newScopeElement = aIsNowScoped ?
|
||||
thisContent->GetParentElement() :
|
||||
nullptr;
|
||||
@@ -483,14 +499,14 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
|
||||
ShadowRoot* containingShadow = thisContent->GetContainingShadow();
|
||||
containingShadow->RemoveSheet(mStyleSheet);
|
||||
|
||||
mStyleSheet->SetScopeElement(newScopeElement);
|
||||
sheet->SetScopeElement(newScopeElement);
|
||||
|
||||
containingShadow->InsertSheet(mStyleSheet, thisContent);
|
||||
} else {
|
||||
document->BeginUpdate(UPDATE_STYLE);
|
||||
document->RemoveStyleSheet(mStyleSheet);
|
||||
|
||||
mStyleSheet->SetScopeElement(newScopeElement);
|
||||
sheet->SetScopeElement(newScopeElement);
|
||||
|
||||
document->AddStyleSheet(mStyleSheet);
|
||||
document->EndUpdate(UPDATE_STYLE);
|
||||
|
||||
@@ -24,6 +24,7 @@ class nsIDocument;
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
namespace dom {
|
||||
class ShadowRoot;
|
||||
} // namespace dom
|
||||
@@ -37,11 +38,19 @@ public:
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override = 0;
|
||||
|
||||
mozilla::CSSStyleSheet* GetSheet() const { return mStyleSheet; }
|
||||
mozilla::CSSStyleSheet* GetSheet() const
|
||||
{
|
||||
// XXXheycam Return nullptr for ServoStyleSheets until we have a way of
|
||||
// exposing them to script.
|
||||
NS_ASSERTION(!mStyleSheet || mStyleSheet->IsGecko(),
|
||||
"stylo: ServoStyleSheets can't be exposed to script yet");
|
||||
return mStyleSheet && mStyleSheet->IsGecko() ? mStyleSheet->AsGecko() :
|
||||
nullptr;
|
||||
}
|
||||
|
||||
// nsIStyleSheetLinkingElement
|
||||
NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
NS_IMETHOD_(mozilla::CSSStyleSheet*) GetStyleSheet() override;
|
||||
NS_IMETHOD SetStyleSheet(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
NS_IMETHOD_(mozilla::StyleSheetHandle) GetStyleSheet() override;
|
||||
NS_IMETHOD InitStyleLinkElement(bool aDontLoadStyle) override;
|
||||
NS_IMETHOD UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
|
||||
bool* aWillNotify,
|
||||
@@ -128,7 +137,7 @@ private:
|
||||
bool* aIsAlternate,
|
||||
bool aForceUpdate);
|
||||
|
||||
RefPtr<mozilla::CSSStyleSheet> mStyleSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mStyleSheet;
|
||||
protected:
|
||||
bool mDontLoadStyle;
|
||||
bool mUpdatesEnabled;
|
||||
|
||||
@@ -2445,13 +2445,13 @@ GetRequestBody(nsIVariant* aBody, nsIInputStream** aResult, uint64_t* aContentLe
|
||||
}
|
||||
|
||||
// ArrayBuffer?
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> realVal(cx);
|
||||
JSContext* rootingCx = nsContentUtils::RootingCx();
|
||||
JS::Rooted<JS::Value> realVal(rootingCx);
|
||||
|
||||
nsresult rv = aBody->GetAsJSVal(&realVal);
|
||||
if (NS_SUCCEEDED(rv) && !realVal.isPrimitive()) {
|
||||
JS::Rooted<JSObject*> obj(cx, realVal.toObjectOrNull());
|
||||
ArrayBuffer buf;
|
||||
JS::Rooted<JSObject*> obj(rootingCx, realVal.toObjectOrNull());
|
||||
RootedTypedArray<ArrayBuffer> buf(rootingCx);
|
||||
if (buf.Init(obj)) {
|
||||
buf.ComputeLengthAndData();
|
||||
return GetRequestBody(buf.Data(), buf.Length(), aResult,
|
||||
|
||||
@@ -497,6 +497,22 @@ ErrorResult::SetPendingException(JSContext* cx)
|
||||
SetPendingGenericErrorException(cx);
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::StealExceptionFromJSContext(JSContext* cx)
|
||||
{
|
||||
MOZ_ASSERT(mMightHaveUnreportedJSException,
|
||||
"Why didn't you tell us you planned to throw a JS exception?");
|
||||
|
||||
JS::Rooted<JS::Value> exn(cx);
|
||||
if (!JS_GetPendingException(cx, &exn)) {
|
||||
ThrowUncatchableException();
|
||||
return;
|
||||
}
|
||||
|
||||
ThrowJSException(cx, exn);
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
bool
|
||||
|
||||
@@ -413,6 +413,7 @@ DOMInterfaces = {
|
||||
'binaryNames': {
|
||||
'message': 'messageMoz',
|
||||
},
|
||||
'implicitJSContext': [ 'filename', 'lineNumber', 'stack' ],
|
||||
},
|
||||
|
||||
'DOMMatrixReadOnly': {
|
||||
@@ -482,6 +483,7 @@ DOMInterfaces = {
|
||||
'binaryNames': {
|
||||
'message': 'messageMoz',
|
||||
},
|
||||
'implicitJSContext': [ '__stringifier', 'filename', 'lineNumber', 'stack' ],
|
||||
},
|
||||
|
||||
'ExtendableEvent': {
|
||||
@@ -1589,16 +1591,13 @@ DOMInterfaces = {
|
||||
'Worker': {
|
||||
'headerFile': 'mozilla/dom/WorkerPrivate.h',
|
||||
'nativeType': 'mozilla::dom::workers::WorkerPrivate',
|
||||
'implicitJSContext': [
|
||||
'terminate',
|
||||
],
|
||||
},
|
||||
|
||||
'WorkerDebuggerGlobalScope': {
|
||||
'headerFile': 'mozilla/dom/WorkerScope.h',
|
||||
'nativeType': 'mozilla::dom::workers::WorkerDebuggerGlobalScope',
|
||||
'implicitJSContext': [
|
||||
'dump', 'global', 'setImmediate', 'reportError',
|
||||
'dump', 'global', 'reportError',
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1607,7 +1606,7 @@ DOMInterfaces = {
|
||||
'workers': True,
|
||||
'concrete': False,
|
||||
'implicitJSContext': [
|
||||
'close', 'importScripts',
|
||||
'close',
|
||||
],
|
||||
# Rename a few things so we don't have both classes and methods
|
||||
# with the same name
|
||||
|
||||
@@ -322,7 +322,11 @@ CallbackObjectHolderBase::ToXPCOMCallback(CallbackObject* aCallback,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
// We don't init the AutoJSAPI with our callback because we don't want it
|
||||
// reporting errors to its global's onerror handlers.
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::Rooted<JSObject*> callback(cx, aCallback->Callback());
|
||||
|
||||
|
||||
@@ -12843,6 +12843,46 @@ class CGRegisterWorkerBindings(CGAbstractMethod):
|
||||
lines.append(CGGeneric("return true;\n"))
|
||||
return CGList(lines, "\n").define()
|
||||
|
||||
class CGRegisterWorkerDebuggerBindings(CGAbstractMethod):
|
||||
def __init__(self, config):
|
||||
CGAbstractMethod.__init__(self, None, 'RegisterWorkerDebuggerBindings', 'bool',
|
||||
[Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aObj')])
|
||||
self.config = config
|
||||
|
||||
def definition_body(self):
|
||||
# We have to be a bit careful: Some of the interfaces we want to expose
|
||||
# in workers only have one descriptor, while others have both a worker
|
||||
# and a non-worker descriptor. When both are present we want the worker
|
||||
# descriptor, but otherwise we want whatever descriptor we've got.
|
||||
descriptors = self.config.getDescriptors(hasInterfaceObject=True,
|
||||
isExposedInWorkerDebugger=True,
|
||||
register=True,
|
||||
skipGen=False,
|
||||
workers=True)
|
||||
workerDescriptorIfaceNames = set(d.interface.identifier.name for
|
||||
d in descriptors)
|
||||
descriptors.extend(
|
||||
filter(
|
||||
lambda d: d.interface.identifier.name not in workerDescriptorIfaceNames,
|
||||
self.config.getDescriptors(hasInterfaceObject=True,
|
||||
isExposedInWorkerDebugger=True,
|
||||
register=True,
|
||||
skipGen=False,
|
||||
workers=False)))
|
||||
conditions = []
|
||||
for desc in descriptors:
|
||||
bindingNS = toBindingNamespace(desc.name)
|
||||
condition = "!%s::GetConstructorObject(aCx, aObj)" % bindingNS
|
||||
if desc.isExposedConditionally():
|
||||
condition = (
|
||||
"%s::ConstructorEnabled(aCx, aObj) && " % bindingNS
|
||||
+ condition)
|
||||
conditions.append(condition)
|
||||
lines = [CGIfWrapper(CGGeneric("return false;\n"), condition) for
|
||||
condition in conditions]
|
||||
lines.append(CGGeneric("return true;\n"))
|
||||
return CGList(lines, "\n").define()
|
||||
|
||||
class CGResolveSystemBinding(CGAbstractMethod):
|
||||
def __init__(self, config):
|
||||
@@ -16098,6 +16138,32 @@ class GlobalGenRoots():
|
||||
# Done.
|
||||
return curr
|
||||
|
||||
@staticmethod
|
||||
def RegisterWorkerDebuggerBindings(config):
|
||||
|
||||
curr = CGRegisterWorkerDebuggerBindings(config)
|
||||
|
||||
# Wrap all of that in our namespaces.
|
||||
curr = CGNamespace.build(['mozilla', 'dom'],
|
||||
CGWrapper(curr, post='\n'))
|
||||
curr = CGWrapper(curr, post='\n')
|
||||
|
||||
# Add the includes
|
||||
defineIncludes = [CGHeaders.getDeclarationFilename(desc.interface)
|
||||
for desc in config.getDescriptors(hasInterfaceObject=True,
|
||||
register=True,
|
||||
isExposedInWorkerDebugger=True,
|
||||
skipGen=False)]
|
||||
|
||||
curr = CGHeaders([], [], [], [], [], defineIncludes,
|
||||
'RegisterWorkerDebuggerBindings', curr)
|
||||
|
||||
# Add include guards.
|
||||
curr = CGIncludeGuard('RegisterWorkerDebuggerBindings', curr)
|
||||
|
||||
# Done.
|
||||
return curr
|
||||
|
||||
@staticmethod
|
||||
def ResolveSystemBinding(config):
|
||||
|
||||
|
||||
@@ -228,6 +228,8 @@ class Configuration:
|
||||
getter = lambda x: x.interface.getNavigatorProperty() is not None
|
||||
elif key == 'isExposedInAnyWorker':
|
||||
getter = lambda x: x.interface.isExposedInAnyWorker()
|
||||
elif key == 'isExposedInWorkerDebugger':
|
||||
getter = lambda x: x.interface.isExposedInWorkerDebugger()
|
||||
elif key == 'isExposedInSystemGlobals':
|
||||
getter = lambda x: x.interface.isExposedInSystemGlobals()
|
||||
elif key == 'isExposedInWindow':
|
||||
|
||||
@@ -184,6 +184,18 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use StealExceptionFromJSContext to convert a pending exception on a
|
||||
// JSContext to an ErrorResult. This function must be called only when a
|
||||
// JSAPI operation failed. It assumes that lack of pending exception on the
|
||||
// JSContext means an uncatchable exception was thrown.
|
||||
//
|
||||
// Codepaths that might call this method must call MightThrowJSException even
|
||||
// if the relevant JSAPI calls do not fail.
|
||||
//
|
||||
// When this function returns, JS_IsExceptionPending(cx) will definitely be
|
||||
// false.
|
||||
void StealExceptionFromJSContext(JSContext* cx);
|
||||
|
||||
template<dom::ErrNum errorNumber, typename... Ts>
|
||||
void ThrowTypeError(Ts&&... messageArgs)
|
||||
{
|
||||
@@ -202,10 +214,10 @@ public:
|
||||
|
||||
// Facilities for throwing a preexisting JS exception value via this
|
||||
// ErrorResult. The contract is that any code which might end up calling
|
||||
// ThrowJSException() must call MightThrowJSException() even if no exception
|
||||
// is being thrown. Code that conditionally calls ToJSValue on this
|
||||
// ErrorResult only if Failed() must first call WouldReportJSException even if
|
||||
// this ErrorResult has not failed.
|
||||
// ThrowJSException() or StealExceptionFromJSContext() must call
|
||||
// MightThrowJSException() even if no exception is being thrown. Code that
|
||||
// conditionally calls ToJSValue on this ErrorResult only if Failed() must
|
||||
// first call WouldReportJSException even if this ErrorResult has not failed.
|
||||
//
|
||||
// The exn argument to ThrowJSException can be in any compartment. It does
|
||||
// not have to be in the compartment of cx. If someone later uses it, they
|
||||
|
||||
+97
-242
@@ -139,7 +139,7 @@ ThrowAndReport(nsPIDOMWindow* aWindow, nsresult aRv)
|
||||
MOZ_ASSERT(aRv != NS_ERROR_UNCATCHABLE_EXCEPTION,
|
||||
"Doesn't make sense to report uncatchable exceptions!");
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(aWindow))) {
|
||||
if (NS_WARN_IF(!jsapi.Init(aWindow))) {
|
||||
return;
|
||||
}
|
||||
jsapi.TakeOwnershipOfErrorReporting();
|
||||
@@ -175,29 +175,16 @@ CreateException(JSContext* aCx, nsresult aRv, const nsACString& aMessage)
|
||||
}
|
||||
|
||||
already_AddRefed<nsIStackFrame>
|
||||
GetCurrentJSStack()
|
||||
GetCurrentJSStack(int32_t aMaxDepth)
|
||||
{
|
||||
// is there a current context available?
|
||||
JSContext* cx = nullptr;
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
MOZ_ASSERT(nsContentUtils::XPConnect());
|
||||
cx = nsContentUtils::GetCurrentJSContext();
|
||||
} else {
|
||||
cx = workers::GetCurrentThreadJSContext();
|
||||
}
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
|
||||
if (!cx || !js::GetContextCompartment(cx)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> stack = exceptions::CreateStack(cx);
|
||||
if (!stack) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Note that CreateStack only returns JS frames, so we're done here.
|
||||
return stack.forget();
|
||||
return exceptions::CreateStack(cx, aMaxDepth);
|
||||
}
|
||||
|
||||
AutoForceSetExceptionOnContext::AutoForceSetExceptionOnContext(JSContext* aCx)
|
||||
@@ -214,37 +201,26 @@ AutoForceSetExceptionOnContext::~AutoForceSetExceptionOnContext()
|
||||
|
||||
namespace exceptions {
|
||||
|
||||
class StackFrame : public nsIStackFrame
|
||||
class JSStackFrame : public nsIStackFrame
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(StackFrame)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(JSStackFrame)
|
||||
NS_DECL_NSISTACKFRAME
|
||||
|
||||
StackFrame()
|
||||
: mLineno(0)
|
||||
, mColNo(0)
|
||||
, mLanguage(nsIProgrammingLanguage::UNKNOWN)
|
||||
{
|
||||
}
|
||||
// aStack must not be null.
|
||||
explicit JSStackFrame(JS::Handle<JSObject*> aStack);
|
||||
|
||||
protected:
|
||||
virtual ~StackFrame();
|
||||
int32_t GetLineno(JSContext* aCx);
|
||||
|
||||
virtual bool IsJSFrame() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int32_t GetColNo(JSContext* aCx);
|
||||
|
||||
virtual int32_t GetLineno()
|
||||
{
|
||||
return mLineno;
|
||||
}
|
||||
private:
|
||||
virtual ~JSStackFrame();
|
||||
|
||||
virtual int32_t GetColNo()
|
||||
{
|
||||
return mColNo;
|
||||
}
|
||||
JS::Heap<JSObject*> mStack;
|
||||
nsString mFormattedStack;
|
||||
|
||||
nsCOMPtr<nsIStackFrame> mCaller;
|
||||
nsCOMPtr<nsIStackFrame> mAsyncCaller;
|
||||
@@ -253,57 +229,6 @@ protected:
|
||||
nsString mAsyncCause;
|
||||
int32_t mLineno;
|
||||
int32_t mColNo;
|
||||
uint32_t mLanguage;
|
||||
};
|
||||
|
||||
StackFrame::~StackFrame()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(StackFrame, mCaller, mAsyncCaller)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(StackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(StackFrame)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StackFrame)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStackFrame)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
class JSStackFrame : public StackFrame
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(JSStackFrame,
|
||||
StackFrame)
|
||||
|
||||
// aStack must not be null.
|
||||
explicit JSStackFrame(JS::Handle<JSObject*> aStack);
|
||||
|
||||
static already_AddRefed<nsIStackFrame>
|
||||
CreateStack(JSContext* aCx, int32_t aMaxDepth = -1);
|
||||
|
||||
NS_IMETHOD GetLanguageName(nsACString& aLanguageName) override;
|
||||
NS_IMETHOD GetFilename(nsAString& aFilename) override;
|
||||
NS_IMETHOD GetName(nsAString& aFunction) override;
|
||||
NS_IMETHOD GetAsyncCause(nsAString& aAsyncCause) override;
|
||||
NS_IMETHOD GetAsyncCaller(nsIStackFrame** aAsyncCaller) override;
|
||||
NS_IMETHOD GetCaller(nsIStackFrame** aCaller) override;
|
||||
NS_IMETHOD GetFormattedStack(nsAString& aStack) override;
|
||||
NS_IMETHOD GetNativeSavedFrame(JS::MutableHandle<JS::Value> aSavedFrame) override;
|
||||
|
||||
protected:
|
||||
virtual bool IsJSFrame() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int32_t GetLineno() override;
|
||||
virtual int32_t GetColNo() override;
|
||||
|
||||
private:
|
||||
virtual ~JSStackFrame();
|
||||
|
||||
JS::Heap<JSObject*> mStack;
|
||||
nsString mFormattedStack;
|
||||
|
||||
bool mFilenameInitialized;
|
||||
bool mFunnameInitialized;
|
||||
@@ -317,6 +242,8 @@ private:
|
||||
|
||||
JSStackFrame::JSStackFrame(JS::Handle<JSObject*> aStack)
|
||||
: mStack(aStack)
|
||||
, mLineno(0)
|
||||
, mColNo(0)
|
||||
, mFilenameInitialized(false)
|
||||
, mFunnameInitialized(false)
|
||||
, mLinenoInitialized(false)
|
||||
@@ -329,8 +256,6 @@ JSStackFrame::JSStackFrame(JS::Handle<JSObject*> aStack)
|
||||
MOZ_ASSERT(mStack);
|
||||
|
||||
mozilla::HoldJSObjects(this);
|
||||
mLineno = 0;
|
||||
mLanguage = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
}
|
||||
|
||||
JSStackFrame::~JSStackFrame()
|
||||
@@ -339,31 +264,31 @@ JSStackFrame::~JSStackFrame()
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(JSStackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(JSStackFrame, StackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(JSStackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCaller)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAsyncCaller)
|
||||
tmp->mStack = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(JSStackFrame, StackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(JSStackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCaller)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAsyncCaller)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(JSStackFrame, StackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(JSStackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mStack)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(JSStackFrame, StackFrame)
|
||||
NS_IMPL_RELEASE_INHERITED(JSStackFrame, StackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(JSStackFrame)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(JSStackFrame)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(JSStackFrame)
|
||||
NS_INTERFACE_MAP_END_INHERITING(StackFrame)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JSStackFrame)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStackFrame)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetLanguage(uint32_t* aLanguage)
|
||||
NS_IMETHODIMP JSStackFrame::GetLanguage(uint32_t* aLanguage)
|
||||
{
|
||||
*aLanguage = mLanguage;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetLanguageName(nsACString& aLanguageName)
|
||||
{
|
||||
aLanguageName.AssignLiteral("C++");
|
||||
*aLanguage = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -411,25 +336,26 @@ GetValueIfNotCached(JSContext* aCx, JSObject* aStack,
|
||||
aPropGetter(aCx, stack, aValue, JS::SavedFrameSelfHosted::Exclude);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
{
|
||||
if (!mStack) {
|
||||
aFilename.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSString*> filename(cx);
|
||||
JS::Rooted<JSString*> filename(aCx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameSource, mFilenameInitialized,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameSource,
|
||||
mFilenameInitialized,
|
||||
&canCache, &useCachedValue, &filename);
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetFilename(aFilename);
|
||||
aFilename = mFilename;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, filename)) {
|
||||
JS_ClearPendingException(cx);
|
||||
if (!str.init(aCx, filename)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
aFilename.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -443,40 +369,28 @@ NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
// The filename must be set to null if empty.
|
||||
if (mFilename.IsEmpty()) {
|
||||
aFilename.SetIsVoid(true);
|
||||
} else {
|
||||
aFilename.Assign(mFilename);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
NS_IMETHODIMP JSStackFrame::GetName(JSContext* aCx, nsAString& aFunction)
|
||||
{
|
||||
if (!mStack) {
|
||||
aFunction.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSString*> name(cx);
|
||||
JS::Rooted<JSString*> name(aCx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameFunctionDisplayName,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameFunctionDisplayName,
|
||||
mFunnameInitialized, &canCache, &useCachedValue,
|
||||
&name);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetName(aFunction);
|
||||
aFunction = mFunname;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, name)) {
|
||||
JS_ClearPendingException(cx);
|
||||
if (!str.init(aCx, name)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
aFunction.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -493,34 +407,20 @@ NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetName(nsAString& aFunction)
|
||||
{
|
||||
// The function name must be set to null if empty.
|
||||
if (mFunname.IsEmpty()) {
|
||||
aFunction.SetIsVoid(true);
|
||||
} else {
|
||||
aFunction.Assign(mFunname);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// virtual
|
||||
int32_t
|
||||
JSStackFrame::GetLineno()
|
||||
JSStackFrame::GetLineno(JSContext* aCx)
|
||||
{
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
uint32_t line;
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameLine, mLinenoInitialized,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameLine, mLinenoInitialized,
|
||||
&canCache, &useCachedValue, &line);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetLineno();
|
||||
return mLineno;
|
||||
}
|
||||
|
||||
if (canCache) {
|
||||
@@ -531,28 +431,26 @@ JSStackFrame::GetLineno()
|
||||
return line;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetLineNumber(int32_t* aLineNumber)
|
||||
NS_IMETHODIMP JSStackFrame::GetLineNumber(JSContext* aCx, int32_t* aLineNumber)
|
||||
{
|
||||
*aLineNumber = GetLineno();
|
||||
*aLineNumber = GetLineno(aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// virtual
|
||||
int32_t
|
||||
JSStackFrame::GetColNo()
|
||||
JSStackFrame::GetColNo(JSContext* aCx)
|
||||
{
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
uint32_t col;
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameColumn, mColNoInitialized,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameColumn, mColNoInitialized,
|
||||
&canCache, &useCachedValue, &col);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetColNo();
|
||||
return mColNo;
|
||||
}
|
||||
|
||||
if (canCache) {
|
||||
@@ -563,40 +461,42 @@ JSStackFrame::GetColNo()
|
||||
return col;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetColumnNumber(int32_t* aColumnNumber)
|
||||
NS_IMETHODIMP JSStackFrame::GetColumnNumber(JSContext* aCx,
|
||||
int32_t* aColumnNumber)
|
||||
{
|
||||
*aColumnNumber = GetColNo();
|
||||
*aColumnNumber = GetColNo(aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetSourceLine(nsACString& aSourceLine)
|
||||
NS_IMETHODIMP JSStackFrame::GetSourceLine(nsACString& aSourceLine)
|
||||
{
|
||||
aSourceLine.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCause(JSContext* aCx,
|
||||
nsAString& aAsyncCause)
|
||||
{
|
||||
if (!mStack) {
|
||||
aAsyncCause.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSString*> asyncCause(cx);
|
||||
JS::Rooted<JSString*> asyncCause(aCx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameAsyncCause,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameAsyncCause,
|
||||
mAsyncCauseInitialized, &canCache, &useCachedValue,
|
||||
&asyncCause);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetAsyncCause(aAsyncCause);
|
||||
aAsyncCause = mAsyncCause;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (asyncCause) {
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, asyncCause)) {
|
||||
JS_ClearPendingException(cx);
|
||||
if (!str.init(aCx, asyncCause)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
aAsyncCause.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -613,34 +513,23 @@ NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
{
|
||||
// The async cause must be set to null if empty.
|
||||
if (mAsyncCause.IsEmpty()) {
|
||||
aAsyncCause.SetIsVoid(true);
|
||||
} else {
|
||||
aAsyncCause.Assign(mAsyncCause);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCaller(JSContext* aCx,
|
||||
nsIStackFrame** aAsyncCaller)
|
||||
{
|
||||
if (!mStack) {
|
||||
*aAsyncCaller = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> asyncCallerObj(cx);
|
||||
JS::Rooted<JSObject*> asyncCallerObj(aCx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameAsyncParent,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameAsyncParent,
|
||||
mAsyncCallerInitialized, &canCache, &useCachedValue,
|
||||
&asyncCallerObj);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetAsyncCaller(aAsyncCaller);
|
||||
NS_IF_ADDREF(*aAsyncCaller = mAsyncCaller);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> asyncCaller =
|
||||
@@ -655,27 +544,21 @@ NS_IMETHODIMP JSStackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
{
|
||||
NS_IF_ADDREF(*aAsyncCaller = mAsyncCaller);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
NS_IMETHODIMP JSStackFrame::GetCaller(JSContext* aCx, nsIStackFrame** aCaller)
|
||||
{
|
||||
if (!mStack) {
|
||||
*aCaller = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> callerObj(cx);
|
||||
JS::Rooted<JSObject*> callerObj(aCx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameParent, mCallerInitialized,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameParent, mCallerInitialized,
|
||||
&canCache, &useCachedValue, &callerObj);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetCaller(aCaller);
|
||||
NS_IF_ADDREF(*aCaller = mCaller);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> caller =
|
||||
@@ -690,13 +573,7 @@ NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
{
|
||||
NS_IF_ADDREF(*aCaller = mCaller);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetFormattedStack(nsAString& aStack)
|
||||
NS_IMETHODIMP JSStackFrame::GetFormattedStack(JSContext* aCx, nsAString& aStack)
|
||||
{
|
||||
if (!mStack) {
|
||||
aStack.Truncate();
|
||||
@@ -707,30 +584,29 @@ NS_IMETHODIMP JSStackFrame::GetFormattedStack(nsAString& aStack)
|
||||
// returns bool, not JS::SavedFrameResult. Maybe it's possible to
|
||||
// make the templates more complicated to deal, but in the meantime
|
||||
// let's just inline GetValueIfNotCached here.
|
||||
ThreadsafeAutoJSContext cx;
|
||||
|
||||
// Allow caching if cx and stack are same-compartment. Otherwise take the
|
||||
// Allow caching if aCx and stack are same-compartment. Otherwise take the
|
||||
// slow path.
|
||||
bool canCache =
|
||||
js::GetContextCompartment(cx) == js::GetObjectCompartment(mStack);
|
||||
js::GetContextCompartment(aCx) == js::GetObjectCompartment(mStack);
|
||||
if (canCache && mFormattedStackInitialized) {
|
||||
aStack = mFormattedStack;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
JS::Rooted<JSObject*> stack(cx, mStack);
|
||||
JS::Rooted<JSObject*> stack(aCx, mStack);
|
||||
|
||||
JS::Rooted<JSString*> formattedStack(cx);
|
||||
if (!JS::BuildStackString(cx, stack, &formattedStack)) {
|
||||
JS_ClearPendingException(cx);
|
||||
JS::Rooted<JSString*> formattedStack(aCx);
|
||||
if (!JS::BuildStackString(aCx, stack, &formattedStack)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
aStack.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, formattedStack)) {
|
||||
JS_ClearPendingException(cx);
|
||||
if (!str.init(aCx, formattedStack)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
aStack.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -745,32 +621,18 @@ NS_IMETHODIMP JSStackFrame::GetFormattedStack(nsAString& aStack)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetFormattedStack(nsAString& aStack)
|
||||
{
|
||||
aStack.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetNativeSavedFrame(JS::MutableHandle<JS::Value> aSavedFrame)
|
||||
{
|
||||
aSavedFrame.setObjectOrNull(mStack);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::GetNativeSavedFrame(JS::MutableHandle<JS::Value> aSavedFrame)
|
||||
{
|
||||
aSavedFrame.setNull();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP StackFrame::ToString(nsACString& _retval)
|
||||
NS_IMETHODIMP JSStackFrame::ToString(JSContext* aCx, nsACString& _retval)
|
||||
{
|
||||
_retval.Truncate();
|
||||
|
||||
const char* frametype = IsJSFrame() ? "JS" : "native";
|
||||
|
||||
nsString filename;
|
||||
nsresult rv = GetFilename(filename);
|
||||
nsresult rv = GetFilename(aCx, filename);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (filename.IsEmpty()) {
|
||||
@@ -778,25 +640,25 @@ NS_IMETHODIMP StackFrame::ToString(nsACString& _retval)
|
||||
}
|
||||
|
||||
nsString funname;
|
||||
rv = GetName(funname);
|
||||
rv = GetName(aCx, funname);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (funname.IsEmpty()) {
|
||||
funname.AssignLiteral("<TOP_LEVEL>");
|
||||
}
|
||||
|
||||
int32_t lineno = GetLineno();
|
||||
int32_t lineno = GetLineno(aCx);
|
||||
|
||||
static const char format[] = "%s frame :: %s :: %s :: line %d";
|
||||
_retval.AppendPrintf(format, frametype,
|
||||
static const char format[] = "JS frame :: %s :: %s :: line %d";
|
||||
_retval.AppendPrintf(format,
|
||||
NS_ConvertUTF16toUTF8(filename).get(),
|
||||
NS_ConvertUTF16toUTF8(funname).get(),
|
||||
lineno);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsIStackFrame>
|
||||
JSStackFrame::CreateStack(JSContext* aCx, int32_t aMaxDepth)
|
||||
already_AddRefed<nsIStackFrame>
|
||||
CreateStack(JSContext* aCx, int32_t aMaxDepth)
|
||||
{
|
||||
static const unsigned MAX_FRAMES = 100;
|
||||
if (aMaxDepth < 0) {
|
||||
@@ -808,19 +670,12 @@ JSStackFrame::CreateStack(JSContext* aCx, int32_t aMaxDepth)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> first;
|
||||
if (!stack) {
|
||||
first = new StackFrame();
|
||||
} else {
|
||||
first = new JSStackFrame(stack);
|
||||
return nullptr;
|
||||
}
|
||||
return first.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIStackFrame>
|
||||
CreateStack(JSContext* aCx, int32_t aMaxDepth)
|
||||
{
|
||||
return JSStackFrame::CreateStack(aCx, aMaxDepth);
|
||||
nsCOMPtr<nsIStackFrame> frame = new JSStackFrame(stack);
|
||||
return frame.forget();
|
||||
}
|
||||
|
||||
} // namespace exceptions
|
||||
|
||||
@@ -48,8 +48,11 @@ already_AddRefed<Exception>
|
||||
CreateException(JSContext* aCx, nsresult aRv,
|
||||
const nsACString& aMessage = EmptyCString());
|
||||
|
||||
// aMaxDepth can be used to define a maximal depth for the stack trace. If the
|
||||
// value is -1, a default maximal depth will be selected. Will return null if
|
||||
// there is no JS stack right now.
|
||||
already_AddRefed<nsIStackFrame>
|
||||
GetCurrentJSStack();
|
||||
GetCurrentJSStack(int32_t aMaxDepth = -1);
|
||||
|
||||
// Throwing a TypeError on an ErrorResult may result in SpiderMonkey using its
|
||||
// own error reporting mechanism instead of just setting the exception on the
|
||||
@@ -68,7 +71,8 @@ public:
|
||||
namespace exceptions {
|
||||
|
||||
// aMaxDepth can be used to define a maximal depth for the stack trace. If the
|
||||
// value is -1, a default maximal depth will be selected.
|
||||
// value is -1, a default maximal depth will be selected. Will return null if
|
||||
// there is no JS stack right now.
|
||||
already_AddRefed<nsIStackFrame>
|
||||
CreateStack(JSContext* aCx, int32_t aMaxDepth = -1);
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ class WebIDLCodegenManager(LoggingMixin):
|
||||
'PrototypeList.h',
|
||||
'RegisterBindings.h',
|
||||
'RegisterWorkerBindings.h',
|
||||
'RegisterWorkerDebuggerBindings.h',
|
||||
'ResolveSystemBinding.h',
|
||||
'UnionConversions.h',
|
||||
'UnionTypes.h',
|
||||
@@ -142,6 +143,7 @@ class WebIDLCodegenManager(LoggingMixin):
|
||||
GLOBAL_DEFINE_FILES = {
|
||||
'RegisterBindings.cpp',
|
||||
'RegisterWorkerBindings.cpp',
|
||||
'RegisterWorkerDebuggerBindings.cpp',
|
||||
'ResolveSystemBinding.cpp',
|
||||
'UnionTypes.cpp',
|
||||
'PrototypeList.cpp',
|
||||
|
||||
@@ -508,6 +508,9 @@ class IDLExposureMixins():
|
||||
def isExposedInAnyWorker(self):
|
||||
return len(self.getWorkerExposureSet()) > 0
|
||||
|
||||
def isExposedInWorkerDebugger(self):
|
||||
return len(self.getWorkerDebuggerExposureSet()) > 0
|
||||
|
||||
def isExposedInSystemGlobals(self):
|
||||
return 'BackstagePass' in self.exposureSet
|
||||
|
||||
@@ -527,6 +530,10 @@ class IDLExposureMixins():
|
||||
workerScopes = self._globalScope.globalNameMapping["Worker"]
|
||||
return workerScopes.intersection(self.exposureSet)
|
||||
|
||||
def getWorkerDebuggerExposureSet(self):
|
||||
workerDebuggerScopes = self._globalScope.globalNameMapping["WorkerDebugger"]
|
||||
return workerDebuggerScopes.intersection(self.exposureSet)
|
||||
|
||||
|
||||
class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
|
||||
def __init__(self, location, parentScope, identifier):
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "DOMRequest.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
@@ -92,8 +93,7 @@ BluetoothReplyRunnable::Run()
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mReply);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> v(cx, JS::UndefinedValue());
|
||||
JS::Rooted<JS::Value> v(nsContentUtils::RootingCx(), JS::UndefinedValue());
|
||||
|
||||
nsresult rv;
|
||||
if (mReply->type() != BluetoothReply::TBluetoothReplySuccess) {
|
||||
|
||||
@@ -420,8 +420,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
|
||||
}
|
||||
} else {
|
||||
bc->mWorkerFeature = new BroadcastChannelFeature(bc);
|
||||
JSContext* cx = workerPrivate->GetJSContext();
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(cx, bc->mWorkerFeature))) {
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(bc->mWorkerFeature))) {
|
||||
NS_WARNING("Failed to register the BroadcastChannel worker feature.");
|
||||
bc->mWorkerFeature = nullptr;
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
@@ -545,7 +544,7 @@ BroadcastChannel::Shutdown()
|
||||
|
||||
if (mWorkerFeature) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
workerPrivate->RemoveFeature(workerPrivate->GetJSContext(), mWorkerFeature);
|
||||
workerPrivate->RemoveFeature(mWorkerFeature);
|
||||
mWorkerFeature = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ function runTests() {
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.workers.sharedWorkers.enabled", true]]}, runTests);
|
||||
runTests();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
Vendored
+2
-2
@@ -25,7 +25,7 @@ Feature::Create(WorkerPrivate* aWorkerPrivate)
|
||||
|
||||
RefPtr<Feature> feature = new Feature(aWorkerPrivate);
|
||||
|
||||
if (!aWorkerPrivate->AddFeature(aWorkerPrivate->GetJSContext(), feature)) {
|
||||
if (!aWorkerPrivate->AddFeature(feature)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ Feature::~Feature()
|
||||
NS_ASSERT_OWNINGTHREAD(Feature);
|
||||
MOZ_ASSERT(mActorList.IsEmpty());
|
||||
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
|
||||
mWorkerPrivate->RemoveFeature(this);
|
||||
}
|
||||
|
||||
} // namespace cache
|
||||
|
||||
@@ -121,6 +121,8 @@
|
||||
#include "nsFontMetrics.h"
|
||||
#include "Units.h"
|
||||
#include "CanvasUtils.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
|
||||
#undef free // apparently defined by some windows header, clashing with a free()
|
||||
// method in SkTypes.h
|
||||
@@ -2213,6 +2215,16 @@ GetFontParentStyleContext(Element* aElement, nsIPresShell* aPresShell,
|
||||
}
|
||||
|
||||
// otherwise inherit from default (10px sans-serif)
|
||||
|
||||
nsStyleSet* styleSet = aPresShell->StyleSet()->GetAsGecko();
|
||||
if (!styleSet) {
|
||||
// XXXheycam ServoStyleSets do not support resolving style from a list of
|
||||
// rules yet.
|
||||
NS_ERROR("stylo: cannot resolve style for canvas from a ServoStyleSet yet");
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool changed;
|
||||
RefPtr<css::Declaration> parentRule =
|
||||
CreateFontDeclaration(NS_LITERAL_STRING("10px sans-serif"),
|
||||
@@ -2221,7 +2233,7 @@ GetFontParentStyleContext(Element* aElement, nsIPresShell* aPresShell,
|
||||
nsTArray<nsCOMPtr<nsIStyleRule>> parentRules;
|
||||
parentRules.AppendElement(parentRule);
|
||||
RefPtr<nsStyleContext> result =
|
||||
aPresShell->StyleSet()->ResolveStyleForRules(nullptr, parentRules);
|
||||
styleSet->ResolveStyleForRules(nullptr, parentRules);
|
||||
|
||||
if (!result) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
@@ -2248,6 +2260,15 @@ GetFontStyleContext(Element* aElement, const nsAString& aFont,
|
||||
nsAString& aOutUsedFont,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsStyleSet* styleSet = aPresShell->StyleSet()->GetAsGecko();
|
||||
if (!styleSet) {
|
||||
// XXXheycam ServoStyleSets do not support resolving style from a list of
|
||||
// rules yet.
|
||||
NS_ERROR("stylo: cannot resolve style for canvas from a ServoStyleSet yet");
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool fontParsedSuccessfully = false;
|
||||
RefPtr<css::Declaration> decl =
|
||||
CreateFontDeclaration(aFont, aPresShell->GetDocument(),
|
||||
@@ -2287,7 +2308,6 @@ GetFontStyleContext(Element* aElement, const nsAString& aFont,
|
||||
// add a rule to prevent text zoom from affecting the style
|
||||
rules.AppendElement(new nsDisableTextZoomStyleRule);
|
||||
|
||||
nsStyleSet* styleSet = aPresShell->StyleSet();
|
||||
RefPtr<nsStyleContext> sc =
|
||||
styleSet->ResolveStyleForRules(parentContext, rules);
|
||||
|
||||
@@ -2317,6 +2337,15 @@ ResolveStyleForFilter(const nsAString& aFilterString,
|
||||
nsStyleContext* aParentContext,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsStyleSet* styleSet = aPresShell->StyleSet()->GetAsGecko();
|
||||
if (!styleSet) {
|
||||
// XXXheycam ServoStyleSets do not support resolving style from a list of
|
||||
// rules yet.
|
||||
NS_ERROR("stylo: cannot resolve style for canvas from a ServoStyleSet yet");
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDocument* document = aPresShell->GetDocument();
|
||||
bool filterChanged = false;
|
||||
RefPtr<css::Declaration> decl =
|
||||
@@ -2337,7 +2366,7 @@ ResolveStyleForFilter(const nsAString& aFilterString,
|
||||
rules.AppendElement(decl);
|
||||
|
||||
RefPtr<nsStyleContext> sc =
|
||||
aPresShell->StyleSet()->ResolveStyleForRules(aParentContext, rules);
|
||||
styleSet->ResolveStyleForRules(aParentContext, rules);
|
||||
|
||||
return sc.forget();
|
||||
}
|
||||
@@ -2441,12 +2470,12 @@ public:
|
||||
|
||||
virtual float GetExLength() const override
|
||||
{
|
||||
gfxTextPerfMetrics* tp = mPresContext->GetTextPerfMetrics();
|
||||
RefPtr<nsFontMetrics> fontMetrics;
|
||||
nsDeviceContext* dc = mPresContext->DeviceContext();
|
||||
dc->GetMetricsFor(mFont, mFontLanguage, mExplicitLanguage,
|
||||
gfxFont::eHorizontal, nullptr, tp,
|
||||
*getter_AddRefs(fontMetrics));
|
||||
nsFontMetrics::Params params;
|
||||
params.language = mFontLanguage;
|
||||
params.explicitLanguage = mExplicitLanguage;
|
||||
params.textPerf = mPresContext->GetTextPerfMetrics();
|
||||
RefPtr<nsFontMetrics> fontMetrics = dc->GetMetricsFor(mFont, params);
|
||||
return NSAppUnitsToFloatPixels(fontMetrics->XHeight(),
|
||||
nsPresContext::AppUnitsPerCSSPixel());
|
||||
}
|
||||
@@ -3202,14 +3231,13 @@ CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont,
|
||||
resizedFont.size =
|
||||
(fontStyle->mSize * c->AppUnitsPerDevPixel()) / c->AppUnitsPerCSSPixel();
|
||||
|
||||
RefPtr<nsFontMetrics> metrics;
|
||||
c->DeviceContext()->GetMetricsFor(resizedFont,
|
||||
fontStyle->mLanguage,
|
||||
fontStyle->mExplicitLanguage,
|
||||
gfxFont::eHorizontal,
|
||||
c->GetUserFontSet(),
|
||||
c->GetTextPerfMetrics(),
|
||||
*getter_AddRefs(metrics));
|
||||
nsFontMetrics::Params params;
|
||||
params.language = fontStyle->mLanguage;
|
||||
params.explicitLanguage = fontStyle->mExplicitLanguage;
|
||||
params.userFontSet = c->GetUserFontSet();
|
||||
params.textPerf = c->GetTextPerfMetrics();
|
||||
RefPtr<nsFontMetrics> metrics =
|
||||
c->DeviceContext()->GetMetricsFor(resizedFont, params);
|
||||
|
||||
gfxFontGroup* newFontGroup = metrics->GetThebesFontGroup();
|
||||
CurrentState().fontGroup = newFontGroup;
|
||||
|
||||
@@ -894,7 +894,7 @@ AsyncFulfillImageBitmapPromise(Promise* aPromise, ImageBitmap* aImageBitmap)
|
||||
} else {
|
||||
RefPtr<FulfillImageBitmapPromiseWorkerTask> task =
|
||||
new FulfillImageBitmapPromiseWorkerTask(aPromise, aImageBitmap);
|
||||
task->Dispatch(GetCurrentThreadWorkerPrivate()->GetJSContext()); // Actually, to the current worker-thread.
|
||||
task->Dispatch(); // Actually, to the current worker-thread.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1167,7 +1167,7 @@ AsyncCreateImageBitmapFromBlob(Promise* aPromise, nsIGlobalObject* aGlobal,
|
||||
} else {
|
||||
RefPtr<CreateImageBitmapFromBlobWorkerTask> task =
|
||||
new CreateImageBitmapFromBlobWorkerTask(aPromise, aGlobal, aBlob, aCropRect);
|
||||
task->Dispatch(GetCurrentThreadWorkerPrivate()->GetJSContext()); // Actually, to the current worker-thread.
|
||||
task->Dispatch(); // Actually, to the current worker-thread.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ WebGLContextLossHandler::RunTimer()
|
||||
nsCOMPtr<nsIEventTarget> target = workerPrivate->GetEventTarget();
|
||||
mTimer->SetTarget(new ContextLossWorkerEventTarget(target));
|
||||
if (!mFeatureAdded) {
|
||||
workerPrivate->AddFeature(workerPrivate->GetJSContext(), this);
|
||||
workerPrivate->AddFeature(this);
|
||||
mFeatureAdded = true;
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ WebGLContextLossHandler::DisableTimer()
|
||||
dom::workers::WorkerPrivate* workerPrivate =
|
||||
dom::workers::GetCurrentThreadWorkerPrivate();
|
||||
MOZ_RELEASE_ASSERT(workerPrivate);
|
||||
workerPrivate->RemoveFeature(workerPrivate->GetJSContext(), this);
|
||||
workerPrivate->RemoveFeature(this);
|
||||
mFeatureAdded = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,9 @@ DataStoreDB::CreateFactoryIfNeeded()
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
MOZ_ASSERT(xpc);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JSObject*> global(cx);
|
||||
rv = xpc->CreateSandbox(cx, principal, global.address());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@@ -222,10 +224,8 @@ DataStoreDB::UpgradeSchema(nsIDOMEvent* aEvent)
|
||||
MOZ_ASSERT(version.Value() == DATASTOREDB_VERSION);
|
||||
#endif
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
ErrorResult error;
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
JS::Rooted<JS::Value> result(nsContentUtils::RootingCx());
|
||||
mRequest->GetResult(&result, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
@@ -284,10 +284,8 @@ DataStoreDB::DatabaseOpened()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
ErrorResult error;
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
JS::Rooted<JS::Value> result(nsContentUtils::RootingCx());
|
||||
mRequest->GetResult(&result, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
|
||||
@@ -1444,23 +1444,14 @@ ContentEventHandler::OnQueryCaretRect(WidgetQueryContentEvent* aEvent)
|
||||
rect.x = posInFrame.x;
|
||||
rect.y = posInFrame.y;
|
||||
|
||||
nscoord fontHeight = 0;
|
||||
float inflation = nsLayoutUtils::FontSizeInflationFor(frame);
|
||||
RefPtr<nsFontMetrics> fontMetrics;
|
||||
rv = nsLayoutUtils::GetFontMetricsForFrame(frame, getter_AddRefs(fontMetrics),
|
||||
inflation);
|
||||
if (NS_WARN_IF(!fontMetrics)) {
|
||||
// If we cannot get font height, use frame size instead.
|
||||
fontHeight = isVertical ? frame->GetSize().width : frame->GetSize().height;
|
||||
} else {
|
||||
fontHeight = fontMetrics->MaxAscent() + fontMetrics->MaxDescent();
|
||||
}
|
||||
RefPtr<nsFontMetrics> fontMetrics =
|
||||
nsLayoutUtils::GetInflatedFontMetricsForFrame(frame);
|
||||
if (isVertical) {
|
||||
rect.width = fontHeight;
|
||||
rect.width = fontMetrics->MaxHeight();
|
||||
rect.height = caretRect.height;
|
||||
} else {
|
||||
rect.width = caretRect.width;
|
||||
rect.height = fontHeight;
|
||||
rect.height = fontMetrics->MaxHeight();
|
||||
}
|
||||
|
||||
rv = ConvertToRootRelativeOffset(frame, rect);
|
||||
|
||||
@@ -2515,9 +2515,8 @@ EventStateManager::GetScrollAmount(nsPresContext* aPresContext,
|
||||
if (!rootFrame) {
|
||||
return nsSize(0, 0);
|
||||
}
|
||||
RefPtr<nsFontMetrics> fm;
|
||||
nsLayoutUtils::GetFontMetricsForFrame(rootFrame, getter_AddRefs(fm),
|
||||
nsLayoutUtils::FontSizeInflationFor(rootFrame));
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetInflatedFontMetricsForFrame(rootFrame);
|
||||
NS_ENSURE_TRUE(fm, nsSize(0, 0));
|
||||
return nsSize(fm->AveCharWidth(), fm->MaxHeight());
|
||||
}
|
||||
|
||||
+7
-13
@@ -307,7 +307,7 @@ public:
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
mResolver->mPromiseProxy->CleanUp(aCx);
|
||||
mResolver->mPromiseProxy->CleanUp();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -326,9 +326,7 @@ WorkerFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse)
|
||||
new WorkerFetchResponseRunnable(mPromiseProxy->GetWorkerPrivate(), this,
|
||||
aResponse);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!r->Dispatch(jsapi.cx())) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch fetch response");
|
||||
}
|
||||
}
|
||||
@@ -345,9 +343,7 @@ WorkerFetchResolver::OnResponseEnd()
|
||||
RefPtr<WorkerFetchResponseEndRunnable> r =
|
||||
new WorkerFetchResponseEndRunnable(mPromiseProxy->GetWorkerPrivate(), this);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!r->Dispatch(jsapi.cx())) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch fetch response end");
|
||||
}
|
||||
}
|
||||
@@ -611,8 +607,7 @@ public:
|
||||
if (mBody->mWorkerPrivate) {
|
||||
RefPtr<FailConsumeBodyWorkerRunnable<Derived>> r =
|
||||
new FailConsumeBodyWorkerRunnable<Derived>(mBody);
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
MOZ_CRASH("We are going to leak");
|
||||
}
|
||||
} else {
|
||||
@@ -662,8 +657,7 @@ public:
|
||||
aStatus,
|
||||
aResultLength,
|
||||
nonconstResult);
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
// XXXcatalinb: The worker is shutting down, the pump will be canceled
|
||||
// by FetchBodyFeature::Notify.
|
||||
NS_WARNING("Could not dispatch ConsumeBodyRunnable");
|
||||
@@ -824,7 +818,7 @@ FetchBody<Derived>::RegisterFeature()
|
||||
MOZ_ASSERT(!mFeature);
|
||||
mFeature = new FetchBodyFeature<Derived>(this);
|
||||
|
||||
if (!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), mFeature)) {
|
||||
if (!mWorkerPrivate->AddFeature(mFeature)) {
|
||||
NS_WARNING("Failed to add feature");
|
||||
mFeature = nullptr;
|
||||
return false;
|
||||
@@ -841,7 +835,7 @@ FetchBody<Derived>::UnregisterFeature()
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
MOZ_ASSERT(mFeature);
|
||||
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), mFeature);
|
||||
mWorkerPrivate->RemoveFeature(mFeature);
|
||||
mFeature = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "nsPresContext.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
#include "mozilla/dom/HTMLBodyElement.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@@ -3354,7 +3356,7 @@ IsOrHasAncestorWithDisplayNone(Element* aElement, nsIPresShell* aPresShell)
|
||||
return false;
|
||||
}
|
||||
|
||||
nsStyleSet* styleSet = aPresShell->StyleSet();
|
||||
StyleSetHandle styleSet = aPresShell->StyleSet();
|
||||
RefPtr<nsStyleContext> sc;
|
||||
for (int32_t i = elementsToCheck.Length() - 1; i >= 0; --i) {
|
||||
if (sc) {
|
||||
|
||||
+14
-10
@@ -114,6 +114,8 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@@ -267,7 +269,7 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
||||
already_AddRefed<nsIPresShell>
|
||||
nsHTMLDocument::CreateShell(nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet)
|
||||
StyleSetHandle aStyleSet)
|
||||
{
|
||||
return doCreateShell(aContext, aViewManager, aStyleSet);
|
||||
}
|
||||
@@ -2642,12 +2644,14 @@ nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor)
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
||||
presShell->GetAgentStyleSheets(agentSheets);
|
||||
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::ContentEditableSheet());
|
||||
auto cache = nsLayoutStylesheetCache::For(GetStyleBackendType());
|
||||
|
||||
agentSheets.RemoveElement(cache->ContentEditableSheet());
|
||||
if (oldState == eDesignMode)
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
agentSheets.RemoveElement(cache->DesignModeSheet());
|
||||
|
||||
presShell->SetAgentStyleSheets(agentSheets);
|
||||
|
||||
@@ -2781,12 +2785,13 @@ nsHTMLDocument::EditingStateChanged()
|
||||
// Before making this window editable, we need to modify UA style sheet
|
||||
// because new style may change whether focused element will be focusable
|
||||
// or not.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
||||
rv = presShell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CSSStyleSheet* contentEditableSheet =
|
||||
nsLayoutStylesheetCache::ContentEditableSheet();
|
||||
auto cache = nsLayoutStylesheetCache::For(GetStyleBackendType());
|
||||
|
||||
StyleSheetHandle contentEditableSheet = cache->ContentEditableSheet();
|
||||
|
||||
if (!agentSheets.Contains(contentEditableSheet)) {
|
||||
agentSheets.AppendElement(contentEditableSheet);
|
||||
@@ -2797,8 +2802,7 @@ nsHTMLDocument::EditingStateChanged()
|
||||
// specific states on the elements.
|
||||
if (designMode) {
|
||||
// designMode is being turned on (overrides contentEditable).
|
||||
CSSStyleSheet* designModeSheet =
|
||||
nsLayoutStylesheetCache::DesignModeSheet();
|
||||
StyleSheetHandle designModeSheet = cache->DesignModeSheet();
|
||||
if (!agentSheets.Contains(designModeSheet)) {
|
||||
agentSheets.AppendElement(designModeSheet);
|
||||
}
|
||||
@@ -2808,7 +2812,7 @@ nsHTMLDocument::EditingStateChanged()
|
||||
}
|
||||
else if (oldState == eDesignMode) {
|
||||
// designMode is being turned off (contentEditable is still on).
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
agentSheets.RemoveElement(cache->DesignModeSheet());
|
||||
updateState = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,10 @@ public:
|
||||
virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
|
||||
nsIPrincipal* aPrincipal) override;
|
||||
|
||||
virtual already_AddRefed<nsIPresShell> CreateShell(nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet) override;
|
||||
virtual already_AddRefed<nsIPresShell> CreateShell(
|
||||
nsPresContext* aContext,
|
||||
nsViewManager* aViewManager,
|
||||
mozilla::StyleSetHandle aStyleSet) override;
|
||||
|
||||
virtual nsresult StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
|
||||
+2
-5
@@ -19,6 +19,7 @@
|
||||
#include "nsIStkCmdFactory.h"
|
||||
#include "nsIStkProactiveCmd.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using mozilla::dom::icc::IccCallback;
|
||||
using mozilla::dom::icc::IccContact;
|
||||
@@ -93,11 +94,7 @@ Icc::NotifyEvent(const nsAString& aName)
|
||||
nsresult
|
||||
Icc::NotifyStkEvent(const nsAString& aName, nsIStkProactiveCmd* aStkProactiveCmd)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetOwner()))) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSContext* cx = nsContentUtils::RootingCxForThread();
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
|
||||
nsCOMPtr<nsIStkCmdFactory> cmdFactory =
|
||||
|
||||
@@ -80,8 +80,8 @@ function IDPProvisioningContext(aID, aOrigin, aTargetMM) {
|
||||
}
|
||||
|
||||
IDPProvisioningContext.prototype = {
|
||||
get id() this._id,
|
||||
get origin() this._origin,
|
||||
get id() { return this._id; },
|
||||
get origin() { return this._origin; },
|
||||
|
||||
sendAsyncMessage: _sendAsyncMessage,
|
||||
|
||||
@@ -112,8 +112,8 @@ function IDPAuthenticationContext(aID, aOrigin, aTargetMM) {
|
||||
}
|
||||
|
||||
IDPAuthenticationContext.prototype = {
|
||||
get id() this._id,
|
||||
get origin() this._origin,
|
||||
get id() { return this._id; },
|
||||
get origin() { return this._origin; },
|
||||
|
||||
sendAsyncMessage: _sendAsyncMessage,
|
||||
|
||||
|
||||
@@ -943,7 +943,7 @@ public:
|
||||
RefPtr<WorkerPermissionOperationCompleted> runnable =
|
||||
new WorkerPermissionOperationCompleted(mWorkerPrivate, this);
|
||||
|
||||
MOZ_ALWAYS_TRUE(runnable->Dispatch(nullptr));
|
||||
MOZ_ALWAYS_TRUE(runnable->Dispatch());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -959,8 +959,7 @@ public:
|
||||
mActor = nullptr;
|
||||
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
JSContext* cx = mWorkerPrivate->GetJSContext();
|
||||
mWorkerPrivate->RemoveFeature(cx, this);
|
||||
mWorkerPrivate->RemoveFeature(this);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1412,10 +1411,7 @@ BackgroundFactoryRequestChild::RecvPermissionChallenge(
|
||||
new WorkerPermissionChallenge(workerPrivate, this, mFactory,
|
||||
aPrincipalInfo);
|
||||
|
||||
JSContext* cx = workerPrivate->GetJSContext();
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(cx, challenge))) {
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(challenge))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -368,12 +368,13 @@ IDBRequest::SetResultCallback(ResultCallback* aCallback)
|
||||
} else {
|
||||
// Otherwise our owner is a window and we use that to initialize.
|
||||
MOZ_ASSERT(GetOwner());
|
||||
if (!autoJS.InitWithLegacyErrorReporting(GetOwner())) {
|
||||
if (!autoJS.Init(GetOwner())) {
|
||||
IDB_WARNING("Failed to initialize AutoJSAPI!");
|
||||
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
autoJS.TakeOwnershipOfErrorReporting();
|
||||
|
||||
JSContext* cx = autoJS.cx();
|
||||
|
||||
@@ -491,7 +492,7 @@ public:
|
||||
MOZ_COUNT_DTOR(IDBOpenDBRequest::WorkerFeature);
|
||||
|
||||
if (mWorkerPrivate) {
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
|
||||
mWorkerPrivate->RemoveFeature(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,11 +573,8 @@ IDBOpenDBRequest::CreateForJS(IDBFactory* aFactory,
|
||||
|
||||
workerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
JSContext* cx = workerPrivate->GetJSContext();
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
nsAutoPtr<WorkerFeature> feature(new WorkerFeature(workerPrivate));
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(cx, feature))) {
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(feature))) {
|
||||
feature->NoteAddFeatureFailed();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
MOZ_COUNT_DTOR(IDBTransaction::WorkerFeature);
|
||||
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
|
||||
mWorkerPrivate->RemoveFeature(this);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -239,11 +239,8 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
|
||||
|
||||
workerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
JSContext* cx = workerPrivate->GetJSContext();
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
transaction->mWorkerFeature = new WorkerFeature(workerPrivate, transaction);
|
||||
MOZ_ALWAYS_TRUE(workerPrivate->AddFeature(cx, transaction->mWorkerFeature));
|
||||
MOZ_ALWAYS_TRUE(workerPrivate->AddFeature(transaction->mWorkerFeature));
|
||||
}
|
||||
|
||||
return transaction.forget();
|
||||
|
||||
@@ -42,8 +42,7 @@ interface nsIStructuredCloneContainer : nsISupports
|
||||
* stream, stored in aData. aFormatVersion should be the version of the
|
||||
* structured clone algorithm which was used to generate aData.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void initFromBase64(in AString aData,in unsigned long aFormatVersion);
|
||||
void initFromBase64(in AString aData, in unsigned long aFormatVersion);
|
||||
|
||||
/**
|
||||
* Deserializes this structured clone container returning it as a jsval.
|
||||
|
||||
@@ -19,7 +19,6 @@ interface nsINotificationStorageCallback : nsISupports
|
||||
* @param body: the notification body
|
||||
* @param tag: the notification tag
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void handle(in DOMString id,
|
||||
in DOMString title,
|
||||
in DOMString dir,
|
||||
@@ -35,7 +34,6 @@ interface nsINotificationStorageCallback : nsISupports
|
||||
* Callback function used to notify C++ the we have returned
|
||||
* all notification objects for this Notification.get call.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void done();
|
||||
};
|
||||
|
||||
|
||||
@@ -2569,7 +2569,10 @@ static void
|
||||
PreloadSlowThings()
|
||||
{
|
||||
// This fetches and creates all the built-in stylesheets.
|
||||
nsLayoutStylesheetCache::UserContentSheet();
|
||||
//
|
||||
// XXXheycam In the future we might want to preload the Servo-flavoured
|
||||
// UA sheets too, but for now that will be a waste of time.
|
||||
nsLayoutStylesheetCache::For(StyleBackendType::Gecko)->UserContentSheet();
|
||||
|
||||
TabChild::PreloadSlowThings();
|
||||
}
|
||||
|
||||
+5
-140
@@ -184,6 +184,8 @@
|
||||
#include "nsPluginHost.h"
|
||||
#include "nsPluginTags.h"
|
||||
#include "nsIBlocklistService.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#include "nsIBidiKeyboard.h"
|
||||
|
||||
@@ -240,13 +242,6 @@ using namespace mozilla::system;
|
||||
#include "mozilla/dom/SpeechSynthesisParent.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
#include "BackgroundChildImpl.h"
|
||||
#include "mozilla/ipc/PBackgroundChild.h"
|
||||
#include "nsIIPCBackgroundChildCreateCallback.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
|
||||
#include "mozilla/SandboxInfo.h"
|
||||
#include "mozilla/SandboxBroker.h"
|
||||
@@ -305,130 +300,6 @@ using namespace mozilla::jsipc;
|
||||
using namespace mozilla::psm;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
|
||||
class BackgroundTester final : public nsIIPCBackgroundChildCreateCallback,
|
||||
public nsIObserver
|
||||
{
|
||||
static uint32_t sCallbackCount;
|
||||
|
||||
private:
|
||||
~BackgroundTester()
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ActorCreated(PBackgroundChild* aActor) override
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(aActor,
|
||||
"Failed to create a PBackgroundChild actor!");
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(testStr, "0123456789");
|
||||
|
||||
PBackgroundTestChild* testActor =
|
||||
aActor->SendPBackgroundTestConstructor(testStr);
|
||||
MOZ_RELEASE_ASSERT(testActor);
|
||||
|
||||
if (!sCallbackCount) {
|
||||
PBackgroundChild* existingBackgroundChild =
|
||||
BackgroundChild::GetForCurrentThread();
|
||||
|
||||
MOZ_RELEASE_ASSERT(existingBackgroundChild);
|
||||
MOZ_RELEASE_ASSERT(existingBackgroundChild == aActor);
|
||||
|
||||
bool ok =
|
||||
existingBackgroundChild->
|
||||
SendPBackgroundTestConstructor(testStr);
|
||||
MOZ_RELEASE_ASSERT(ok);
|
||||
|
||||
// Callback 3.
|
||||
ok = BackgroundChild::GetOrCreateForCurrentThread(this);
|
||||
MOZ_RELEASE_ASSERT(ok);
|
||||
}
|
||||
|
||||
sCallbackCount++;
|
||||
}
|
||||
|
||||
virtual void
|
||||
ActorFailed() override
|
||||
{
|
||||
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
|
||||
override
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
MOZ_RELEASE_ASSERT(observerService);
|
||||
|
||||
nsresult rv = observerService->RemoveObserver(this, aTopic);
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
if (!strcmp(aTopic, "profile-after-change")) {
|
||||
if (mozilla::Preferences::GetBool("pbackground.testing", false)) {
|
||||
rv = observerService->AddObserver(this, "xpcom-shutdown", false);
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// Callback 1.
|
||||
bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
|
||||
MOZ_RELEASE_ASSERT(ok);
|
||||
|
||||
BackgroundChildImpl::ThreadLocal* threadLocal =
|
||||
BackgroundChildImpl::GetThreadLocalForCurrentThread();
|
||||
MOZ_RELEASE_ASSERT(threadLocal);
|
||||
|
||||
// Callback 2.
|
||||
ok = BackgroundChild::GetOrCreateForCurrentThread(this);
|
||||
MOZ_RELEASE_ASSERT(ok);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, "xpcom-shutdown")) {
|
||||
MOZ_RELEASE_ASSERT(sCallbackCount == 3);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unknown observer topic!");
|
||||
}
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
};
|
||||
|
||||
uint32_t BackgroundTester::sCallbackCount = 0;
|
||||
|
||||
NS_IMPL_ISUPPORTS(BackgroundTester, nsIIPCBackgroundChildCreateCallback,
|
||||
nsIObserver)
|
||||
|
||||
#endif // ENABLE_TESTS
|
||||
|
||||
void
|
||||
MaybeTestPBackground()
|
||||
{
|
||||
#ifdef ENABLE_TESTS
|
||||
// This test relies on running the event loop and XPCShell does not always
|
||||
// do so. Bail out here if we detect that we're running in XPCShell.
|
||||
if (PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This is called too early at startup to test preferences directly. We have
|
||||
// to install an observer to be notified when preferences are available.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
MOZ_RELEASE_ASSERT(observerService);
|
||||
|
||||
nsCOMPtr<nsIObserver> observer = new BackgroundTester();
|
||||
nsresult rv = observerService->AddObserver(observer, "profile-after-change",
|
||||
false);
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
}
|
||||
|
||||
// XXX Workaround for bug 986973 to maintain the existing broken semantics
|
||||
template<>
|
||||
struct nsIConsoleService::COMTypeInfo<nsConsoleService, void> {
|
||||
@@ -862,10 +733,6 @@ ContentParent::StartUp()
|
||||
// Try to preallocate a process that we can transform into an app later.
|
||||
PreallocatedProcessManager::AllocateAfterDelay();
|
||||
|
||||
// Test the PBackground infrastructure on ENABLE_TESTS builds when a special
|
||||
// testing preference is set.
|
||||
MaybeTestPBackground();
|
||||
|
||||
sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
|
||||
|
||||
#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
|
||||
@@ -2697,19 +2564,19 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
// This looks like a lot of work, but in a normal browser session we just
|
||||
// send two loads.
|
||||
|
||||
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AgentStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
|
||||
}
|
||||
|
||||
for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->UserStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
|
||||
}
|
||||
|
||||
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AuthorStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
|
||||
@@ -3695,13 +3562,11 @@ ContentParent::DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParen
|
||||
/* static */ void
|
||||
ContentParent::ForceKillTimerCallback(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
#ifdef ENABLE_TESTS
|
||||
// We don't want to time out the content process during XPCShell tests. This
|
||||
// is the easiest way to ensure that.
|
||||
if (PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR")) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto self = static_cast<ContentParent*>(aClosure);
|
||||
self->KillHard("ShutDownKill");
|
||||
|
||||
@@ -111,9 +111,9 @@ nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
// Enable MathML and setup the style sheet during binding, not element
|
||||
// construction, because we could move a MathML element from the document
|
||||
// that created it to another document.
|
||||
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
|
||||
doc->SetMathMLEnabled();
|
||||
doc->
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::MathMLSheet());
|
||||
doc->EnsureOnDemandBuiltInUASheet(cache->MathMLSheet());
|
||||
|
||||
// Rebuild style data for the presshell, because style system
|
||||
// optimizations may have taken place assuming MathML was disabled.
|
||||
|
||||
@@ -243,9 +243,12 @@ MediaPermissionRequest::Allow(JS::HandleValue aChoices)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
// iterate through audio-capture and video-capture
|
||||
AutoSafeJSContext cx;
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.init(&aChoices.toObject())) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JSObject*> obj(cx, &aChoices.toObject());
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
|
||||
// get selected audio device name
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
#include "mozilla/dom/WorkerRunnable.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MessageChannel, mWindow, mPort1, mPort2)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MessageChannel, mGlobal, mPort1, mPort2)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MessageChannel)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MessageChannel)
|
||||
|
||||
@@ -29,9 +29,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MessageChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
MessageChannel::MessageChannel(nsPIDOMWindow* aWindow)
|
||||
: mWindow(aWindow)
|
||||
MessageChannel::MessageChannel(nsIGlobalObject* aGlobal)
|
||||
: mGlobal(aGlobal)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
}
|
||||
|
||||
MessageChannel::~MessageChannel()
|
||||
@@ -48,13 +49,15 @@ MessageChannel::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
MessageChannel::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
// window can be null in workers.
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
return Constructor(window, aRv);
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
return Constructor(global, aRv);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<MessageChannel>
|
||||
MessageChannel::Constructor(nsPIDOMWindow* aWindow, ErrorResult& aRv)
|
||||
MessageChannel::Constructor(nsIGlobalObject* aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
nsID portUUID1;
|
||||
aRv = nsContentUtils::GenerateUUIDInPlace(portUUID1);
|
||||
if (aRv.Failed()) {
|
||||
@@ -67,14 +70,14 @@ MessageChannel::Constructor(nsPIDOMWindow* aWindow, ErrorResult& aRv)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<MessageChannel> channel = new MessageChannel(aWindow);
|
||||
RefPtr<MessageChannel> channel = new MessageChannel(aGlobal);
|
||||
|
||||
channel->mPort1 = MessagePort::Create(aWindow, portUUID1, portUUID2, aRv);
|
||||
channel->mPort1 = MessagePort::Create(aGlobal, portUUID1, portUUID2, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
channel->mPort2 = MessagePort::Create(aWindow, portUUID2, portUUID1, aRv);
|
||||
channel->mPort2 = MessagePort::Create(aGlobal, portUUID2, portUUID1, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@@ -28,10 +28,10 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessageChannel)
|
||||
|
||||
nsPIDOMWindow*
|
||||
nsIGlobalObject*
|
||||
GetParentObject() const
|
||||
{
|
||||
return mWindow;
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
virtual JSObject*
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<MessageChannel>
|
||||
Constructor(nsPIDOMWindow* aWindow, ErrorResult& aRv);
|
||||
Constructor(nsIGlobalObject* aGlobal, ErrorResult& aRv);
|
||||
|
||||
MessagePort*
|
||||
Port1() const
|
||||
@@ -56,10 +56,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
explicit MessageChannel(nsPIDOMWindow* aWindow);
|
||||
explicit MessageChannel(nsIGlobalObject* aGlobal);
|
||||
~MessageChannel();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
|
||||
RefPtr<MessagePort> mPort1;
|
||||
RefPtr<MessagePort> mPort2;
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/PBackgroundChild.h"
|
||||
#include "mozilla/MessagePortTimelineMarker.h"
|
||||
#include "mozilla/TimelineConsumers.h"
|
||||
#include "mozilla/TimelineMarker.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
@@ -44,46 +47,10 @@ using namespace mozilla::dom::workers;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DispatchEventRunnable final : public nsICancelableRunnable
|
||||
class PostMessageRunnable final : public nsICancelableRunnable
|
||||
{
|
||||
friend class MessagePort;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
explicit DispatchEventRunnable(MessagePort* aPort)
|
||||
: mPort(aPort)
|
||||
{ }
|
||||
|
||||
NS_IMETHOD
|
||||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(mPort);
|
||||
MOZ_ASSERT(mPort->mDispatchRunnable == this);
|
||||
mPort->mDispatchRunnable = nullptr;
|
||||
mPort->Dispatch();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Cancel() override
|
||||
{
|
||||
mPort = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
~DispatchEventRunnable()
|
||||
{}
|
||||
|
||||
RefPtr<MessagePort> mPort;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(DispatchEventRunnable, nsICancelableRunnable, nsIRunnable)
|
||||
|
||||
class PostMessageRunnable final : public nsICancelableRunnable
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -98,15 +65,34 @@ public:
|
||||
NS_IMETHOD
|
||||
Run() override
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> globalObject;
|
||||
MOZ_ASSERT(mPort);
|
||||
MOZ_ASSERT(mPort->mPostMessageRunnable == this);
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
globalObject = do_QueryInterface(mPort->GetParentObject());
|
||||
} else {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
globalObject = workerPrivate->GlobalScope();
|
||||
}
|
||||
nsresult rv = DispatchMessage();
|
||||
|
||||
// We must check if we were waiting for this message in order to shutdown
|
||||
// the port.
|
||||
mPort->UpdateMustKeepAlive();
|
||||
|
||||
mPort->mPostMessageRunnable = nullptr;
|
||||
mPort->Dispatch();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Cancel() override
|
||||
{
|
||||
mPort = nullptr;
|
||||
mData = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult
|
||||
DispatchMessage() const
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = mPort->GetParentObject();
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (!globalObject || !jsapi.Init(globalObject)) {
|
||||
@@ -119,7 +105,27 @@ public:
|
||||
ErrorResult rv;
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
|
||||
UniquePtr<AbstractTimelineMarker> start;
|
||||
UniquePtr<AbstractTimelineMarker> end;
|
||||
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
||||
bool isTimelineRecording = timelines && !timelines->IsEmpty();
|
||||
|
||||
if (isTimelineRecording) {
|
||||
start = MakeUnique<MessagePortTimelineMarker>(
|
||||
ProfileTimelineMessagePortOperationType::DeserializeData,
|
||||
MarkerTracingType::START);
|
||||
}
|
||||
|
||||
mData->Read(mPort->GetParentObject(), cx, &value, rv);
|
||||
|
||||
if (isTimelineRecording) {
|
||||
end = MakeUnique<MessagePortTimelineMarker>(
|
||||
ProfileTimelineMessagePortOperationType::DeserializeData,
|
||||
MarkerTracingType::END);
|
||||
timelines->AddMarkerForAllObservedDocShells(start);
|
||||
timelines->AddMarkerForAllObservedDocShells(end);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
@@ -147,17 +153,6 @@ public:
|
||||
bool dummy;
|
||||
mPort->DispatchEvent(static_cast<dom::Event*>(event.get()), &dummy);
|
||||
|
||||
// We must check if we were waiting for this message in order to shutdown
|
||||
// the port.
|
||||
mPort->UpdateMustKeepAlive();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Cancel() override
|
||||
{
|
||||
mPort = nullptr;
|
||||
mData = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -175,8 +170,8 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(MessagePort)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessagePort,
|
||||
DOMEventTargetHelper)
|
||||
if (tmp->mDispatchRunnable) {
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDispatchRunnable->mPort);
|
||||
if (tmp->mPostMessageRunnable) {
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPostMessageRunnable->mPort);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessages);
|
||||
@@ -186,8 +181,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessagePort,
|
||||
DOMEventTargetHelper)
|
||||
if (tmp->mDispatchRunnable) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDispatchRunnable->mPort);
|
||||
if (tmp->mPostMessageRunnable) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPostMessageRunnable->mPort);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUnshippedEntangledPort);
|
||||
@@ -279,20 +274,17 @@ NS_IMPL_ISUPPORTS(ForceCloseHelper, nsIIPCBackgroundChildCreateCallback)
|
||||
|
||||
} // namespace
|
||||
|
||||
MessagePort::MessagePort(nsISupports* aSupports)
|
||||
: mInnerID(0)
|
||||
MessagePort::MessagePort(nsIGlobalObject* aGlobal)
|
||||
: DOMEventTargetHelper(aGlobal)
|
||||
, mInnerID(0)
|
||||
, mMessageQueueEnabled(false)
|
||||
, mIsKeptAlive(false)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
mIdentifier = new MessagePortIdentifier();
|
||||
mIdentifier->neutered() = true;
|
||||
mIdentifier->sequenceId() = 0;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = do_QueryInterface(aSupports);
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return;
|
||||
}
|
||||
BindToOwner(globalObject);
|
||||
}
|
||||
|
||||
MessagePort::~MessagePort()
|
||||
@@ -302,21 +294,25 @@ MessagePort::~MessagePort()
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<MessagePort>
|
||||
MessagePort::Create(nsISupports* aSupport, const nsID& aUUID,
|
||||
MessagePort::Create(nsIGlobalObject* aGlobal, const nsID& aUUID,
|
||||
const nsID& aDestinationUUID, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<MessagePort> mp = new MessagePort(aSupport);
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
RefPtr<MessagePort> mp = new MessagePort(aGlobal);
|
||||
mp->Initialize(aUUID, aDestinationUUID, 1 /* 0 is an invalid sequence ID */,
|
||||
false /* Neutered */, eStateUnshippedEntangled, aRv);
|
||||
return mp.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<MessagePort>
|
||||
MessagePort::Create(nsISupports* aSupport,
|
||||
MessagePort::Create(nsIGlobalObject* aGlobal,
|
||||
const MessagePortIdentifier& aIdentifier,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<MessagePort> mp = new MessagePort(aSupport);
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
RefPtr<MessagePort> mp = new MessagePort(aGlobal);
|
||||
mp->Initialize(aIdentifier.uuid(), aIdentifier.destinationUuid(),
|
||||
aIdentifier.sequenceId(), aIdentifier.neutered(),
|
||||
eStateEntangling, aRv);
|
||||
@@ -367,8 +363,7 @@ MessagePort::Initialize(const nsID& aUUID,
|
||||
MOZ_ASSERT(!mWorkerFeature);
|
||||
|
||||
nsAutoPtr<WorkerFeature> feature(new MessagePortFeature(this));
|
||||
JSContext* cx = workerPrivate->GetJSContext();
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(cx, feature))) {
|
||||
if (NS_WARN_IF(!workerPrivate->AddFeature(feature))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
@@ -441,7 +436,27 @@ MessagePort::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
||||
|
||||
RefPtr<SharedMessagePortMessage> data = new SharedMessagePortMessage();
|
||||
|
||||
UniquePtr<AbstractTimelineMarker> start;
|
||||
UniquePtr<AbstractTimelineMarker> end;
|
||||
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
||||
bool isTimelineRecording = timelines && !timelines->IsEmpty();
|
||||
|
||||
if (isTimelineRecording) {
|
||||
start = MakeUnique<MessagePortTimelineMarker>(
|
||||
ProfileTimelineMessagePortOperationType::SerializeData,
|
||||
MarkerTracingType::START);
|
||||
}
|
||||
|
||||
data->Write(aCx, aMessage, transferable, aRv);
|
||||
|
||||
if (isTimelineRecording) {
|
||||
end = MakeUnique<MessagePortTimelineMarker>(
|
||||
ProfileTimelineMessagePortOperationType::SerializeData,
|
||||
MarkerTracingType::END);
|
||||
timelines->AddMarkerForAllObservedDocShells(start);
|
||||
timelines->AddMarkerForAllObservedDocShells(end);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
@@ -498,7 +513,7 @@ MessagePort::Start()
|
||||
void
|
||||
MessagePort::Dispatch()
|
||||
{
|
||||
if (!mMessageQueueEnabled || mMessages.IsEmpty() || mDispatchRunnable) {
|
||||
if (!mMessageQueueEnabled || mMessages.IsEmpty() || mPostMessageRunnable) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -550,13 +565,9 @@ MessagePort::Dispatch()
|
||||
RefPtr<SharedMessagePortMessage> data = mMessages.ElementAt(0);
|
||||
mMessages.RemoveElementAt(0);
|
||||
|
||||
RefPtr<PostMessageRunnable> runnable = new PostMessageRunnable(this, data);
|
||||
mPostMessageRunnable = new PostMessageRunnable(this, data);
|
||||
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(runnable)));
|
||||
|
||||
mDispatchRunnable = new DispatchEventRunnable(this);
|
||||
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(mDispatchRunnable)));
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(mPostMessageRunnable)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -908,8 +919,7 @@ MessagePort::UpdateMustKeepAlive()
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
workerPrivate->RemoveFeature(workerPrivate->GetJSContext(),
|
||||
mWorkerFeature);
|
||||
workerPrivate->RemoveFeature(mWorkerFeature);
|
||||
mWorkerFeature = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
#undef PostMessage
|
||||
#endif
|
||||
|
||||
class nsPIDOMWindow;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DispatchEventRunnable;
|
||||
class MessagePortChild;
|
||||
class MessagePortIdentifier;
|
||||
class MessagePortMessage;
|
||||
@@ -36,7 +35,6 @@ class MessagePort final : public DOMEventTargetHelper
|
||||
, public nsIIPCBackgroundChildCreateCallback
|
||||
, public nsIObserver
|
||||
{
|
||||
friend class DispatchEventRunnable;
|
||||
friend class PostMessageRunnable;
|
||||
|
||||
public:
|
||||
@@ -47,11 +45,12 @@ public:
|
||||
DOMEventTargetHelper)
|
||||
|
||||
static already_AddRefed<MessagePort>
|
||||
Create(nsISupports* aSupport, const nsID& aUUID,
|
||||
Create(nsIGlobalObject* aGlobal, const nsID& aUUID,
|
||||
const nsID& aDestinationUUID, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<MessagePort>
|
||||
Create(nsISupports* aSupport, const MessagePortIdentifier& aIdentifier,
|
||||
Create(nsIGlobalObject* aGlobal,
|
||||
const MessagePortIdentifier& aIdentifier,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// For IPC.
|
||||
@@ -90,7 +89,7 @@ public:
|
||||
void Closed();
|
||||
|
||||
private:
|
||||
explicit MessagePort(nsISupports* nsISupports);
|
||||
explicit MessagePort(nsIGlobalObject* aGlobal);
|
||||
~MessagePort();
|
||||
|
||||
enum State {
|
||||
@@ -166,7 +165,7 @@ private:
|
||||
|
||||
nsAutoPtr<workers::WorkerFeature> mWorkerFeature;
|
||||
|
||||
RefPtr<DispatchEventRunnable> mDispatchRunnable;
|
||||
RefPtr<PostMessageRunnable> mPostMessageRunnable;
|
||||
|
||||
RefPtr<MessagePortChild> mActor;
|
||||
|
||||
|
||||
@@ -97,8 +97,7 @@ public:
|
||||
const nsAString& aIcon,
|
||||
const nsAString& aData,
|
||||
const nsAString& aBehavior,
|
||||
const nsAString& aServiceWorkerRegistrationID,
|
||||
JSContext* aCx) final
|
||||
const nsAString& aServiceWorkerRegistrationID) final
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!aID.IsEmpty());
|
||||
@@ -125,7 +124,7 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD Done(JSContext* aCx) override = 0;
|
||||
NS_IMETHOD Done() override = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ScopeCheckingGetCallback()
|
||||
@@ -151,12 +150,8 @@ public:
|
||||
MOZ_ASSERT(aPromise);
|
||||
}
|
||||
|
||||
NS_IMETHOD Done(JSContext* aCx) final
|
||||
NS_IMETHOD Done() final
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
DebugOnly<bool> ok = jsapi.Init(mWindow, aCx);
|
||||
MOZ_ASSERT(ok);
|
||||
|
||||
ErrorResult result;
|
||||
AutoTArray<RefPtr<Notification>, 5> notifications;
|
||||
|
||||
@@ -373,7 +368,7 @@ protected:
|
||||
}
|
||||
|
||||
bool
|
||||
PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
PreDispatch(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
// We don't call WorkerRunnable::PreDispatch because it would assert the
|
||||
// wrong thing about which thread we're on.
|
||||
@@ -382,8 +377,7 @@ protected:
|
||||
}
|
||||
|
||||
void
|
||||
PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
bool aDispatchResult) override
|
||||
PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
|
||||
{
|
||||
// We don't call WorkerRunnable::PostDispatch because it would assert the
|
||||
// wrong thing about which thread we're on.
|
||||
@@ -394,8 +388,8 @@ protected:
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(aCx, true);
|
||||
WorkerRunInternal(aCx, aWorkerPrivate);
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(true);
|
||||
WorkerRunInternal(aWorkerPrivate);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -403,11 +397,11 @@ protected:
|
||||
PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
bool aRunResult) override
|
||||
{
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false);
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(false);
|
||||
}
|
||||
|
||||
virtual void
|
||||
WorkerRunInternal(JSContext* aCx, WorkerPrivate* aWorkerPrivate) = 0;
|
||||
WorkerRunInternal(WorkerPrivate* aWorkerPrivate) = 0;
|
||||
};
|
||||
|
||||
// Overrides dispatch and run handlers so we can directly dispatch from main
|
||||
@@ -425,7 +419,7 @@ public:
|
||||
{}
|
||||
|
||||
void
|
||||
WorkerRunInternal(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
WorkerRunInternal(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
mNotification->DispatchTrustedEvent(mEventName);
|
||||
}
|
||||
@@ -441,7 +435,7 @@ public:
|
||||
{}
|
||||
|
||||
void
|
||||
WorkerRunInternal(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
WorkerRunInternal(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
mNotification->ReleaseObject();
|
||||
}
|
||||
@@ -504,12 +498,10 @@ public:
|
||||
RefPtr<ReleaseNotificationRunnable> r =
|
||||
new ReleaseNotificationRunnable(notification);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!r->Dispatch(jsapi.cx())) {
|
||||
if (!r->Dispatch()) {
|
||||
RefPtr<ReleaseNotificationControlRunnable> r =
|
||||
new ReleaseNotificationControlRunnable(notification);
|
||||
MOZ_ALWAYS_TRUE(r->Dispatch(jsapi.cx()));
|
||||
MOZ_ALWAYS_TRUE(r->Dispatch());
|
||||
}
|
||||
} else {
|
||||
notification->AssertIsOnTargetThread();
|
||||
@@ -1057,7 +1049,8 @@ Notification::Constructor(const GlobalObject& aGlobal,
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
RefPtr<Notification> notification =
|
||||
CreateAndShow(global, aTitle, aOptions, EmptyString(), aRv);
|
||||
CreateAndShow(aGlobal.Context(), global, aTitle, aOptions,
|
||||
EmptyString(), aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1084,20 +1077,16 @@ Notification::ConstructFromFields(
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
DebugOnly<bool> ok = jsapi.Init(aGlobal);
|
||||
MOZ_ASSERT(ok);
|
||||
|
||||
RootedDictionary<NotificationOptions> options(jsapi.cx());
|
||||
RootedDictionary<NotificationOptions> options(nsContentUtils::RootingCxForThread());
|
||||
options.mDir = Notification::StringToDirection(nsString(aDir));
|
||||
options.mLang = aLang;
|
||||
options.mBody = aBody;
|
||||
options.mTag = aTag;
|
||||
options.mIcon = aIcon;
|
||||
RefPtr<Notification> notification = CreateInternal(aGlobal, aID, aTitle,
|
||||
options);
|
||||
options);
|
||||
|
||||
notification->InitFromBase64(jsapi.cx(), aData, aRv);
|
||||
notification->InitFromBase64(aData, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1376,7 +1365,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
WorkerRunInternal(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
WorkerRunInternal(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
bool doDefaultAction = mNotification->DispatchClickEvent();
|
||||
MOZ_ASSERT_IF(mWorkerPrivate->IsServiceWorker(), !doDefaultAction);
|
||||
@@ -1559,8 +1548,7 @@ WorkerNotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
}
|
||||
|
||||
MOZ_ASSERT(r);
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch event to worker notification");
|
||||
}
|
||||
return NS_OK;
|
||||
@@ -1587,8 +1575,7 @@ public:
|
||||
const nsAString& aIcon,
|
||||
const nsAString& aData,
|
||||
const nsAString& aBehavior,
|
||||
const nsAString& aServiceWorkerRegistrationID,
|
||||
JSContext* aCx) override
|
||||
const nsAString& aServiceWorkerRegistrationID) override
|
||||
{
|
||||
MOZ_ASSERT(!aID.IsEmpty());
|
||||
MOZ_ASSERT(mScope.Equals(aServiceWorkerRegistrationID));
|
||||
@@ -1620,7 +1607,7 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD Done(JSContext* aCx) override
|
||||
NS_IMETHOD Done() override
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1731,8 +1718,7 @@ Notification::ShowInternal()
|
||||
RefPtr<NotificationEventWorkerRunnable> r =
|
||||
new NotificationEventWorkerRunnable(this,
|
||||
NS_LITERAL_STRING("error"));
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch event to worker notification");
|
||||
}
|
||||
} else {
|
||||
@@ -2095,7 +2081,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
WorkerRunInternal(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
WorkerRunInternal(WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
RefPtr<Promise> workerPromise = mPromiseProxy->WorkerPromise();
|
||||
|
||||
@@ -2125,7 +2111,7 @@ public:
|
||||
}
|
||||
|
||||
workerPromise->MaybeResolve(notifications);
|
||||
mPromiseProxy->CleanUp(aCx);
|
||||
mPromiseProxy->CleanUp();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2142,7 +2128,7 @@ public:
|
||||
MOZ_ASSERT(aProxy);
|
||||
}
|
||||
|
||||
NS_IMETHOD Done(JSContext* aCx) final
|
||||
NS_IMETHOD Done() final
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(mPromiseProxy, "Was Done() called twice?");
|
||||
@@ -2158,7 +2144,7 @@ public:
|
||||
proxy,
|
||||
Move(mStrings));
|
||||
|
||||
r->Dispatch(aCx);
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -2190,14 +2176,11 @@ public:
|
||||
nsCOMPtr<nsINotificationStorageCallback> callback =
|
||||
new WorkerGetCallback(mPromiseProxy, mScope);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINotificationStorage> notificationStorage =
|
||||
do_GetService(NS_NOTIFICATION_STORAGE_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
callback->Done(jsapi.cx());
|
||||
callback->Done();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -2211,13 +2194,13 @@ public:
|
||||
Notification::GetOrigin(mPromiseProxy->GetWorkerPrivate()->GetPrincipal(),
|
||||
origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
callback->Done(jsapi.cx());
|
||||
callback->Done();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = notificationStorage->Get(origin, mTag, callback);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
callback->Done(jsapi.cx());
|
||||
callback->Done();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -2341,8 +2324,7 @@ Notification::GetData(JSContext* aCx,
|
||||
nsresult rv;
|
||||
RefPtr<nsStructuredCloneContainer> container =
|
||||
new nsStructuredCloneContainer();
|
||||
rv = container->InitFromBase64(mDataAsBase64, JS_STRUCTURED_CLONE_VERSION,
|
||||
aCx);
|
||||
rv = container->InitFromBase64(mDataAsBase64, JS_STRUCTURED_CLONE_VERSION);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRetval.setNull();
|
||||
return;
|
||||
@@ -2386,8 +2368,7 @@ Notification::InitFromJSVal(JSContext* aCx, JS::Handle<JS::Value> aData,
|
||||
dataObjectContainer->GetDataAsBase64(mDataAsBase64);
|
||||
}
|
||||
|
||||
void Notification::InitFromBase64(JSContext* aCx, const nsAString& aData,
|
||||
ErrorResult& aRv)
|
||||
void Notification::InitFromBase64(const nsAString& aData, ErrorResult& aRv)
|
||||
{
|
||||
if (!mDataAsBase64.IsEmpty() || aData.IsEmpty()) {
|
||||
return;
|
||||
@@ -2396,8 +2377,7 @@ void Notification::InitFromBase64(JSContext* aCx, const nsAString& aData,
|
||||
// To and fro to ensure it is valid base64.
|
||||
RefPtr<nsStructuredCloneContainer> container =
|
||||
new nsStructuredCloneContainer();
|
||||
aRv = container->InitFromBase64(aData, JS_STRUCTURED_CLONE_VERSION,
|
||||
aCx);
|
||||
aRv = container->InitFromBase64(aData, JS_STRUCTURED_CLONE_VERSION);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
@@ -2531,8 +2511,7 @@ Notification::RegisterFeature()
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
MOZ_ASSERT(!mFeature);
|
||||
mFeature = MakeUnique<NotificationFeature>(this);
|
||||
bool added = mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(),
|
||||
mFeature.get());
|
||||
bool added = mWorkerPrivate->AddFeature(mFeature.get());
|
||||
if (!added) {
|
||||
mFeature = nullptr;
|
||||
}
|
||||
@@ -2546,8 +2525,7 @@ Notification::UnregisterFeature()
|
||||
MOZ_ASSERT(mWorkerPrivate);
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
MOZ_ASSERT(mFeature);
|
||||
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(),
|
||||
mFeature.get());
|
||||
mWorkerPrivate->RemoveFeature(mFeature.get());
|
||||
mFeature = nullptr;
|
||||
}
|
||||
|
||||
@@ -2605,7 +2583,8 @@ public:
|
||||
|
||||
/* static */
|
||||
already_AddRefed<Promise>
|
||||
Notification::ShowPersistentNotification(nsIGlobalObject *aGlobal,
|
||||
Notification::ShowPersistentNotification(JSContext* aCx,
|
||||
nsIGlobalObject *aGlobal,
|
||||
const nsAString& aScope,
|
||||
const nsAString& aTitle,
|
||||
const NotificationOptions& aOptions,
|
||||
@@ -2682,7 +2661,7 @@ Notification::ShowPersistentNotification(nsIGlobalObject *aGlobal,
|
||||
p->MaybeResolve(JS::UndefinedHandleValue);
|
||||
|
||||
RefPtr<Notification> notification =
|
||||
CreateAndShow(aGlobal, aTitle, aOptions, aScope, aRv);
|
||||
CreateAndShow(aCx, aGlobal, aTitle, aOptions, aScope, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2691,7 +2670,8 @@ Notification::ShowPersistentNotification(nsIGlobalObject *aGlobal,
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Notification>
|
||||
Notification::CreateAndShow(nsIGlobalObject* aGlobal,
|
||||
Notification::CreateAndShow(JSContext* aCx,
|
||||
nsIGlobalObject* aGlobal,
|
||||
const nsAString& aTitle,
|
||||
const NotificationOptions& aOptions,
|
||||
const nsAString& aScope,
|
||||
@@ -2699,21 +2679,12 @@ Notification::CreateAndShow(nsIGlobalObject* aGlobal,
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(aGlobal)))
|
||||
{
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
RefPtr<Notification> notification = CreateInternal(aGlobal, EmptyString(),
|
||||
aTitle, aOptions);
|
||||
aTitle, aOptions);
|
||||
|
||||
// Make a structured clone of the aOptions.mData object
|
||||
JS::Rooted<JS::Value> data(cx, aOptions.mData);
|
||||
notification->InitFromJSVal(cx, data, aRv);
|
||||
JS::Rooted<JS::Value> data(aCx, aOptions.mData);
|
||||
notification->InitFromJSVal(aCx, data, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user