mirror of
https://github.com/Feodor2/Mypal68.git
synced 2025-06-18 14:55:44 -04:00
68.14.5 - dom
This commit is contained in:
parent
1b3a309103
commit
dad6ce97e1
@ -83,8 +83,7 @@ void AbortSignal::Abort() {
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
|
||||
RefPtr<Event> event =
|
||||
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
|
||||
RefPtr<Event> event = Event::Constructor(this, u"abort"_ns, init);
|
||||
event->SetTrusted(true);
|
||||
|
||||
DispatchEvent(*event);
|
||||
|
@ -502,8 +502,7 @@ void Animation::Cancel(PostRestyleMode aPostRestyle) {
|
||||
}
|
||||
ResetFinishedPromise();
|
||||
|
||||
QueuePlaybackEvent(NS_LITERAL_STRING("cancel"),
|
||||
GetTimelineCurrentTimeAsTimeStamp());
|
||||
QueuePlaybackEvent(u"cancel"_ns, GetTimelineCurrentTimeAsTimeStamp());
|
||||
}
|
||||
|
||||
StickyTimeDuration activeTime =
|
||||
@ -1107,8 +1106,7 @@ void Animation::Remove() {
|
||||
UpdateEffect(PostRestyleMode::IfNeeded);
|
||||
PostUpdate();
|
||||
|
||||
QueuePlaybackEvent(NS_LITERAL_STRING("remove"),
|
||||
GetTimelineCurrentTimeAsTimeStamp());
|
||||
QueuePlaybackEvent(u"remove"_ns, GetTimelineCurrentTimeAsTimeStamp());
|
||||
}
|
||||
|
||||
bool Animation::HasLowerCompositeOrderThan(const Animation& aOther) const {
|
||||
@ -1764,8 +1762,7 @@ void Animation::DoFinishNotificationImmediately(MicroTaskRunnable* aAsync) {
|
||||
|
||||
MaybeResolveFinishedPromise();
|
||||
|
||||
QueuePlaybackEvent(NS_LITERAL_STRING("finish"),
|
||||
AnimationTimeToTimeStamp(EffectEnd()));
|
||||
QueuePlaybackEvent(u"finish"_ns, AnimationTimeToTimeStamp(EffectEnd()));
|
||||
}
|
||||
|
||||
void Animation::QueuePlaybackEvent(const nsAString& aName,
|
||||
|
@ -320,7 +320,7 @@ void AnimationEffect::GetComputedTimingAsDict(
|
||||
void AnimationEffect::UpdateTiming(const OptionalEffectTiming& aTiming,
|
||||
ErrorResult& aRv) {
|
||||
TimingParams timing =
|
||||
TimingParams::MergeOptionalEffectTiming(mTiming, aTiming, mDocument, aRv);
|
||||
TimingParams::MergeOptionalEffectTiming(mTiming, aTiming, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
@ -790,8 +790,7 @@ already_AddRefed<KeyframeEffect> KeyframeEffect::ConstructKeyframeEffect(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TimingParams timingParams =
|
||||
TimingParams::FromOptionsUnion(aOptions, doc, aRv);
|
||||
TimingParams timingParams = TimingParams::FromOptionsUnion(aOptions, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -441,8 +441,8 @@ static bool ConvertKeyframeSequence(JSContext* aCx, dom::Document* aDocument,
|
||||
}
|
||||
|
||||
if (!parseEasingResult.Failed()) {
|
||||
keyframe->mTimingFunction = TimingParams::ParseEasing(
|
||||
keyframeDict.mEasing, aDocument, parseEasingResult);
|
||||
keyframe->mTimingFunction =
|
||||
TimingParams::ParseEasing(keyframeDict.mEasing, parseEasingResult);
|
||||
// Even if the above fails, we still need to continue reading off all the
|
||||
// properties since checking the validity of easing should be treated as
|
||||
// a separate step that happens *after* all the other processing in this
|
||||
@ -623,9 +623,9 @@ static void ReportInvalidPropertyValueToConsole(
|
||||
params.AppendElement(aInvalidPropertyValue);
|
||||
CopyASCIItoUTF16(nsCSSProps::GetStringValue(aProperty),
|
||||
*params.AppendElement());
|
||||
nsContentUtils::ReportToConsole(
|
||||
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Animation"), aDoc,
|
||||
nsContentUtils::eDOM_PROPERTIES, "InvalidKeyframePropertyValue", params);
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Animation"_ns,
|
||||
aDoc, nsContentUtils::eDOM_PROPERTIES,
|
||||
"InvalidKeyframePropertyValue", params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1096,7 +1096,7 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
|
||||
FallibleTArray<Maybe<ComputedTimingFunction>> easings;
|
||||
auto parseAndAppendEasing = [&](const nsString& easingString,
|
||||
ErrorResult& aRv) {
|
||||
auto easing = TimingParams::ParseEasing(easingString, aDocument, aRv);
|
||||
auto easing = TimingParams::ParseEasing(easingString, aRv);
|
||||
if (!aRv.Failed() && !easings.AppendElement(std::move(easing), fallible)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ const dom::EffectTiming& GetTimingProperties(
|
||||
template <class OptionsType>
|
||||
/* static */
|
||||
TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions,
|
||||
dom::Document* aDocument,
|
||||
ErrorResult& aRv) {
|
||||
TimingParams result;
|
||||
|
||||
@ -53,7 +52,7 @@ TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions,
|
||||
result.Update();
|
||||
} else {
|
||||
const dom::EffectTiming& timing = GetTimingProperties(aOptions);
|
||||
result = FromEffectTiming(timing, aDocument, aRv);
|
||||
result = FromEffectTiming(timing, aRv);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -62,21 +61,20 @@ TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions,
|
||||
/* static */
|
||||
TimingParams TimingParams::FromOptionsUnion(
|
||||
const dom::UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
||||
dom::Document* aDocument, ErrorResult& aRv) {
|
||||
return FromOptionsType(aOptions, aDocument, aRv);
|
||||
ErrorResult& aRv) {
|
||||
return FromOptionsType(aOptions, aRv);
|
||||
}
|
||||
|
||||
/* static */
|
||||
TimingParams TimingParams::FromOptionsUnion(
|
||||
const dom::UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
||||
dom::Document* aDocument, ErrorResult& aRv) {
|
||||
return FromOptionsType(aOptions, aDocument, aRv);
|
||||
ErrorResult& aRv) {
|
||||
return FromOptionsType(aOptions, aRv);
|
||||
}
|
||||
|
||||
/* static */
|
||||
TimingParams TimingParams::FromEffectTiming(
|
||||
const dom::EffectTiming& aEffectTiming, dom::Document* aDocument,
|
||||
ErrorResult& aRv) {
|
||||
const dom::EffectTiming& aEffectTiming, ErrorResult& aRv) {
|
||||
TimingParams result;
|
||||
|
||||
Maybe<StickyTimeDuration> duration =
|
||||
@ -93,7 +91,7 @@ TimingParams TimingParams::FromEffectTiming(
|
||||
return result;
|
||||
}
|
||||
Maybe<ComputedTimingFunction> easing =
|
||||
TimingParams::ParseEasing(aEffectTiming.mEasing, aDocument, aRv);
|
||||
TimingParams::ParseEasing(aEffectTiming.mEasing, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return result;
|
||||
}
|
||||
@ -115,7 +113,7 @@ TimingParams TimingParams::FromEffectTiming(
|
||||
/* static */
|
||||
TimingParams TimingParams::MergeOptionalEffectTiming(
|
||||
const TimingParams& aSource, const dom::OptionalEffectTiming& aEffectTiming,
|
||||
dom::Document* aDocument, ErrorResult& aRv) {
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT(!aRv.Failed(), "Initially return value should be ok");
|
||||
|
||||
TimingParams result = aSource;
|
||||
@ -148,8 +146,7 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
|
||||
|
||||
Maybe<ComputedTimingFunction> easing;
|
||||
if (aEffectTiming.mEasing.WasPassed()) {
|
||||
easing = TimingParams::ParseEasing(aEffectTiming.mEasing.Value(), aDocument,
|
||||
aRv);
|
||||
easing = TimingParams::ParseEasing(aEffectTiming.mEasing.Value(), aRv);
|
||||
if (aRv.Failed()) {
|
||||
return result;
|
||||
}
|
||||
@ -191,12 +188,9 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
|
||||
|
||||
/* static */
|
||||
Maybe<ComputedTimingFunction> TimingParams::ParseEasing(
|
||||
const nsAString& aEasing, dom::Document* aDocument, ErrorResult& aRv) {
|
||||
MOZ_ASSERT(aDocument);
|
||||
|
||||
const nsAString& aEasing, ErrorResult& aRv) {
|
||||
nsTimingFunction timingFunction;
|
||||
RefPtr<URLExtraData> url = ServoCSSParser::GetURLExtraData(aDocument);
|
||||
if (!ServoCSSParser::ParseEasing(aEasing, url, timingFunction)) {
|
||||
if (!ServoCSSParser::ParseEasing(aEasing, timingFunction)) {
|
||||
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(
|
||||
NS_ConvertUTF16toUTF8(aEasing));
|
||||
return Nothing();
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class Document;
|
||||
class UnrestrictedDoubleOrKeyframeEffectOptions;
|
||||
class UnrestrictedDoubleOrKeyframeAnimationOptions;
|
||||
} // namespace dom
|
||||
@ -54,16 +53,14 @@ struct TimingParams {
|
||||
|
||||
template <class OptionsType>
|
||||
static TimingParams FromOptionsType(const OptionsType& aOptions,
|
||||
dom::Document* aDocument,
|
||||
ErrorResult& aRv);
|
||||
static TimingParams FromOptionsUnion(
|
||||
const dom::UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
||||
dom::Document* aDocument, ErrorResult& aRv);
|
||||
ErrorResult& aRv);
|
||||
static TimingParams FromOptionsUnion(
|
||||
const dom::UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
||||
dom::Document* aDocument, ErrorResult& aRv);
|
||||
ErrorResult& aRv);
|
||||
static TimingParams FromEffectTiming(const dom::EffectTiming& aEffectTiming,
|
||||
dom::Document* aDocument,
|
||||
ErrorResult& aRv);
|
||||
// Returns a copy of |aSource| where each timing property in |aSource| that
|
||||
// is also specified in |aEffectTiming| is replaced with the value from
|
||||
@ -73,8 +70,7 @@ struct TimingParams {
|
||||
// true and an unmodified copy of |aSource| will be returned.
|
||||
static TimingParams MergeOptionalEffectTiming(
|
||||
const TimingParams& aSource,
|
||||
const dom::OptionalEffectTiming& aEffectTiming, dom::Document* aDocument,
|
||||
ErrorResult& aRv);
|
||||
const dom::OptionalEffectTiming& aEffectTiming, ErrorResult& aRv);
|
||||
|
||||
// Range-checks and validates an UnrestrictedDoubleOrString or
|
||||
// OwningUnrestrictedDoubleOrString object and converts to a
|
||||
@ -120,7 +116,6 @@ struct TimingParams {
|
||||
}
|
||||
|
||||
static Maybe<ComputedTimingFunction> ParseEasing(const nsAString& aEasing,
|
||||
dom::Document* aDocument,
|
||||
ErrorResult& aRv);
|
||||
|
||||
static StickyTimeDuration CalcActiveDuration(
|
||||
|
@ -190,9 +190,8 @@ void AnonymousContent::GetComputedStylePropertyValue(
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<nsComputedDOMStyle> cs =
|
||||
new nsComputedDOMStyle(element, NS_LITERAL_STRING(""),
|
||||
element->OwnerDoc(), nsComputedDOMStyle::eAll);
|
||||
RefPtr<nsComputedDOMStyle> cs = new nsComputedDOMStyle(
|
||||
element, u""_ns, element->OwnerDoc(), nsComputedDOMStyle::eAll);
|
||||
aRv = cs->GetPropertyValue(aPropertyName, aResult);
|
||||
}
|
||||
|
||||
@ -215,7 +214,7 @@ void AnonymousContent::SetStyle(const nsACString& aProperty,
|
||||
|
||||
nsGenericHTMLElement* element = nsGenericHTMLElement::FromNode(mContentNode);
|
||||
nsCOMPtr<nsICSSDeclaration> declaration = element->Style();
|
||||
declaration->SetProperty(aProperty, aValue, EmptyString(), IgnoreErrors());
|
||||
declaration->SetProperty(aProperty, aValue, u""_ns, IgnoreErrors());
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
@ -153,15 +153,13 @@ class MOZ_STACK_CLASS FormDataParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (seenFormData &&
|
||||
StringBeginsWith(token, NS_LITERAL_CSTRING("name="))) {
|
||||
if (seenFormData && StringBeginsWith(token, "name="_ns)) {
|
||||
mName = StringTail(token, token.Length() - 5);
|
||||
mName.Trim(" \"");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (seenFormData &&
|
||||
StringBeginsWith(token, NS_LITERAL_CSTRING("filename="))) {
|
||||
if (seenFormData && StringBeginsWith(token, "filename="_ns)) {
|
||||
mFilename = StringTail(token, token.Length() - 9);
|
||||
mFilename.Trim(" \"");
|
||||
continue;
|
||||
@ -321,7 +319,7 @@ class MOZ_STACK_CLASS FormDataParser {
|
||||
case START_PART:
|
||||
mName.SetIsVoid(true);
|
||||
mFilename.SetIsVoid(true);
|
||||
mContentType = NS_LITERAL_CSTRING("text/plain");
|
||||
mContentType = "text/plain"_ns;
|
||||
|
||||
// MUST start with boundary.
|
||||
if (!PushOverBoundary(boundaryString, start, end)) {
|
||||
@ -420,7 +418,7 @@ already_AddRefed<FormData> BodyUtil::ConsumeFormData(nsIGlobalObject* aParent,
|
||||
const nsCString& aMimeType,
|
||||
const nsCString& aStr,
|
||||
ErrorResult& aRv) {
|
||||
NS_NAMED_LITERAL_CSTRING(formDataMimeType, "multipart/form-data");
|
||||
constexpr auto formDataMimeType = "multipart/form-data"_ns;
|
||||
|
||||
// Allow semicolon separated boundary/encoding suffix like
|
||||
// multipart/form-data; boundary= but disallow multipart/form-datafoobar.
|
||||
@ -443,8 +441,7 @@ already_AddRefed<FormData> BodyUtil::ConsumeFormData(nsIGlobalObject* aParent,
|
||||
return fd.forget();
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(urlDataMimeType,
|
||||
"application/x-www-form-urlencoded");
|
||||
constexpr auto urlDataMimeType = "application/x-www-form-urlencoded"_ns;
|
||||
bool isValidUrlEncodedMimeType = StringBeginsWith(aMimeType, urlDataMimeType);
|
||||
|
||||
if (isValidUrlEncodedMimeType &&
|
||||
|
644
dom/base/CCGCScheduler.h
Normal file
644
dom/base/CCGCScheduler.h
Normal file
@ -0,0 +1,644 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "js/SliceBudget.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/MainThreadIdlePeriod.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsCycleCollector.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static const TimeDuration kOneMinute = TimeDuration::FromSeconds(60.0f);
|
||||
|
||||
// The amount of time we wait between a request to CC (after GC ran)
|
||||
// and doing the actual CC.
|
||||
static const TimeDuration kCCDelay = TimeDuration::FromSeconds(6);
|
||||
|
||||
static const TimeDuration kCCSkippableDelay =
|
||||
TimeDuration::FromMilliseconds(250);
|
||||
|
||||
// In case the cycle collector isn't run at all, we don't want forget skippables
|
||||
// to run too often. So limit the forget skippable cycle to start at earliest 2
|
||||
// seconds after the end of the previous cycle.
|
||||
static const TimeDuration kTimeBetweenForgetSkippableCycles =
|
||||
TimeDuration::FromSeconds(2);
|
||||
|
||||
// ForgetSkippable is usually fast, so we can use small budgets.
|
||||
// This isn't a real budget but a hint to IdleTaskRunner whether there
|
||||
// is enough time to call ForgetSkippable.
|
||||
static const TimeDuration kForgetSkippableSliceDuration =
|
||||
TimeDuration::FromMilliseconds(2);
|
||||
|
||||
// Maximum amount of time that should elapse between incremental CC slices
|
||||
static const TimeDuration kICCIntersliceDelay =
|
||||
TimeDuration::FromMilliseconds(64);
|
||||
|
||||
// Time budget for an incremental CC slice when using timer to run it.
|
||||
static const TimeDuration kICCSliceBudget = TimeDuration::FromMilliseconds(3);
|
||||
// Minimum budget for an incremental CC slice when using idle time to run it.
|
||||
static const TimeDuration kIdleICCSliceBudget =
|
||||
TimeDuration::FromMilliseconds(2);
|
||||
|
||||
// Maximum total duration for an ICC
|
||||
static const TimeDuration kMaxICCDuration = TimeDuration::FromSeconds(2);
|
||||
|
||||
// Force a CC after this long if there's more than NS_CC_FORCED_PURPLE_LIMIT
|
||||
// objects in the purple buffer.
|
||||
static const TimeDuration kCCForced = kOneMinute * 2;
|
||||
static const uint32_t kCCForcedPurpleLimit = 10;
|
||||
|
||||
// Don't allow an incremental GC to lock out the CC for too long.
|
||||
static const TimeDuration kMaxCCLockedoutTime = TimeDuration::FromSeconds(30);
|
||||
|
||||
// Trigger a CC if the purple buffer exceeds this size when we check it.
|
||||
static const uint32_t kCCPurpleLimit = 200;
|
||||
|
||||
enum class CCRunnerAction {
|
||||
None,
|
||||
ForgetSkippable,
|
||||
CleanupContentUnbinder,
|
||||
CleanupDeferred,
|
||||
CycleCollect,
|
||||
StopRunning
|
||||
};
|
||||
|
||||
enum CCRunnerYield { Continue, Yield };
|
||||
|
||||
enum CCRunnerForgetSkippableRemoveChildless {
|
||||
KeepChildless = false,
|
||||
RemoveChildless = true
|
||||
};
|
||||
|
||||
struct CCRunnerStep {
|
||||
// The action to scheduler is instructing the caller to perform.
|
||||
CCRunnerAction mAction;
|
||||
|
||||
// Whether to stop processing actions for this invocation of the timer
|
||||
// callback.
|
||||
CCRunnerYield mYield;
|
||||
|
||||
// If the action is ForgetSkippable, then whether to remove childless nodes
|
||||
// or not. (ForgetSkippable is the only action requiring a parameter; if
|
||||
// that changes, this will become a union.)
|
||||
CCRunnerForgetSkippableRemoveChildless mRemoveChildless;
|
||||
};
|
||||
|
||||
class CCGCScheduler {
|
||||
public:
|
||||
// Mockable functions to interface with the code being scheduled.
|
||||
|
||||
// Current time. In real usage, this will just return TimeStamp::Now(), but
|
||||
// tests can reimplement it to return a value controlled by the test.
|
||||
static inline TimeStamp Now();
|
||||
|
||||
// Number of entries in the purple buffer (those objects whose ref counts
|
||||
// have been decremented since the previous CC, roughly), and are therefore
|
||||
// "suspected" of being members of cyclic garbage.
|
||||
static inline uint32_t SuspectedCCObjects();
|
||||
|
||||
// Parameter setting
|
||||
|
||||
void SetActiveIntersliceGCBudget(TimeDuration aDuration) {
|
||||
mActiveIntersliceGCBudget = aDuration;
|
||||
}
|
||||
|
||||
// State retrieval
|
||||
|
||||
TimeDuration GetCCBlockedTime(TimeStamp aNow) const {
|
||||
MOZ_ASSERT(mInIncrementalGC);
|
||||
MOZ_ASSERT(!mCCBlockStart.IsNull());
|
||||
return aNow - mCCBlockStart;
|
||||
}
|
||||
|
||||
bool InIncrementalGC() const { return mInIncrementalGC; }
|
||||
|
||||
TimeStamp GetLastCCEndTime() const { return mLastCCEndTime; }
|
||||
|
||||
bool IsEarlyForgetSkippable(uint32_t aN = kMajorForgetSkippableCalls) const {
|
||||
return mCleanupsSinceLastGC < aN;
|
||||
}
|
||||
|
||||
bool NeedsFullGC() const { return mNeedsFullGC; }
|
||||
|
||||
// State modification
|
||||
|
||||
void SetNeedsFullGC(bool aNeedGC = true) { mNeedsFullGC = aNeedGC; }
|
||||
|
||||
// Ensure that the current runner does a cycle collection, and trigger a GC
|
||||
// after it finishes.
|
||||
void EnsureCCThenGC() {
|
||||
MOZ_ASSERT(mCCRunnerState != CCRunnerState::Inactive);
|
||||
mNeedsFullCC = true;
|
||||
mNeedsGCAfterCC = true;
|
||||
}
|
||||
|
||||
void NoteGCBegin() {
|
||||
// Treat all GC as incremental here; non-incremental GC will just appear to
|
||||
// be one slice.
|
||||
mInIncrementalGC = true;
|
||||
}
|
||||
|
||||
void NoteGCEnd() {
|
||||
mInIncrementalGC = false;
|
||||
mCCBlockStart = TimeStamp();
|
||||
mInIncrementalGC = false;
|
||||
mNeedsFullCC = true;
|
||||
mHasRunGC = true;
|
||||
|
||||
mCleanupsSinceLastGC = 0;
|
||||
mCCollectedWaitingForGC = 0;
|
||||
mCCollectedZonesWaitingForGC = 0;
|
||||
mLikelyShortLivingObjectsNeedingGC = 0;
|
||||
}
|
||||
|
||||
// When we decide to do a cycle collection but we're in the middle of an
|
||||
// incremental GC, the CC is "locked out" until the GC completes -- unless
|
||||
// the wait is too long, and we decide to finish the incremental GC early.
|
||||
void BlockCC(TimeStamp aNow) {
|
||||
MOZ_ASSERT(mInIncrementalGC);
|
||||
MOZ_ASSERT(mCCBlockStart.IsNull());
|
||||
mCCBlockStart = aNow;
|
||||
}
|
||||
|
||||
void UnblockCC() { mCCBlockStart = TimeStamp(); }
|
||||
|
||||
// Returns the number of purple buffer items that were processed and removed.
|
||||
uint32_t NoteForgetSkippableComplete(
|
||||
TimeStamp aNow, uint32_t aSuspectedBeforeForgetSkippable) {
|
||||
mLastForgetSkippableEndTime = aNow;
|
||||
uint32_t suspected = SuspectedCCObjects();
|
||||
mPreviousSuspectedCount = suspected;
|
||||
mCleanupsSinceLastGC++;
|
||||
return aSuspectedBeforeForgetSkippable - suspected;
|
||||
}
|
||||
|
||||
// After collecting cycles, record the results that are used in scheduling
|
||||
// decisions.
|
||||
void NoteCycleCollected(const CycleCollectorResults& aResults) {
|
||||
mCCollectedWaitingForGC += aResults.mFreedGCed;
|
||||
mCCollectedZonesWaitingForGC += aResults.mFreedJSZones;
|
||||
}
|
||||
|
||||
// This is invoked when the whole process of collection is done -- i.e., CC
|
||||
// preparation (eg ForgetSkippables), the CC itself, and the optional
|
||||
// followup GC. There really ought to be a separate name for the overall CC
|
||||
// as opposed to the actual cycle collection portion.
|
||||
void NoteCCEnd(TimeStamp aWhen) {
|
||||
mLastCCEndTime = aWhen;
|
||||
mNeedsFullCC = false;
|
||||
|
||||
// The GC for this CC has already been requested.
|
||||
mNeedsGCAfterCC = false;
|
||||
}
|
||||
|
||||
// The CC was abandoned without running a slice, so we only did forget
|
||||
// skippables. Prevent running another cycle soon.
|
||||
void NoteForgetSkippableOnlyCycle() {
|
||||
mLastForgetSkippableCycleEndTime = Now();
|
||||
}
|
||||
|
||||
void Shutdown() { mDidShutdown = true; }
|
||||
|
||||
// Scheduling
|
||||
|
||||
// Return a budget along with a boolean saying whether to prefer to run short
|
||||
// slices and stop rather than continuing to the next phase of cycle
|
||||
// collection.
|
||||
inline js::SliceBudget ComputeCCSliceBudget(TimeStamp aDeadline,
|
||||
TimeStamp aCCBeginTime,
|
||||
TimeStamp aPrevSliceEndTime,
|
||||
bool* aPreferShorterSlices) const;
|
||||
|
||||
inline TimeDuration ComputeInterSliceGCBudget(TimeStamp aDeadline,
|
||||
TimeStamp aNow) const;
|
||||
|
||||
bool ShouldForgetSkippable() const {
|
||||
// Only do a forget skippable if there are more than a few new objects
|
||||
// or we're doing the initial forget skippables.
|
||||
return ((mPreviousSuspectedCount + 100) <= SuspectedCCObjects()) ||
|
||||
mCleanupsSinceLastGC < kMajorForgetSkippableCalls;
|
||||
}
|
||||
|
||||
// There is reason to suspect that there may be a significant amount of
|
||||
// garbage to cycle collect: either we just finished a GC, or the purple
|
||||
// buffer is getting really big, or it's getting somewhat big and it has been
|
||||
// too long since the last CC.
|
||||
bool IsCCNeeded(TimeStamp aNow = Now()) const {
|
||||
if (mNeedsFullCC) {
|
||||
return true;
|
||||
}
|
||||
uint32_t suspected = SuspectedCCObjects();
|
||||
return suspected > kCCPurpleLimit ||
|
||||
(suspected > kCCForcedPurpleLimit && mLastCCEndTime &&
|
||||
aNow - mLastCCEndTime > kCCForced);
|
||||
}
|
||||
|
||||
inline bool ShouldScheduleCC() const;
|
||||
|
||||
// If we collected a substantial amount of cycles, poke the GC since more
|
||||
// objects might be unreachable now.
|
||||
bool NeedsGCAfterCC() const {
|
||||
return mCCollectedWaitingForGC > 250 || mCCollectedZonesWaitingForGC > 0 ||
|
||||
mLikelyShortLivingObjectsNeedingGC > 2500 || mNeedsGCAfterCC;
|
||||
}
|
||||
|
||||
bool IsLastEarlyCCTimer(int32_t aCurrentFireCount) const {
|
||||
int32_t numEarlyTimerFires =
|
||||
std::max(int32_t(mCCDelay / kCCSkippableDelay) - 2, 1);
|
||||
|
||||
return aCurrentFireCount >= numEarlyTimerFires;
|
||||
}
|
||||
|
||||
enum class CCRunnerState {
|
||||
Inactive,
|
||||
ReducePurple,
|
||||
CleanupChildless,
|
||||
CleanupContentUnbinder,
|
||||
CleanupDeferred,
|
||||
StartCycleCollection,
|
||||
CycleCollecting,
|
||||
Canceled,
|
||||
NumStates
|
||||
};
|
||||
|
||||
void InitCCRunnerStateMachine(CCRunnerState initialState) {
|
||||
// The state machine should always have been deactivated after the previous
|
||||
// collection, however far that collection may have gone.
|
||||
MOZ_ASSERT(mCCRunnerState == CCRunnerState::Inactive,
|
||||
"DeactivateCCRunner should have been called");
|
||||
mCCRunnerState = initialState;
|
||||
|
||||
// Currently, there are only two entry points to the non-Inactive part of
|
||||
// the state machine.
|
||||
if (initialState == CCRunnerState::ReducePurple) {
|
||||
mCCDelay = kCCDelay;
|
||||
mCCRunnerEarlyFireCount = 0;
|
||||
} else if (initialState == CCRunnerState::CycleCollecting) {
|
||||
// Nothing needed.
|
||||
} else {
|
||||
MOZ_CRASH("Invalid initial state");
|
||||
}
|
||||
}
|
||||
|
||||
void DeactivateCCRunner() { mCCRunnerState = CCRunnerState::Inactive; }
|
||||
|
||||
inline CCRunnerStep GetNextCCRunnerAction(TimeStamp aDeadline);
|
||||
|
||||
// aStartTimeStamp : when the ForgetSkippable timer fired. This may be some
|
||||
// time ago, if an incremental GC needed to be finished.
|
||||
js::SliceBudget ComputeForgetSkippableBudget(TimeStamp aStartTimeStamp,
|
||||
TimeStamp aDeadline);
|
||||
|
||||
private:
|
||||
// State
|
||||
|
||||
// An incremental GC is in progress, which blocks the CC from running for its
|
||||
// duration (or until it goes too long and is finished synchronously.)
|
||||
bool mInIncrementalGC = false;
|
||||
|
||||
// When the CC started actually waiting for the GC to finish. This will be
|
||||
// set to non-null at a later time than mCCLockedOut.
|
||||
TimeStamp mCCBlockStart;
|
||||
|
||||
bool mDidShutdown = false;
|
||||
|
||||
TimeStamp mLastForgetSkippableEndTime;
|
||||
uint32_t mForgetSkippableCounter = 0;
|
||||
TimeStamp mForgetSkippableFrequencyStartTime;
|
||||
TimeStamp mLastCCEndTime;
|
||||
TimeStamp mLastForgetSkippableCycleEndTime;
|
||||
|
||||
CCRunnerState mCCRunnerState = CCRunnerState::Inactive;
|
||||
int32_t mCCRunnerEarlyFireCount = 0;
|
||||
TimeDuration mCCDelay = kCCDelay;
|
||||
|
||||
// Prevent the very first CC from running before we have GC'd and set the
|
||||
// gray bits.
|
||||
bool mHasRunGC = false;
|
||||
|
||||
bool mNeedsFullCC = false;
|
||||
bool mNeedsFullGC = true;
|
||||
bool mNeedsGCAfterCC = false;
|
||||
uint32_t mPreviousSuspectedCount = 0;
|
||||
|
||||
uint32_t mCleanupsSinceLastGC = UINT32_MAX;
|
||||
|
||||
public:
|
||||
uint32_t mCCollectedWaitingForGC = 0;
|
||||
uint32_t mCCollectedZonesWaitingForGC = 0;
|
||||
uint32_t mLikelyShortLivingObjectsNeedingGC = 0;
|
||||
|
||||
// Configuration parameters
|
||||
|
||||
TimeDuration mActiveIntersliceGCBudget = TimeDuration::FromMilliseconds(5);
|
||||
};
|
||||
|
||||
js::SliceBudget CCGCScheduler::ComputeCCSliceBudget(
|
||||
TimeStamp aDeadline, TimeStamp aCCBeginTime, TimeStamp aPrevSliceEndTime,
|
||||
bool* aPreferShorterSlices) const {
|
||||
TimeStamp now = Now();
|
||||
|
||||
*aPreferShorterSlices =
|
||||
aDeadline.IsNull() || (aDeadline - now) < kICCSliceBudget;
|
||||
|
||||
TimeDuration baseBudget =
|
||||
aDeadline.IsNull() ? kICCSliceBudget : aDeadline - now;
|
||||
|
||||
if (aCCBeginTime.IsNull()) {
|
||||
// If no CC is in progress, use the standard slice time.
|
||||
return js::SliceBudget(baseBudget);
|
||||
}
|
||||
|
||||
// Only run a limited slice if we're within the max running time.
|
||||
MOZ_ASSERT(now >= aCCBeginTime);
|
||||
TimeDuration runningTime = now - aCCBeginTime;
|
||||
if (runningTime >= kMaxICCDuration) {
|
||||
return js::SliceBudget::unlimited();
|
||||
}
|
||||
|
||||
const TimeDuration maxSlice =
|
||||
TimeDuration::FromMilliseconds(MainThreadIdlePeriod::GetLongIdlePeriod());
|
||||
|
||||
// Try to make up for a delay in running this slice.
|
||||
MOZ_ASSERT(now >= aPrevSliceEndTime);
|
||||
double sliceDelayMultiplier = (now - aPrevSliceEndTime) / kICCIntersliceDelay;
|
||||
TimeDuration delaySliceBudget =
|
||||
std::min(baseBudget.MultDouble(sliceDelayMultiplier), maxSlice);
|
||||
|
||||
// Increase slice budgets up to |maxSlice| as we approach
|
||||
// half way through the ICC, to avoid large sync CCs.
|
||||
double percentToHalfDone =
|
||||
std::min(2.0 * (runningTime / kMaxICCDuration), 1.0);
|
||||
TimeDuration laterSliceBudget = maxSlice.MultDouble(percentToHalfDone);
|
||||
|
||||
// Note: We may have already overshot the deadline, in which case
|
||||
// baseBudget will be negative and we will end up returning
|
||||
// laterSliceBudget.
|
||||
return js::SliceBudget(std::max({delaySliceBudget, laterSliceBudget, baseBudget}));
|
||||
}
|
||||
|
||||
inline TimeDuration CCGCScheduler::ComputeInterSliceGCBudget(
|
||||
TimeStamp aDeadline, TimeStamp aNow) const {
|
||||
// We use longer budgets when the CC has been locked out but the CC has
|
||||
// tried to run since that means we may have a significant amount of
|
||||
// garbage to collect and it's better to GC in several longer slices than
|
||||
// in a very long one.
|
||||
TimeDuration budget =
|
||||
aDeadline.IsNull() ? mActiveIntersliceGCBudget * 2 : aDeadline - aNow;
|
||||
if (!mCCBlockStart) {
|
||||
return budget;
|
||||
}
|
||||
|
||||
TimeDuration blockedTime = aNow - mCCBlockStart;
|
||||
TimeDuration maxSliceGCBudget = mActiveIntersliceGCBudget * 10;
|
||||
double percentOfBlockedTime =
|
||||
std::min(blockedTime / kMaxCCLockedoutTime, 1.0);
|
||||
return std::max(budget, maxSliceGCBudget.MultDouble(percentOfBlockedTime));
|
||||
}
|
||||
|
||||
bool CCGCScheduler::ShouldScheduleCC() const {
|
||||
if (!mHasRunGC) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TimeStamp now = Now();
|
||||
|
||||
// Don't run consecutive CCs too often.
|
||||
if (mCleanupsSinceLastGC && !mLastCCEndTime.IsNull()) {
|
||||
if (now - mLastCCEndTime < kCCDelay) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If GC hasn't run recently and forget skippable only cycle was run,
|
||||
// don't start a new cycle too soon.
|
||||
if ((mCleanupsSinceLastGC > kMajorForgetSkippableCalls) &&
|
||||
!mLastForgetSkippableCycleEndTime.IsNull()) {
|
||||
if (now - mLastForgetSkippableCycleEndTime <
|
||||
kTimeBetweenForgetSkippableCycles) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return IsCCNeeded(now);
|
||||
}
|
||||
|
||||
CCRunnerStep CCGCScheduler::GetNextCCRunnerAction(TimeStamp aDeadline) {
|
||||
struct StateDescriptor {
|
||||
// When in this state, should we first check to see if we still have
|
||||
// enough reason to CC?
|
||||
bool mCanAbortCC;
|
||||
|
||||
// If we do decide to abort the CC, should we still try to forget
|
||||
// skippables one more time?
|
||||
bool mTryFinalForgetSkippable;
|
||||
};
|
||||
|
||||
// The state descriptors for Inactive and Canceled will never actually be
|
||||
// used. We will never call this function while Inactive, and Canceled is
|
||||
// handled specially at the beginning.
|
||||
constexpr StateDescriptor stateDescriptors[] = {
|
||||
{false, false}, /* CCRunnerState::Inactive */
|
||||
{false, false}, /* CCRunnerState::ReducePurple */
|
||||
{true, true}, /* CCRunnerState::CleanupChildless */
|
||||
{true, false}, /* CCRunnerState::CleanupContentUnbinder */
|
||||
{false, false}, /* CCRunnerState::CleanupDeferred */
|
||||
{false, false}, /* CCRunnerState::StartCycleCollection */
|
||||
{false, false}, /* CCRunnerState::CycleCollecting */
|
||||
{false, false}}; /* CCRunnerState::Canceled */
|
||||
static_assert(
|
||||
ArrayLength(stateDescriptors) == size_t(CCRunnerState::NumStates),
|
||||
"need one state descriptor per state");
|
||||
const StateDescriptor& desc = stateDescriptors[int(mCCRunnerState)];
|
||||
|
||||
// Make sure we initialized the state machine.
|
||||
MOZ_ASSERT(mCCRunnerState != CCRunnerState::Inactive);
|
||||
|
||||
if (mDidShutdown) {
|
||||
return {CCRunnerAction::StopRunning, Yield};
|
||||
}
|
||||
|
||||
if (mCCRunnerState == CCRunnerState::Canceled) {
|
||||
// When we cancel a cycle, there may have been a final ForgetSkippable.
|
||||
return {CCRunnerAction::StopRunning, Yield};
|
||||
}
|
||||
|
||||
TimeStamp now = Now();
|
||||
|
||||
if (InIncrementalGC()) {
|
||||
if (mCCBlockStart.IsNull()) {
|
||||
BlockCC(now);
|
||||
|
||||
// If we have reached the CycleCollecting state, then ignore CC timer
|
||||
// fires while incremental GC is running. (Running ICC during an IGC
|
||||
// would cause us to synchronously finish the GC, which is bad.)
|
||||
//
|
||||
// If we have not yet started cycle collecting, then reset our state so
|
||||
// that we run forgetSkippable often enough before CC. Because of reduced
|
||||
// mCCDelay, forgetSkippable will be called just a few times.
|
||||
//
|
||||
// The kMaxCCLockedoutTime limit guarantees that we end up calling
|
||||
// forgetSkippable and CycleCollectNow eventually.
|
||||
|
||||
if (mCCRunnerState != CCRunnerState::CycleCollecting) {
|
||||
mCCRunnerState = CCRunnerState::ReducePurple;
|
||||
mCCRunnerEarlyFireCount = 0;
|
||||
mCCDelay = kCCDelay / int64_t(3);
|
||||
}
|
||||
return {CCRunnerAction::None, Yield};
|
||||
}
|
||||
|
||||
if (GetCCBlockedTime(now) < kMaxCCLockedoutTime) {
|
||||
return {CCRunnerAction::None, Yield};
|
||||
}
|
||||
|
||||
// Locked out for too long, so proceed and finish the incremental GC
|
||||
// synchronously.
|
||||
}
|
||||
|
||||
// For states that aren't just continuations of previous states, check
|
||||
// whether a CC is still needed (after doing various things to reduce the
|
||||
// purple buffer).
|
||||
if (desc.mCanAbortCC && !IsCCNeeded(now)) {
|
||||
// If we don't pass the threshold for wanting to cycle collect, stop now
|
||||
// (after possibly doing a final ForgetSkippable).
|
||||
mCCRunnerState = CCRunnerState::Canceled;
|
||||
NoteForgetSkippableOnlyCycle();
|
||||
|
||||
// Preserve the previous code's idea of when to check whether a
|
||||
// ForgetSkippable should be fired.
|
||||
if (desc.mTryFinalForgetSkippable && ShouldForgetSkippable()) {
|
||||
// The Canceled state will make us StopRunning after this action is
|
||||
// performed (see conditional at top of function).
|
||||
return {CCRunnerAction::ForgetSkippable, Yield, KeepChildless};
|
||||
}
|
||||
|
||||
return {CCRunnerAction::StopRunning, Yield};
|
||||
}
|
||||
|
||||
switch (mCCRunnerState) {
|
||||
// ReducePurple: a GC ran (or we otherwise decided to try CC'ing). Wait
|
||||
// for some amount of time (kCCDelay, or less if incremental GC blocked
|
||||
// this CC) while firing regular ForgetSkippable actions before continuing
|
||||
// on.
|
||||
case CCRunnerState::ReducePurple:
|
||||
++mCCRunnerEarlyFireCount;
|
||||
if (IsLastEarlyCCTimer(mCCRunnerEarlyFireCount)) {
|
||||
mCCRunnerState = CCRunnerState::CleanupChildless;
|
||||
}
|
||||
|
||||
if (ShouldForgetSkippable()) {
|
||||
return {CCRunnerAction::ForgetSkippable, Yield, KeepChildless};
|
||||
}
|
||||
|
||||
if (aDeadline.IsNull()) {
|
||||
return {CCRunnerAction::None, Yield};
|
||||
}
|
||||
|
||||
// If we're called during idle time, try to find some work to do by
|
||||
// advancing to the next state, effectively bypassing some possible forget
|
||||
// skippable calls.
|
||||
mCCRunnerState = CCRunnerState::CleanupChildless;
|
||||
|
||||
// Continue on to CleanupChildless, but only after checking IsCCNeeded
|
||||
// again.
|
||||
return {CCRunnerAction::None, Continue};
|
||||
|
||||
// CleanupChildless: do a stronger ForgetSkippable that removes nodes with
|
||||
// no children in the cycle collector graph. This state is split into 3
|
||||
// parts; the other Cleanup* actions will happen within the same callback
|
||||
// (unless the ForgetSkippable shrinks the purple buffer enough for the CC
|
||||
// to be skipped entirely.)
|
||||
case CCRunnerState::CleanupChildless:
|
||||
mCCRunnerState = CCRunnerState::CleanupContentUnbinder;
|
||||
return {CCRunnerAction::ForgetSkippable, Yield, RemoveChildless};
|
||||
|
||||
// CleanupContentUnbinder: continuing cleanup, clear out the content
|
||||
// unbinder.
|
||||
case CCRunnerState::CleanupContentUnbinder:
|
||||
if (aDeadline.IsNull()) {
|
||||
// Non-idle (waiting) callbacks skip the rest of the cleanup, but still
|
||||
// wait for another fire before the actual CC.
|
||||
mCCRunnerState = CCRunnerState::StartCycleCollection;
|
||||
return {CCRunnerAction::None, Yield};
|
||||
}
|
||||
|
||||
// Running in an idle callback.
|
||||
|
||||
// The deadline passed, so go straight to CC in the next slice.
|
||||
if (now >= aDeadline) {
|
||||
mCCRunnerState = CCRunnerState::StartCycleCollection;
|
||||
return {CCRunnerAction::None, Yield};
|
||||
}
|
||||
|
||||
mCCRunnerState = CCRunnerState::CleanupDeferred;
|
||||
return {CCRunnerAction::CleanupContentUnbinder, Continue};
|
||||
|
||||
// CleanupDeferred: continuing cleanup, do deferred deletion.
|
||||
case CCRunnerState::CleanupDeferred:
|
||||
MOZ_ASSERT(!aDeadline.IsNull(),
|
||||
"Should only be in CleanupDeferred state when idle");
|
||||
|
||||
// Our efforts to avoid a CC have failed. Let the timer fire once more
|
||||
// to trigger a CC.
|
||||
mCCRunnerState = CCRunnerState::StartCycleCollection;
|
||||
if (now >= aDeadline) {
|
||||
// The deadline passed, go straight to CC in the next slice.
|
||||
return {CCRunnerAction::None, Yield};
|
||||
}
|
||||
|
||||
return {CCRunnerAction::CleanupDeferred, Yield};
|
||||
|
||||
// StartCycleCollection: start actually doing cycle collection slices.
|
||||
case CCRunnerState::StartCycleCollection:
|
||||
// We are in the final timer fire and still meet the conditions for
|
||||
// triggering a CC. Let RunCycleCollectorSlice finish the current IGC if
|
||||
// any, because that will allow us to include the GC time in the CC pause.
|
||||
mCCRunnerState = CCRunnerState::CycleCollecting;
|
||||
[[fallthrough]];
|
||||
|
||||
// CycleCollecting: continue running slices until done.
|
||||
case CCRunnerState::CycleCollecting:
|
||||
return {CCRunnerAction::CycleCollect, Yield};
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unexpected CCRunner state");
|
||||
};
|
||||
}
|
||||
|
||||
inline js::SliceBudget CCGCScheduler::ComputeForgetSkippableBudget(
|
||||
TimeStamp aStartTimeStamp, TimeStamp aDeadline) {
|
||||
if (mForgetSkippableFrequencyStartTime.IsNull()) {
|
||||
mForgetSkippableFrequencyStartTime = aStartTimeStamp;
|
||||
} else if (aStartTimeStamp - mForgetSkippableFrequencyStartTime >
|
||||
kOneMinute) {
|
||||
TimeStamp startPlusMinute = mForgetSkippableFrequencyStartTime + kOneMinute;
|
||||
|
||||
// If we had forget skippables only at the beginning of the interval, we
|
||||
// still want to use the whole time, minute or more, for frequency
|
||||
// calculation. mLastForgetSkippableEndTime is needed if forget skippable
|
||||
// takes enough time to push the interval to be over a minute.
|
||||
TimeStamp endPoint = std::max(startPlusMinute, mLastForgetSkippableEndTime);
|
||||
|
||||
// Duration in minutes.
|
||||
double duration =
|
||||
(endPoint - mForgetSkippableFrequencyStartTime).ToSeconds() / 60;
|
||||
uint32_t frequencyPerMinute = uint32_t(mForgetSkippableCounter / duration);
|
||||
Telemetry::Accumulate(Telemetry::FORGET_SKIPPABLE_FREQUENCY,
|
||||
frequencyPerMinute);
|
||||
mForgetSkippableCounter = 0;
|
||||
mForgetSkippableFrequencyStartTime = aStartTimeStamp;
|
||||
}
|
||||
++mForgetSkippableCounter;
|
||||
|
||||
TimeDuration budgetTime =
|
||||
aDeadline ? (aDeadline - aStartTimeStamp) : kForgetSkippableSliceDuration;
|
||||
return js::SliceBudget(budgetTime);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
@ -164,7 +164,7 @@ void ChromeUtils::ReleaseAssert(GlobalObject& aGlobal, bool aCondition,
|
||||
location->GetFilename(aGlobal.Context(), filename);
|
||||
lineNo = location->GetLineNumber(aGlobal.Context());
|
||||
} else {
|
||||
filename.Assign(NS_LITERAL_STRING("<unknown>"));
|
||||
filename.Assign(u"<unknown>"_ns);
|
||||
}
|
||||
|
||||
// Convert to utf-8 for adding as the MozCrashReason.
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "nsStringStream.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/RandomNum.h"
|
||||
#include "mozilla/StaticPrefs_privacy.h"
|
||||
#include "mozilla/StaticPrefs_telemetry.h"
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/ForOfIterator.h" // JS::ForOfIterator
|
||||
|
@ -359,7 +359,7 @@ already_AddRefed<DOMException> DOMException::Constructor(
|
||||
const Optional<nsAString>& aName) {
|
||||
nsresult exceptionResult = NS_OK;
|
||||
uint16_t exceptionCode = 0;
|
||||
nsCString name(NS_LITERAL_CSTRING("Error"));
|
||||
nsCString name("Error"_ns);
|
||||
|
||||
if (aName.WasPassed()) {
|
||||
CopyUTF16toUTF8(aName.Value(), name);
|
||||
|
@ -93,8 +93,7 @@ already_AddRefed<Document> DOMParser::ParseFromString(const nsAString& aStr,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ParseFromStream(stream, NS_LITERAL_STRING("UTF-8"), utf8str.Length(),
|
||||
aType, aRv);
|
||||
return ParseFromStream(stream, u"UTF-8"_ns, utf8str.Length(), aType, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<Document> DOMParser::ParseFromSafeString(const nsAString& aStr,
|
||||
@ -308,9 +307,9 @@ already_AddRefed<Document> DOMParser::SetUpDocument(DocumentFlavor aFlavor,
|
||||
NS_ASSERTION(mDocumentURI, "Must have document URI by now");
|
||||
|
||||
nsCOMPtr<Document> doc;
|
||||
nsresult rv = NS_NewDOMDocument(
|
||||
getter_AddRefs(doc), EmptyString(), EmptyString(), nullptr, mDocumentURI,
|
||||
mBaseURI, mPrincipal, true, scriptHandlingObject, aFlavor);
|
||||
nsresult rv = NS_NewDOMDocument(getter_AddRefs(doc), u""_ns, u""_ns, nullptr,
|
||||
mDocumentURI, mBaseURI, mPrincipal, true,
|
||||
scriptHandlingObject, aFlavor);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include "mozilla/dom/DOMQuad.h"
|
||||
|
||||
#include "mozilla/dom/DOMQuadBinding.h"
|
||||
#include "mozilla/dom/DOMPoint.h"
|
||||
#include "mozilla/dom/DOMQuadBinding.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/DOMRectBinding.h"
|
||||
#include <algorithm>
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -89,8 +89,8 @@ void DOMQuad::GetHorizontalMinMax(double* aX1, double* aX2) const {
|
||||
x1 = x2 = Point(0)->X();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double x = Point(i)->X();
|
||||
x1 = std::min(x1, x);
|
||||
x2 = std::max(x2, x);
|
||||
x1 = NaNSafeMin(x1, x);
|
||||
x2 = NaNSafeMax(x2, x);
|
||||
}
|
||||
*aX1 = x1;
|
||||
*aX2 = x2;
|
||||
@ -101,8 +101,8 @@ void DOMQuad::GetVerticalMinMax(double* aY1, double* aY2) const {
|
||||
y1 = y2 = Point(0)->Y();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double y = Point(i)->Y();
|
||||
y1 = std::min(y1, y);
|
||||
y2 = std::max(y2, y);
|
||||
y1 = NaNSafeMin(y1, y);
|
||||
y2 = NaNSafeMax(y2, y);
|
||||
}
|
||||
*aY1 = y1;
|
||||
*aY2 = y2;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include <algorithm>
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
struct nsRect;
|
||||
class nsIGlobalObject;
|
||||
@ -57,19 +57,19 @@ class DOMRectReadOnly : public nsISupports, public nsWrapperCache {
|
||||
|
||||
double Left() const {
|
||||
double x = X(), w = Width();
|
||||
return std::min(x, x + w);
|
||||
return NaNSafeMin(x, x + w);
|
||||
}
|
||||
double Top() const {
|
||||
double y = Y(), h = Height();
|
||||
return std::min(y, y + h);
|
||||
return NaNSafeMin(y, y + h);
|
||||
}
|
||||
double Right() const {
|
||||
double x = X(), w = Width();
|
||||
return std::max(x, x + w);
|
||||
return NaNSafeMax(x, x + w);
|
||||
}
|
||||
double Bottom() const {
|
||||
double y = Y(), h = Height();
|
||||
return std::max(y, y + h);
|
||||
return NaNSafeMax(y, y + h);
|
||||
}
|
||||
|
||||
bool WriteStructuredClone(JSContext* aCx,
|
||||
|
@ -80,7 +80,7 @@ void DOMRequest::FireSuccess(JS::Handle<JS::Value> aResult) {
|
||||
}
|
||||
mResult = aResult;
|
||||
|
||||
FireEvent(NS_LITERAL_STRING("success"), false, false);
|
||||
FireEvent(u"success"_ns, false, false);
|
||||
|
||||
if (mPromise) {
|
||||
mPromise->MaybeResolve(mResult);
|
||||
@ -97,7 +97,7 @@ void DOMRequest::FireError(const nsAString& aError) {
|
||||
mError = DOMException::Create(NS_ERROR_DOM_UNKNOWN_ERR,
|
||||
NS_ConvertUTF16toUTF8(aError));
|
||||
|
||||
FireEvent(NS_LITERAL_STRING("error"), true, true);
|
||||
FireEvent(u"error"_ns, true, true);
|
||||
|
||||
if (mPromise) {
|
||||
mPromise->MaybeRejectBrokenly(mError);
|
||||
@ -112,7 +112,7 @@ void DOMRequest::FireError(nsresult aError) {
|
||||
mDone = true;
|
||||
mError = DOMException::Create(aError);
|
||||
|
||||
FireEvent(NS_LITERAL_STRING("error"), true, true);
|
||||
FireEvent(u"error"_ns, true, true);
|
||||
|
||||
if (mPromise) {
|
||||
mPromise->MaybeRejectBrokenly(mError);
|
||||
@ -127,7 +127,7 @@ void DOMRequest::FireDetailedError(DOMException& aError) {
|
||||
mDone = true;
|
||||
mError = &aError;
|
||||
|
||||
FireEvent(NS_LITERAL_STRING("error"), true, true);
|
||||
FireEvent(u"error"_ns, true, true);
|
||||
|
||||
if (mPromise) {
|
||||
mPromise->MaybeRejectBrokenly(mError);
|
||||
|
@ -269,7 +269,7 @@
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "mozilla/dom/DocumentL10n.h"
|
||||
#include "mozilla/ExtensionPolicyService.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsDOMCaretPosition.h"
|
||||
#include "nsViewportInfo.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
@ -331,6 +331,7 @@
|
||||
#include "ThirdPartyUtil.h"
|
||||
#include "nsHtml5Module.h"
|
||||
#include "nsHtml5Parser.h"
|
||||
#include "nsTableWrapperFrame.h"
|
||||
|
||||
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
|
||||
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
|
||||
@ -1759,6 +1760,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(Document)
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp->mResizeObserverController) {
|
||||
tmp->mResizeObserverController->Traverse(cb);
|
||||
}
|
||||
for (size_t i = 0; i < tmp->mMetaViewports.Length(); i++) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMetaViewports[i].mElement);
|
||||
}
|
||||
@ -1884,6 +1888,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Document)
|
||||
|
||||
tmp->mInUnlinkOrDeletion = false;
|
||||
|
||||
if (tmp->mResizeObserverController) {
|
||||
tmp->mResizeObserverController->Unlink();
|
||||
}
|
||||
tmp->mMetaViewports.Clear();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mL10nProtoElements)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
@ -3318,9 +3325,10 @@ void Document::InitializeLocalization(nsTArray<nsString>& aResourceIds) {
|
||||
DocumentL10n* Document::GetL10n() { return mDocumentL10n; }
|
||||
|
||||
bool Document::DocumentSupportsL10n(JSContext* aCx, JSObject* aObject) {
|
||||
JS::Rooted<JSObject*> object(aCx, aObject);
|
||||
nsCOMPtr<nsIPrincipal> callerPrincipal =
|
||||
nsContentUtils::SubjectPrincipal(aCx);
|
||||
nsGlobalWindowInner* win = xpc::WindowOrNull(aObject);
|
||||
nsGlobalWindowInner* win = xpc::WindowOrNull(object);
|
||||
bool allowed = false;
|
||||
callerPrincipal->IsL10nAllowed(win ? win->GetDocumentURI() : nullptr,
|
||||
&allowed);
|
||||
@ -6877,7 +6885,8 @@ void Document::ContentStateChanged(nsIContent* aContent,
|
||||
(this, aContent, aStateMask));
|
||||
}
|
||||
|
||||
void Document::RuleChanged(StyleSheet& aSheet, css::Rule* aRule) {
|
||||
void Document::RuleChanged(StyleSheet& aSheet, css::Rule*,
|
||||
StyleRuleChangeKind) {
|
||||
if (aSheet.IsApplicable()) {
|
||||
ApplicableStylesChanged();
|
||||
}
|
||||
@ -8127,6 +8136,7 @@ void Document::TryCancelFrameLoaderInitialization(nsIDocShell* aShell) {
|
||||
|
||||
void Document::SetPrototypeDocument(nsXULPrototypeDocument* aPrototype) {
|
||||
mPrototypeDocument = aPrototype;
|
||||
mSynchronousDOMContentLoaded = true;
|
||||
}
|
||||
|
||||
Document* Document::RequestExternalResource(
|
||||
@ -8658,7 +8668,7 @@ void Document::WriteCommon(const nsAString& aText, bool aNewlineTerminate,
|
||||
}
|
||||
}
|
||||
|
||||
static NS_NAMED_LITERAL_STRING(new_line, "\n");
|
||||
static constexpr auto new_line = u"\n"_ns;
|
||||
|
||||
++mWriteLevel;
|
||||
|
||||
@ -11921,7 +11931,7 @@ already_AddRefed<nsDOMCaretPosition> Document::CaretPositionFromPoint(
|
||||
nsPoint adjustedPoint =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, refPoint, ptFrame);
|
||||
|
||||
nsFrame::ContentOffsets offsets =
|
||||
nsIFrame::ContentOffsets offsets =
|
||||
ptFrame->GetContentOffsetsFromPoint(adjustedPoint);
|
||||
|
||||
nsCOMPtr<nsIContent> node = offsets.content;
|
||||
@ -11965,33 +11975,27 @@ bool Document::IsPotentiallyScrollable(HTMLBodyElement* aBody) {
|
||||
// We rely on correct frame information here, so need to flush frames.
|
||||
FlushPendingNotifications(FlushType::Frames);
|
||||
|
||||
// An element is potentially scrollable if all of the following conditions are
|
||||
// true:
|
||||
// An element that is the HTML body element is potentially scrollable if all
|
||||
// of the following conditions are true:
|
||||
|
||||
// The element has an associated CSS layout box.
|
||||
nsIFrame* bodyFrame = aBody->GetPrimaryFrame();
|
||||
nsIFrame* bodyFrame = nsLayoutUtils::GetStyleFrame(aBody);
|
||||
if (!bodyFrame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The element is not the HTML body element, or it is and the root element's
|
||||
// used value of the overflow-x or overflow-y properties is not visible.
|
||||
// The element's parent element's computed value of the overflow-x and
|
||||
// overflow-y properties are visible.
|
||||
MOZ_ASSERT(aBody->GetParent() == aBody->OwnerDoc()->GetRootElement());
|
||||
nsIFrame* parentFrame = aBody->GetParent()->GetPrimaryFrame();
|
||||
nsIFrame* parentFrame = nsLayoutUtils::GetStyleFrame(aBody->GetParent());
|
||||
if (parentFrame &&
|
||||
parentFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible &&
|
||||
parentFrame->StyleDisplay()->mOverflowY == StyleOverflow::Visible) {
|
||||
parentFrame->StyleDisplay()->OverflowIsVisibleInBothAxis()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The element's used value of the overflow-x or overflow-y properties is not
|
||||
// visible.
|
||||
if (bodyFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible &&
|
||||
bodyFrame->StyleDisplay()->mOverflowY == StyleOverflow::Visible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// The element's computed value of the overflow-x or overflow-y properties is
|
||||
// not visible.
|
||||
return !bodyFrame->StyleDisplay()->OverflowIsVisibleInBothAxis();
|
||||
}
|
||||
|
||||
Element* Document::GetScrollingElement() {
|
||||
|
@ -148,6 +148,7 @@ enum class StyleOrigin : uint8_t;
|
||||
class SMILAnimationController;
|
||||
enum class StyleCursorKind : uint8_t;
|
||||
enum class StylePrefersColorScheme : uint8_t;
|
||||
enum class StyleRuleChangeKind : uint32_t;
|
||||
template <typename>
|
||||
class OwningNonNull;
|
||||
struct URLExtraData;
|
||||
@ -468,7 +469,7 @@ class Document : public nsINode,
|
||||
public nsIApplicationCacheContainer,
|
||||
public nsStubMutationObserver,
|
||||
public DispatcherTrait,
|
||||
public SupportsWeakPtr<Document> {
|
||||
public SupportsWeakPtr {
|
||||
friend class DocumentOrShadowRoot;
|
||||
|
||||
protected:
|
||||
@ -493,8 +494,6 @@ class Document : public nsINode,
|
||||
*/
|
||||
static void Shutdown();
|
||||
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Document)
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
@ -2268,7 +2267,7 @@ class Document : public nsINode,
|
||||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
void RuleChanged(StyleSheet&, css::Rule*);
|
||||
void RuleChanged(StyleSheet&, css::Rule*, StyleRuleChangeKind);
|
||||
void RuleAdded(StyleSheet&, css::Rule&);
|
||||
void RuleRemoved(StyleSheet&, css::Rule&);
|
||||
void SheetCloned(StyleSheet&) {}
|
||||
|
@ -142,6 +142,7 @@
|
||||
#ifdef MOZ_VR
|
||||
# include "mozilla/dom/VRDisplay.h"
|
||||
#endif
|
||||
#include "mozilla/dom/Exceptions.h" //XBL
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
@ -1401,8 +1402,8 @@ bool Element::ToggleAttribute(const nsAString& aName,
|
||||
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return false;
|
||||
}
|
||||
aError = SetAttr(kNameSpaceID_None, nameAtom, EmptyString(),
|
||||
aTriggeringPrincipal, true);
|
||||
aError = SetAttr(kNameSpaceID_None, nameAtom, u""_ns, aTriggeringPrincipal,
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
if (aForce.WasPassed() && aForce.Value()) {
|
||||
@ -3158,7 +3159,7 @@ nsresult Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) {
|
||||
|
||||
switch (aVisitor.mEvent->mMessage) {
|
||||
case eMouseDown: {
|
||||
if (aVisitor.mEvent->AsMouseEvent()->mButton == MouseButton::eLeft &&
|
||||
if (aVisitor.mEvent->AsMouseEvent()->mButton == MouseButton::ePrimary &&
|
||||
OwnerDoc()->LinkHandlingEnabled()) {
|
||||
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
|
||||
|
||||
@ -3387,7 +3388,7 @@ static const char* GetFullscreenError(CallerType aCallerType) {
|
||||
// button
|
||||
if (StaticPrefs::full_screen_api_mouse_event_allow_left_button_only() &&
|
||||
(EventStateManager::sCurrentMouseBtn == MouseButton::eMiddle ||
|
||||
EventStateManager::sCurrentMouseBtn == MouseButton::eRight)) {
|
||||
EventStateManager::sCurrentMouseBtn == MouseButton::eSecondary)) {
|
||||
return "FullscreenDeniedMouseEventOnlyLeftBtn";
|
||||
}
|
||||
|
||||
@ -3867,7 +3868,7 @@ TextEditor* Element::GetTextEditorInternal() {
|
||||
|
||||
nsresult Element::SetBoolAttr(nsAtom* aAttr, bool aValue) {
|
||||
if (aValue) {
|
||||
return SetAttr(kNameSpaceID_None, aAttr, EmptyString(), true);
|
||||
return SetAttr(kNameSpaceID_None, aAttr, u""_ns, true);
|
||||
}
|
||||
|
||||
return UnsetAttr(kNameSpaceID_None, aAttr, true);
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/DirectionalityUtils.h"
|
||||
#include "mozilla/dom/FragmentOrElement.h"
|
||||
#include "mozilla/dom/NameSpaceConstants.h"
|
||||
#include "mozilla/dom/NodeInfo.h"
|
||||
#include "mozilla/dom/PointerEventHandler.h"
|
||||
#include "mozilla/dom/ShadowRootBinding.h"
|
||||
|
||||
@ -947,7 +949,7 @@ class Element : public FragmentOrElement {
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override {
|
||||
List(out, aIndent, EmptyCString());
|
||||
List(out, aIndent, ""_ns);
|
||||
}
|
||||
virtual void DumpContent(FILE* out, int32_t aIndent,
|
||||
bool aDumpAll) const override;
|
||||
|
@ -341,7 +341,7 @@ class CleanupRunnable final : public WorkerMainThreadRunnable {
|
||||
public:
|
||||
explicit CleanupRunnable(EventSourceImpl* aEventSourceImpl)
|
||||
: WorkerMainThreadRunnable(GetCurrentThreadWorkerPrivate(),
|
||||
NS_LITERAL_CSTRING("EventSource :: Cleanup")),
|
||||
"EventSource :: Cleanup"_ns),
|
||||
mImpl(aEventSourceImpl) {
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
}
|
||||
@ -426,8 +426,7 @@ class InitRunnable final : public WorkerMainThreadRunnable {
|
||||
public:
|
||||
InitRunnable(WorkerPrivate* aWorkerPrivate, EventSourceImpl* aEventSourceImpl,
|
||||
const nsAString& aURL)
|
||||
: WorkerMainThreadRunnable(aWorkerPrivate,
|
||||
NS_LITERAL_CSTRING("EventSource :: Init")),
|
||||
: WorkerMainThreadRunnable(aWorkerPrivate, "EventSource :: Init"_ns),
|
||||
mImpl(aEventSourceImpl),
|
||||
mURL(aURL),
|
||||
mRv(NS_ERROR_NOT_INITIALIZED) {
|
||||
@ -468,8 +467,7 @@ class ConnectRunnable final : public WorkerMainThreadRunnable {
|
||||
public:
|
||||
explicit ConnectRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
EventSourceImpl* aEventSourceImpl)
|
||||
: WorkerMainThreadRunnable(aWorkerPrivate,
|
||||
NS_LITERAL_CSTRING("EventSource :: Connect")),
|
||||
: WorkerMainThreadRunnable(aWorkerPrivate, "EventSource :: Connect"_ns),
|
||||
mImpl(aEventSourceImpl) {
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
@ -898,14 +896,13 @@ nsresult EventSourceImpl::GetBaseURI(nsIURI** aBaseURI) {
|
||||
void EventSourceImpl::SetupHttpChannel() {
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!IsShutDown());
|
||||
nsresult rv = mHttpChannel->SetRequestMethod(NS_LITERAL_CSTRING("GET"));
|
||||
nsresult rv = mHttpChannel->SetRequestMethod("GET"_ns);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
/* set the http request headers */
|
||||
|
||||
rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
||||
NS_LITERAL_CSTRING(TEXT_EVENT_STREAM),
|
||||
false);
|
||||
rv = mHttpChannel->SetRequestHeader(
|
||||
"Accept"_ns, nsLiteralCString(TEXT_EVENT_STREAM), false);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// LOAD_BYPASS_CACHE already adds the Cache-Control: no-cache header
|
||||
@ -914,8 +911,7 @@ void EventSourceImpl::SetupHttpChannel() {
|
||||
return;
|
||||
}
|
||||
NS_ConvertUTF16toUTF8 eventId(mLastEventID);
|
||||
rv = mHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Last-Event-ID"),
|
||||
eventId, false);
|
||||
rv = mHttpChannel->SetRequestHeader("Last-Event-ID"_ns, eventId, false);
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_LOG(gEventSourceLog, LogLevel::Warning,
|
||||
@ -1037,7 +1033,7 @@ void EventSourceImpl::AnnounceConnection() {
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
rv = mEventSource->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open"));
|
||||
rv = mEventSource->CreateAndDispatchSimpleEvent(u"open"_ns);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the error event!!!");
|
||||
return;
|
||||
@ -1065,9 +1061,8 @@ void EventSourceImpl::ResetDecoder() {
|
||||
class CallRestartConnection final : public WorkerMainThreadRunnable {
|
||||
public:
|
||||
explicit CallRestartConnection(EventSourceImpl* aEventSourceImpl)
|
||||
: WorkerMainThreadRunnable(
|
||||
aEventSourceImpl->mWorkerRef->Private(),
|
||||
NS_LITERAL_CSTRING("EventSource :: RestartConnection")),
|
||||
: WorkerMainThreadRunnable(aEventSourceImpl->mWorkerRef->Private(),
|
||||
"EventSource :: RestartConnection"_ns),
|
||||
mImpl(aEventSourceImpl) {
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
}
|
||||
@ -1121,7 +1116,7 @@ void EventSourceImpl::ReestablishConnection() {
|
||||
|
||||
SetReadyState(CONNECTING);
|
||||
ResetDecoder();
|
||||
rv = mEventSource->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error"));
|
||||
rv = mEventSource->CreateAndDispatchSimpleEvent(u"error"_ns);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the error event!!!");
|
||||
return;
|
||||
@ -1179,9 +1174,9 @@ nsresult EventSourceImpl::PrintErrorOnConsole(
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = errObj->InitWithWindowID(
|
||||
message, mScriptFile, EmptyString(), mScriptLine, mScriptColumn,
|
||||
nsIScriptError::errorFlag, "Event Source", mInnerWindowID);
|
||||
rv = errObj->InitWithWindowID(message, mScriptFile, u""_ns, mScriptLine,
|
||||
mScriptColumn, nsIScriptError::errorFlag,
|
||||
"Event Source", mInnerWindowID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// print the error message directly to the JS console
|
||||
@ -1244,7 +1239,7 @@ void EventSourceImpl::FailConnection() {
|
||||
// named error at the EventSource object.
|
||||
nsresult rv = mEventSource->CheckCurrentGlobalCorrectness();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mEventSource->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error"));
|
||||
rv = mEventSource->CreateAndDispatchSimpleEvent(u"error"_ns);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the error event!!!");
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ already_AddRefed<File> GetOrCreateFileCalledBlob(Blob& aBlob,
|
||||
}
|
||||
|
||||
// Forcing 'blob' as filename
|
||||
file = aBlob.ToFile(NS_LITERAL_STRING("blob"), aRv);
|
||||
file = aBlob.ToFile(u"blob"_ns, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1051,12 +1051,6 @@ bool nsIContent::IsFocusable(int32_t* aTabIndex, bool aWithMouse) {
|
||||
// Ensure that the return value and aTabIndex are consistent in the case
|
||||
// we're in userfocusignored context.
|
||||
if (focusable || (aTabIndex && *aTabIndex != -1)) {
|
||||
if (nsContentUtils::IsUserFocusIgnored(this)) {
|
||||
if (aTabIndex) {
|
||||
*aTabIndex = -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return focusable;
|
||||
}
|
||||
return false;
|
||||
@ -1896,7 +1890,7 @@ static inline bool IsVoidTag(nsAtom* aTag) {
|
||||
nsGkAtoms::link, nsGkAtoms::meta, nsGkAtoms::param,
|
||||
nsGkAtoms::source, nsGkAtoms::track, nsGkAtoms::wbr};
|
||||
|
||||
static mozilla::BloomFilter<12, nsAtom> sFilter;
|
||||
static mozilla::BitBloomFilter<12, nsAtom> sFilter;
|
||||
static bool sInitialized = false;
|
||||
if (!sInitialized) {
|
||||
sInitialized = true;
|
||||
|
@ -101,9 +101,9 @@ class FullscreenRequest : public FullscreenChange {
|
||||
std::move(pendingEvent));
|
||||
}
|
||||
MayRejectPromise("Fullscreen request denied");
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||
NS_LITERAL_CSTRING("DOM"), Document(),
|
||||
nsContentUtils::eDOM_PROPERTIES, aReason);
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns,
|
||||
Document(), nsContentUtils::eDOM_PROPERTIES,
|
||||
aReason);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -205,7 +205,7 @@ class IdentifierMapEntry : public PLDHashEntryHdr {
|
||||
// and only assign to it if aOther.mString is not null, but having it be
|
||||
// const is nice.
|
||||
: mAtom(aOther.mAtom),
|
||||
mString(aOther.mString ? *aOther.mString : EmptyString()) {}
|
||||
mString(aOther.mString ? *aOther.mString : u""_ns) {}
|
||||
|
||||
RefPtr<nsAtom> mAtom;
|
||||
nsString mString;
|
||||
|
@ -72,13 +72,13 @@ already_AddRefed<DataSourceSurface> GetBRGADataSourceSurfaceSync(
|
||||
return helper->GetDataSurfaceSafe();
|
||||
}
|
||||
|
||||
class EncodingCompleteEvent : public CancelableRunnable {
|
||||
class EncodingCompleteEvent : public Runnable {
|
||||
virtual ~EncodingCompleteEvent() = default;
|
||||
|
||||
public:
|
||||
explicit EncodingCompleteEvent(
|
||||
EncodeCompleteCallback* aEncodeCompleteCallback)
|
||||
: CancelableRunnable("EncodingCompleteEvent"),
|
||||
: Runnable("EncodingCompleteEvent"),
|
||||
mImgSize(0),
|
||||
mType(),
|
||||
mImgData(nullptr),
|
||||
@ -165,9 +165,8 @@ class EncodingRunnable : public Runnable {
|
||||
// the default values for the encoder without any options at all.
|
||||
if (rv == NS_ERROR_INVALID_ARG && mUsingCustomOptions) {
|
||||
rv = ImageEncoder::ExtractDataInternal(
|
||||
mType, EmptyString(), mImageBuffer.get(), mFormat, mSize,
|
||||
mUsePlaceholder, mImage, nullptr, nullptr, getter_AddRefs(stream),
|
||||
mEncoder);
|
||||
mType, u""_ns, mImageBuffer.get(), mFormat, mSize, mUsePlaceholder,
|
||||
mImage, nullptr, nullptr, getter_AddRefs(stream), mEncoder);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -407,7 +406,7 @@ already_AddRefed<imgIEncoder> ImageEncoder::GetImageEncoder(nsAString& aType) {
|
||||
encoderCID += encoderType;
|
||||
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get());
|
||||
|
||||
if (!encoder && aType != NS_LITERAL_STRING("image/png")) {
|
||||
if (!encoder && aType != u"image/png"_ns) {
|
||||
// Unable to create an encoder instance of the specified type. Falling back
|
||||
// to PNG.
|
||||
aType.AssignLiteral("image/png");
|
||||
|
@ -182,7 +182,7 @@ void InProcessBrowserChildMessageManager::FireUnloadEvent() {
|
||||
|
||||
// Don't let the unload event propagate to chrome event handlers.
|
||||
mPreventEventsEscaping = true;
|
||||
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
|
||||
DOMEventTargetHelper::DispatchTrustedEvent(u"unload"_ns);
|
||||
|
||||
// Allow events fired during docshell destruction (pagehide, unload) to
|
||||
// propagate to the <browser> element since chrome code depends on this.
|
||||
|
343
dom/base/JSExecutionContext.cpp
Normal file
343
dom/base/JSExecutionContext.cpp
Normal file
@ -0,0 +1,343 @@
|
||||
/* 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 is not a generated file. It contains common utility functions
|
||||
* invoked from the JavaScript code generated from IDL interfaces.
|
||||
* The goal of the utility functions is to cut down on the size of
|
||||
* the generated code itself.
|
||||
*/
|
||||
|
||||
#include "mozilla/dom/JSExecutionContext.h"
|
||||
|
||||
#include <utility>
|
||||
#include "MainThreadUtils.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/CompileOptions.h"
|
||||
#include "js/Conversions.h"
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/OffThreadScriptCompilation.h"
|
||||
#include "js/ProfilingCategory.h"
|
||||
#include "js/Promise.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "js/Transcoding.h"
|
||||
#include "js/Value.h"
|
||||
#include "js/Wrapper.h"
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTPromiseFlatString.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
#if !defined(DEBUG) && !defined(MOZ_ENABLE_JS_DUMP)
|
||||
# include "mozilla/StaticPrefs_browser.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
static nsresult EvaluationExceptionToNSResult(JSContext* aCx) {
|
||||
if (JS_IsExceptionPending(aCx)) {
|
||||
return NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW;
|
||||
}
|
||||
return NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE;
|
||||
}
|
||||
|
||||
JSExecutionContext::JSExecutionContext(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGlobal)
|
||||
:
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
mAutoProfilerLabel("JSExecutionContext",
|
||||
/* dynamicStr */ nullptr,
|
||||
JS::ProfilingCategoryPair::JS),
|
||||
#endif
|
||||
mCx(aCx),
|
||||
mRealm(aCx, aGlobal),
|
||||
mRetValue(aCx),
|
||||
mScopeChain(aCx),
|
||||
mScript(aCx),
|
||||
mRv(NS_OK),
|
||||
mSkip(false),
|
||||
mCoerceToString(false),
|
||||
mEncodeBytecode(false)
|
||||
#ifdef DEBUG
|
||||
,
|
||||
mWantsReturnValue(false),
|
||||
mExpectScopeChain(false),
|
||||
mScriptUsed(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(CycleCollectedJSContext::Get() &&
|
||||
CycleCollectedJSContext::Get()->MicroTaskLevel());
|
||||
MOZ_ASSERT(mRetValue.isUndefined());
|
||||
|
||||
MOZ_ASSERT(JS_IsGlobalObject(aGlobal));
|
||||
if (MOZ_UNLIKELY(!xpc::Scriptability::Get(aGlobal).Allowed())) {
|
||||
mSkip = true;
|
||||
mRv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
void JSExecutionContext::SetScopeChain(
|
||||
JS::HandleVector<JSObject*> aScopeChain) {
|
||||
if (mSkip) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mExpectScopeChain = true;
|
||||
#endif
|
||||
// Now make sure to wrap the scope chain into the right compartment.
|
||||
if (!mScopeChain.reserve(aScopeChain.length())) {
|
||||
mSkip = true;
|
||||
mRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < aScopeChain.length(); ++i) {
|
||||
JS::ExposeObjectToActiveJS(aScopeChain[i]);
|
||||
mScopeChain.infallibleAppend(aScopeChain[i]);
|
||||
if (!JS_WrapObject(mCx, mScopeChain[i])) {
|
||||
mSkip = true;
|
||||
mRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::JoinCompile(JS::OffThreadToken** aOffThreadToken) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
MOZ_ASSERT(!mExpectScopeChain);
|
||||
MOZ_ASSERT(!mScript);
|
||||
|
||||
if (mEncodeBytecode) {
|
||||
mScript.set(JS::FinishOffThreadScriptAndStartIncrementalEncoding(
|
||||
mCx, *aOffThreadToken));
|
||||
} else {
|
||||
mScript.set(JS::FinishOffThreadScript(mCx, *aOffThreadToken));
|
||||
}
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
nsresult JSExecutionContext::InternalCompile(
|
||||
JS::CompileOptions& aCompileOptions, JS::SourceText<Unit>& aSrcBuf) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSrcBuf.get());
|
||||
MOZ_ASSERT(mRetValue.isUndefined());
|
||||
#ifdef DEBUG
|
||||
mWantsReturnValue = !aCompileOptions.noScriptRval;
|
||||
#endif
|
||||
|
||||
MOZ_ASSERT(!mScript);
|
||||
|
||||
if (mScopeChain.length() != 0) {
|
||||
// Serialized bytecode should not be mixed with non-syntactic mode.
|
||||
// Currently, mScopeChain is only used by nsNPAPIPlugin which does not
|
||||
// support bytecode caching. This will all be removed in Bug 1689348.
|
||||
MOZ_ASSERT(!mEncodeBytecode);
|
||||
MOZ_ASSERT(mExpectScopeChain);
|
||||
|
||||
aCompileOptions.setNonSyntacticScope(true);
|
||||
}
|
||||
|
||||
if (mEncodeBytecode) {
|
||||
mScript =
|
||||
JS::CompileAndStartIncrementalEncoding(mCx, aCompileOptions, aSrcBuf);
|
||||
} else {
|
||||
mScript = JS::Compile(mCx, aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::Compile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<char16_t>& aSrcBuf) {
|
||||
return InternalCompile(aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::Compile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<Utf8Unit>& aSrcBuf) {
|
||||
return InternalCompile(aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::Compile(JS::CompileOptions& aCompileOptions,
|
||||
const nsAString& aScript) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
const nsPromiseFlatString& flatScript = PromiseFlatString(aScript);
|
||||
JS::SourceText<char16_t> srcBuf;
|
||||
if (!srcBuf.init(mCx, flatScript.get(), flatScript.Length(),
|
||||
JS::SourceOwnership::Borrowed)) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return Compile(aCompileOptions, srcBuf);
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::Decode(JS::CompileOptions& aCompileOptions,
|
||||
mozilla::Vector<uint8_t>& aBytecodeBuf,
|
||||
size_t aBytecodeIndex) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
JS::TranscodeResult tr = JS::DecodeScriptMaybeStencil(
|
||||
mCx, aCompileOptions, aBytecodeBuf, &mScript, aBytecodeIndex);
|
||||
// These errors are external parameters which should be handled before the
|
||||
// decoding phase, and which are the only reasons why you might want to
|
||||
// fallback on decoding failures.
|
||||
MOZ_ASSERT(tr != JS::TranscodeResult::Failure_BadBuildId &&
|
||||
tr != JS::TranscodeResult::Failure_WrongCompileOption);
|
||||
if (tr != JS::TranscodeResult::Ok) {
|
||||
mSkip = true;
|
||||
mRv = NS_ERROR_DOM_JS_DECODING_ERROR;
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return mRv;
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::JoinDecode(JS::OffThreadToken** aOffThreadToken) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
MOZ_ASSERT(!mExpectScopeChain);
|
||||
mScript.set(JS::FinishOffThreadScriptDecoder(mCx, *aOffThreadToken));
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::JoinDecodeBinAST(
|
||||
JS::OffThreadToken** aOffThreadToken) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::DecodeBinAST(JS::CompileOptions& aCompileOptions,
|
||||
const uint8_t* aBuf, size_t aLength) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
JSScript* JSExecutionContext::GetScript() {
|
||||
#ifdef DEBUG
|
||||
MOZ_ASSERT(!mSkip);
|
||||
MOZ_ASSERT(mScript);
|
||||
mScriptUsed = true;
|
||||
#endif
|
||||
|
||||
return MaybeGetScript();
|
||||
}
|
||||
|
||||
JSScript* JSExecutionContext::MaybeGetScript() { return mScript; }
|
||||
|
||||
nsresult JSExecutionContext::ExecScript() {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mScript);
|
||||
|
||||
if (!(mScopeChain.empty() ? JS_ExecuteScript(mCx, mScript)
|
||||
: JS_ExecuteScript(mCx, mScopeChain, mScript))) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool IsPromiseValue(JSContext* aCx, JS::Handle<JS::Value> aValue) {
|
||||
if (!aValue.isObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We only care about Promise here, so CheckedUnwrapStatic is fine.
|
||||
JS::Rooted<JSObject*> obj(aCx, js::CheckedUnwrapStatic(&aValue.toObject()));
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return JS::IsPromiseObject(obj);
|
||||
}
|
||||
|
||||
nsresult JSExecutionContext::ExecScript(
|
||||
JS::MutableHandle<JS::Value> aRetValue) {
|
||||
if (mSkip) {
|
||||
aRetValue.setUndefined();
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mScript);
|
||||
MOZ_ASSERT(mWantsReturnValue);
|
||||
|
||||
if (!(mScopeChain.empty()
|
||||
? JS_ExecuteScript(mCx, mScript, aRetValue)
|
||||
: JS_ExecuteScript(mCx, mScopeChain, mScript, aRetValue))) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mWantsReturnValue = false;
|
||||
#endif
|
||||
if (mCoerceToString && IsPromiseValue(mCx, aRetValue)) {
|
||||
// We're a javascript: url and we should treat Promise return values as
|
||||
// undefined.
|
||||
//
|
||||
// Once bug 1477821 is fixed this code might be able to go away, or will
|
||||
// become enshrined in the spec, depending.
|
||||
aRetValue.setUndefined();
|
||||
}
|
||||
|
||||
if (mCoerceToString && !aRetValue.isUndefined()) {
|
||||
JSString* str = JS::ToString(mCx, aRetValue);
|
||||
if (!str) {
|
||||
// ToString can be a function call, so an exception can be raised while
|
||||
// executing the function.
|
||||
mSkip = true;
|
||||
return EvaluationExceptionToNSResult(mCx);
|
||||
}
|
||||
aRetValue.set(JS::StringValue(str));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
169
dom/base/JSExecutionContext.h
Normal file
169
dom/base/JSExecutionContext.h
Normal file
@ -0,0 +1,169 @@
|
||||
/* 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 DOM_BASE_JSEXECUTIONCONTEXT_H_
|
||||
#define DOM_BASE_JSEXECUTIONCONTEXT_H_
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
#include "js/GCVector.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Vector.h"
|
||||
#include "nsStringFwd.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsIScriptElement;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsXBLPrototypeBinding;
|
||||
|
||||
namespace mozilla {
|
||||
union Utf8Unit;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class MOZ_STACK_CLASS JSExecutionContext final {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
// Register stack annotations for the Gecko profiler.
|
||||
mozilla::AutoProfilerLabel mAutoProfilerLabel;
|
||||
#endif
|
||||
|
||||
JSContext* mCx;
|
||||
|
||||
// Handles switching to our global's realm.
|
||||
JSAutoRealm mRealm;
|
||||
|
||||
// Set to a valid handle if a return value is expected.
|
||||
JS::Rooted<JS::Value> mRetValue;
|
||||
|
||||
// Scope chain in which the execution takes place.
|
||||
JS::RootedVector<JSObject*> mScopeChain;
|
||||
|
||||
// The compiled script.
|
||||
JS::Rooted<JSScript*> mScript;
|
||||
|
||||
// returned value forwarded when we have to interupt the execution eagerly
|
||||
// with mSkip.
|
||||
nsresult mRv;
|
||||
|
||||
// Used to skip upcoming phases in case of a failure. In such case the
|
||||
// result is carried by mRv.
|
||||
bool mSkip;
|
||||
|
||||
// Should the result be serialized before being returned.
|
||||
bool mCoerceToString;
|
||||
|
||||
// Encode the bytecode before it is being executed.
|
||||
bool mEncodeBytecode;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Should we set the return value.
|
||||
bool mWantsReturnValue;
|
||||
|
||||
bool mExpectScopeChain;
|
||||
|
||||
bool mScriptUsed;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Compile a script contained in a SourceText.
|
||||
template <typename Unit>
|
||||
nsresult InternalCompile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<Unit>& aSrcBuf);
|
||||
|
||||
public:
|
||||
// Enter compartment in which the code would be executed. The JSContext
|
||||
// must come from an AutoEntryScript.
|
||||
JSExecutionContext(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
|
||||
JSExecutionContext(const JSExecutionContext&) = delete;
|
||||
JSExecutionContext(JSExecutionContext&&) = delete;
|
||||
|
||||
~JSExecutionContext() {
|
||||
// This flag is reset when the returned value is extracted.
|
||||
MOZ_ASSERT_IF(!mSkip, !mWantsReturnValue);
|
||||
|
||||
// If encoding was started we expect the script to have been
|
||||
// used when ending the encoding.
|
||||
MOZ_ASSERT_IF(mEncodeBytecode && mScript && mRv == NS_OK, mScriptUsed);
|
||||
}
|
||||
|
||||
// The returned value would be converted to a string if the
|
||||
// |aCoerceToString| is flag set.
|
||||
JSExecutionContext& SetCoerceToString(bool aCoerceToString) {
|
||||
mCoerceToString = aCoerceToString;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// When set, this flag records and encodes the bytecode as soon as it is
|
||||
// being compiled, and before it is being executed. The bytecode can then be
|
||||
// requested by using |JS::FinishIncrementalEncoding| with the mutable
|
||||
// handle |aScript| argument of |CompileAndExec| or |JoinAndExec|.
|
||||
JSExecutionContext& SetEncodeBytecode(bool aEncodeBytecode) {
|
||||
mEncodeBytecode = aEncodeBytecode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Set the scope chain in which the code should be executed.
|
||||
void SetScopeChain(JS::HandleVector<JSObject*> aScopeChain);
|
||||
|
||||
// After getting a notification that an off-thread compilation terminated,
|
||||
// this function will take the result of the parser and move it to the main
|
||||
// thread.
|
||||
MOZ_MUST_USE nsresult JoinCompile(JS::OffThreadToken** aOffThreadToken);
|
||||
|
||||
// Compile a script contained in a SourceText.
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<char16_t>& aSrcBuf);
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<mozilla::Utf8Unit>& aSrcBuf);
|
||||
|
||||
// Compile a script contained in a string.
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
const nsAString& aScript);
|
||||
|
||||
// Decode a script contained in a buffer.
|
||||
nsresult Decode(JS::CompileOptions& aCompileOptions,
|
||||
mozilla::Vector<uint8_t>& aBytecodeBuf,
|
||||
size_t aBytecodeIndex);
|
||||
|
||||
// After getting a notification that an off-thread decoding terminated, this
|
||||
// function will get the result of the decoder and move it to the main
|
||||
// thread.
|
||||
nsresult JoinDecode(JS::OffThreadToken** aOffThreadToken);
|
||||
|
||||
nsresult JoinDecodeBinAST(JS::OffThreadToken** aOffThreadToken);
|
||||
|
||||
// Decode a BinAST encoded script contained in a buffer.
|
||||
nsresult DecodeBinAST(JS::CompileOptions& aCompileOptions,
|
||||
const uint8_t* aBuf, size_t aLength);
|
||||
|
||||
// Get a successfully compiled script.
|
||||
JSScript* GetScript();
|
||||
|
||||
// Get the compiled script if present, or nullptr.
|
||||
JSScript* MaybeGetScript();
|
||||
|
||||
// Execute the compiled script and ignore the return value.
|
||||
MOZ_MUST_USE nsresult ExecScript();
|
||||
|
||||
// Execute the compiled script a get the return value.
|
||||
//
|
||||
// Copy the returned value into the mutable handle argument. In case of a
|
||||
// evaluation failure either during the execution or the conversion of the
|
||||
// result to a string, the nsresult is be set to the corresponding result
|
||||
// code and the mutable handle argument remains unchanged.
|
||||
//
|
||||
// The value returned in the mutable handle argument is part of the
|
||||
// compartment given as argument to the JSExecutionContext constructor. If the
|
||||
// caller is in a different compartment, then the out-param value should be
|
||||
// wrapped by calling |JS_WrapValue|.
|
||||
MOZ_MUST_USE nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
|
||||
};
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* DOM_BASE_JSEXECUTIONCONTEXT_H_ */
|
@ -25,6 +25,8 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Components.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/ServoStyleConsts.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
|
@ -591,7 +591,7 @@ class VibrateWindowListener : public nsIDOMEventListener {
|
||||
mWindow = do_GetWeakReference(aWindow);
|
||||
mDocument = do_GetWeakReference(aDocument);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange");
|
||||
constexpr auto visibilitychange = u"visibilitychange"_ns;
|
||||
aDocument->AddSystemEventListener(visibilitychange, this, /* listener */
|
||||
true, /* use capture */
|
||||
false /* wants untrusted */);
|
||||
@ -642,7 +642,7 @@ void VibrateWindowListener::RemoveListener() {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange");
|
||||
constexpr auto visibilitychange = u"visibilitychange"_ns;
|
||||
target->RemoveSystemEventListener(visibilitychange, this,
|
||||
true /* use capture */);
|
||||
}
|
||||
|
@ -60,8 +60,7 @@ NodeInfo::NodeInfo(nsAtom* aName, nsAtom* aPrefix, int32_t aNamespaceID,
|
||||
// Qualified name. If we have no prefix, use ToString on
|
||||
// mInner.mName so that we get to share its buffer.
|
||||
if (aPrefix) {
|
||||
mQualifiedName = nsDependentAtomString(mInner.mPrefix) +
|
||||
NS_LITERAL_STRING(":") +
|
||||
mQualifiedName = nsDependentAtomString(mInner.mPrefix) + u":"_ns +
|
||||
nsDependentAtomString(mInner.mName);
|
||||
} else {
|
||||
mInner.mName->ToString(mQualifiedName);
|
||||
|
@ -12,11 +12,9 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class PlacesWeakCallbackWrapper final
|
||||
: public nsWrapperCache,
|
||||
public SupportsWeakPtr<PlacesWeakCallbackWrapper> {
|
||||
class PlacesWeakCallbackWrapper final : public nsWrapperCache,
|
||||
public SupportsWeakPtr {
|
||||
public:
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PlacesWeakCallbackWrapper)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PlacesWeakCallbackWrapper)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PlacesWeakCallbackWrapper)
|
||||
|
||||
|
@ -123,7 +123,7 @@ bool PopupBlocker::CanShowPopupByPermission(nsIPrincipal* aPrincipal) {
|
||||
|
||||
if (permissionManager &&
|
||||
NS_SUCCEEDED(permissionManager->TestPermissionFromPrincipal(
|
||||
aPrincipal, NS_LITERAL_CSTRING("popup"), &permit))) {
|
||||
aPrincipal, "popup"_ns, &permit))) {
|
||||
if (permit == nsIPermissionManager::ALLOW_ACTION) {
|
||||
return true;
|
||||
}
|
||||
@ -293,7 +293,7 @@ PopupBlocker::PopupControlState PopupBlocker::GetEventPopupControlState(
|
||||
break;
|
||||
case eMouseEventClass:
|
||||
if (aEvent->IsTrusted()) {
|
||||
if (aEvent->AsMouseEvent()->mButton == MouseButton::eLeft) {
|
||||
if (aEvent->AsMouseEvent()->mButton == MouseButton::ePrimary) {
|
||||
abuse = PopupBlocker::openBlocked;
|
||||
switch (aEvent->mMessage) {
|
||||
case eMouseUp:
|
||||
@ -350,7 +350,7 @@ PopupBlocker::PopupControlState PopupBlocker::GetEventPopupControlState(
|
||||
break;
|
||||
case ePointerEventClass:
|
||||
if (aEvent->IsTrusted() &&
|
||||
aEvent->AsPointerEvent()->mButton == MouseButton::eLeft) {
|
||||
aEvent->AsPointerEvent()->mButton == MouseButton::ePrimary) {
|
||||
switch (aEvent->mMessage) {
|
||||
case ePointerUp:
|
||||
if (PopupAllowedForEvent("pointerup")) {
|
||||
|
@ -190,7 +190,7 @@ PostMessageEvent::Run() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), CanBubble::eNo,
|
||||
event->InitMessageEvent(nullptr, u"message"_ns, CanBubble::eNo,
|
||||
Cancelable::eNo, messageData, mCallerOrigin,
|
||||
EmptyString(), source, ports);
|
||||
|
||||
@ -210,8 +210,8 @@ void PostMessageEvent::DispatchError(JSContext* aCx,
|
||||
init.mSource.SetValue().SetAsWindowProxy() = mSource;
|
||||
}
|
||||
|
||||
RefPtr<Event> event = MessageEvent::Constructor(
|
||||
aEventTarget, NS_LITERAL_STRING("messageerror"), init);
|
||||
RefPtr<Event> event =
|
||||
MessageEvent::Constructor(aEventTarget, u"messageerror"_ns, init);
|
||||
Dispatch(aTargetWindow, event);
|
||||
}
|
||||
|
||||
|
@ -87,47 +87,10 @@ static nsSize GetTargetSize(Element* aTarget, ResizeObserverBoxOptions aBox) {
|
||||
return size;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ResizeObservation)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ResizeObservation)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTarget);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ResizeObservation)
|
||||
tmp->Unlink(RemoveFromObserver::Yes);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(ResizeObservation, mTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ResizeObservation, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ResizeObservation, Release)
|
||||
|
||||
ResizeObservation::ResizeObservation(Element& aTarget,
|
||||
ResizeObserver& aObserver,
|
||||
ResizeObserverBoxOptions aBox,
|
||||
WritingMode aWm)
|
||||
: mTarget(&aTarget),
|
||||
mObserver(&aObserver),
|
||||
mObservedBox(aBox),
|
||||
// This starts us with a 0,0 last-reported-size:
|
||||
mLastReportedSize(aWm),
|
||||
mLastReportedWM(aWm) {
|
||||
aTarget.BindObject(mObserver);
|
||||
}
|
||||
|
||||
void ResizeObservation::Unlink(RemoveFromObserver aRemoveFromObserver) {
|
||||
ResizeObserver* observer = std::exchange(mObserver, nullptr);
|
||||
nsCOMPtr<Element> target = std::move(mTarget);
|
||||
if (observer && target) {
|
||||
if (aRemoveFromObserver == RemoveFromObserver::Yes) {
|
||||
IgnoredErrorResult rv;
|
||||
observer->Unobserve(*target, rv);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!rv.Failed(),
|
||||
"How could we keep the observer and target around "
|
||||
"without being in the observation map?");
|
||||
}
|
||||
target->UnbindObject(observer);
|
||||
}
|
||||
}
|
||||
|
||||
bool ResizeObservation::IsActive() const {
|
||||
nsIFrame* frame = mTarget->GetPrimaryFrame();
|
||||
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
|
||||
@ -143,22 +106,9 @@ void ResizeObservation::UpdateLastReportedSize(const nsSize& aSize) {
|
||||
}
|
||||
|
||||
// Only needed for refcounted objects.
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ResizeObserver)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(ResizeObserver)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ResizeObserver)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner, mDocument, mCallback,
|
||||
mActiveTargets, mObservationMap);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ResizeObserver)
|
||||
tmp->Disconnect();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner, mDocument, mCallback, mActiveTargets,
|
||||
mObservationMap);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ResizeObserver, mOwner, mDocument,
|
||||
mCallback, mActiveTargets,
|
||||
mObservationMap)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ResizeObserver)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ResizeObserver)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ResizeObserver)
|
||||
@ -221,9 +171,8 @@ void ResizeObserver::Observe(Element& aTarget,
|
||||
// FIXME(emilio): This should probably either flush or not look at the
|
||||
// writing-mode or something.
|
||||
nsIFrame* frame = aTarget.GetPrimaryFrame();
|
||||
observation =
|
||||
new ResizeObservation(aTarget, *this, aOptions.mBox,
|
||||
frame ? frame->GetWritingMode() : WritingMode());
|
||||
observation = new ResizeObservation(
|
||||
aTarget, aOptions.mBox, frame ? frame->GetWritingMode() : WritingMode());
|
||||
mObservationList.insertBack(observation);
|
||||
|
||||
// Per the spec, we need to trigger notification in event loop that
|
||||
@ -251,10 +200,7 @@ void ResizeObserver::Unobserve(Element& aTarget, ErrorResult& aRv) {
|
||||
|
||||
void ResizeObserver::Disconnect() {
|
||||
const bool registered = !mObservationList.isEmpty();
|
||||
while (auto* observation = mObservationList.popFirst()) {
|
||||
observation->Unlink(ResizeObservation::RemoveFromObserver::No);
|
||||
}
|
||||
MOZ_ASSERT(mObservationList.isEmpty());
|
||||
mObservationList.clear();
|
||||
mObservationMap.Clear();
|
||||
mActiveTargets.Clear();
|
||||
if (registered && MOZ_LIKELY(mDocument)) {
|
||||
|
@ -24,6 +24,12 @@ namespace dom {
|
||||
|
||||
class Element;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// For the internal implementation in ResizeObserver. Normally, this is owned by
|
||||
// ResizeObserver.
|
||||
class ResizeObservation final : public LinkedListElement<ResizeObservation> {
|
||||
@ -31,8 +37,15 @@ class ResizeObservation final : public LinkedListElement<ResizeObservation> {
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ResizeObservation)
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ResizeObservation)
|
||||
|
||||
ResizeObservation(Element&, ResizeObserver&, ResizeObserverBoxOptions,
|
||||
WritingMode);
|
||||
ResizeObservation(Element& aTarget, ResizeObserverBoxOptions aBox,
|
||||
const WritingMode aWM)
|
||||
: mTarget(&aTarget),
|
||||
mObservedBox(aBox),
|
||||
// This starts us with a 0,0 last-reported-size:
|
||||
mLastReportedSize(aWM),
|
||||
mLastReportedWM(aWM) {
|
||||
MOZ_ASSERT(mTarget, "Need a non-null target element");
|
||||
}
|
||||
|
||||
Element* Target() const { return mTarget; }
|
||||
|
||||
@ -49,17 +62,11 @@ class ResizeObservation final : public LinkedListElement<ResizeObservation> {
|
||||
*/
|
||||
void UpdateLastReportedSize(const nsSize& aSize);
|
||||
|
||||
enum class RemoveFromObserver : bool { No, Yes };
|
||||
void Unlink(RemoveFromObserver);
|
||||
|
||||
protected:
|
||||
~ResizeObservation() { Unlink(RemoveFromObserver::No); };
|
||||
~ResizeObservation() = default;
|
||||
|
||||
nsCOMPtr<Element> mTarget;
|
||||
|
||||
// Weak, observer always outlives us.
|
||||
ResizeObserver* mObserver;
|
||||
|
||||
const ResizeObserverBoxOptions mObservedBox;
|
||||
|
||||
// The latest recorded size of observed target.
|
||||
@ -137,7 +144,7 @@ class ResizeObserver final : public nsISupports, public nsWrapperCache {
|
||||
MOZ_CAN_RUN_SCRIPT uint32_t BroadcastActiveObservations();
|
||||
|
||||
protected:
|
||||
~ResizeObserver() { Disconnect(); }
|
||||
~ResizeObserver() { mObservationList.clear(); }
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> mOwner;
|
||||
// The window's document at the time of ResizeObserver creation.
|
||||
|
@ -73,6 +73,13 @@ ResizeObserverNotificationHelper::~ResizeObserverNotificationHelper() {
|
||||
MOZ_RELEASE_ASSERT(!mOwner, "Forgot to clear weak pointer?");
|
||||
}
|
||||
|
||||
void ResizeObserverController::Traverse(
|
||||
nsCycleCollectionTraversalCallback& aCb) {
|
||||
ImplCycleCollectionTraverse(aCb, mResizeObservers, "mResizeObservers");
|
||||
}
|
||||
|
||||
void ResizeObserverController::Unlink() { mResizeObservers.Clear(); }
|
||||
|
||||
void ResizeObserverController::ShellDetachedFromDocument() {
|
||||
mResizeObserverNotificationHelper->Unregister();
|
||||
}
|
||||
|
@ -64,6 +64,10 @@ class ResizeObserverController final {
|
||||
MOZ_ASSERT(mDocument, "Need a non-null document");
|
||||
}
|
||||
|
||||
// Methods for supporting cycle-collection
|
||||
void Traverse(nsCycleCollectionTraversalCallback& aCb);
|
||||
void Unlink();
|
||||
|
||||
void AddSizeOfIncludingThis(nsWindowSizes&) const;
|
||||
|
||||
void ShellDetachedFromDocument();
|
||||
|
@ -283,8 +283,8 @@ void Selection::Stringify(nsAString& aResult, FlushFrames aFlushFrames) {
|
||||
}
|
||||
|
||||
IgnoredErrorResult rv;
|
||||
ToStringWithFormat(NS_LITERAL_STRING("text/plain"),
|
||||
nsIDocumentEncoder::SkipInvisibleContent, 0, aResult, rv);
|
||||
ToStringWithFormat(u"text/plain"_ns, nsIDocumentEncoder::SkipInvisibleContent,
|
||||
0, aResult, rv);
|
||||
if (rv.Failed()) {
|
||||
aResult.Truncate();
|
||||
}
|
||||
@ -402,20 +402,20 @@ void Selection::SetCaretBidiLevel(const Nullable<int16_t>& aCaretBidiLevel,
|
||||
* a table element isn't selected.
|
||||
*/
|
||||
// TODO: Figure out TableSelectionMode::Column and TableSelectionMode::AllCells
|
||||
static nsresult GetTableSelectionType(const nsRange* aRange,
|
||||
static nsresult GetTableSelectionMode(const nsRange& aRange,
|
||||
TableSelectionMode* aTableSelectionType) {
|
||||
if (!aRange || !aTableSelectionType) {
|
||||
if (!aTableSelectionType) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aTableSelectionType = TableSelectionMode::None;
|
||||
|
||||
nsINode* startNode = aRange->GetStartContainer();
|
||||
nsINode* startNode = aRange.GetStartContainer();
|
||||
if (!startNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsINode* endNode = aRange->GetEndContainer();
|
||||
nsINode* endNode = aRange.GetEndContainer();
|
||||
if (!endNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -425,10 +425,10 @@ static nsresult GetTableSelectionType(const nsRange* aRange,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent* child = aRange->GetChildAtStartOffset();
|
||||
nsIContent* child = aRange.GetChildAtStartOffset();
|
||||
|
||||
// Not a single selected node
|
||||
if (!child || child->GetNextSibling() != aRange->GetChildAtEndOffset()) {
|
||||
if (!child || child->GetNextSibling() != aRange.GetChildAtEndOffset()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -454,45 +454,6 @@ static nsresult GetTableSelectionType(const nsRange* aRange,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT static nsresult GetTableCellLocationFromRange(
|
||||
const nsRange* aRange, TableSelectionMode* aSelectionType, int32_t* aRow,
|
||||
int32_t* aCol) {
|
||||
if (!aRange || !aSelectionType || !aRow || !aCol) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aSelectionType = TableSelectionMode::None;
|
||||
*aRow = 0;
|
||||
*aCol = 0;
|
||||
|
||||
nsresult result = GetTableSelectionType(aRange, aSelectionType);
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// Don't fail if range does not point to a single table cell,
|
||||
// let aSelectionType tell user if we don't have a cell
|
||||
if (*aSelectionType != TableSelectionMode::Cell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the child content (the cell) pointed to by starting node of range
|
||||
// We do minimal checking since GetTableSelectionType assures
|
||||
// us that this really is a table cell
|
||||
nsCOMPtr<nsIContent> child = aRange->GetChildAtStartOffset();
|
||||
if (!child) return NS_ERROR_FAILURE;
|
||||
|
||||
// GetCellLayout depends on current frame, we need flush frame to get
|
||||
// nsITableCellLayout
|
||||
if (RefPtr<PresShell> presShell = child->OwnerDoc()->GetPresShell()) {
|
||||
presShell->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
|
||||
// Note: This is a non-ref-counted pointer to the frame
|
||||
nsITableCellLayout* cellLayout = nsFrameSelection::GetCellLayout(child);
|
||||
if (!cellLayout) return NS_ERROR_FAILURE;
|
||||
|
||||
return cellLayout->GetCellIndexes(*aRow, *aCol);
|
||||
}
|
||||
|
||||
nsresult Selection::MaybeAddTableCellRange(nsRange& aRange, bool* aDidAddRange,
|
||||
int32_t* aOutIndex) {
|
||||
if (!aDidAddRange || !aOutIndex) {
|
||||
@ -504,12 +465,9 @@ nsresult Selection::MaybeAddTableCellRange(nsRange& aRange, bool* aDidAddRange,
|
||||
|
||||
if (!mFrameSelection) return NS_OK;
|
||||
|
||||
nsresult result;
|
||||
|
||||
// Get if we are adding a cell selection and the row, col of cell if we are
|
||||
int32_t newRow, newCol;
|
||||
TableSelectionMode tableMode;
|
||||
result = GetTableCellLocationFromRange(&aRange, &tableMode, &newRow, &newCol);
|
||||
nsresult result = GetTableSelectionMode(aRange, &tableMode);
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// If not adding a cell range, we are done here
|
||||
@ -527,9 +485,11 @@ nsresult Selection::MaybeAddTableCellRange(nsRange& aRange, bool* aDidAddRange,
|
||||
mFrameSelection->mTableSelection.mMode = tableMode;
|
||||
}
|
||||
|
||||
*aDidAddRange = true;
|
||||
return AddRangesForSelectableNodes(&aRange, aOutIndex,
|
||||
DispatchSelectstartEvent::Maybe);
|
||||
result = AddRangesForSelectableNodes(&aRange, aOutIndex,
|
||||
DispatchSelectstartEvent::Maybe);
|
||||
|
||||
*aDidAddRange = *aOutIndex != -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
Selection::Selection(SelectionType aSelectionType,
|
||||
@ -842,8 +802,8 @@ static bool MaybeDispatchSelectstartEvent(
|
||||
|
||||
if (selectstartEventTarget) {
|
||||
nsContentUtils::DispatchTrustedEvent(
|
||||
aDocument, selectstartEventTarget, NS_LITERAL_STRING("selectstart"),
|
||||
CanBubble::eYes, Cancelable::eYes, &executeDefaultAction);
|
||||
aDocument, selectstartEventTarget, u"selectstart"_ns, CanBubble::eYes,
|
||||
Cancelable::eYes, &executeDefaultAction);
|
||||
}
|
||||
|
||||
return executeDefaultAction;
|
||||
@ -2127,7 +2087,7 @@ void Selection::Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv) {
|
||||
}
|
||||
|
||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
||||
frameSelection->InvalidateDesiredPos();
|
||||
frameSelection->InvalidateDesiredCaretPos();
|
||||
if (!frameSelection->IsValidSelectionPoint(aPoint.Container())) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
@ -3560,7 +3520,7 @@ nsresult Selection::SelectionLanguageChange(bool aLangRTL) {
|
||||
|
||||
// The caret might have moved, so invalidate the desired position
|
||||
// for future usages of up-arrow or down-arrow
|
||||
frameSelection->InvalidateDesiredPos();
|
||||
frameSelection->InvalidateDesiredCaretPos();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3577,8 +3537,8 @@ void Selection::SetColors(const nsAString& aForegroundColor,
|
||||
|
||||
mCustomColors.reset(new SelectionCustomColors);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(currentColorStr, "currentColor");
|
||||
NS_NAMED_LITERAL_STRING(transparentStr, "transparent");
|
||||
constexpr auto currentColorStr = u"currentColor"_ns;
|
||||
constexpr auto transparentStr = u"transparent"_ns;
|
||||
|
||||
if (!aForegroundColor.Equals(currentColorStr)) {
|
||||
nscolor foregroundColor;
|
||||
|
@ -54,7 +54,7 @@ namespace dom {
|
||||
// is never deleted before its Selections.
|
||||
class Selection final : public nsSupportsWeakReference,
|
||||
public nsWrapperCache,
|
||||
public SupportsWeakPtr<Selection> {
|
||||
public SupportsWeakPtr {
|
||||
protected:
|
||||
virtual ~Selection();
|
||||
|
||||
@ -65,8 +65,6 @@ class Selection final : public nsSupportsWeakReference,
|
||||
explicit Selection(SelectionType aSelectionType,
|
||||
nsFrameSelection* aFrameSelection);
|
||||
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Selection)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Selection)
|
||||
|
||||
|
@ -328,7 +328,8 @@ void ShadowRoot::RuleRemoved(StyleSheet& aSheet, css::Rule& aRule) {
|
||||
ApplicableRulesChanged();
|
||||
}
|
||||
|
||||
void ShadowRoot::RuleChanged(StyleSheet& aSheet, css::Rule*) {
|
||||
void ShadowRoot::RuleChanged(StyleSheet& aSheet, css::Rule*,
|
||||
StyleRuleChangeKind) {
|
||||
if (!aSheet.IsApplicable()) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ namespace mozilla {
|
||||
class EventChainPreVisitor;
|
||||
class ServoStyleRuleMap;
|
||||
|
||||
enum class StyleRuleChangeKind : uint32_t;
|
||||
|
||||
namespace css {
|
||||
class Rule;
|
||||
}
|
||||
@ -75,7 +77,7 @@ class ShadowRoot final : public DocumentFragment,
|
||||
void RemoveSheetFromStyles(StyleSheet&);
|
||||
void RuleAdded(StyleSheet&, css::Rule&);
|
||||
void RuleRemoved(StyleSheet&, css::Rule&);
|
||||
void RuleChanged(StyleSheet&, css::Rule*);
|
||||
void RuleChanged(StyleSheet&, css::Rule*, StyleRuleChangeKind);
|
||||
void ImportRuleLoaded(CSSImportRule&, StyleSheet&);
|
||||
void SheetCloned(StyleSheet&);
|
||||
void StyleSheetApplicableStateChanged(StyleSheet&);
|
||||
|
@ -96,7 +96,7 @@ nsCString ThirdPartyUtil::GetBaseDomainFromWindow(nsPIDOMWindowOuter* aWindow) {
|
||||
mozilla::dom::Document* doc = aWindow ? aWindow->GetExtantDoc() : nullptr;
|
||||
|
||||
if (!doc) {
|
||||
return EmptyCString();
|
||||
return ""_ns;
|
||||
}
|
||||
|
||||
return doc->GetBaseDomain();
|
||||
|
@ -296,8 +296,7 @@ bool TimeoutManager::IsInvalidFiringId(uint32_t aFiringId) const {
|
||||
return !mFiringIdStack.Contains(aFiringId);
|
||||
}
|
||||
|
||||
// The number of nested timeouts before we start clamping. HTML5 says 1, WebKit
|
||||
// uses 5.
|
||||
// The number of nested timeouts before we start clamping. HTML says 5.
|
||||
#define DOM_CLAMP_TIMEOUT_NESTING_LEVEL 5u
|
||||
|
||||
TimeDuration TimeoutManager::CalculateDelay(Timeout* aTimeout) const {
|
||||
|
@ -262,13 +262,9 @@ JSObject* WindowNamedPropertiesHandler::Create(JSContext* aCx,
|
||||
js::ProxyOptions options;
|
||||
options.setClass(&WindowNamedPropertiesClass.mBase);
|
||||
|
||||
// Note: since the scope polluter proxy lives on the window's prototype
|
||||
// chain, it needs a singleton type to avoid polluting type information
|
||||
// for properties on the window.
|
||||
JS::Rooted<JSObject*> gsp(
|
||||
aCx, js::NewSingletonProxyObject(
|
||||
aCx, WindowNamedPropertiesHandler::getInstance(),
|
||||
JS::NullHandleValue, aProto, options));
|
||||
aCx, js::NewProxyObject(aCx, WindowNamedPropertiesHandler::getInstance(),
|
||||
JS::NullHandleValue, aProto, options));
|
||||
if (!gsp) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ void WindowOrientationObserver::Notify(
|
||||
uint16_t currentAngle = aConfiguration.angle();
|
||||
if (mAngle != currentAngle && mWindow->IsCurrentInnerWindow()) {
|
||||
mAngle = currentAngle;
|
||||
mWindow->GetOuterWindow()->DispatchCustomEvent(
|
||||
NS_LITERAL_STRING("orientationchange"));
|
||||
mWindow->GetOuterWindow()->DispatchCustomEvent(u"orientationchange"_ns);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,15 +101,14 @@ void GenerateConcatExpression(const nsAString& aStr, nsAString& aResult) {
|
||||
}
|
||||
|
||||
// Prepend concat(' and append ').
|
||||
aResult.Assign(NS_LITERAL_STRING("concat(\'") + result +
|
||||
NS_LITERAL_STRING("\')"));
|
||||
aResult.Assign(u"concat(\'"_ns + result + u"\')"_ns);
|
||||
}
|
||||
|
||||
void XPathGenerator::QuoteArgument(const nsAString& aArg, nsAString& aResult) {
|
||||
if (!aArg.Contains('\'')) {
|
||||
aResult.Assign(NS_LITERAL_STRING("\'") + aArg + NS_LITERAL_STRING("\'"));
|
||||
aResult.Assign(u"\'"_ns + aArg + u"\'"_ns);
|
||||
} else if (!aArg.Contains('\"')) {
|
||||
aResult.Assign(NS_LITERAL_STRING("\"") + aArg + NS_LITERAL_STRING("\""));
|
||||
aResult.Assign(u"\""_ns + aArg + u"\""_ns);
|
||||
} else {
|
||||
GenerateConcatExpression(aArg, aResult);
|
||||
}
|
||||
@ -119,8 +118,7 @@ void XPathGenerator::EscapeName(const nsAString& aName, nsAString& aResult) {
|
||||
if (ContainNonWordCharacter(aName)) {
|
||||
nsAutoString quotedArg;
|
||||
QuoteArgument(aName, quotedArg);
|
||||
aResult.Assign(NS_LITERAL_STRING("*[local-name()=") + quotedArg +
|
||||
NS_LITERAL_STRING("]"));
|
||||
aResult.Assign(u"*[local-name()="_ns + quotedArg + u"]"_ns);
|
||||
} else {
|
||||
aResult.Assign(aName);
|
||||
}
|
||||
@ -144,7 +142,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
|
||||
if (prefix.IsEmpty()) {
|
||||
tag.Assign(nodeEscapeName);
|
||||
} else {
|
||||
tag.Assign(prefix + NS_LITERAL_STRING(":") + nodeEscapeName);
|
||||
tag.Assign(prefix + u":"_ns + nodeEscapeName);
|
||||
}
|
||||
|
||||
if (aNode->HasID()) {
|
||||
@ -154,8 +152,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
|
||||
nsAutoString quotedArgument;
|
||||
elem->GetId(elemId);
|
||||
QuoteArgument(elemId, quotedArgument);
|
||||
aResult.Assign(NS_LITERAL_STRING("//") + tag + NS_LITERAL_STRING("[@id=") +
|
||||
quotedArgument + NS_LITERAL_STRING("]"));
|
||||
aResult.Assign(u"//"_ns + tag + u"[@id="_ns + quotedArgument + u"]"_ns);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -181,8 +178,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
|
||||
if (!nodeNameAttribute.IsEmpty()) {
|
||||
nsAutoString quotedArgument;
|
||||
QuoteArgument(nodeNameAttribute, quotedArgument);
|
||||
namePart.Assign(NS_LITERAL_STRING("[@name=") + quotedArgument +
|
||||
NS_LITERAL_STRING("]"));
|
||||
namePart.Assign(u"[@name="_ns + quotedArgument + u"]"_ns);
|
||||
}
|
||||
if (count != 1) {
|
||||
countPart.AssignLiteral(u"[");
|
||||
@ -190,5 +186,5 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) {
|
||||
countPart.AppendLiteral(u"]");
|
||||
}
|
||||
Generate(aNode->GetParentNode(), aResult);
|
||||
aResult.Append(NS_LITERAL_STRING("/") + tag + namePart + countPart);
|
||||
aResult.Append(u"/"_ns + tag + namePart + countPart);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
with Files('*Selection*'):
|
||||
BUG_COMPONENT = ('Core', 'Selection')
|
||||
BUG_COMPONENT = ('Core', 'DOM: Selection')
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Core", "DOM: Core & HTML")
|
||||
@ -141,6 +141,7 @@ EXPORTS.mozilla.dom += [
|
||||
'BodyStream.h',
|
||||
'BodyUtil.h',
|
||||
'BorrowedAttrInfo.h',
|
||||
'CCGCScheduler.h',
|
||||
'CharacterData.h',
|
||||
'ChildIterator.h',
|
||||
'ChildProcessMessageManager.h',
|
||||
@ -188,6 +189,7 @@ EXPORTS.mozilla.dom += [
|
||||
'ImageEncoder.h',
|
||||
'ImageTracker.h',
|
||||
'IntlUtils.h',
|
||||
'JSExecutionContext.h',
|
||||
'Link.h',
|
||||
'LinkStyle.h',
|
||||
'Location.h',
|
||||
@ -307,6 +309,7 @@ UNIFIED_SOURCES += [
|
||||
'ImageTracker.cpp',
|
||||
'InProcessBrowserChildMessageManager.cpp',
|
||||
'IntlUtils.cpp',
|
||||
'JSExecutionContext.cpp',
|
||||
'Link.cpp',
|
||||
'LinkStyle.cpp',
|
||||
'Location.cpp',
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "mozilla/ServoUtils.h"
|
||||
#include "mozilla/ShadowParts.h"
|
||||
#include "mozilla/DeclarationBlock.h"
|
||||
#include "mozilla/dom/CSSRuleBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsHTMLCSSStyleSheet.h"
|
||||
@ -550,7 +551,7 @@ void nsAttrValue::ToString(nsAString& aResult) const {
|
||||
} else {
|
||||
str.AppendInt(GetIntInternal());
|
||||
}
|
||||
aResult = str + NS_LITERAL_STRING("%");
|
||||
aResult = str + u"%"_ns;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1730,10 +1731,10 @@ bool nsAttrValue::ParseStyleAttribute(const nsAString& aString,
|
||||
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
dom::ReferrerInfo::CreateForInternalCSSResources(ownerDoc);
|
||||
RefPtr<URLExtraData> data =
|
||||
new URLExtraData(baseURI, referrerInfo, principal);
|
||||
auto data = MakeRefPtr<URLExtraData>(baseURI, referrerInfo, principal);
|
||||
RefPtr<DeclarationBlock> decl = DeclarationBlock::FromCssText(
|
||||
aString, data, ownerDoc->GetCompatibilityMode(), ownerDoc->CSSLoader());
|
||||
aString, data, ownerDoc->GetCompatibilityMode(), ownerDoc->CSSLoader(),
|
||||
dom::CSSRule_Binding::STYLE_RULE);
|
||||
if (!decl) {
|
||||
return false;
|
||||
}
|
||||
|
@ -308,8 +308,9 @@ nsresult nsCCUncollectableMarker::Observe(nsISupports* aSubject,
|
||||
!strcmp(aTopic, "cycle-collector-forget-skippable"),
|
||||
"wrong topic");
|
||||
|
||||
// JS cleanup can be slow. Do it only if there has been a GC.
|
||||
const bool cleanupJS = nsJSContext::CleanupsSinceLastGC() == 0 &&
|
||||
// JS cleanup can be slow. Do it only if this is the first forget-skippable
|
||||
// after a GC.
|
||||
const bool cleanupJS = nsJSContext::HasHadCleanupSinceLastGC() &&
|
||||
!strcmp(aTopic, "cycle-collector-forget-skippable");
|
||||
|
||||
const bool prepareForCC = !strcmp(aTopic, "cycle-collector-begin");
|
||||
|
@ -175,7 +175,7 @@ nsresult CheckAndGetExtensionForMime(const nsCString& aExtension,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMIMEInfo> mimeInfo;
|
||||
rv = mimeService->GetFromTypeAndExtension(aMimeType, EmptyCString(),
|
||||
rv = mimeService->GetFromTypeAndExtension(aMimeType, ""_ns,
|
||||
getter_AddRefs(mimeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -390,9 +390,8 @@ void DragDataProducer::CreateLinkText(const nsAString& inURL,
|
||||
// use a temp var in case |inText| is the same string as
|
||||
// |outLinkText| to avoid overwriting it while building up the
|
||||
// string in pieces.
|
||||
nsAutoString linkText(NS_LITERAL_STRING("<a href=\"") + inURL +
|
||||
NS_LITERAL_STRING("\">") + inText +
|
||||
NS_LITERAL_STRING("</a>"));
|
||||
nsAutoString linkText(u"<a href=\""_ns + inURL + u"\">"_ns + inText +
|
||||
u"</a>"_ns);
|
||||
|
||||
outLinkText = linkText;
|
||||
}
|
||||
@ -447,7 +446,7 @@ nsresult DragDataProducer::GetImageData(imgIContainer* aImage,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMIMEInfo> mimeInfo;
|
||||
mimeService->GetFromTypeAndExtension(mimeType, EmptyCString(),
|
||||
mimeService->GetFromTypeAndExtension(mimeType, ""_ns,
|
||||
getter_AddRefs(mimeInfo));
|
||||
if (mimeInfo) {
|
||||
nsAutoCString extension;
|
||||
@ -814,34 +813,35 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
|
||||
title.ReplaceChar("\r\n", ' ');
|
||||
dragData += title;
|
||||
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kURLMime), dragData, principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kURLMime), dragData,
|
||||
principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDescriptionMime),
|
||||
mTitleString, principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING("text/uri-list"), mUrlString,
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kURLDataMime),
|
||||
mUrlString, principal);
|
||||
AddString(aDataTransfer,
|
||||
NS_LITERAL_STRING_FROM_CSTRING(kURLDescriptionMime), mTitleString,
|
||||
principal);
|
||||
AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
|
||||
}
|
||||
|
||||
// add a special flavor for the html context data
|
||||
if (!mContextString.IsEmpty())
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), mContextString,
|
||||
principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLContext),
|
||||
mContextString, principal);
|
||||
|
||||
// add a special flavor if we have html info data
|
||||
if (!mInfoString.IsEmpty())
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), mInfoString,
|
||||
principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLInfo),
|
||||
mInfoString, principal);
|
||||
|
||||
// add the full html
|
||||
if (!mHtmlString.IsEmpty())
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kHTMLMime), mHtmlString,
|
||||
principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLMime),
|
||||
mHtmlString, principal);
|
||||
|
||||
// add the plain text. we use the url for text/plain data if an anchor is
|
||||
// being dragged, rather than the title text of the link or the alt text for
|
||||
// an anchor image.
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kTextMime),
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kTextMime),
|
||||
mIsAnchor ? mUrlString : mTitleString, principal);
|
||||
|
||||
// add image data, if present. For now, all we're going to do with
|
||||
@ -851,8 +851,9 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
|
||||
if (mImage) {
|
||||
RefPtr<nsVariantCC> variant = new nsVariantCC();
|
||||
variant->SetAsISupports(mImage);
|
||||
aDataTransfer->SetDataWithPrincipal(NS_LITERAL_STRING(kNativeImageMime),
|
||||
variant, 0, principal);
|
||||
aDataTransfer->SetDataWithPrincipal(
|
||||
NS_LITERAL_STRING_FROM_CSTRING(kNativeImageMime), variant, 0,
|
||||
principal);
|
||||
|
||||
// assume the image comes from a file, and add a file promise. We
|
||||
// register ourselves as a nsIFlavorDataProvider, and will use the
|
||||
@ -863,25 +864,27 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
|
||||
if (dataProvider) {
|
||||
RefPtr<nsVariantCC> variant = new nsVariantCC();
|
||||
variant->SetAsISupports(dataProvider);
|
||||
aDataTransfer->SetDataWithPrincipal(NS_LITERAL_STRING(kFilePromiseMime),
|
||||
variant, 0, principal);
|
||||
aDataTransfer->SetDataWithPrincipal(
|
||||
NS_LITERAL_STRING_FROM_CSTRING(kFilePromiseMime), variant, 0,
|
||||
principal);
|
||||
}
|
||||
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kFilePromiseURLMime),
|
||||
AddString(aDataTransfer,
|
||||
NS_LITERAL_STRING_FROM_CSTRING(kFilePromiseURLMime),
|
||||
mImageSourceString, principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kFilePromiseDestFilename),
|
||||
AddString(aDataTransfer,
|
||||
NS_LITERAL_STRING_FROM_CSTRING(kFilePromiseDestFilename),
|
||||
mImageDestFileName, principal);
|
||||
#if defined(XP_MACOSX)
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kImageRequestMime),
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kImageRequestMime),
|
||||
mImageRequestMime, principal, /* aHidden= */ true);
|
||||
#endif
|
||||
|
||||
// if not an anchor, add the image url
|
||||
if (!mIsAnchor) {
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
|
||||
principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING("text/uri-list"), mUrlString,
|
||||
principal);
|
||||
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kURLDataMime),
|
||||
mUrlString, principal);
|
||||
AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/ServiceWorkerDescriptor.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsParserConstants.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "Link.h"
|
||||
|
@ -5981,7 +5981,7 @@ nsresult nsContentUtils::CreateArrayBuffer(JSContext* aCx,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
int32_t dataLen = aData.Length();
|
||||
size_t dataLen = aData.Length();
|
||||
*aResult = JS::NewArrayBuffer(aCx, dataLen);
|
||||
if (!*aResult) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -6127,27 +6127,6 @@ bool nsContentUtils::IsSubDocumentTabbable(nsIContent* aContent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsContentUtils::IsUserFocusIgnored(nsINode* aNode) {
|
||||
if (!StaticPrefs::dom_mozBrowserFramesEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if our mozbrowser iframe ancestors has ignoreuserfocus attribute.
|
||||
while (aNode) {
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aNode);
|
||||
if (browserFrame &&
|
||||
aNode->AsElement()->HasAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::ignoreuserfocus) &&
|
||||
browserFrame->GetReallyIsBrowser()) {
|
||||
return true;
|
||||
}
|
||||
nsPIDOMWindowOuter* win = aNode->OwnerDoc()->GetWindow();
|
||||
aNode = win ? win->GetFrameElementInternal() : nullptr;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nsContentUtils::HasScrollgrab(nsIContent* aContent) {
|
||||
// If we ever standardize this feature we'll want to hook this up properly
|
||||
// again. For now we're removing all the DOM-side code related to it but
|
||||
@ -7758,12 +7737,12 @@ int16_t nsContentUtils::GetButtonsFlagForButton(int32_t aButton) {
|
||||
switch (aButton) {
|
||||
case -1:
|
||||
return MouseButtonsFlag::eNoButtons;
|
||||
case MouseButton::eLeft:
|
||||
return MouseButtonsFlag::eLeftFlag;
|
||||
case MouseButton::ePrimary:
|
||||
return MouseButtonsFlag::ePrimaryFlag;
|
||||
case MouseButton::eMiddle:
|
||||
return MouseButtonsFlag::eMiddleFlag;
|
||||
case MouseButton::eRight:
|
||||
return MouseButtonsFlag::eRightFlag;
|
||||
case MouseButton::eSecondary:
|
||||
return MouseButtonsFlag::eSecondaryFlag;
|
||||
case 4:
|
||||
return MouseButtonsFlag::e4thFlag;
|
||||
case 5:
|
||||
@ -8270,12 +8249,13 @@ class StringBuilder {
|
||||
if (!mLength.isValid()) {
|
||||
return false;
|
||||
}
|
||||
nsresult rv;
|
||||
BulkAppender appender(aOut.BulkWrite(mLength.value(), 0, true, rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
auto appenderOrErr = aOut.BulkWrite(mLength.value(), 0, true);
|
||||
if (appenderOrErr.isErr()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BulkAppender appender{appenderOrErr.unwrap()};
|
||||
|
||||
for (StringBuilder* current = this; current;
|
||||
current = current->mNext.get()) {
|
||||
uint32_t len = current->mUnits.Length();
|
||||
@ -8598,14 +8578,10 @@ static inline bool ShouldEscape(nsIContent* aParent) {
|
||||
}
|
||||
|
||||
static const nsAtom* nonEscapingElements[] = {
|
||||
nsGkAtoms::style, nsGkAtoms::script, nsGkAtoms::xmp, nsGkAtoms::iframe,
|
||||
nsGkAtoms::noembed, nsGkAtoms::noframes, nsGkAtoms::plaintext,
|
||||
// Per the current spec noscript should be escaped in case
|
||||
// scripts are disabled or if document doesn't have
|
||||
// browsing context. However the latter seems to be a spec bug
|
||||
// and Gecko hasn't traditionally done the former.
|
||||
nsGkAtoms::noscript};
|
||||
static mozilla::BloomFilter<12, nsAtom> sFilter;
|
||||
nsGkAtoms::style, nsGkAtoms::script, nsGkAtoms::xmp,
|
||||
nsGkAtoms::iframe, nsGkAtoms::noembed, nsGkAtoms::noframes,
|
||||
nsGkAtoms::plaintext, nsGkAtoms::noscript};
|
||||
static mozilla::BitBloomFilter<12, nsAtom> sFilter;
|
||||
static bool sInitialized = false;
|
||||
if (!sInitialized) {
|
||||
sInitialized = true;
|
||||
@ -8618,6 +8594,10 @@ static inline bool ShouldEscape(nsIContent* aParent) {
|
||||
if (sFilter.mightContain(tag)) {
|
||||
for (auto& nonEscapingElement : nonEscapingElements) {
|
||||
if (tag == nonEscapingElement) {
|
||||
if (MOZ_UNLIKELY(tag == nsGkAtoms::noscript) &&
|
||||
MOZ_UNLIKELY(!aParent->OwnerDoc()->IsScriptEnabled())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1048,7 +1048,7 @@ class nsContentUtils {
|
||||
* @param aCategory Name of module reporting error.
|
||||
* @param aDocument Reference to the document which triggered the message.
|
||||
* @param [aURI=nullptr] (Optional) URI of resource containing error.
|
||||
* @param [aSourceLine=EmptyString()] (Optional) The text of the line that
|
||||
* @param [aSourceLine=u""_ns] (Optional) The text of the line that
|
||||
contains the error (may be empty).
|
||||
* @param [aLineNumber=0] (Optional) Line number within resource
|
||||
containing error.
|
||||
@ -1067,7 +1067,7 @@ class nsContentUtils {
|
||||
static nsresult ReportToConsoleNonLocalized(
|
||||
const nsAString& aErrorText, uint32_t aErrorFlags,
|
||||
const nsACString& aCategory, const Document* aDocument,
|
||||
nsIURI* aURI = nullptr, const nsString& aSourceLine = EmptyString(),
|
||||
nsIURI* aURI = nullptr, const nsString& aSourceLine = u""_ns,
|
||||
uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0,
|
||||
MissingErrorLocationMode aLocationMode = eUSE_CALLING_LOCATION);
|
||||
|
||||
@ -1080,7 +1080,7 @@ class nsContentUtils {
|
||||
* @param [aInnerWindowID] Inner window ID for document which triggered the
|
||||
* message.
|
||||
* @param [aURI=nullptr] (Optional) URI of resource containing error.
|
||||
* @param [aSourceLine=EmptyString()] (Optional) The text of the line that
|
||||
* @param [aSourceLine=u""_ns] (Optional) The text of the line that
|
||||
contains the error (may be empty).
|
||||
* @param [aLineNumber=0] (Optional) Line number within resource
|
||||
containing error.
|
||||
@ -1093,7 +1093,7 @@ class nsContentUtils {
|
||||
static nsresult ReportToConsoleByWindowID(
|
||||
const nsAString& aErrorText, uint32_t aErrorFlags,
|
||||
const nsACString& aCategory, uint64_t aInnerWindowID,
|
||||
nsIURI* aURI = nullptr, const nsString& aSourceLine = EmptyString(),
|
||||
nsIURI* aURI = nullptr, const nsString& aSourceLine = u""_ns,
|
||||
uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0,
|
||||
MissingErrorLocationMode aLocationMode = eUSE_CALLING_LOCATION);
|
||||
|
||||
@ -1107,7 +1107,7 @@ class nsContentUtils {
|
||||
* @param [aParams=empty-array] (Optional) Parameters to be substituted into
|
||||
localized message.
|
||||
* @param [aURI=nullptr] (Optional) URI of resource containing error.
|
||||
* @param [aSourceLine=EmptyString()] (Optional) The text of the line that
|
||||
* @param [aSourceLine=u""_ns] (Optional) The text of the line that
|
||||
contains the error (may be empty).
|
||||
* @param [aLineNumber=0] (Optional) Line number within resource
|
||||
containing error.
|
||||
@ -1138,7 +1138,7 @@ class nsContentUtils {
|
||||
uint32_t aErrorFlags, const nsACString& aCategory,
|
||||
const Document* aDocument, PropertiesFile aFile, const char* aMessageName,
|
||||
const nsTArray<nsString>& aParams = nsTArray<nsString>(),
|
||||
nsIURI* aURI = nullptr, const nsString& aSourceLine = EmptyString(),
|
||||
nsIURI* aURI = nullptr, const nsString& aSourceLine = u""_ns,
|
||||
uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0);
|
||||
|
||||
static void ReportEmptyGetElementByIdArg(const Document* aDoc);
|
||||
@ -2467,15 +2467,6 @@ class nsContentUtils {
|
||||
*/
|
||||
static bool IsSubDocumentTabbable(nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* Returns if aNode ignores user focus.
|
||||
*
|
||||
* @param aNode node to test
|
||||
*
|
||||
* @return Whether the node ignores user focus.
|
||||
*/
|
||||
static bool IsUserFocusIgnored(nsINode* aNode);
|
||||
|
||||
/**
|
||||
* Returns if aContent has the 'scrollgrab' property.
|
||||
* aContent may be null (in this case false is returned).
|
||||
|
@ -561,10 +561,10 @@ static nsresult AppendDOMNode(nsITransferable* aTransferable,
|
||||
NS_ENSURE_TRUE(document->IsHTMLDocument(), NS_OK);
|
||||
|
||||
// init encoder with document and node
|
||||
rv =
|
||||
docEncoder->NativeInit(document, NS_LITERAL_STRING(kHTMLMime),
|
||||
nsIDocumentEncoder::OutputAbsoluteLinks |
|
||||
nsIDocumentEncoder::OutputEncodeBasicEntities);
|
||||
rv = docEncoder->NativeInit(
|
||||
document, NS_LITERAL_STRING_FROM_CSTRING(kHTMLMime),
|
||||
nsIDocumentEncoder::OutputAbsoluteLinks |
|
||||
nsIDocumentEncoder::OutputEncodeBasicEntities);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = docEncoder->SetNode(aDOMNode);
|
||||
@ -629,7 +629,7 @@ static nsresult AppendImagePromise(nsITransferable* aTransferable,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMIMEInfo> mimeInfo;
|
||||
mimeService->GetFromTypeAndExtension(mimeType, EmptyCString(),
|
||||
mimeService->GetFromTypeAndExtension(mimeType, ""_ns,
|
||||
getter_AddRefs(mimeInfo));
|
||||
NS_ENSURE_TRUE(mimeInfo, NS_OK);
|
||||
|
||||
@ -929,7 +929,7 @@ bool nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
|
||||
// Now that we have copied, update the clipboard commands. This should have
|
||||
// the effect of updating the enabled state of the paste menu item.
|
||||
if (doDefault || count) {
|
||||
piWindow->UpdateCommands(NS_LITERAL_STRING("clipboard"), nullptr, 0);
|
||||
piWindow->UpdateCommands(u"clipboard"_ns, nullptr, 0);
|
||||
}
|
||||
|
||||
if (aActionTaken) {
|
||||
|
@ -122,7 +122,7 @@ Attr* nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo) {
|
||||
// Newly inserted entry!
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
auto* nim = ni->NodeInfoManager();
|
||||
entryValue = new (nim) Attr(this, ni.forget(), EmptyString());
|
||||
entryValue = new (nim) Attr(this, ni.forget(), u""_ns);
|
||||
node = entryValue;
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ nsresult nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
|
||||
if (aBinary) {
|
||||
if (mBinaryType == DC_BINARY_TYPE_BLOB) {
|
||||
RefPtr<Blob> blob =
|
||||
Blob::CreateStringBlob(GetOwnerGlobal(), aData, EmptyString());
|
||||
Blob::CreateStringBlob(GetOwnerGlobal(), aData, u""_ns);
|
||||
if (NS_WARN_IF(!blob)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -310,9 +310,9 @@ nsresult nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
|
||||
|
||||
RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
|
||||
|
||||
event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), CanBubble::eNo,
|
||||
Cancelable::eNo, jsData, mOrigin, EmptyString(),
|
||||
nullptr, Sequence<OwningNonNull<MessagePort>>());
|
||||
event->InitMessageEvent(nullptr, u"message"_ns, CanBubble::eNo,
|
||||
Cancelable::eNo, jsData, mOrigin, u""_ns, nullptr,
|
||||
Sequence<OwningNonNull<MessagePort>>());
|
||||
event->SetTrusted(true);
|
||||
|
||||
DC_DEBUG(
|
||||
@ -362,7 +362,7 @@ nsresult nsDOMDataChannel::OnChannelConnected(nsISupports* aContext) {
|
||||
DC_DEBUG(
|
||||
("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, __FUNCTION__));
|
||||
|
||||
return OnSimpleEvent(aContext, NS_LITERAL_STRING("open"));
|
||||
return OnSimpleEvent(aContext, u"open"_ns);
|
||||
}
|
||||
|
||||
nsresult nsDOMDataChannel::OnChannelClosed(nsISupports* aContext) {
|
||||
@ -375,7 +375,7 @@ nsresult nsDOMDataChannel::OnChannelClosed(nsISupports* aContext) {
|
||||
DC_DEBUG(("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel,
|
||||
__FUNCTION__));
|
||||
|
||||
rv = OnSimpleEvent(aContext, NS_LITERAL_STRING("close"));
|
||||
rv = OnSimpleEvent(aContext, u"close"_ns);
|
||||
// no more events can happen
|
||||
mSentClose = true;
|
||||
} else {
|
||||
@ -389,7 +389,7 @@ nsresult nsDOMDataChannel::OnBufferLow(nsISupports* aContext) {
|
||||
DC_DEBUG(
|
||||
("%p(%p): %s - Dispatching\n", this, (void*)mDataChannel, __FUNCTION__));
|
||||
|
||||
return OnSimpleEvent(aContext, NS_LITERAL_STRING("bufferedamountlow"));
|
||||
return OnSimpleEvent(aContext, u"bufferedamountlow"_ns);
|
||||
}
|
||||
|
||||
nsresult nsDOMDataChannel::NotBuffered(nsISupports* aContext) {
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef nsDOMJSUtils_h__
|
||||
#define nsDOMJSUtils_h__
|
||||
|
||||
#include "nsIScriptContext.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIJSArgArray;
|
||||
|
||||
|
@ -31,7 +31,7 @@ static already_AddRefed<nsIDocumentEncoder> SetUpEncoder(
|
||||
|
||||
// This method will fail if no document
|
||||
nsresult rv = encoder->NativeInit(
|
||||
doc, NS_LITERAL_STRING("application/xhtml+xml"),
|
||||
doc, u"application/xhtml+xml"_ns,
|
||||
nsIDocumentEncoder::OutputRaw |
|
||||
nsIDocumentEncoder::OutputDontRewriteEncodingDeclaration);
|
||||
|
||||
@ -73,8 +73,7 @@ void nsDOMSerializer::SerializeToString(nsINode& aRoot, nsAString& aStr,
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder =
|
||||
SetUpEncoder(aRoot, EmptyString(), aRv);
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder = SetUpEncoder(aRoot, u""_ns, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
@ -50,27 +50,7 @@ const nsAttrValue* nsDOMTokenList::GetParsedAttr() {
|
||||
return mElement->GetAttrInfo(kNameSpaceID_None, mAttrAtom).mValue;
|
||||
}
|
||||
|
||||
void nsDOMTokenList::RemoveDuplicates(const nsAttrValue* aAttr) {
|
||||
if (!aAttr || aAttr->Type() != nsAttrValue::eAtomArray) {
|
||||
return;
|
||||
}
|
||||
|
||||
BloomFilter<8, nsAtom> filter;
|
||||
AtomArray* array = aAttr->GetAtomArrayValue();
|
||||
for (uint32_t i = 0; i < array->Length(); i++) {
|
||||
nsAtom* atom = array->ElementAt(i);
|
||||
if (filter.mightContain(atom)) {
|
||||
// Start again, with a hashtable
|
||||
RemoveDuplicatesInternal(array, i);
|
||||
return;
|
||||
} else {
|
||||
filter.add(atom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsDOMTokenList::RemoveDuplicatesInternal(AtomArray* aArray,
|
||||
uint32_t aStart) {
|
||||
static void RemoveDuplicatesInternal(AtomArray* aArray, uint32_t aStart) {
|
||||
nsDataHashtable<nsPtrHashKey<nsAtom>, bool> tokens;
|
||||
|
||||
for (uint32_t i = 0; i < aArray->Length(); i++) {
|
||||
@ -85,6 +65,25 @@ void nsDOMTokenList::RemoveDuplicatesInternal(AtomArray* aArray,
|
||||
}
|
||||
}
|
||||
|
||||
void nsDOMTokenList::RemoveDuplicates(const nsAttrValue* aAttr) {
|
||||
if (!aAttr || aAttr->Type() != nsAttrValue::eAtomArray) {
|
||||
return;
|
||||
}
|
||||
|
||||
BitBloomFilter<8, nsAtom> filter;
|
||||
AtomArray* array = aAttr->GetAtomArrayValue();
|
||||
for (uint32_t i = 0; i < array->Length(); i++) {
|
||||
nsAtom* atom = array->ElementAt(i);
|
||||
if (filter.mightContain(atom)) {
|
||||
// Start again, with a hashtable
|
||||
RemoveDuplicatesInternal(array, i);
|
||||
return;
|
||||
} else {
|
||||
filter.add(atom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t nsDOMTokenList::Length() {
|
||||
const nsAttrValue* attr = GetParsedAttr();
|
||||
if (!attr) {
|
||||
|
@ -81,8 +81,6 @@ class nsDOMTokenList : public nsISupports, public nsWrapperCache {
|
||||
|
||||
nsresult CheckToken(const nsAString& aStr);
|
||||
nsresult CheckTokens(const nsTArray<nsString>& aStr);
|
||||
void RemoveDuplicatesInternal(nsTArray<RefPtr<nsAtom>>* aArray,
|
||||
uint32_t aStart);
|
||||
void AddInternal(const nsAttrValue* aAttr, const nsTArray<nsString>& aTokens);
|
||||
void RemoveInternal(const nsAttrValue* aAttr,
|
||||
const nsTArray<nsString>& aTokens);
|
||||
|
@ -22,8 +22,9 @@
|
||||
#include "mozilla/dom/Touch.h"
|
||||
#include "mozilla/dom/UserActivation.h"
|
||||
#include "mozilla/PendingAnimationTracker.h"
|
||||
#include "mozilla/ServoStyleSet.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "ClientLayerManager.h"
|
||||
@ -3167,9 +3168,8 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior,
|
||||
nsPoint relPoint =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, targetFrame);
|
||||
|
||||
nsresult rv = static_cast<nsFrame*>(targetFrame)
|
||||
->SelectByTypeAtPoint(GetPresContext(), relPoint, amount,
|
||||
amount, nsFrame::SELECT_ACCUMULATE);
|
||||
nsresult rv = targetFrame->SelectByTypeAtPoint(
|
||||
GetPresContext(), relPoint, amount, amount, nsIFrame::SELECT_ACCUMULATE);
|
||||
*_retval = !NS_FAILED(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1509,8 +1509,7 @@ bool nsFocusManager::IsNonFocusableRoot(nsIContent* aContent) {
|
||||
Document* doc = aContent->GetComposedDoc();
|
||||
NS_ASSERTION(doc, "aContent must have current document");
|
||||
return aContent == doc->GetRootElement() &&
|
||||
(doc->HasFlag(NODE_IS_EDITABLE) || !aContent->IsEditable() ||
|
||||
nsContentUtils::IsUserFocusIgnored(aContent));
|
||||
(doc->HasFlag(NODE_IS_EDITABLE) || !aContent->IsEditable());
|
||||
}
|
||||
|
||||
Element* nsFocusManager::FlushAndCheckIfFocusable(Element* aElement,
|
||||
@ -1543,7 +1542,7 @@ Element* nsFocusManager::FlushAndCheckIfFocusable(Element* aElement,
|
||||
// the root content can always be focused,
|
||||
// except in userfocusignored context.
|
||||
if (aElement == doc->GetRootElement()) {
|
||||
return nsContentUtils::IsUserFocusIgnored(aElement) ? nullptr : aElement;
|
||||
return aElement;
|
||||
}
|
||||
|
||||
// cannot focus content in print preview mode. Only the root can be focused.
|
||||
@ -2101,10 +2100,7 @@ void nsFocusManager::SendFocusOrBlurEvent(
|
||||
aRelatedTarget = nullptr;
|
||||
}
|
||||
|
||||
bool dontDispatchEvent =
|
||||
eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc);
|
||||
|
||||
if (!dontDispatchEvent && aDocument && aDocument->EventHandlingSuppressed()) {
|
||||
if (aDocument && aDocument->EventHandlingSuppressed()) {
|
||||
for (uint32_t i = mDelayedBlurFocusEvents.Length(); i > 0; --i) {
|
||||
// if this event was already queued, remove it and append it to the end
|
||||
if (mDelayedBlurFocusEvents[i - 1].mEventMessage == aEventMessage &&
|
||||
@ -2137,17 +2133,12 @@ void nsFocusManager::FireFocusOrBlurEvent(EventMessage aEventMessage,
|
||||
nsISupports* aTarget,
|
||||
bool aWindowRaised, bool aIsRefocus,
|
||||
EventTarget* aRelatedTarget) {
|
||||
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
|
||||
nsCOMPtr<Document> eventTargetDoc = GetDocumentHelper(eventTarget);
|
||||
nsCOMPtr<nsPIDOMWindowOuter> currentWindow = mFocusedWindow;
|
||||
nsCOMPtr<nsPIDOMWindowInner> targetWindow = do_QueryInterface(aTarget);
|
||||
nsCOMPtr<Document> targetDocument = do_QueryInterface(aTarget);
|
||||
nsCOMPtr<nsIContent> currentFocusedContent =
|
||||
currentWindow ? currentWindow->GetFocusedElement() : nullptr;
|
||||
|
||||
bool dontDispatchEvent =
|
||||
eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc);
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (accService) {
|
||||
@ -2159,25 +2150,23 @@ void nsFocusManager::FireFocusOrBlurEvent(EventMessage aEventMessage,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!dontDispatchEvent) {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
new FocusBlurEvent(aTarget, aEventMessage, aPresShell->GetPresContext(),
|
||||
aWindowRaised, aIsRefocus, aRelatedTarget));
|
||||
nsContentUtils::AddScriptRunner(
|
||||
new FocusBlurEvent(aTarget, aEventMessage, aPresShell->GetPresContext(),
|
||||
aWindowRaised, aIsRefocus, aRelatedTarget));
|
||||
|
||||
// Check that the target is not a window or document before firing
|
||||
// focusin/focusout. Other browsers do not fire focusin/focusout on window,
|
||||
// despite being required in the spec, so follow their behavior.
|
||||
//
|
||||
// As for document, we should not even fire focus/blur, but until then, we
|
||||
// need this check. targetDocument should be removed once bug 1228802 is
|
||||
// resolved.
|
||||
if (!targetWindow && !targetDocument) {
|
||||
EventMessage focusInOrOutMessage =
|
||||
aEventMessage == eFocus ? eFocusIn : eFocusOut;
|
||||
FireFocusInOrOutEvent(focusInOrOutMessage, aPresShell, aTarget,
|
||||
currentWindow, currentFocusedContent,
|
||||
aRelatedTarget);
|
||||
}
|
||||
// Check that the target is not a window or document before firing
|
||||
// focusin/focusout. Other browsers do not fire focusin/focusout on window,
|
||||
// despite being required in the spec, so follow their behavior.
|
||||
//
|
||||
// As for document, we should not even fire focus/blur, but until then, we
|
||||
// need this check. targetDocument should be removed once bug 1228802 is
|
||||
// resolved.
|
||||
if (!targetWindow && !targetDocument) {
|
||||
EventMessage focusInOrOutMessage =
|
||||
aEventMessage == eFocus ? eFocusIn : eFocusOut;
|
||||
FireFocusInOrOutEvent(focusInOrOutMessage, aPresShell, aTarget,
|
||||
currentWindow, currentFocusedContent,
|
||||
aRelatedTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3397,20 +3386,14 @@ nsresult nsFocusManager::GetNextTabbableContent(
|
||||
} else if (aRootContent->IsFocusable()) {
|
||||
frameTraversal->Next();
|
||||
}
|
||||
frame = static_cast<nsIFrame*>(frameTraversal->CurrentItem());
|
||||
frame = frameTraversal->CurrentItem();
|
||||
} else if (getNextFrame &&
|
||||
(!iterStartContent ||
|
||||
!iterStartContent->IsHTMLElement(nsGkAtoms::area))) {
|
||||
// Need to do special check in case we're in an imagemap which has
|
||||
// multiple content nodes per frame, so don't skip over the starting
|
||||
// frame.
|
||||
if (aForward) {
|
||||
frameTraversal->Next();
|
||||
} else {
|
||||
frameTraversal->Prev();
|
||||
}
|
||||
|
||||
frame = static_cast<nsIFrame*>(frameTraversal->CurrentItem());
|
||||
frame = frameTraversal->Traverse(aForward);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3228,18 +3228,16 @@ void nsFrameLoader::InitializeBrowserAPI() {
|
||||
if (!OwnerIsMozBrowserFrame()) {
|
||||
return;
|
||||
}
|
||||
if (!IsRemoteFrame()) {
|
||||
nsresult rv = EnsureMessageManager();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
if (mMessageManager) {
|
||||
mMessageManager->LoadFrameScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
|
||||
/* allowDelayedLoad = */ true,
|
||||
/* aRunInGlobalScope */ true, IgnoreErrors());
|
||||
}
|
||||
|
||||
nsresult rv = EnsureMessageManager();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
mMessageManager->LoadFrameScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
|
||||
/* allowDelayedLoad = */ true,
|
||||
/* aRunInGlobalScope */ true, IgnoreErrors());
|
||||
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
if (browserFrame) {
|
||||
browserFrame->InitializeBrowserAPI();
|
||||
|
@ -389,12 +389,12 @@ bool nsFrameMessageManager::GetParamsForMessage(JSContext* aCx,
|
||||
nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column);
|
||||
nsCOMPtr<nsIScriptError> error(
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
||||
error->Init(NS_LITERAL_STRING("Sending message that cannot be cloned. Are "
|
||||
"you trying to send an XPCOM object?"),
|
||||
filename, EmptyString(), lineno, column,
|
||||
nsIScriptError::warningFlag, "chrome javascript",
|
||||
false /* from private window */,
|
||||
true /* from chrome context */);
|
||||
error->Init(
|
||||
u"Sending message that cannot be cloned. Are "
|
||||
"you trying to send an XPCOM object?"_ns,
|
||||
filename, u""_ns, lineno, column, nsIScriptError::warningFlag,
|
||||
"chrome javascript", false /* from private window */,
|
||||
true /* from chrome context */);
|
||||
console->LogMessage(error);
|
||||
}
|
||||
|
||||
@ -740,18 +740,18 @@ void nsFrameMessageManager::ReceiveMessage(
|
||||
data->Write(cx, rval, aError);
|
||||
if (NS_WARN_IF(aError.Failed())) {
|
||||
aRetVal->RemoveLastElement();
|
||||
nsString msg = aMessage + NS_LITERAL_STRING(
|
||||
": message reply cannot be cloned. Are "
|
||||
"you trying to send an XPCOM object?");
|
||||
nsString msg =
|
||||
aMessage + nsLiteralString(
|
||||
u": message reply cannot be cloned. Are "
|
||||
"you trying to send an XPCOM object?");
|
||||
|
||||
nsCOMPtr<nsIConsoleService> console(
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (console) {
|
||||
nsCOMPtr<nsIScriptError> error(
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
||||
error->Init(msg, EmptyString(), EmptyString(), 0, 0,
|
||||
nsIScriptError::warningFlag, "chrome javascript",
|
||||
false /* from private window */,
|
||||
error->Init(msg, u""_ns, u""_ns, 0, 0, nsIScriptError::warningFlag,
|
||||
"chrome javascript", false /* from private window */,
|
||||
true /* from chrome context */);
|
||||
console->LogMessage(error);
|
||||
}
|
||||
@ -996,11 +996,11 @@ void MessageManagerReporter::CountReferents(
|
||||
static void ReportReferentCount(
|
||||
const char* aManagerType, const MessageManagerReferentCount& aReferentCount,
|
||||
nsIHandleReportCallback* aHandleReport, nsISupports* aData) {
|
||||
#define REPORT(_path, _amount, _desc) \
|
||||
do { \
|
||||
aHandleReport->Callback( \
|
||||
EmptyCString(), _path, nsIMemoryReporter::KIND_OTHER, \
|
||||
nsIMemoryReporter::UNITS_COUNT, _amount, _desc, aData); \
|
||||
#define REPORT(_path, _amount, _desc) \
|
||||
do { \
|
||||
aHandleReport->Callback(""_ns, _path, nsIMemoryReporter::KIND_OTHER, \
|
||||
nsIMemoryReporter::UNITS_COUNT, _amount, _desc, \
|
||||
aData); \
|
||||
} while (0)
|
||||
|
||||
REPORT(nsPrintfCString("message-manager/referent/%s/strong", aManagerType),
|
||||
@ -1186,8 +1186,17 @@ void nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
// message manager per process, treat this script as run-once. Run-once
|
||||
// scripts can be compiled directly for the target global, and will be dropped
|
||||
// from the preloader cache after they're executed and serialized.
|
||||
//
|
||||
// NOTE: This does not affect the JS::CompileOptions. We generate the same
|
||||
// bytecode as though it were run multiple times. This is required for the
|
||||
// batch decoding from ScriptPreloader to work.
|
||||
bool isRunOnce = !aShouldCache || IsProcessScoped();
|
||||
|
||||
// We don't cache data: scripts!
|
||||
nsAutoCString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
bool useScriptPreloader = aShouldCache && !scheme.EqualsLiteral("data");
|
||||
|
||||
// If the script will be reused in this session, compile it in the compilation
|
||||
// scope instead of the current global to avoid keeping the current
|
||||
// compartment alive.
|
||||
@ -1232,7 +1241,7 @@ void nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
|
||||
uint32_t size = (uint32_t)std::min(written, (uint64_t)UINT32_MAX);
|
||||
ScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), size,
|
||||
EmptyString(), nullptr, dataStringBuf,
|
||||
u""_ns, nullptr, dataStringBuf,
|
||||
dataStringLength);
|
||||
}
|
||||
|
||||
@ -1240,6 +1249,12 @@ void nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are not encoding to the ScriptPreloader cache, we can now relax the
|
||||
// compile options and use the JS syntax-parser for lower latency.
|
||||
if (!useScriptPreloader || !ScriptPreloader::GetChildSingleton().Active()) {
|
||||
options.setSourceIsLazy(false);
|
||||
}
|
||||
|
||||
JS::UniqueTwoByteChars srcChars(dataStringBuf);
|
||||
|
||||
JS::SourceText<char16_t> srcBuf;
|
||||
@ -1256,10 +1271,7 @@ void nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
MOZ_ASSERT(script);
|
||||
aScriptp.set(script);
|
||||
|
||||
nsAutoCString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
// We don't cache data: scripts!
|
||||
if (aShouldCache && !scheme.EqualsLiteral("data")) {
|
||||
if (useScriptPreloader) {
|
||||
ScriptPreloader::GetChildSingleton().NoteScript(url, url, script,
|
||||
isRunOnce);
|
||||
|
||||
|
@ -2,34 +2,141 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
// Local Includes
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdint>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include "AudioChannelService.h"
|
||||
#include "Crypto.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "Navigator.h"
|
||||
#include "nsContentSecurityManager.h"
|
||||
#include "nsScreen.h"
|
||||
#include "nsHistory.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsIDOMStorageManager.h"
|
||||
#include "mozilla/dom/CallbackDebuggerNotification.h"
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "PaintWorkletImpl.h"
|
||||
#include "SessionStorageCache.h"
|
||||
#include "Units.h"
|
||||
#include "WindowDestroyedEvent.h"
|
||||
#include "WindowNamedPropertiesHandler.h"
|
||||
#include "js/ComparisonOperators.h"
|
||||
#include "js/CompileOptions.h"
|
||||
#include "js/Id.h"
|
||||
#include "js/PropertyDescriptor.h"
|
||||
#include "js/RealmOptions.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Value.h"
|
||||
#include "js/Warnings.h"
|
||||
#include "js/shadow/String.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozIDOMWindow.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/ArrayIterator.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventQueue.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/FlushType.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/MacroForEach.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/OwningNonNull.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ProcessHangMonitor.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/ScrollTypes.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/SizeOfState.h"
|
||||
#include "mozilla/Span.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/StorageAccess.h"
|
||||
#include "mozilla/TaskCategory.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/TelemetryHistogramEnums.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/AudioContext.h"
|
||||
#include "mozilla/dom/BarProps.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/CSPEvalChecker.h"
|
||||
#include "mozilla/dom/DebuggerNotification.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "mozilla/dom/CallbackDebuggerNotification.h"
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "mozilla/dom/ClientInfo.h"
|
||||
#include "mozilla/dom/ClientManager.h"
|
||||
#include "mozilla/dom/ClientSource.h"
|
||||
#include "mozilla/dom/ClientState.h"
|
||||
#include "mozilla/dom/ClientsBinding.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "mozilla/dom/DOMJSProxyHandler.h"
|
||||
#include "mozilla/dom/DebuggerNotification.h"
|
||||
#include "mozilla/dom/DebuggerNotificationBinding.h"
|
||||
#include "mozilla/dom/DebuggerNotificationManager.h"
|
||||
#include "mozilla/dom/DispatcherTrait.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/EventTarget.h"
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/Gamepad.h"
|
||||
#include "mozilla/dom/GamepadManager.h"
|
||||
#include "mozilla/dom/HashChangeEvent.h"
|
||||
#include "mozilla/dom/HashChangeEventBinding.h"
|
||||
#include "mozilla/dom/IDBFactory.h"
|
||||
#include "mozilla/dom/IdleRequest.h"
|
||||
#include "mozilla/dom/ImageBitmap.h"
|
||||
#include "mozilla/dom/ImageBitmapSource.h"
|
||||
#include "mozilla/dom/InstallTriggerBinding.h"
|
||||
#include "mozilla/dom/IntlUtils.h"
|
||||
#include "mozilla/dom/JSExecutionContext.h"
|
||||
#include "mozilla/dom/LSObject.h"
|
||||
#include "mozilla/dom/LoadedScript.h"
|
||||
#include "mozilla/dom/LocalStorage.h"
|
||||
#include "mozilla/dom/LocalStorageCommon.h"
|
||||
#include "mozilla/dom/LSObject.h"
|
||||
#include "mozilla/dom/Location.h"
|
||||
#include "mozilla/dom/NavigatorBinding.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/PartitionedLocalStorage.h"
|
||||
#include "mozilla/dom/Storage.h"
|
||||
#include "mozilla/dom/IdleRequest.h"
|
||||
#include "mozilla/dom/Performance.h"
|
||||
#include "mozilla/dom/PopStateEvent.h"
|
||||
#include "mozilla/dom/PopStateEventBinding.h"
|
||||
#include "mozilla/dom/PopupBlocker.h"
|
||||
#include "mozilla/dom/PrimitiveConversions.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/Report.h"
|
||||
#include "mozilla/dom/ReportingObserver.h"
|
||||
#include "mozilla/dom/RootedDictionary.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/ServiceWorker.h"
|
||||
#include "mozilla/dom/ServiceWorkerDescriptor.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistration.h"
|
||||
#include "mozilla/dom/SharedWorker.h"
|
||||
#include "mozilla/dom/Storage.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/StorageNotifierService.h"
|
||||
@ -37,125 +144,149 @@
|
||||
#include "mozilla/dom/Timeout.h"
|
||||
#include "mozilla/dom/TimeoutHandler.h"
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "mozilla/dom/VisualViewport.h"
|
||||
#include "mozilla/dom/WindowProxyHolder.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/Result.h"
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
# include "mozilla/dom/WindowOrientationObserver.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/U2F.h"
|
||||
#ifdef MOZ_VR
|
||||
# include "mozilla/dom/VRDisplay.h"
|
||||
# include "mozilla/dom/VRDisplayEvent.h"
|
||||
# include "mozilla/dom/VRDisplayEventBinding.h"
|
||||
# include "mozilla/dom/VREventObserver.h"
|
||||
#endif
|
||||
#include "nsDOMOfflineResourceList.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsError.h"
|
||||
#include "nsISizeOfEventTarget.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsArrayUtils.h"
|
||||
#include "nsDOMWindowList.h"
|
||||
#include "mozilla/dom/VisualViewport.h"
|
||||
#include "mozilla/dom/WakeLock.h"
|
||||
#include "mozilla/dom/power/PowerManagerService.h"
|
||||
#include "mozilla/dom/WebIDLGlobalNameHash.h"
|
||||
#include "mozilla/dom/WindowBinding.h"
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
#include "mozilla/dom/WindowProxyHolder.h"
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "mozilla/dom/Worklet.h"
|
||||
#include "mozilla/dom/cache/CacheStorage.h"
|
||||
#include "mozilla/dom/cache/Types.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/gfx/BasePoint.h"
|
||||
#include "mozilla/gfx/BaseRect.h"
|
||||
#include "mozilla/gfx/BaseSize.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsBaseHashtable.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsCanvasFrame.h"
|
||||
#include "nsCharTraits.h"
|
||||
#include "nsCheapSets.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsCycleCollectionNoteChild.h"
|
||||
#include "nsCycleCollectionTraversalCallback.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsDOMOfflineResourceList.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsGlobalWindowOuter.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsHistory.h"
|
||||
#include "nsIAddonPolicyService.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIBrowserChild.h"
|
||||
#include "nsICancelableRunnable.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIDOMStorageManager.h"
|
||||
#include "nsIDeviceSensors.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsISlowScriptDebug.h"
|
||||
#include "nsWindowMemoryReporter.h"
|
||||
#include "nsWindowSizes.h"
|
||||
#include "WindowNamedPropertiesHandler.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsVariant.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
#include "WindowDestroyedEvent.h"
|
||||
|
||||
// Helper Classes
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Warnings.h" // JS::WarnASCII
|
||||
#include "js/Wrapper.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/StorageAccess.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
// Other Classes
|
||||
#include "mozilla/dom/BarProps.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Debug.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ProcessHangMonitor.h"
|
||||
#include "mozilla/ScrollTypes.h"
|
||||
#include "mozilla/ThrottledEventQueue.h"
|
||||
#include "AudioChannelService.h"
|
||||
#include "nsAboutProtocolUtils.h"
|
||||
#include "nsCharTraits.h" // NS_IS_HIGH/LOW_SURROGATE
|
||||
#include "PostMessageEvent.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/dom/TabGroup.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "PaintWorkletImpl.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIDragService.h"
|
||||
#include "nsIFocusManager.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsCanvasFrame.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIIdleRunnable.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsINamed.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIScreen.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsISerialEventTarget.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsISizeOfEventTarget.h"
|
||||
#include "nsISlowScriptDebug.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsITimedChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIVariant.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWidgetListener.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDeviceSensors.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "Crypto.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsView.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAddonPolicyService.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMWindowUtils.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsGlobalWindowCommands.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPIWindowRoot.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsITimedChannel.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsScreen.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringFlags.h"
|
||||
#include "nsStringFwd.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsTLiteralString.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsTStringRepr.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsWindowMemoryReporter.h"
|
||||
#include "nsWindowSizes.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsrootidl.h"
|
||||
#include "prclist.h"
|
||||
#include "prtypes.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
# include "nsIDOMXULControlElement.h"
|
||||
# include "nsMenuPopupFrame.h"
|
||||
#endif
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
|
||||
#include "xpcprivate.h"
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
# include "nsIPrintSettings.h"
|
||||
@ -163,78 +294,9 @@
|
||||
# include "nsIWebBrowserPrint.h"
|
||||
#endif
|
||||
|
||||
#include "nsWindowRoot.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIArray.h"
|
||||
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsXBLService.h"
|
||||
|
||||
#include "nsIDragService.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#include "mozilla/dom/IDBFactory.h"
|
||||
#include "mozilla/dom/MessageChannel.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
#include "mozilla/dom/Gamepad.h"
|
||||
#include "mozilla/dom/GamepadManager.h"
|
||||
|
||||
#ifdef MOZ_VR
|
||||
# include "gfxVR.h"
|
||||
# include "mozilla/dom/VRDisplay.h"
|
||||
# include "mozilla/dom/VRDisplayEvent.h"
|
||||
# include "mozilla/dom/VRDisplayEventBinding.h"
|
||||
# include "mozilla/dom/VREventObserver.h"
|
||||
#endif
|
||||
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "Layers.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/Location.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "prrng.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "mozilla/dom/AudioContext.h"
|
||||
#include "mozilla/dom/BrowserElementDictionariesBinding.h"
|
||||
#include "mozilla/dom/cache/CacheStorage.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/FunctionBinding.h"
|
||||
#include "mozilla/dom/HashChangeEvent.h"
|
||||
#include "mozilla/dom/IntlUtils.h"
|
||||
#include "mozilla/dom/PopStateEvent.h"
|
||||
#include "mozilla/dom/PopupBlocker.h"
|
||||
#include "mozilla/dom/PopupBlockedEvent.h"
|
||||
#include "mozilla/dom/PrimitiveConversions.h"
|
||||
#include "mozilla/dom/WindowBinding.h"
|
||||
#include "nsIBrowserChild.h"
|
||||
#include "mozilla/dom/LoadedScript.h"
|
||||
#include "mozilla/dom/MediaQueryList.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/NavigatorBinding.h"
|
||||
#include "mozilla/dom/ImageBitmap.h"
|
||||
#include "mozilla/dom/ImageBitmapBinding.h"
|
||||
#include "mozilla/dom/InstallTriggerBinding.h"
|
||||
#include "mozilla/dom/Report.h"
|
||||
#include "mozilla/dom/ReportingObserver.h"
|
||||
#include "mozilla/dom/SharedWorker.h"
|
||||
#include "mozilla/dom/ServiceWorker.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistration.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "mozilla/dom/U2F.h"
|
||||
#include "mozilla/dom/WebIDLGlobalNameHash.h"
|
||||
#include "mozilla/dom/Worklet.h"
|
||||
#ifdef HAVE_SIDEBAR
|
||||
# include "mozilla/dom/ExternalBinding.h"
|
||||
#endif
|
||||
@ -243,22 +305,16 @@
|
||||
# include "mozilla/dom/SpeechSynthesis.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/dom/ClientManager.h"
|
||||
#include "mozilla/dom/ClientSource.h"
|
||||
#include "mozilla/dom/ClientState.h"
|
||||
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
|
||||
#include "AccessCheck.h"
|
||||
#include "SessionStorageCache.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
# include <android/log.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
# include "mozilla/dom/WindowOrientationObserver.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "mozilla/Debug.h"
|
||||
# include <process.h>
|
||||
# define getpid _getpid
|
||||
#else
|
||||
@ -1385,8 +1441,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mGroupMessageManagers)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingPromises)
|
||||
|
||||
for (size_t i = 0; i < tmp->mDocumentFlushedResolvers.Length(); i++) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentFlushedResolvers[i]->mPromise);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentFlushedResolvers[i]->mCallback);
|
||||
@ -1408,7 +1462,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
|
||||
if (wrapper) {
|
||||
// Mark our realm as dead, so the JS engine won't hand out our
|
||||
// global after this point.
|
||||
JS::RealmBehaviorsRef(js::GetNonCCWObjectRealm(wrapper)).setNonLive();
|
||||
JS::SetRealmNonLive(js::GetNonCCWObjectRealm(wrapper));
|
||||
}
|
||||
|
||||
tmp->CleanupCachedXBLHandlers();
|
||||
@ -1511,7 +1565,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeFields.mGroupMessageManagers)
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingPromises)
|
||||
for (size_t i = 0; i < tmp->mDocumentFlushedResolvers.Length(); i++) {
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentFlushedResolvers[i]->mPromise);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentFlushedResolvers[i]->mCallback);
|
||||
@ -3427,7 +3480,7 @@ void nsGlobalWindowInner::Dump(const nsAString& aStr) {
|
||||
|
||||
void nsGlobalWindowInner::Alert(nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aError) {
|
||||
Alert(EmptyString(), aSubjectPrincipal, aError);
|
||||
Alert(u""_ns, aSubjectPrincipal, aError);
|
||||
}
|
||||
|
||||
void nsGlobalWindowInner::Alert(const nsAString& aMessage,
|
||||
@ -5674,7 +5727,7 @@ bool WindowScriptTimeoutHandler::Call(const char* aExecutionReason) {
|
||||
options.setNoScriptRval(true);
|
||||
JS::Rooted<JSObject*> global(aes.cx(), mGlobal->GetGlobalJSObject());
|
||||
{
|
||||
nsJSUtils::ExecutionContext exec(aes.cx(), global);
|
||||
JSExecutionContext exec(aes.cx(), global);
|
||||
nsresult rv = exec.Compile(options, mExpr);
|
||||
|
||||
JS::Rooted<JSScript*> script(aes.cx(), exec.MaybeGetScript());
|
||||
@ -5841,12 +5894,8 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
|
||||
// timeouts from repeatedly opening poups.
|
||||
timeout->mPopupState = PopupBlocker::openAbused;
|
||||
|
||||
bool trackNestingLevel = !timeout->mIsInterval;
|
||||
uint32_t nestingLevel;
|
||||
if (trackNestingLevel) {
|
||||
nestingLevel = TimeoutManager::GetNestingLevel();
|
||||
TimeoutManager::SetNestingLevel(timeout->mNestingLevel);
|
||||
}
|
||||
uint32_t nestingLevel = TimeoutManager::GetNestingLevel();
|
||||
TimeoutManager::SetNestingLevel(timeout->mNestingLevel);
|
||||
|
||||
const char* reason;
|
||||
if (timeout->mIsInterval) {
|
||||
@ -5885,9 +5934,7 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
|
||||
// point anyway, and the script context should have already reported
|
||||
// the script error in the usual way - so we just drop it.
|
||||
|
||||
if (trackNestingLevel) {
|
||||
TimeoutManager::SetNestingLevel(nestingLevel);
|
||||
}
|
||||
TimeoutManager::SetNestingLevel(nestingLevel);
|
||||
|
||||
mTimeoutManager->EndRunningTimeout(last_running_timeout);
|
||||
timeout->mRunning = false;
|
||||
@ -6125,9 +6172,6 @@ void nsGlobalWindowInner::AddSizeOfIncludingThis(
|
||||
aWindowSizes.mDOMPerformanceResourceEntries =
|
||||
mPerformance->SizeOfResourceEntries(aWindowSizes.mState.mMallocSizeOf);
|
||||
}
|
||||
|
||||
aWindowSizes.mDOMOtherSize += mPendingPromises.ShallowSizeOfExcludingThis(
|
||||
aWindowSizes.mState.mMallocSizeOf);
|
||||
}
|
||||
|
||||
void nsGlobalWindowInner::AddGamepad(uint32_t aIndex, Gamepad* aGamepad) {
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
@ -94,6 +93,8 @@ class PromiseDocumentFlushedResolver;
|
||||
|
||||
namespace mozilla {
|
||||
class AbstractThread;
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
class BarProp;
|
||||
class BrowsingContext;
|
||||
@ -1434,8 +1435,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||
|
||||
mozilla::UniquePtr<mozilla::dom::ClientSource> mClientSource;
|
||||
|
||||
nsTArray<RefPtr<mozilla::dom::Promise>> mPendingPromises;
|
||||
|
||||
nsTArray<mozilla::UniquePtr<PromiseDocumentFlushedResolver>>
|
||||
mDocumentFlushedResolvers;
|
||||
|
||||
|
@ -1075,10 +1075,10 @@ static JSObject* NewOuterWindowProxy(JSContext* cx,
|
||||
js::WrapperOptions options;
|
||||
options.setClass(&OuterWindowProxyClass);
|
||||
JSObject* obj =
|
||||
js::Wrapper::NewSingleton(cx, global,
|
||||
isChrome ? &nsChromeOuterWindowProxy::singleton
|
||||
: &nsOuterWindowProxy::singleton,
|
||||
options);
|
||||
js::Wrapper::New(cx, global,
|
||||
isChrome ? &nsChromeOuterWindowProxy::singleton
|
||||
: &nsOuterWindowProxy::singleton,
|
||||
options);
|
||||
MOZ_ASSERT_IF(obj, js::IsWindowProxy(obj));
|
||||
return obj;
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ bool nsHTMLContentSerializer::SerializeHTMLAttributes(
|
||||
|
||||
// Filter out any attribute starting with [-|_]moz
|
||||
nsDependentAtomString attrNameStr(attrName);
|
||||
if (StringBeginsWith(attrNameStr, NS_LITERAL_STRING("_moz")) ||
|
||||
StringBeginsWith(attrNameStr, NS_LITERAL_STRING("-moz"))) {
|
||||
if (StringBeginsWith(attrNameStr, u"_moz"_ns) ||
|
||||
StringBeginsWith(attrNameStr, u"-moz"_ns)) {
|
||||
continue;
|
||||
}
|
||||
aElement->GetAttr(namespaceID, attrName, valueStr);
|
||||
@ -105,8 +105,7 @@ bool nsHTMLContentSerializer::SerializeHTMLAttributes(
|
||||
nsAutoString header;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
|
||||
if (header.LowerCaseEqualsLiteral("content-type")) {
|
||||
valueStr = NS_LITERAL_STRING("text/html; charset=") +
|
||||
NS_ConvertASCIItoUTF16(mCharset);
|
||||
valueStr = u"text/html; charset="_ns + NS_ConvertASCIItoUTF16(mCharset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +226,8 @@ nsHTMLContentSerializer::AppendElementStart(Element* aElement,
|
||||
// for serializing attributes other than "value".
|
||||
nsAutoString dummyPrefix;
|
||||
NS_ENSURE_TRUE(
|
||||
SerializeHTMLAttributes(aElement, aOriginalElement, dummyPrefix,
|
||||
EmptyString(), name, ns, *mOutput),
|
||||
SerializeHTMLAttributes(aElement, aOriginalElement, dummyPrefix, u""_ns,
|
||||
name, ns, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ENSURE_TRUE(AppendToString(kGreaterThan, *mOutput),
|
||||
|
@ -725,14 +725,13 @@ std::ostream& operator<<(std::ostream& aStream, const nsINode& aNode) {
|
||||
}
|
||||
|
||||
if (!elemDesc.IsEmpty()) {
|
||||
elemDesc = elemDesc + NS_LITERAL_STRING(".");
|
||||
elemDesc = elemDesc + u"."_ns;
|
||||
}
|
||||
|
||||
elemDesc = elemDesc + localName;
|
||||
|
||||
if (!id.IsEmpty()) {
|
||||
elemDesc =
|
||||
elemDesc + NS_LITERAL_STRING("['") + id + NS_LITERAL_STRING("']");
|
||||
elemDesc = elemDesc + u"['"_ns + id + u"']"_ns;
|
||||
}
|
||||
|
||||
curr = curr->GetParentNode();
|
||||
@ -2854,9 +2853,8 @@ const RawServoSelectorList* nsINode::ParseSelectorList(
|
||||
if (list) {
|
||||
if (!*list) {
|
||||
// Invalid selector.
|
||||
aRv.ThrowSyntaxError(NS_LITERAL_CSTRING("'") +
|
||||
NS_ConvertUTF16toUTF8(aSelectorString) +
|
||||
NS_LITERAL_CSTRING("' is not a valid selector"));
|
||||
aRv.ThrowSyntaxError("'"_ns + NS_ConvertUTF16toUTF8(aSelectorString) +
|
||||
"' is not a valid selector"_ns);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2874,8 +2872,8 @@ const RawServoSelectorList* nsINode::ParseSelectorList(
|
||||
|
||||
// Now make sure we throw an exception if the selector was invalid.
|
||||
if (!ret) {
|
||||
aRv.ThrowSyntaxError(NS_LITERAL_CSTRING("'") + selectorString +
|
||||
NS_LITERAL_CSTRING("' is not a valid selector"));
|
||||
aRv.ThrowSyntaxError("'"_ns + selectorString +
|
||||
"' is not a valid selector"_ns);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1494,7 +1494,7 @@ class nsINode : public mozilla::dom::EventTarget {
|
||||
void LookupPrefix(const nsAString& aNamespace, nsAString& aResult);
|
||||
bool IsDefaultNamespace(const nsAString& aNamespaceURI) {
|
||||
nsAutoString defaultNamespace;
|
||||
LookupNamespaceURI(EmptyString(), defaultNamespace);
|
||||
LookupNamespaceURI(u""_ns, defaultNamespace);
|
||||
return aNamespaceURI.Equals(defaultNamespace);
|
||||
}
|
||||
void LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "nsImageLoadingContent.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsContentList.h"
|
||||
@ -24,7 +22,6 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsSVGImageFrame.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
@ -34,7 +31,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "SVGObserverUtils.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
@ -42,13 +38,17 @@
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs_image.h"
|
||||
#include "mozilla/SVGImageFrame.h"
|
||||
#include "mozilla/SVGObserverUtils.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ImageTracker.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs_image.h"
|
||||
|
||||
#ifdef LoadImage
|
||||
// Undefine LoadImage to prevent naming conflict with Windows.
|
||||
@ -430,9 +430,16 @@ void nsImageLoadingContent::MaybeResolveDecodePromises() {
|
||||
// before LOAD_COMPLETE because we want to start as soon as possible.
|
||||
uint32_t flags = imgIContainer::FLAG_HIGH_QUALITY_SCALING |
|
||||
imgIContainer::FLAG_AVOID_REDECODE_FOR_SIZE;
|
||||
if (!mCurrentRequest->RequestDecodeWithResult(flags)) {
|
||||
imgIContainer::DecodeResult decodeResult =
|
||||
mCurrentRequest->RequestDecodeWithResult(flags);
|
||||
if (decodeResult == imgIContainer::DECODE_REQUESTED) {
|
||||
return;
|
||||
}
|
||||
if (decodeResult == imgIContainer::DECODE_REQUEST_FAILED) {
|
||||
RejectDecodePromises(NS_ERROR_DOM_IMAGE_BROKEN);
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(decodeResult == imgIContainer::DECODE_SURFACE_AVAILABLE);
|
||||
|
||||
// We can only fulfill the promises once we have all the data.
|
||||
if (!(status & imgIRequest::STATUS_LOAD_COMPLETE)) {
|
||||
@ -507,7 +514,7 @@ void nsImageLoadingContent::MaybeForceSyncDecoding(
|
||||
bool aPrepareNextRequest, nsIFrame* aFrame /* = nullptr */) {
|
||||
nsIFrame* frame = aFrame ? aFrame : GetOurPrimaryFrame();
|
||||
nsImageFrame* imageFrame = do_QueryFrame(frame);
|
||||
nsSVGImageFrame* svgImageFrame = do_QueryFrame(frame);
|
||||
SVGImageFrame* svgImageFrame = do_QueryFrame(frame);
|
||||
if (!imageFrame && !svgImageFrame) {
|
||||
return;
|
||||
}
|
||||
@ -1210,12 +1217,17 @@ uint32_t nsImageLoadingContent::NaturalWidth() {
|
||||
mCurrentRequest->GetImage(getter_AddRefs(image));
|
||||
}
|
||||
|
||||
int32_t width;
|
||||
if (image && NS_SUCCEEDED(image->GetWidth(&width))) {
|
||||
return width;
|
||||
int32_t size = 0;
|
||||
if (image) {
|
||||
if (image->GetOrientation().SwapsWidthAndHeight() &&
|
||||
!image->HandledOrientation() &&
|
||||
StaticPrefs::image_honor_orientation_metadata_natural_size()) {
|
||||
Unused << image->GetHeight(&size);
|
||||
} else {
|
||||
Unused << image->GetWidth(&size);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
uint32_t nsImageLoadingContent::NaturalHeight() {
|
||||
@ -1224,12 +1236,17 @@ uint32_t nsImageLoadingContent::NaturalHeight() {
|
||||
mCurrentRequest->GetImage(getter_AddRefs(image));
|
||||
}
|
||||
|
||||
int32_t height;
|
||||
if (image && NS_SUCCEEDED(image->GetHeight(&height))) {
|
||||
return height;
|
||||
int32_t size = 0;
|
||||
if (image) {
|
||||
if (image->GetOrientation().SwapsWidthAndHeight() &&
|
||||
!image->HandledOrientation() &&
|
||||
StaticPrefs::image_honor_orientation_metadata_natural_size()) {
|
||||
Unused << image->GetWidth(&size);
|
||||
} else {
|
||||
Unused << image->GetHeight(&size);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
EventStates nsImageLoadingContent::ImageState() const {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -69,6 +69,9 @@ class nsJSContext : public nsIScriptContext {
|
||||
|
||||
static void CycleCollectNow(nsICycleCollectorListener* aListener = nullptr);
|
||||
|
||||
// Finish up any in-progress incremental GC.
|
||||
static void PrepareForCycleCollectionSlice(mozilla::TimeStamp aDeadline);
|
||||
|
||||
// Run a cycle collector slice, using a heuristic to decide how long to run
|
||||
// it.
|
||||
static void RunCycleCollectorSlice(mozilla::TimeStamp aDeadline);
|
||||
@ -103,15 +106,16 @@ class nsJSContext : public nsIScriptContext {
|
||||
static void KillShrinkingGCTimer();
|
||||
|
||||
static void MaybePokeCC();
|
||||
static void EnsureCCRunner(mozilla::TimeDuration aDelay,
|
||||
mozilla::TimeDuration aBudget);
|
||||
static void KillCCRunner();
|
||||
static void KillICCRunner();
|
||||
static void KillFullGCTimer();
|
||||
static void KillInterSliceGCRunner();
|
||||
|
||||
// Calling LikelyShortLivingObjectCreated() makes a GC more likely.
|
||||
static void LikelyShortLivingObjectCreated();
|
||||
|
||||
static uint32_t CleanupsSinceLastGC();
|
||||
static bool HasHadCleanupSinceLastGC();
|
||||
|
||||
nsIScriptGlobalObject* GetCachedGlobalObject() {
|
||||
// Verify that we have a global so that this
|
||||
|
@ -10,30 +10,38 @@
|
||||
*/
|
||||
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/Date.h"
|
||||
#include "js/Modules.h" // JS::CompileModule, JS::GetModuleScript, JS::Module{Instantiate,Evaluate}
|
||||
#include "js/OffThreadScriptCompilation.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include <utility>
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "js/ComparisonOperators.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/CompileOptions.h"
|
||||
#include "js/Date.h"
|
||||
#include "js/GCVector.h"
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/Modules.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
#include "mozilla/fallible.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTPromiseFlatString.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "nscore.h"
|
||||
|
||||
#if !defined(DEBUG) && !defined(MOZ_ENABLE_JS_DUMP)
|
||||
# include "mozilla/StaticPrefs_browser.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -103,303 +111,6 @@ nsresult nsJSUtils::CompileFunction(AutoJSAPI& jsapi,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult EvaluationExceptionToNSResult(JSContext* aCx) {
|
||||
if (JS_IsExceptionPending(aCx)) {
|
||||
return NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW;
|
||||
}
|
||||
return NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE;
|
||||
}
|
||||
|
||||
nsJSUtils::ExecutionContext::ExecutionContext(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGlobal)
|
||||
:
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
mAutoProfilerLabel("nsJSUtils::ExecutionContext",
|
||||
/* dynamicStr */ nullptr,
|
||||
JS::ProfilingCategoryPair::JS),
|
||||
#endif
|
||||
mCx(aCx),
|
||||
mRealm(aCx, aGlobal),
|
||||
mRetValue(aCx),
|
||||
mScopeChain(aCx),
|
||||
mScript(aCx),
|
||||
mRv(NS_OK),
|
||||
mSkip(false),
|
||||
mCoerceToString(false),
|
||||
mEncodeBytecode(false)
|
||||
#ifdef DEBUG
|
||||
,
|
||||
mWantsReturnValue(false),
|
||||
mExpectScopeChain(false),
|
||||
mScriptUsed(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(CycleCollectedJSContext::Get() &&
|
||||
CycleCollectedJSContext::Get()->MicroTaskLevel());
|
||||
MOZ_ASSERT(mRetValue.isUndefined());
|
||||
|
||||
MOZ_ASSERT(JS_IsGlobalObject(aGlobal));
|
||||
if (MOZ_UNLIKELY(!xpc::Scriptability::Get(aGlobal).Allowed())) {
|
||||
mSkip = true;
|
||||
mRv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
void nsJSUtils::ExecutionContext::SetScopeChain(
|
||||
JS::HandleVector<JSObject*> aScopeChain) {
|
||||
if (mSkip) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mExpectScopeChain = true;
|
||||
#endif
|
||||
// Now make sure to wrap the scope chain into the right compartment.
|
||||
if (!mScopeChain.reserve(aScopeChain.length())) {
|
||||
mSkip = true;
|
||||
mRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < aScopeChain.length(); ++i) {
|
||||
JS::ExposeObjectToActiveJS(aScopeChain[i]);
|
||||
mScopeChain.infallibleAppend(aScopeChain[i]);
|
||||
if (!JS_WrapObject(mCx, mScopeChain[i])) {
|
||||
mSkip = true;
|
||||
mRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::JoinCompile(
|
||||
JS::OffThreadToken** aOffThreadToken) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
MOZ_ASSERT(!mExpectScopeChain);
|
||||
MOZ_ASSERT(!mScript);
|
||||
|
||||
if (mEncodeBytecode) {
|
||||
mScript.set(JS::FinishOffThreadScriptAndStartIncrementalEncoding(
|
||||
mCx, *aOffThreadToken));
|
||||
} else {
|
||||
mScript.set(JS::FinishOffThreadScript(mCx, *aOffThreadToken));
|
||||
}
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
nsresult nsJSUtils::ExecutionContext::InternalCompile(
|
||||
JS::CompileOptions& aCompileOptions, JS::SourceText<Unit>& aSrcBuf) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSrcBuf.get());
|
||||
MOZ_ASSERT(mRetValue.isUndefined());
|
||||
#ifdef DEBUG
|
||||
mWantsReturnValue = !aCompileOptions.noScriptRval;
|
||||
#endif
|
||||
|
||||
MOZ_ASSERT(!mScript);
|
||||
|
||||
if (mScopeChain.length() != 0) {
|
||||
aCompileOptions.setNonSyntacticScope(true);
|
||||
}
|
||||
|
||||
if (mEncodeBytecode) {
|
||||
mScript =
|
||||
JS::CompileAndStartIncrementalEncoding(mCx, aCompileOptions, aSrcBuf);
|
||||
} else {
|
||||
mScript = JS::Compile(mCx, aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::Compile(
|
||||
JS::CompileOptions& aCompileOptions, JS::SourceText<char16_t>& aSrcBuf) {
|
||||
return InternalCompile(aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::Compile(
|
||||
JS::CompileOptions& aCompileOptions, JS::SourceText<Utf8Unit>& aSrcBuf) {
|
||||
return InternalCompile(aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::Compile(
|
||||
JS::CompileOptions& aCompileOptions, const nsAString& aScript) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
const nsPromiseFlatString& flatScript = PromiseFlatString(aScript);
|
||||
JS::SourceText<char16_t> srcBuf;
|
||||
if (!srcBuf.init(mCx, flatScript.get(), flatScript.Length(),
|
||||
JS::SourceOwnership::Borrowed)) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return Compile(aCompileOptions, srcBuf);
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::Decode(
|
||||
JS::CompileOptions& aCompileOptions, mozilla::Vector<uint8_t>& aBytecodeBuf,
|
||||
size_t aBytecodeIndex) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
JS::TranscodeResult tr = JS::DecodeScriptMaybeStencil(
|
||||
mCx, aCompileOptions, aBytecodeBuf, &mScript, aBytecodeIndex);
|
||||
// These errors are external parameters which should be handled before the
|
||||
// decoding phase, and which are the only reasons why you might want to
|
||||
// fallback on decoding failures.
|
||||
MOZ_ASSERT(tr != JS::TranscodeResult_Failure_BadBuildId &&
|
||||
tr != JS::TranscodeResult_Failure_WrongCompileOption);
|
||||
if (tr != JS::TranscodeResult_Ok) {
|
||||
mSkip = true;
|
||||
mRv = NS_ERROR_DOM_JS_DECODING_ERROR;
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return mRv;
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::JoinDecode(
|
||||
JS::OffThreadToken** aOffThreadToken) {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
MOZ_ASSERT(!mExpectScopeChain);
|
||||
mScript.set(JS::FinishOffThreadScriptDecoder(mCx, *aOffThreadToken));
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::JoinDecodeBinAST(
|
||||
JS::OffThreadToken** aOffThreadToken) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::DecodeBinAST(
|
||||
JS::CompileOptions& aCompileOptions, const uint8_t* aBuf, size_t aLength) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
JSScript* nsJSUtils::ExecutionContext::GetScript() {
|
||||
#ifdef DEBUG
|
||||
MOZ_ASSERT(!mSkip);
|
||||
MOZ_ASSERT(mScript);
|
||||
mScriptUsed = true;
|
||||
#endif
|
||||
|
||||
return MaybeGetScript();
|
||||
}
|
||||
|
||||
JSScript* nsJSUtils::ExecutionContext::MaybeGetScript() { return mScript; }
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::ExecScript() {
|
||||
if (mSkip) {
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mScript);
|
||||
|
||||
if (!JS_ExecuteScript(mCx, mScopeChain, mScript)) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool IsPromiseValue(JSContext* aCx, JS::Handle<JS::Value> aValue) {
|
||||
if (!aValue.isObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We only care about Promise here, so CheckedUnwrapStatic is fine.
|
||||
JS::Rooted<JSObject*> obj(aCx, js::CheckedUnwrapStatic(&aValue.toObject()));
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return JS::IsPromiseObject(obj);
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ExecutionContext::ExecScript(
|
||||
JS::MutableHandle<JS::Value> aRetValue) {
|
||||
if (mSkip) {
|
||||
aRetValue.setUndefined();
|
||||
return mRv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mScript);
|
||||
MOZ_ASSERT(mWantsReturnValue);
|
||||
|
||||
if (!JS_ExecuteScript(mCx, mScopeChain, mScript, aRetValue)) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mWantsReturnValue = false;
|
||||
#endif
|
||||
if (mCoerceToString && IsPromiseValue(mCx, aRetValue)) {
|
||||
// We're a javascript: url and we should treat Promise return values as
|
||||
// undefined.
|
||||
//
|
||||
// Once bug 1477821 is fixed this code might be able to go away, or will
|
||||
// become enshrined in the spec, depending.
|
||||
aRetValue.setUndefined();
|
||||
}
|
||||
|
||||
if (mCoerceToString && !aRetValue.isUndefined()) {
|
||||
JSString* str = JS::ToString(mCx, aRetValue);
|
||||
if (!str) {
|
||||
// ToString can be a function call, so an exception can be raised while
|
||||
// executing the function.
|
||||
mSkip = true;
|
||||
return EvaluationExceptionToNSResult(mCx);
|
||||
}
|
||||
aRetValue.set(JS::StringValue(str));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
static nsresult CompileJSModule(JSContext* aCx, JS::SourceText<Unit>& aSrcBuf,
|
||||
JS::Handle<JSObject*> aEvaluationGlobal,
|
||||
@ -462,7 +173,8 @@ nsresult nsJSUtils::ModuleInstantiate(JSContext* aCx,
|
||||
}
|
||||
|
||||
nsresult nsJSUtils::ModuleEvaluate(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aModule) {
|
||||
JS::Handle<JSObject*> aModule,
|
||||
JS::MutableHandle<JS::Value> aResult) {
|
||||
AUTO_PROFILER_LABEL("nsJSUtils::ModuleEvaluate", JS);
|
||||
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
@ -472,7 +184,7 @@ nsresult nsJSUtils::ModuleEvaluate(JSContext* aCx,
|
||||
|
||||
NS_ENSURE_TRUE(xpc::Scriptability::Get(aModule).Allowed(), NS_OK);
|
||||
|
||||
if (!JS::ModuleEvaluate(aCx, aModule)) {
|
||||
if (!JS::ModuleEvaluate(aCx, aModule, aResult)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -13,15 +13,9 @@
|
||||
*/
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Conversions.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "js/StableStringChars.h"
|
||||
#include "js/String.h" // JS::{,Lossy}CopyLinearStringChars, JS::CopyStringChars, JS::Get{,Linear}StringLength, JS::MaxStringLength, JS::StringHasLatin1Chars
|
||||
#include "nsString.h"
|
||||
#include "xpcpublic.h"
|
||||
@ -32,6 +26,8 @@ class nsIScriptGlobalObject;
|
||||
class nsXBLPrototypeBinding;
|
||||
|
||||
namespace mozilla {
|
||||
union Utf8Unit;
|
||||
|
||||
namespace dom {
|
||||
class AutoJSAPI;
|
||||
class Element;
|
||||
@ -65,146 +61,6 @@ class nsJSUtils {
|
||||
const nsAString& aBody,
|
||||
JSObject** aFunctionObject);
|
||||
|
||||
// ExecutionContext is used to switch compartment.
|
||||
class MOZ_STACK_CLASS ExecutionContext {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
// Register stack annotations for the Gecko profiler.
|
||||
mozilla::AutoProfilerLabel mAutoProfilerLabel;
|
||||
#endif
|
||||
|
||||
JSContext* mCx;
|
||||
|
||||
// Handles switching to our global's realm.
|
||||
JSAutoRealm mRealm;
|
||||
|
||||
// Set to a valid handle if a return value is expected.
|
||||
JS::Rooted<JS::Value> mRetValue;
|
||||
|
||||
// Scope chain in which the execution takes place.
|
||||
JS::RootedVector<JSObject*> mScopeChain;
|
||||
|
||||
// The compiled script.
|
||||
JS::Rooted<JSScript*> mScript;
|
||||
|
||||
// returned value forwarded when we have to interupt the execution eagerly
|
||||
// with mSkip.
|
||||
nsresult mRv;
|
||||
|
||||
// Used to skip upcoming phases in case of a failure. In such case the
|
||||
// result is carried by mRv.
|
||||
bool mSkip;
|
||||
|
||||
// Should the result be serialized before being returned.
|
||||
bool mCoerceToString;
|
||||
|
||||
// Encode the bytecode before it is being executed.
|
||||
bool mEncodeBytecode;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Should we set the return value.
|
||||
bool mWantsReturnValue;
|
||||
|
||||
bool mExpectScopeChain;
|
||||
|
||||
bool mScriptUsed;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Compile a script contained in a SourceText.
|
||||
template <typename Unit>
|
||||
nsresult InternalCompile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<Unit>& aSrcBuf);
|
||||
|
||||
public:
|
||||
// Enter compartment in which the code would be executed. The JSContext
|
||||
// must come from an AutoEntryScript.
|
||||
ExecutionContext(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
|
||||
ExecutionContext(const ExecutionContext&) = delete;
|
||||
ExecutionContext(ExecutionContext&&) = delete;
|
||||
|
||||
~ExecutionContext() {
|
||||
// This flag is reset when the returned value is extracted.
|
||||
MOZ_ASSERT_IF(!mSkip, !mWantsReturnValue);
|
||||
|
||||
// If encoding was started we expect the script to have been
|
||||
// used when ending the encoding.
|
||||
MOZ_ASSERT_IF(mEncodeBytecode && mScript && mRv == NS_OK, mScriptUsed);
|
||||
}
|
||||
|
||||
// The returned value would be converted to a string if the
|
||||
// |aCoerceToString| is flag set.
|
||||
ExecutionContext& SetCoerceToString(bool aCoerceToString) {
|
||||
mCoerceToString = aCoerceToString;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// When set, this flag records and encodes the bytecode as soon as it is
|
||||
// being compiled, and before it is being executed. The bytecode can then be
|
||||
// requested by using |JS::FinishIncrementalEncoding| with the mutable
|
||||
// handle |aScript| argument of |CompileAndExec| or |JoinAndExec|.
|
||||
ExecutionContext& SetEncodeBytecode(bool aEncodeBytecode) {
|
||||
mEncodeBytecode = aEncodeBytecode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Set the scope chain in which the code should be executed.
|
||||
void SetScopeChain(JS::HandleVector<JSObject*> aScopeChain);
|
||||
|
||||
// After getting a notification that an off-thread compilation terminated,
|
||||
// this function will take the result of the parser and move it to the main
|
||||
// thread.
|
||||
MOZ_MUST_USE nsresult JoinCompile(JS::OffThreadToken** aOffThreadToken);
|
||||
|
||||
// Compile a script contained in a SourceText.
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<char16_t>& aSrcBuf);
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
JS::SourceText<mozilla::Utf8Unit>& aSrcBuf);
|
||||
|
||||
// Compile a script contained in a string.
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
const nsAString& aScript);
|
||||
|
||||
// Decode a script contained in a buffer.
|
||||
nsresult Decode(JS::CompileOptions& aCompileOptions,
|
||||
mozilla::Vector<uint8_t>& aBytecodeBuf,
|
||||
size_t aBytecodeIndex);
|
||||
|
||||
// After getting a notification that an off-thread decoding terminated, this
|
||||
// function will get the result of the decoder and move it to the main
|
||||
// thread.
|
||||
nsresult JoinDecode(JS::OffThreadToken** aOffThreadToken);
|
||||
|
||||
nsresult JoinDecodeBinAST(JS::OffThreadToken** aOffThreadToken);
|
||||
|
||||
// Decode a BinAST encoded script contained in a buffer.
|
||||
nsresult DecodeBinAST(JS::CompileOptions& aCompileOptions,
|
||||
const uint8_t* aBuf, size_t aLength);
|
||||
|
||||
// Get a successfully compiled script.
|
||||
JSScript* GetScript();
|
||||
|
||||
// Get the compiled script if present, or nullptr.
|
||||
JSScript* MaybeGetScript();
|
||||
|
||||
// Execute the compiled script and ignore the return value.
|
||||
MOZ_MUST_USE nsresult ExecScript();
|
||||
|
||||
// Execute the compiled script a get the return value.
|
||||
//
|
||||
// Copy the returned value into the mutable handle argument. In case of a
|
||||
// evaluation failure either during the execution or the conversion of the
|
||||
// result to a string, the nsresult is be set to the corresponding result
|
||||
// code and the mutable handle argument remains unchanged.
|
||||
//
|
||||
// The value returned in the mutable handle argument is part of the
|
||||
// compartment given as argument to the ExecutionContext constructor. If the
|
||||
// caller is in a different compartment, then the out-param value should be
|
||||
// wrapped by calling |JS_WrapValue|.
|
||||
MOZ_MUST_USE nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
|
||||
};
|
||||
|
||||
static bool BinASTEncodingEnabled() { return false; }
|
||||
|
||||
static nsresult CompileModule(JSContext* aCx,
|
||||
@ -222,7 +78,21 @@ class nsJSUtils {
|
||||
static nsresult ModuleInstantiate(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aModule);
|
||||
|
||||
static nsresult ModuleEvaluate(JSContext* aCx, JS::Handle<JSObject*> aModule);
|
||||
/*
|
||||
* Wrapper for JSAPI ModuleEvaluate function.
|
||||
*
|
||||
* @param JSContext aCx
|
||||
* The JSContext where this is executed.
|
||||
* @param JS::Handle<JSObject*> aModule
|
||||
* The module to be evaluated.
|
||||
* @param JS::Handle<Value*> aResult
|
||||
* If Top level await is enabled:
|
||||
* The evaluation promise returned from evaluating the module.
|
||||
* Otherwise:
|
||||
* Undefined
|
||||
*/
|
||||
static nsresult ModuleEvaluate(JSContext* aCx, JS::Handle<JSObject*> aModule,
|
||||
JS::MutableHandle<JS::Value> aResult);
|
||||
|
||||
// Returns false if an exception got thrown on aCx. Passing a null
|
||||
// aElement is allowed; that wil produce an empty aScopeChain.
|
||||
@ -307,13 +177,14 @@ inline bool AssignJSString(JSContext* cx, T& dest, JSString* s) {
|
||||
// Shouldn't really matter, but worth being safe.
|
||||
const bool kAllowShrinking = true;
|
||||
|
||||
nsresult rv;
|
||||
auto handle = dest.BulkWrite(bufLen.value(), 0, kAllowShrinking, rv);
|
||||
if (MOZ_UNLIKELY(NS_FAILED(rv))) {
|
||||
auto handleOrErr = dest.BulkWrite(bufLen.value(), 0, kAllowShrinking);
|
||||
if (MOZ_UNLIKELY(handleOrErr.isErr())) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto handle = handleOrErr.unwrap();
|
||||
|
||||
auto maybe = JS_EncodeStringToUTF8BufferPartial(cx, s, handle.AsSpan());
|
||||
if (MOZ_UNLIKELY(!maybe)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "mozilla/dom/NodeInfoInlines.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAtom.h"
|
||||
|
@ -344,8 +344,8 @@ nsPluginCrashedEvent::Run() {
|
||||
init.mBubbles = true;
|
||||
init.mCancelable = true;
|
||||
|
||||
RefPtr<PluginCrashedEvent> event = PluginCrashedEvent::Constructor(
|
||||
doc, NS_LITERAL_STRING("PluginCrashed"), init);
|
||||
RefPtr<PluginCrashedEvent> event =
|
||||
PluginCrashedEvent::Constructor(doc, u"PluginCrashed"_ns, init);
|
||||
|
||||
event->SetTrusted(true);
|
||||
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
||||
@ -601,7 +601,7 @@ void nsObjectLoadingContent::UnbindFromTree(bool aNullParent) {
|
||||
Document* doc = thisElement->GetComposedDoc();
|
||||
if (doc && doc->IsActive()) {
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsSimplePluginEvent(doc, NS_LITERAL_STRING("PluginRemoved"));
|
||||
new nsSimplePluginEvent(doc, u"PluginRemoved"_ns);
|
||||
NS_DispatchToCurrentThread(ev);
|
||||
}
|
||||
}
|
||||
@ -763,8 +763,8 @@ nsresult nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) {
|
||||
// Fire plugin outdated event if necessary
|
||||
LOG(("OBJLC [%p]: Dispatching plugin outdated event for content\n",
|
||||
this));
|
||||
nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(
|
||||
thisContent, NS_LITERAL_STRING("PluginOutdated"));
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsSimplePluginEvent(thisContent, u"PluginOutdated"_ns);
|
||||
nsresult rv = NS_DispatchToCurrentThread(ev);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to dispatch nsSimplePluginEvent");
|
||||
@ -783,8 +783,8 @@ nsresult nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading) {
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(
|
||||
thisContent, doc, NS_LITERAL_STRING("PluginInstantiated"));
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsSimplePluginEvent(thisContent, doc, u"PluginInstantiated"_ns);
|
||||
NS_DispatchToCurrentThread(ev);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
@ -810,10 +810,9 @@ void nsObjectLoadingContent::GetNestedParams(
|
||||
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
||||
|
||||
nsCOMPtr<nsIHTMLCollection> allParams;
|
||||
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
|
||||
constexpr auto xhtml_ns = u"http://www.w3.org/1999/xhtml"_ns;
|
||||
ErrorResult rv;
|
||||
allParams = ourElement->GetElementsByTagNameNS(
|
||||
xhtml_ns, NS_LITERAL_STRING("param"), rv);
|
||||
allParams = ourElement->GetElementsByTagNameNS(xhtml_ns, u"param"_ns, rv);
|
||||
if (rv.Failed()) {
|
||||
return;
|
||||
}
|
||||
@ -885,7 +884,7 @@ nsresult nsObjectLoadingContent::BuildParametersArray() {
|
||||
|
||||
if (!wmodeOverride.IsEmpty()) {
|
||||
MozPluginParameter param;
|
||||
param.mName = NS_LITERAL_STRING("wmode");
|
||||
param.mName = u"wmode"_ns;
|
||||
CopyASCIItoUTF16(wmodeOverride, param.mValue);
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
@ -901,7 +900,7 @@ nsresult nsObjectLoadingContent::BuildParametersArray() {
|
||||
MozPluginParameter param;
|
||||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::data, param.mValue);
|
||||
if (!param.mValue.IsEmpty()) {
|
||||
param.mName = NS_LITERAL_STRING("SRC");
|
||||
param.mName = u"SRC"_ns;
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
}
|
||||
@ -977,10 +976,10 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest* aRequest) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
chan->GetURI(getter_AddRefs(uri));
|
||||
nsString message =
|
||||
NS_LITERAL_STRING("Blocking ") +
|
||||
u"Blocking "_ns +
|
||||
NS_ConvertASCIItoUTF16(uri->GetSpecOrDefault().get()) +
|
||||
NS_LITERAL_STRING(
|
||||
" since it was found on an internal Firefox blocklist.");
|
||||
nsLiteralString(
|
||||
u" since it was found on an internal Firefox blocklist.");
|
||||
console->LogStringMessage(message.get());
|
||||
}
|
||||
mContentBlockingEnabled = true;
|
||||
@ -1283,7 +1282,7 @@ void nsObjectLoadingContent::MaybeRewriteYoutubeEmbed(nsIURI* aURI,
|
||||
// touch object nodes with "/embed/" urls that already do that right thing.
|
||||
nsAutoCString path;
|
||||
aURI->GetPathQueryRef(path);
|
||||
if (!StringBeginsWith(path, NS_LITERAL_CSTRING("/v/"))) {
|
||||
if (!StringBeginsWith(path, "/v/"_ns)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1325,8 +1324,7 @@ void nsObjectLoadingContent::MaybeRewriteYoutubeEmbed(nsIURI* aURI,
|
||||
}
|
||||
// Switch out video access url formats, which should possibly allow HTML5
|
||||
// video loading.
|
||||
uri.ReplaceSubstring(NS_LITERAL_CSTRING("/v/"),
|
||||
NS_LITERAL_CSTRING("/embed/"));
|
||||
uri.ReplaceSubstring("/v/"_ns, "/embed/"_ns);
|
||||
nsAutoString utf16URI = NS_ConvertUTF8toUTF16(uri);
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(
|
||||
aOutURI, utf16URI, thisContent->OwnerDoc(), aBaseURI);
|
||||
@ -1343,9 +1341,8 @@ void nsObjectLoadingContent::MaybeRewriteYoutubeEmbed(nsIURI* aURI,
|
||||
msgName = "RewriteYouTubeEmbedPathParams";
|
||||
}
|
||||
nsContentUtils::ReportToConsole(
|
||||
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Plugins"),
|
||||
thisContent->OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, msgName,
|
||||
params);
|
||||
nsIScriptError::warningFlag, "Plugins"_ns, thisContent->OwnerDoc(),
|
||||
nsContentUtils::eDOM_PROPERTIES, msgName, params);
|
||||
}
|
||||
|
||||
bool nsObjectLoadingContent::CheckLoadPolicy(int16_t* aContentPolicy) {
|
||||
@ -1541,7 +1538,7 @@ nsObjectLoadingContent::UpdateObjectParameters() {
|
||||
if (rewrittenURI) {
|
||||
newURI = rewrittenURI;
|
||||
mRewrittenYoutubeEmbed = true;
|
||||
newMime = NS_LITERAL_CSTRING("text/html");
|
||||
newMime = "text/html"_ns;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -2639,8 +2636,8 @@ nsNPAPIPluginInstance* nsObjectLoadingContent::ScriptRequestPluginInstance(
|
||||
// types, see header.
|
||||
if (callerIsContentJS && !mScriptRequested && InActiveDocument(thisContent) &&
|
||||
mType == eType_Null && mFallbackType >= eFallbackClickToPlay) {
|
||||
nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(
|
||||
thisContent, NS_LITERAL_STRING("PluginScripted"));
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsSimplePluginEvent(thisContent, u"PluginScripted"_ns);
|
||||
nsresult rv = NS_DispatchToCurrentThread(ev);
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_ASSERT_UNREACHABLE("failed to dispatch PluginScripted event");
|
||||
@ -3192,7 +3189,7 @@ bool nsObjectLoadingContent::HasGoodFallback() {
|
||||
nsresult rv = href->GetAsciiHost(asciiHost);
|
||||
if (NS_SUCCEEDED(rv) && !asciiHost.IsEmpty() &&
|
||||
(asciiHost.EqualsLiteral("adobe.com") ||
|
||||
StringEndsWith(asciiHost, NS_LITERAL_CSTRING(".adobe.com")))) {
|
||||
StringEndsWith(asciiHost, ".adobe.com"_ns))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -3208,12 +3205,10 @@ bool nsObjectLoadingContent::HasGoodFallback() {
|
||||
ErrorResult rv;
|
||||
thisContent->GetTextContent(textContent, rv);
|
||||
bool hasText =
|
||||
!rv.Failed() && (CaseInsensitiveFindInReadable(
|
||||
NS_LITERAL_STRING("Flash"), textContent) ||
|
||||
CaseInsensitiveFindInReadable(
|
||||
NS_LITERAL_STRING("Install"), textContent) ||
|
||||
CaseInsensitiveFindInReadable(
|
||||
NS_LITERAL_STRING("Download"), textContent));
|
||||
!rv.Failed() &&
|
||||
(CaseInsensitiveFindInReadable(u"Flash"_ns, textContent) ||
|
||||
CaseInsensitiveFindInReadable(u"Install"_ns, textContent) ||
|
||||
CaseInsensitiveFindInReadable(u"Download"_ns, textContent));
|
||||
|
||||
if (hasText) {
|
||||
return false;
|
||||
@ -3471,8 +3466,7 @@ void nsObjectLoadingContent::MaybeFireErrorEvent() {
|
||||
if (thisContent->IsHTMLElement(nsGkAtoms::object)) {
|
||||
RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
|
||||
new LoadBlockingAsyncEventDispatcher(
|
||||
thisContent, NS_LITERAL_STRING("error"), CanBubble::eNo,
|
||||
ChromeOnlyDispatch::eNo);
|
||||
thisContent, u"error"_ns, CanBubble::eNo, ChromeOnlyDispatch::eNo);
|
||||
loadBlockingAsyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "mozilla/dom/HTMLBRElement.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_converter.h"
|
||||
#include "mozilla/BinarySearch.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
|
||||
@ -39,7 +40,6 @@ using namespace mozilla::dom;
|
||||
|
||||
#define PREF_STRUCTS "converter.html2txt.structs"
|
||||
#define PREF_HEADER_STRATEGY "converter.html2txt.header_strategy"
|
||||
#define PREF_ALWAYS_INCLUDE_RUBY "converter.html2txt.always_include_ruby"
|
||||
|
||||
static const int32_t kTabSize = 4;
|
||||
static const int32_t kIndentSizeHeaders =
|
||||
@ -66,9 +66,6 @@ static int32_t GetUnicharStringWidth(const nsString& aString);
|
||||
// Someday may want to make this non-const:
|
||||
static const uint32_t TagStackSize = 500;
|
||||
|
||||
static bool gPreferenceInitialized = false;
|
||||
static bool gAlwaysIncludeRuby = false;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPlainTextSerializer)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPlainTextSerializer)
|
||||
|
||||
@ -237,7 +234,7 @@ uint32_t nsPlainTextSerializer::OutputManager::GetOutputLength() const {
|
||||
nsPlainTextSerializer::nsPlainTextSerializer()
|
||||
: mFloatingLines(-1),
|
||||
mLineBreakDue(false),
|
||||
kSpace(NS_LITERAL_STRING(" ")) // Init of "constant"
|
||||
kSpace(u" "_ns) // Init of "constant"
|
||||
{
|
||||
mHeadLevel = 0;
|
||||
mHasWrittenCiteBlockquote = false;
|
||||
@ -263,12 +260,6 @@ nsPlainTextSerializer::nsPlainTextSerializer()
|
||||
mULCount = 0;
|
||||
|
||||
mIgnoredChildNodeLevel = 0;
|
||||
|
||||
if (!gPreferenceInitialized) {
|
||||
Preferences::AddBoolVarCache(&gAlwaysIncludeRuby, PREF_ALWAYS_INCLUDE_RUBY,
|
||||
true);
|
||||
gPreferenceInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
nsPlainTextSerializer::~nsPlainTextSerializer() {
|
||||
@ -319,11 +310,8 @@ void nsPlainTextSerializer::Settings::Init(const int32_t aFlags,
|
||||
mHeaderStrategy = Convert(headerStrategy);
|
||||
}
|
||||
|
||||
// The pref is default inited to false in libpref, but we use true
|
||||
// as fallback value because we don't want to affect behavior in
|
||||
// other places which use this serializer currently.
|
||||
mWithRubyAnnotation =
|
||||
gAlwaysIncludeRuby || (mFlags & nsIDocumentEncoder::OutputRubyAnnotation);
|
||||
mWithRubyAnnotation = StaticPrefs::converter_html2txt_always_include_ruby() ||
|
||||
(mFlags & nsIDocumentEncoder::OutputRubyAnnotation);
|
||||
|
||||
// XXX We should let the caller decide whether to do this or not
|
||||
mFlags &= ~nsIDocumentEncoder::OutputNoFramesContent;
|
||||
@ -804,7 +792,7 @@ nsresult nsPlainTextSerializer::DoOpenContainer(const nsAtom* aTag) {
|
||||
kTabSize; // Check for some maximum value?
|
||||
}
|
||||
} else if (aTag == nsGkAtoms::q) {
|
||||
Write(NS_LITERAL_STRING("\""));
|
||||
Write(u"\""_ns);
|
||||
}
|
||||
|
||||
// Else make sure we'll separate block level tags,
|
||||
@ -858,22 +846,22 @@ void nsPlainTextSerializer::OpenContainerForOutputFormatted(
|
||||
}
|
||||
} else if (aTag == nsGkAtoms::sup && mSettings.GetStructs() &&
|
||||
!currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("^"));
|
||||
Write(u"^"_ns);
|
||||
} else if (aTag == nsGkAtoms::sub && mSettings.GetStructs() &&
|
||||
!currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("_"));
|
||||
Write(u"_"_ns);
|
||||
} else if (aTag == nsGkAtoms::code && mSettings.GetStructs() &&
|
||||
!currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("|"));
|
||||
Write(u"|"_ns);
|
||||
} else if ((aTag == nsGkAtoms::strong || aTag == nsGkAtoms::b) &&
|
||||
mSettings.GetStructs() && !currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("*"));
|
||||
Write(u"*"_ns);
|
||||
} else if ((aTag == nsGkAtoms::em || aTag == nsGkAtoms::i) &&
|
||||
mSettings.GetStructs() && !currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("/"));
|
||||
Write(u"/"_ns);
|
||||
} else if (aTag == nsGkAtoms::u && mSettings.GetStructs() &&
|
||||
!currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("_"));
|
||||
Write(u"_"_ns);
|
||||
}
|
||||
|
||||
/* Container elements are always block elements, so we shouldn't
|
||||
@ -1009,7 +997,7 @@ nsresult nsPlainTextSerializer::DoCloseContainer(const nsAtom* aTag) {
|
||||
}
|
||||
mLineBreakDue = true;
|
||||
} else if (aTag == nsGkAtoms::q) {
|
||||
Write(NS_LITERAL_STRING("\""));
|
||||
Write(u"\""_ns);
|
||||
} else if (IsCssBlockLevelElement(mElement)) {
|
||||
// All other blocks get 1 vertical space after them
|
||||
// in formatted mode, otherwise 0.
|
||||
@ -1066,16 +1054,16 @@ void nsPlainTextSerializer::CloseContainerForOutputFormatted(
|
||||
Write(kSpace);
|
||||
} else if (aTag == nsGkAtoms::code && mSettings.GetStructs() &&
|
||||
!currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("|"));
|
||||
Write(u"|"_ns);
|
||||
} else if ((aTag == nsGkAtoms::strong || aTag == nsGkAtoms::b) &&
|
||||
mSettings.GetStructs() && !currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("*"));
|
||||
Write(u"*"_ns);
|
||||
} else if ((aTag == nsGkAtoms::em || aTag == nsGkAtoms::i) &&
|
||||
mSettings.GetStructs() && !currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("/"));
|
||||
Write(u"/"_ns);
|
||||
} else if (aTag == nsGkAtoms::u && mSettings.GetStructs() &&
|
||||
!currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("_"));
|
||||
Write(u"_"_ns);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1097,7 +1085,7 @@ bool nsPlainTextSerializer::MustSuppressLeaf() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void nsPlainTextSerializer::DoAddText() { DoAddText(true, EmptyString()); }
|
||||
void nsPlainTextSerializer::DoAddText() { DoAddText(true, u""_ns); }
|
||||
|
||||
void nsPlainTextSerializer::DoAddText(bool aIsLineBreak,
|
||||
const nsAString& aText) {
|
||||
@ -1192,8 +1180,7 @@ nsresult nsPlainTextSerializer::DoAddLeaf(const nsAtom* aTag) {
|
||||
} else if (NS_SUCCEEDED(
|
||||
GetAttributeValue(nsGkAtoms::title, imageDescription)) &&
|
||||
!imageDescription.IsEmpty()) {
|
||||
imageDescription =
|
||||
NS_LITERAL_STRING(" [") + imageDescription + NS_LITERAL_STRING("] ");
|
||||
imageDescription = u" ["_ns + imageDescription + u"] "_ns;
|
||||
}
|
||||
|
||||
Write(imageDescription);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsPluginTags.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -222,8 +223,8 @@ void nsPluginArray::NotifyHiddenPluginTouched(nsPluginElement* aHiddenElement) {
|
||||
HiddenPluginEventInit init;
|
||||
init.mTag = aHiddenElement->PluginTag();
|
||||
nsCOMPtr<Document> doc = aHiddenElement->GetParentObject()->GetDoc();
|
||||
RefPtr<HiddenPluginEvent> event = HiddenPluginEvent::Constructor(
|
||||
doc, NS_LITERAL_STRING("HiddenPlugin"), init);
|
||||
RefPtr<HiddenPluginEvent> event =
|
||||
HiddenPluginEvent::Constructor(doc, u"HiddenPlugin"_ns, init);
|
||||
event->SetTarget(doc);
|
||||
event->SetTrusted(true);
|
||||
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
||||
|
@ -952,6 +952,8 @@ void nsRange::RegisterSelection(Selection& aSelection) {
|
||||
RegisterClosestCommonInclusiveAncestor(commonAncestor);
|
||||
}
|
||||
|
||||
Selection* nsRange::GetSelection() const { return mSelection; }
|
||||
|
||||
void nsRange::UnregisterSelection() {
|
||||
mSelection = nullptr;
|
||||
|
||||
|
@ -102,7 +102,7 @@ class nsRange final : public mozilla::dom::AbstractRange,
|
||||
/**
|
||||
* Returns pointer to a Selection if the range is associated with a Selection.
|
||||
*/
|
||||
mozilla::dom::Selection* GetSelection() const { return mSelection; }
|
||||
mozilla::dom::Selection* GetSelection() const;
|
||||
|
||||
/**
|
||||
* Return true if this range was generated.
|
||||
|
@ -1200,7 +1200,7 @@ void nsTreeSanitizer::SanitizeAttributes(mozilla::dom::Element* aElement,
|
||||
RefPtr<URLExtraData> urlExtra(aElement->GetURLDataForStyleAttr());
|
||||
RefPtr<DeclarationBlock> decl = DeclarationBlock::FromCssText(
|
||||
value, urlExtra, document->GetCompatibilityMode(),
|
||||
document->CSSLoader());
|
||||
document->CSSLoader(), dom::CSSRule_Binding::STYLE_RULE);
|
||||
if (decl) {
|
||||
if (SanitizeStyleDeclaration(decl)) {
|
||||
nsAutoString cleanValue;
|
||||
@ -1294,8 +1294,7 @@ void nsTreeSanitizer::SanitizeAttributes(mozilla::dom::Element* aElement,
|
||||
// If we've got HTML audio or video, add the controls attribute, because
|
||||
// otherwise the content is unplayable with scripts removed.
|
||||
if (aElement->IsAnyOfHTMLElements(nsGkAtoms::video, nsGkAtoms::audio)) {
|
||||
aElement->SetAttr(kNameSpaceID_None, nsGkAtoms::controls, EmptyString(),
|
||||
false);
|
||||
aElement->SetAttr(kNameSpaceID_None, nsGkAtoms::controls, u""_ns, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,16 +1500,14 @@ void nsTreeSanitizer::LogMessage(const char* aMessage, Document* aDoc,
|
||||
nsAutoString msg;
|
||||
msg.Assign(NS_ConvertASCIItoUTF16(aMessage));
|
||||
if (aElement) {
|
||||
msg.Append(NS_LITERAL_STRING(" Element: ") + aElement->LocalName() +
|
||||
NS_LITERAL_STRING("."));
|
||||
msg.Append(u" Element: "_ns + aElement->LocalName() + u"."_ns);
|
||||
}
|
||||
if (aAttr) {
|
||||
msg.Append(NS_LITERAL_STRING(" Attribute: ") +
|
||||
nsDependentAtomString(aAttr) + NS_LITERAL_STRING("."));
|
||||
msg.Append(u" Attribute: "_ns + nsDependentAtomString(aAttr) + u"."_ns);
|
||||
}
|
||||
|
||||
nsContentUtils::ReportToConsoleNonLocalized(
|
||||
msg, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), aDoc);
|
||||
msg, nsIScriptError::warningFlag, "DOM"_ns, aDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Class.h"
|
||||
#include "js/Proxy.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
@ -50,6 +51,12 @@ void nsWrapperCache::ReleaseWrapper(void* aScriptObjectHolder) {
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
void nsWrapperCache::AssertUpdatedWrapperZone(const JSObject* aNewObject,
|
||||
const JSObject* aOldObject) {
|
||||
MOZ_ASSERT(js::GetObjectZoneFromAnyThread(aNewObject) ==
|
||||
js::GetObjectZoneFromAnyThread(aOldObject));
|
||||
}
|
||||
|
||||
class DebugWrapperTraversalCallback
|
||||
: public nsCycleCollectionTraversalCallback {
|
||||
public:
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "js/Id.h" // must come before js/RootingAPI.h
|
||||
#include "js/Value.h" // must come before js/RootingAPI.h
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/TracingAPI.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -135,14 +135,15 @@ class nsWrapperCache {
|
||||
* anywhere or pass it into JSAPI functions that may cause the value to
|
||||
* escape.
|
||||
*/
|
||||
JSObject* GetWrapperMaybeDead() const {
|
||||
return mWrapper;
|
||||
}
|
||||
JSObject* GetWrapperMaybeDead() const { return mWrapper; }
|
||||
|
||||
#ifdef DEBUG
|
||||
private:
|
||||
static bool HasJSObjectMovedOp(JSObject* aWrapper);
|
||||
|
||||
static void AssertUpdatedWrapperZone(const JSObject* aNewObject,
|
||||
const JSObject* aOldObject);
|
||||
|
||||
public:
|
||||
#endif
|
||||
|
||||
@ -191,8 +192,9 @@ class nsWrapperCache {
|
||||
* any wrapper cached object.
|
||||
*/
|
||||
void UpdateWrapper(JSObject* aNewObject, const JSObject* aOldObject) {
|
||||
MOZ_ASSERT(js::GetObjectZoneFromAnyThread(aNewObject) ==
|
||||
js::GetObjectZoneFromAnyThread(aOldObject));
|
||||
#ifdef DEBUG
|
||||
AssertUpdatedWrapperZone(aNewObject, aOldObject);
|
||||
#endif
|
||||
if (mWrapper) {
|
||||
MOZ_ASSERT(mWrapper == aOldObject);
|
||||
mWrapper = aNewObject;
|
||||
|
@ -198,8 +198,7 @@ bool nsXHTMLContentSerializer::SerializeAttributes(
|
||||
if (aTagPrefix.IsEmpty()) {
|
||||
// Serialize default namespace decl
|
||||
NS_ENSURE_TRUE(
|
||||
SerializeAttr(EmptyString(), xmlnsStr, aTagNamespaceURI, aStr, true),
|
||||
false);
|
||||
SerializeAttr(u""_ns, xmlnsStr, aTagNamespaceURI, aStr, true), false);
|
||||
} else {
|
||||
// Serialize namespace decl
|
||||
NS_ENSURE_TRUE(
|
||||
@ -228,8 +227,8 @@ bool nsXHTMLContentSerializer::SerializeAttributes(
|
||||
|
||||
// Filter out any attribute starting with [-|_]moz
|
||||
nsDependentAtomString attrNameStr(attrName);
|
||||
if (StringBeginsWith(attrNameStr, NS_LITERAL_STRING("_moz")) ||
|
||||
StringBeginsWith(attrNameStr, NS_LITERAL_STRING("-moz"))) {
|
||||
if (StringBeginsWith(attrNameStr, u"_moz"_ns) ||
|
||||
StringBeginsWith(attrNameStr, u"-moz"_ns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -285,8 +284,8 @@ bool nsXHTMLContentSerializer::SerializeAttributes(
|
||||
nsAutoString header;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
|
||||
if (header.LowerCaseEqualsLiteral("content-type")) {
|
||||
valueStr = NS_LITERAL_STRING("text/html; charset=") +
|
||||
NS_ConvertASCIItoUTF16(mCharset);
|
||||
valueStr =
|
||||
u"text/html; charset="_ns + NS_ConvertASCIItoUTF16(mCharset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,19 +342,15 @@ bool nsXHTMLContentSerializer::AfterElementStart(nsIContent* aContent,
|
||||
NS_ENSURE_TRUE(AppendIndentation(aStr), false);
|
||||
}
|
||||
NS_ENSURE_TRUE(
|
||||
AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""),
|
||||
aStr),
|
||||
false);
|
||||
NS_ENSURE_TRUE(
|
||||
AppendToString(NS_LITERAL_STRING(" content=\"text/html; charset="),
|
||||
aStr),
|
||||
false);
|
||||
AppendToString(u"<meta http-equiv=\"content-type\""_ns, aStr), false);
|
||||
NS_ENSURE_TRUE(AppendToString(u" content=\"text/html; charset="_ns, aStr),
|
||||
false);
|
||||
NS_ENSURE_TRUE(AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr),
|
||||
false);
|
||||
if (mIsHTMLSerializer) {
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("\">"), aStr), false);
|
||||
NS_ENSURE_TRUE(AppendToString(u"\">"_ns, aStr), false);
|
||||
} else {
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("\" />"), aStr), false);
|
||||
NS_ENSURE_TRUE(AppendToString(u"\" />"_ns, aStr), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -688,8 +683,7 @@ bool nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIContent* aElement,
|
||||
if (offset == 0 && found) {
|
||||
// offset = 0 => LI itself has the value attribute and we did not need to
|
||||
// traverse back. Just serialize value attribute like other tags.
|
||||
NS_ENSURE_TRUE(SerializeAttr(EmptyString(), NS_LITERAL_STRING("value"),
|
||||
valueStr, aStr, false),
|
||||
NS_ENSURE_TRUE(SerializeAttr(u""_ns, u"value"_ns, valueStr, aStr, false),
|
||||
false);
|
||||
} else if (offset == 1 && !found) {
|
||||
/*(offset = 1 && !found) means either LI is the first child node of OL
|
||||
@ -704,8 +698,7 @@ bool nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIContent* aElement,
|
||||
|
||||
// As serializer needs to use this valueAttr we are creating here,
|
||||
valueStr.AppendInt(startVal + offset);
|
||||
NS_ENSURE_TRUE(SerializeAttr(EmptyString(), NS_LITERAL_STRING("value"),
|
||||
valueStr, aStr, false),
|
||||
NS_ENSURE_TRUE(SerializeAttr(u""_ns, u"value"_ns, valueStr, aStr, false),
|
||||
false);
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
|
||||
|
||||
nsresult rv;
|
||||
|
||||
NS_NAMED_LITERAL_STRING(cdata, "<![CDATA[");
|
||||
constexpr auto cdata = u"<![CDATA["_ns;
|
||||
|
||||
if (mDoRaw || PreLevel() > 0) {
|
||||
NS_ENSURE_TRUE(AppendToString(cdata, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -239,8 +239,7 @@ nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
|
||||
NS_ENSURE_TRUE(AppendToStringConvertLF(data, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("]]>"), *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(u"]]>"_ns, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -285,8 +284,7 @@ nsXMLContentSerializer::AppendProcessingInstruction(ProcessingInstruction* aPI,
|
||||
NS_ENSURE_TRUE(AppendToStringConvertLF(data, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("?>"), *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(u"?>"_ns, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
MaybeFlagNewlineForRootNode(aPI);
|
||||
|
||||
@ -316,7 +314,7 @@ nsXMLContentSerializer::AppendComment(Comment* aComment, int32_t aStartOffset,
|
||||
|
||||
NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(*mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(startComment, "<!--");
|
||||
constexpr auto startComment = u"<!--"_ns;
|
||||
|
||||
if (mDoRaw || PreLevel() > 0) {
|
||||
NS_ENSURE_TRUE(AppendToString(startComment, *mOutput),
|
||||
@ -339,8 +337,7 @@ nsXMLContentSerializer::AppendComment(Comment* aComment, int32_t aStartOffset,
|
||||
// could have been preformated by the author
|
||||
NS_ENSURE_TRUE(AppendToStringConvertLF(data, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("-->"), *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(u"-->"_ns, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
MaybeFlagNewlineForRootNode(aComment);
|
||||
|
||||
@ -358,13 +355,13 @@ nsXMLContentSerializer::AppendDoctype(DocumentType* aDocType) {
|
||||
|
||||
NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(*mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("<!DOCTYPE "), *mOutput),
|
||||
NS_ENSURE_TRUE(AppendToString(u"<!DOCTYPE "_ns, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(name, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
char16_t quote;
|
||||
if (!publicId.IsEmpty()) {
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING(" PUBLIC "), *mOutput),
|
||||
NS_ENSURE_TRUE(AppendToString(u" PUBLIC "_ns, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
if (publicId.FindChar(char16_t('"')) == -1) {
|
||||
quote = char16_t('"');
|
||||
@ -394,7 +391,7 @@ nsXMLContentSerializer::AppendDoctype(DocumentType* aDocType) {
|
||||
} else {
|
||||
quote = char16_t('\'');
|
||||
}
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING(" SYSTEM "), *mOutput),
|
||||
NS_ENSURE_TRUE(AppendToString(u" SYSTEM "_ns, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(quote, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(systemId, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -656,14 +653,12 @@ bool nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
|
||||
NS_ENSURE_TRUE(attrString.Append(cDelimiter, mozilla::fallible), false);
|
||||
nsAutoString sValue(aValue);
|
||||
NS_ENSURE_TRUE(
|
||||
sValue.ReplaceSubstring(NS_LITERAL_STRING("&"),
|
||||
NS_LITERAL_STRING("&"), mozilla::fallible),
|
||||
sValue.ReplaceSubstring(u"&"_ns, u"&"_ns, mozilla::fallible),
|
||||
false);
|
||||
if (bIncludesDouble && bIncludesSingle) {
|
||||
NS_ENSURE_TRUE(sValue.ReplaceSubstring(NS_LITERAL_STRING("\""),
|
||||
NS_LITERAL_STRING("""),
|
||||
mozilla::fallible),
|
||||
false);
|
||||
NS_ENSURE_TRUE(
|
||||
sValue.ReplaceSubstring(u"\""_ns, u"""_ns, mozilla::fallible),
|
||||
false);
|
||||
}
|
||||
NS_ENSURE_TRUE(attrString.Append(sValue, mozilla::fallible), false);
|
||||
NS_ENSURE_TRUE(attrString.Append(cDelimiter, mozilla::fallible), false);
|
||||
@ -720,7 +715,7 @@ uint32_t nsXMLContentSerializer::ScanNamespaceDeclarations(
|
||||
skipAttr = index;
|
||||
} else {
|
||||
// Default NS attribute does not have prefix (and the name is "xmlns")
|
||||
PushNameSpaceDecl(EmptyString(), uriStr, aOriginalElement);
|
||||
PushNameSpaceDecl(u""_ns, uriStr, aOriginalElement);
|
||||
}
|
||||
} else {
|
||||
PushNameSpaceDecl(nsDependentAtomString(attrName), uriStr,
|
||||
@ -773,8 +768,7 @@ bool nsXMLContentSerializer::SerializeAttributes(
|
||||
if (aTagPrefix.IsEmpty()) {
|
||||
// Serialize default namespace decl
|
||||
NS_ENSURE_TRUE(
|
||||
SerializeAttr(EmptyString(), xmlnsStr, aTagNamespaceURI, aStr, true),
|
||||
false);
|
||||
SerializeAttr(u""_ns, xmlnsStr, aTagNamespaceURI, aStr, true), false);
|
||||
} else {
|
||||
// Serialize namespace decl
|
||||
NS_ENSURE_TRUE(
|
||||
@ -801,8 +795,8 @@ bool nsXMLContentSerializer::SerializeAttributes(
|
||||
|
||||
// Filter out any attribute starting with [-|_]moz
|
||||
nsDependentAtomString attrNameStr(attrName);
|
||||
if (StringBeginsWith(attrNameStr, NS_LITERAL_STRING("_moz")) ||
|
||||
StringBeginsWith(attrNameStr, NS_LITERAL_STRING("-moz"))) {
|
||||
if (StringBeginsWith(attrNameStr, u"_moz"_ns) ||
|
||||
StringBeginsWith(attrNameStr, u"-moz"_ns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -903,8 +897,7 @@ nsXMLContentSerializer::AppendElementStart(Element* aElement,
|
||||
NS_ENSURE_TRUE(AppendToString(kLessThan, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!tagPrefix.IsEmpty()) {
|
||||
NS_ENSURE_TRUE(AppendToString(tagPrefix, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING(":"), *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(u":"_ns, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
NS_ENSURE_TRUE(AppendToString(tagLocalName, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -975,7 +968,7 @@ bool nsXMLContentSerializer::AppendEndOfElementStart(Element* aElement,
|
||||
}
|
||||
}
|
||||
|
||||
return AppendToString(NS_LITERAL_STRING("/>"), aStr);
|
||||
return AppendToString(u"/>"_ns, aStr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1041,8 +1034,7 @@ nsXMLContentSerializer::AppendElementEnd(Element* aElement,
|
||||
NS_ENSURE_TRUE(AppendToString(kEndTag, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!tagPrefix.IsEmpty()) {
|
||||
NS_ENSURE_TRUE(AppendToString(tagPrefix, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING(":"), *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(AppendToString(u":"_ns, *mOutput), NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
NS_ENSURE_TRUE(AppendToString(tagLocalName, *mOutput),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -1095,13 +1087,13 @@ nsXMLContentSerializer::AppendDocumentStart(Document* aDocument) {
|
||||
if (version.IsEmpty())
|
||||
return NS_OK; // A declaration must have version, or there is no decl
|
||||
|
||||
NS_NAMED_LITERAL_STRING(endQuote, "\"");
|
||||
constexpr auto endQuote = u"\""_ns;
|
||||
|
||||
*mOutput += NS_LITERAL_STRING("<?xml version=\"") + version + endQuote;
|
||||
*mOutput += u"<?xml version=\""_ns + version + endQuote;
|
||||
|
||||
if (!mCharset.IsEmpty()) {
|
||||
*mOutput += NS_LITERAL_STRING(" encoding=\"") +
|
||||
NS_ConvertASCIItoUTF16(mCharset) + endQuote;
|
||||
*mOutput +=
|
||||
u" encoding=\""_ns + NS_ConvertASCIItoUTF16(mCharset) + endQuote;
|
||||
}
|
||||
// Otherwise just don't output an encoding attr. Not that we expect
|
||||
// mCharset to ever be empty.
|
||||
@ -1112,7 +1104,7 @@ nsXMLContentSerializer::AppendDocumentStart(Document* aDocument) {
|
||||
#endif
|
||||
|
||||
if (!standalone.IsEmpty()) {
|
||||
*mOutput += NS_LITERAL_STRING(" standalone=\"") + standalone + endQuote;
|
||||
*mOutput += u" standalone=\""_ns + standalone + endQuote;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(mOutput->AppendLiteral("?>", mozilla::fallible),
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define kIndentStr NS_LITERAL_STRING(" ")
|
||||
#define kEndTag NS_LITERAL_STRING("</")
|
||||
#define kIndentStr u" "_ns
|
||||
#define kEndTag u"</"_ns
|
||||
|
||||
class nsAtom;
|
||||
class nsINode;
|
||||
|
@ -97,11 +97,6 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
return frame;
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["network.disable.ipc.security", true]] });
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
for (let scenario of SCENARIOS) {
|
||||
let [ typeA, typeB, options ] = scenario;
|
||||
|
@ -11,7 +11,7 @@ using mozilla::UniquePtr;
|
||||
|
||||
TEST(MimeType, EmptyString)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("");
|
||||
const auto in = u""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Empty string";
|
||||
@ -19,7 +19,7 @@ TEST(MimeType, EmptyString)
|
||||
|
||||
TEST(MimeType, JustWhitespace)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(" \t\r\n ");
|
||||
const auto in = u" \t\r\n "_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Just whitespace";
|
||||
@ -27,7 +27,7 @@ TEST(MimeType, JustWhitespace)
|
||||
|
||||
TEST(MimeType, JustBackslash)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("\\");
|
||||
const auto in = u"\\"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Just backslash";
|
||||
@ -35,7 +35,7 @@ TEST(MimeType, JustBackslash)
|
||||
|
||||
TEST(MimeType, JustForwardslash)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("/");
|
||||
const auto in = u"/"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Just forward slash";
|
||||
@ -43,7 +43,7 @@ TEST(MimeType, JustForwardslash)
|
||||
|
||||
TEST(MimeType, MissingType1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("/bogus");
|
||||
const auto in = u"/bogus"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Missing type #1";
|
||||
@ -51,7 +51,7 @@ TEST(MimeType, MissingType1)
|
||||
|
||||
TEST(MimeType, MissingType2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(" \r\n\t/bogus");
|
||||
const auto in = u" \r\n\t/bogus"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Missing type #2";
|
||||
@ -59,7 +59,7 @@ TEST(MimeType, MissingType2)
|
||||
|
||||
TEST(MimeType, MissingSubtype1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("bogus");
|
||||
const auto in = u"bogus"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Missing subtype #1";
|
||||
@ -67,7 +67,7 @@ TEST(MimeType, MissingSubtype1)
|
||||
|
||||
TEST(MimeType, MissingSubType2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("bogus/");
|
||||
const auto in = u"bogus/"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Missing subtype #2";
|
||||
@ -75,7 +75,7 @@ TEST(MimeType, MissingSubType2)
|
||||
|
||||
TEST(MimeType, MissingSubType3)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("bogus;");
|
||||
const auto in = u"bogus;"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Missing subtype #3";
|
||||
@ -83,7 +83,7 @@ TEST(MimeType, MissingSubType3)
|
||||
|
||||
TEST(MimeType, MissingSubType4)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("bogus; \r\n\t");
|
||||
const auto in = u"bogus; \r\n\t"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Missing subtype #3";
|
||||
@ -91,7 +91,7 @@ TEST(MimeType, MissingSubType4)
|
||||
|
||||
TEST(MimeType, ExtraForwardSlash)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("bogus/bogus/;");
|
||||
const auto in = u"bogus/bogus/;"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Extra forward slash";
|
||||
@ -99,7 +99,7 @@ TEST(MimeType, ExtraForwardSlash)
|
||||
|
||||
TEST(MimeType, WhitespaceInType)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("t\re\nx\tt /html");
|
||||
const auto in = u"t\re\nx\tt /html"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Type with whitespace";
|
||||
@ -107,7 +107,7 @@ TEST(MimeType, WhitespaceInType)
|
||||
|
||||
TEST(MimeType, WhitespaceInSubtype)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/ h\rt\nm\tl");
|
||||
const auto in = u"text/ h\rt\nm\tl"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Subtype with whitespace";
|
||||
@ -115,7 +115,7 @@ TEST(MimeType, WhitespaceInSubtype)
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("</>");
|
||||
const auto in = u"</>"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-alphanumeric media type #1";
|
||||
@ -123,7 +123,7 @@ TEST(MimeType, NonAlphanumericMediaType1)
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("(/)");
|
||||
const auto in = u"(/)"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-alphanumeric media type #2";
|
||||
@ -131,7 +131,7 @@ TEST(MimeType, NonAlphanumericMediaType2)
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType3)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("{/}");
|
||||
const auto in = u"{/}"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-alphanumeric media type #3";
|
||||
@ -139,7 +139,7 @@ TEST(MimeType, NonAlphanumericMediaType3)
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType4)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("\"/\"");
|
||||
const auto in = u"\"/\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-alphanumeric media type #4";
|
||||
@ -147,7 +147,7 @@ TEST(MimeType, NonAlphanumericMediaType4)
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType5)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("\0/\0");
|
||||
const auto in = u"\0/\0"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-alphanumeric media type #5";
|
||||
@ -155,7 +155,7 @@ TEST(MimeType, NonAlphanumericMediaType5)
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType6)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html(;doesnot=matter");
|
||||
const auto in = u"text/html(;doesnot=matter"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-alphanumeric media type #6";
|
||||
@ -163,7 +163,7 @@ TEST(MimeType, NonAlphanumericMediaType6)
|
||||
|
||||
TEST(MimeType, NonLatin1MediaType1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("ÿ/ÿ");
|
||||
const auto in = u"ÿ/ÿ"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-latin1 media type #1";
|
||||
@ -171,7 +171,7 @@ TEST(MimeType, NonLatin1MediaType1)
|
||||
|
||||
TEST(MimeType, NonLatin1MediaType2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(u"\x0100/\x0100");
|
||||
const auto in = u"\x0100/\x0100"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed)
|
||||
<< "Non-latin1 media type #2";
|
||||
@ -179,52 +179,49 @@ TEST(MimeType, NonLatin1MediaType2)
|
||||
|
||||
TEST(MimeType, MultipleParameters)
|
||||
{
|
||||
const auto in =
|
||||
NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2");
|
||||
const auto in = u"text/html;charset=gbk;no=1;charset_=gbk_;yes=2"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(
|
||||
NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2")))
|
||||
ASSERT_TRUE(out.Equals(u"text/html;charset=gbk;no=1;charset_=gbk_;yes=2"_ns))
|
||||
<< "Multiple parameters";
|
||||
}
|
||||
|
||||
TEST(MimeType, DuplicateParameter1)
|
||||
{
|
||||
const auto in =
|
||||
NS_LITERAL_STRING("text/html;charset=gbk;charset=windows-1255");
|
||||
const auto in = u"text/html;charset=gbk;charset=windows-1255"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=gbk")))
|
||||
ASSERT_TRUE(out.Equals(u"text/html;charset=gbk"_ns))
|
||||
<< "Duplicate parameter #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, DuplicateParameter2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=();charset=GBK");
|
||||
const auto in = u"text/html;charset=();charset=GBK"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=\"()\"")))
|
||||
ASSERT_TRUE(out.Equals(u"text/html;charset=\"()\""_ns))
|
||||
<< "Duplicate parameter #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, CString)
|
||||
{
|
||||
const auto in = NS_LITERAL_CSTRING("text/html;charset=();charset=GBK");
|
||||
const auto in = "text/html;charset=();charset=GBK"_ns;
|
||||
UniquePtr<CMimeType> parsed = CMimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
nsCString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(NS_LITERAL_CSTRING("text/html;charset=\"()\"")))
|
||||
ASSERT_TRUE(out.Equals("text/html;charset=\"()\""_ns))
|
||||
<< "Duplicate parameter #2";
|
||||
}
|
||||
|
||||
@ -234,14 +231,13 @@ TEST(MimeType, CString)
|
||||
#endif
|
||||
TEST(MimeType, NonAlphanumericParametersAreQuoted)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;test=\x00FF\\;charset=gbk");
|
||||
const auto in = u"text/html;test=\x00FF\\;charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(
|
||||
NS_LITERAL_STRING("text/html;test=\"\x00FF\\\\\";charset=gbk")))
|
||||
ASSERT_TRUE(out.Equals(u"text/html;test=\"\x00FF\\\\\";charset=gbk"_ns))
|
||||
<< "Non-alphanumeric parameters are quoted";
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
@ -250,7 +246,7 @@ TEST(MimeType, NonAlphanumericParametersAreQuoted)
|
||||
|
||||
TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset= g\\\"bk");
|
||||
const auto in = u"text/html;charset= g\\\"bk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -262,7 +258,7 @@ TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace1)
|
||||
|
||||
TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset= \"g\\bk\"");
|
||||
const auto in = u"text/html;charset= \"g\\bk\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -274,7 +270,7 @@ TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace2)
|
||||
|
||||
TEST(MimeType, ParameterQuotedIfHasInternalWhitespace)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=g \\b\"k");
|
||||
const auto in = u"text/html;charset=g \\b\"k"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -286,7 +282,7 @@ TEST(MimeType, ParameterQuotedIfHasInternalWhitespace)
|
||||
|
||||
TEST(MimeType, ImproperlyQuotedParameter1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("x/x;test=\"");
|
||||
const auto in = u"x/x;test=\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -298,7 +294,7 @@ TEST(MimeType, ImproperlyQuotedParameter1)
|
||||
|
||||
TEST(MimeType, ImproperlyQuotedParameter2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("x/x;test=\"\\");
|
||||
const auto in = u"x/x;test=\"\\"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -310,7 +306,7 @@ TEST(MimeType, ImproperlyQuotedParameter2)
|
||||
|
||||
TEST(MimeType, NonLatin1ParameterIgnored)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(u"x/x;test=\xFFFD;x=x");
|
||||
const auto in = u"x/x;test=\xFFFD;x=x"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -322,7 +318,7 @@ TEST(MimeType, NonLatin1ParameterIgnored)
|
||||
|
||||
TEST(MimeType, ParameterIgnoredIfWhitespaceInName1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset =gbk;charset=123");
|
||||
const auto in = u"text/html;charset =gbk;charset=123"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -334,7 +330,7 @@ TEST(MimeType, ParameterIgnoredIfWhitespaceInName1)
|
||||
|
||||
TEST(MimeType, ParameterIgnoredIfWhitespaceInName2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;cha rset =gbk;charset=123");
|
||||
const auto in = u"text/html;cha rset =gbk;charset=123"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -346,8 +342,7 @@ TEST(MimeType, ParameterIgnoredIfWhitespaceInName2)
|
||||
|
||||
TEST(MimeType, WhitespaceTrimmed)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"\n\r\t text/plain\n\r\t ;\n\r\t charset=123\n\r\t ");
|
||||
const auto in = u"\n\r\t text/plain\n\r\t ;\n\r\t charset=123\n\r\t "_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -359,7 +354,7 @@ TEST(MimeType, WhitespaceTrimmed)
|
||||
|
||||
TEST(MimeType, WhitespaceOnlyParameterIgnored)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("x/x;x= \r\n\t");
|
||||
const auto in = u"x/x;x= \r\n\t"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -371,7 +366,7 @@ TEST(MimeType, WhitespaceOnlyParameterIgnored)
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("x/x;test");
|
||||
const auto in = u"x/x;test"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -383,7 +378,7 @@ TEST(MimeType, IncompleteParameterIgnored1)
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("x/x;test=");
|
||||
const auto in = u"x/x;test="_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -395,7 +390,7 @@ TEST(MimeType, IncompleteParameterIgnored2)
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored3)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("x/x;test= \r\n\t");
|
||||
const auto in = u"x/x;test= \r\n\t"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -407,7 +402,7 @@ TEST(MimeType, IncompleteParameterIgnored3)
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored4)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;test;charset=gbk");
|
||||
const auto in = u"text/html;test;charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -419,7 +414,7 @@ TEST(MimeType, IncompleteParameterIgnored4)
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored5)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;test=;charset=gbk");
|
||||
const auto in = u"text/html;test=;charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -431,7 +426,7 @@ TEST(MimeType, IncompleteParameterIgnored5)
|
||||
|
||||
TEST(MimeType, EmptyParameterIgnored1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html ; ; charset=gbk");
|
||||
const auto in = u"text/html ; ; charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -443,7 +438,7 @@ TEST(MimeType, EmptyParameterIgnored1)
|
||||
|
||||
TEST(MimeType, EmptyParameterIgnored2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;;;;charset=gbk");
|
||||
const auto in = u"text/html;;;;charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -455,7 +450,7 @@ TEST(MimeType, EmptyParameterIgnored2)
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;';charset=gbk");
|
||||
const auto in = u"text/html;';charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -467,7 +462,7 @@ TEST(MimeType, InvalidParameterIgnored1)
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;\";charset=gbk;=123; =321");
|
||||
const auto in = u"text/html;\";charset=gbk;=123; =321"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -479,7 +474,7 @@ TEST(MimeType, InvalidParameterIgnored2)
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored3)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset= \"\u007F;charset=GBK");
|
||||
const auto in = u"text/html;charset= \"\u007F;charset=GBK"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -491,8 +486,8 @@ TEST(MimeType, InvalidParameterIgnored3)
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored4)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"text/html;charset=\"\u007F;charset=foo\";charset=GBK;charset=");
|
||||
const auto in = nsLiteralString(
|
||||
u"text/html;charset=\"\u007F;charset=foo\";charset=GBK;charset=");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -504,7 +499,7 @@ TEST(MimeType, InvalidParameterIgnored4)
|
||||
|
||||
TEST(MimeType, SingleQuotes1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset='gbk'");
|
||||
const auto in = u"text/html;charset='gbk'"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -516,7 +511,7 @@ TEST(MimeType, SingleQuotes1)
|
||||
|
||||
TEST(MimeType, SingleQuotes2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset='gbk");
|
||||
const auto in = u"text/html;charset='gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -528,7 +523,7 @@ TEST(MimeType, SingleQuotes2)
|
||||
|
||||
TEST(MimeType, SingleQuotes3)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=gbk'");
|
||||
const auto in = u"text/html;charset=gbk'"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -540,7 +535,7 @@ TEST(MimeType, SingleQuotes3)
|
||||
|
||||
TEST(MimeType, SingleQuotes4)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=';charset=GBK");
|
||||
const auto in = u"text/html;charset=';charset=GBK"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -552,7 +547,7 @@ TEST(MimeType, SingleQuotes4)
|
||||
|
||||
TEST(MimeType, SingleQuotes5)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=''';charset=GBK");
|
||||
const auto in = u"text/html;charset=''';charset=GBK"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -564,7 +559,7 @@ TEST(MimeType, SingleQuotes5)
|
||||
|
||||
TEST(MimeType, DoubleQuotes1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk\"");
|
||||
const auto in = u"text/html;charset=\"gbk\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -576,7 +571,7 @@ TEST(MimeType, DoubleQuotes1)
|
||||
|
||||
TEST(MimeType, DoubleQuotes2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk");
|
||||
const auto in = u"text/html;charset=\"gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -588,7 +583,7 @@ TEST(MimeType, DoubleQuotes2)
|
||||
|
||||
TEST(MimeType, DoubleQuotes3)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=gbk\"");
|
||||
const auto in = u"text/html;charset=gbk\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -600,7 +595,7 @@ TEST(MimeType, DoubleQuotes3)
|
||||
|
||||
TEST(MimeType, DoubleQuotes4)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\" gbk\"");
|
||||
const auto in = u"text/html;charset=\" gbk\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -612,7 +607,7 @@ TEST(MimeType, DoubleQuotes4)
|
||||
|
||||
TEST(MimeType, DoubleQuotes5)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk \"");
|
||||
const auto in = u"text/html;charset=\"gbk \""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -624,7 +619,7 @@ TEST(MimeType, DoubleQuotes5)
|
||||
|
||||
TEST(MimeType, DoubleQuotes6)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"\\ gbk\"");
|
||||
const auto in = u"text/html;charset=\"\\ gbk\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -636,7 +631,7 @@ TEST(MimeType, DoubleQuotes6)
|
||||
|
||||
TEST(MimeType, DoubleQuotes7)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"\\g\\b\\k\"");
|
||||
const auto in = u"text/html;charset=\"\\g\\b\\k\""_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -648,7 +643,7 @@ TEST(MimeType, DoubleQuotes7)
|
||||
|
||||
TEST(MimeType, DoubleQuotes8)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk\"x");
|
||||
const auto in = u"text/html;charset=\"gbk\"x"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -660,7 +655,7 @@ TEST(MimeType, DoubleQuotes8)
|
||||
|
||||
TEST(MimeType, DoubleQuotes9)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"\";charset=GBK");
|
||||
const auto in = u"text/html;charset=\"\";charset=GBK"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -672,7 +667,7 @@ TEST(MimeType, DoubleQuotes9)
|
||||
|
||||
TEST(MimeType, DoubleQuotes10)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\";charset=GBK");
|
||||
const auto in = u"text/html;charset=\";charset=GBK"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -684,7 +679,7 @@ TEST(MimeType, DoubleQuotes10)
|
||||
|
||||
TEST(MimeType, UnexpectedCodePoints)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset={gbk}");
|
||||
const auto in = u"text/html;charset={gbk}"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -696,8 +691,9 @@ TEST(MimeType, UnexpectedCodePoints)
|
||||
|
||||
TEST(MimeType, LongTypesSubtypesAccepted)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"012345678901234567890123456789012345678901234567890123456789012345678901"
|
||||
const auto in = nsLiteralString(
|
||||
u"01234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
u"1"
|
||||
"2345678901234567890123456789012345678901234567890123456789/"
|
||||
"012345678901234567890123456789012345678901234567890123456789012345678901"
|
||||
"2345678901234567890123456789012345678901234567890123456789");
|
||||
@ -712,8 +708,8 @@ TEST(MimeType, LongTypesSubtypesAccepted)
|
||||
|
||||
TEST(MimeType, LongParametersAccepted)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"text/"
|
||||
const auto in = nsLiteralString(
|
||||
u"text/"
|
||||
"html;"
|
||||
"012345678901234567890123456789012345678901234567890123456789012345678901"
|
||||
"2345678901234567890123456789012345678901234567890123456789=x;charset="
|
||||
@ -729,7 +725,7 @@ TEST(MimeType, LongParametersAccepted)
|
||||
|
||||
TEST(MimeType, AllValidCharactersAccepted1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
const auto in = nsLiteralString(
|
||||
u"x/x;x=\"\t "
|
||||
u"!\\\"#$%&'()*+,-./"
|
||||
u"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`"
|
||||
@ -757,7 +753,7 @@ TEST(MimeType, AllValidCharactersAccepted1)
|
||||
|
||||
TEST(MimeType, CaseNormalization1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("TEXT/PLAIN;CHARSET=TEST");
|
||||
const auto in = u"TEXT/PLAIN;CHARSET=TEST"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -769,8 +765,8 @@ TEST(MimeType, CaseNormalization1)
|
||||
|
||||
TEST(MimeType, CaseNormalization2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"!#$%&'*+-.^_`|~"
|
||||
const auto in = nsLiteralString(
|
||||
u"!#$%&'*+-.^_`|~"
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/"
|
||||
"!#$%&'*+-.^_`|~"
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;!#$%&'*+-"
|
||||
@ -795,7 +791,7 @@ TEST(MimeType, CaseNormalization2)
|
||||
|
||||
TEST(MimeType, LegacyCommentSyntax1)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=gbk(");
|
||||
const auto in = u"text/html;charset=gbk("_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
@ -807,7 +803,7 @@ TEST(MimeType, LegacyCommentSyntax1)
|
||||
|
||||
TEST(MimeType, LegacyCommentSyntax2)
|
||||
{
|
||||
const auto in = NS_LITERAL_STRING("text/html;x=(;charset=gbk");
|
||||
const auto in = u"text/html;x=(;charset=gbk"_ns;
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
|
337
dom/base/test/gtest/TestScheduler.cpp
Normal file
337
dom/base/test/gtest/TestScheduler.cpp
Normal file
@ -0,0 +1,337 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "mozilla/dom/CCGCScheduler.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
// This is a test for mozilla::CCGCScheduler.
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static TimeDuration kOneSecond = TimeDuration::FromSeconds(1);
|
||||
static TimeDuration kTenthSecond = TimeDuration::FromSeconds(0.1);
|
||||
static TimeDuration kFrameDuration = TimeDuration::FromSeconds(1.0 / 60.0);
|
||||
|
||||
static mozilla::TimeStamp sNow = TimeStamp::Now();
|
||||
|
||||
static mozilla::TimeStamp sStartupTime = sNow;
|
||||
|
||||
inline mozilla::TimeStamp mozilla::CCGCScheduler::Now() { return sNow; }
|
||||
|
||||
static mozilla::TimeStamp AdvanceTime(TimeDuration aDuration) {
|
||||
sNow += aDuration;
|
||||
return sNow;
|
||||
}
|
||||
|
||||
static uint32_t sSuspected = 0;
|
||||
|
||||
inline uint32_t mozilla::CCGCScheduler::SuspectedCCObjects() {
|
||||
return sSuspected;
|
||||
}
|
||||
static void SetNumSuspected(uint32_t n) { sSuspected = n; }
|
||||
static void SuspectMore(uint32_t n) { sSuspected += n; }
|
||||
|
||||
using CCRunnerState = mozilla::CCGCScheduler::CCRunnerState;
|
||||
|
||||
static TimeStamp Now() { return sNow; }
|
||||
|
||||
class TestGC {
|
||||
protected:
|
||||
CCGCScheduler& mScheduler;
|
||||
|
||||
public:
|
||||
explicit TestGC(CCGCScheduler& aScheduler) : mScheduler(aScheduler) {}
|
||||
void Run(int aNumSlices);
|
||||
};
|
||||
|
||||
void TestGC::Run(int aNumSlices) {
|
||||
// Make the purple buffer nearly empty so it is itself not an adequate reason
|
||||
// for wanting a CC.
|
||||
static_assert(3 < mozilla::kCCPurpleLimit);
|
||||
SetNumSuspected(3);
|
||||
|
||||
// Running the GC should not influence whether a CC is currently seen as
|
||||
// needed. But the first time we run GC, it will be false; later, we will
|
||||
// have run a GC and set it to true.
|
||||
bool neededCCAtStartOfGC = mScheduler.IsCCNeeded();
|
||||
|
||||
mScheduler.NoteGCBegin();
|
||||
|
||||
for (int slice = 0; slice < aNumSlices; slice++) {
|
||||
EXPECT_TRUE(mScheduler.InIncrementalGC());
|
||||
TimeStamp idleDeadline = Now() + kTenthSecond;
|
||||
TimeDuration budget =
|
||||
mScheduler.ComputeInterSliceGCBudget(idleDeadline, Now());
|
||||
EXPECT_NEAR(budget.ToSeconds(), 0.1, 1.e-6);
|
||||
// Pretend the GC took exactly the budget.
|
||||
AdvanceTime(budget);
|
||||
|
||||
EXPECT_EQ(mScheduler.IsCCNeeded(), neededCCAtStartOfGC);
|
||||
|
||||
// Mutator runs for 1 second.
|
||||
AdvanceTime(kOneSecond);
|
||||
}
|
||||
|
||||
mScheduler.NoteGCEnd();
|
||||
mScheduler.SetNeedsFullGC(false);
|
||||
}
|
||||
|
||||
class TestCC {
|
||||
protected:
|
||||
CCGCScheduler& mScheduler;
|
||||
|
||||
public:
|
||||
explicit TestCC(CCGCScheduler& aScheduler) : mScheduler(aScheduler) {}
|
||||
|
||||
void Run(int aNumSlices) {
|
||||
Prepare();
|
||||
MaybePokeCC();
|
||||
TimerFires(aNumSlices);
|
||||
EndCycleCollectionCallback();
|
||||
KillCCRunner();
|
||||
}
|
||||
|
||||
virtual void Prepare() = 0;
|
||||
virtual void MaybePokeCC();
|
||||
virtual void TimerFires(int aNumSlices);
|
||||
virtual void RunSlices(int aNumSlices);
|
||||
virtual void RunSlice(TimeStamp aCCStartTime, TimeStamp aPrevSliceEnd,
|
||||
int aSliceNum, int aNumSlices) = 0;
|
||||
virtual void ForgetSkippable();
|
||||
virtual void EndCycleCollectionCallback();
|
||||
virtual void KillCCRunner();
|
||||
};
|
||||
|
||||
void TestCC::MaybePokeCC() {
|
||||
// nsJSContext::MaybePokeCC
|
||||
EXPECT_TRUE(mScheduler.ShouldScheduleCC());
|
||||
|
||||
mScheduler.InitCCRunnerStateMachine(CCRunnerState::ReducePurple);
|
||||
EXPECT_TRUE(mScheduler.IsEarlyForgetSkippable());
|
||||
}
|
||||
|
||||
void TestCC::TimerFires(int aNumSlices) {
|
||||
// Series of CCRunner timer fires.
|
||||
CCRunnerStep step;
|
||||
|
||||
while (true) {
|
||||
SuspectMore(1000);
|
||||
TimeStamp idleDeadline = Now() + kOneSecond;
|
||||
step = mScheduler.GetNextCCRunnerAction(idleDeadline);
|
||||
// Should first see a series of ForgetSkippable actions.
|
||||
if (step.mAction != CCRunnerAction::ForgetSkippable ||
|
||||
step.mRemoveChildless != KeepChildless) {
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(step.mYield, Yield);
|
||||
ForgetSkippable();
|
||||
}
|
||||
|
||||
while (step.mYield == Continue) {
|
||||
TimeStamp idleDeadline = Now() + kOneSecond;
|
||||
step = mScheduler.GetNextCCRunnerAction(idleDeadline);
|
||||
}
|
||||
EXPECT_EQ(step.mAction, CCRunnerAction::ForgetSkippable);
|
||||
EXPECT_EQ(step.mRemoveChildless, RemoveChildless);
|
||||
ForgetSkippable();
|
||||
|
||||
TimeStamp idleDeadline = Now() + kOneSecond;
|
||||
step = mScheduler.GetNextCCRunnerAction(idleDeadline);
|
||||
EXPECT_EQ(step.mAction, CCRunnerAction::CleanupContentUnbinder);
|
||||
step = mScheduler.GetNextCCRunnerAction(idleDeadline);
|
||||
EXPECT_EQ(step.mAction, CCRunnerAction::CleanupDeferred);
|
||||
|
||||
RunSlices(aNumSlices);
|
||||
}
|
||||
|
||||
void TestCC::ForgetSkippable() {
|
||||
uint32_t suspectedBefore = sSuspected;
|
||||
// ...ForgetSkippable would happen here...
|
||||
js::SliceBudget budget =
|
||||
mScheduler.ComputeForgetSkippableBudget(Now(), Now() + kTenthSecond);
|
||||
EXPECT_NEAR(budget.timeBudget(), kTenthSecond.ToMilliseconds(), 1);
|
||||
AdvanceTime(kTenthSecond);
|
||||
mScheduler.NoteForgetSkippableComplete(Now(), suspectedBefore);
|
||||
}
|
||||
|
||||
void TestCC::RunSlices(int aNumSlices) {
|
||||
TimeStamp ccStartTime = Now();
|
||||
TimeStamp prevSliceEnd = ccStartTime;
|
||||
for (int ccslice = 0; ccslice < aNumSlices; ccslice++) {
|
||||
RunSlice(ccStartTime, prevSliceEnd, ccslice, aNumSlices);
|
||||
prevSliceEnd = Now();
|
||||
}
|
||||
|
||||
SetNumSuspected(0);
|
||||
}
|
||||
|
||||
void TestCC::EndCycleCollectionCallback() {
|
||||
// nsJSContext::EndCycleCollectionCallback
|
||||
CycleCollectorResults results;
|
||||
results.mFreedGCed = 10;
|
||||
results.mFreedJSZones = 2;
|
||||
mScheduler.NoteCycleCollected(results);
|
||||
|
||||
// Because > 0 zones were freed.
|
||||
EXPECT_TRUE(mScheduler.NeedsGCAfterCC());
|
||||
}
|
||||
|
||||
void TestCC::KillCCRunner() {
|
||||
// nsJSContext::KillCCRunner
|
||||
mScheduler.UnblockCC();
|
||||
mScheduler.DeactivateCCRunner();
|
||||
mScheduler.NoteCCEnd(Now());
|
||||
}
|
||||
|
||||
class TestIdleCC : public TestCC {
|
||||
public:
|
||||
explicit TestIdleCC(CCGCScheduler& aScheduler) : TestCC(aScheduler) {}
|
||||
|
||||
void Prepare() override;
|
||||
void RunSlice(TimeStamp aCCStartTime, TimeStamp aPrevSliceEnd, int aSliceNum,
|
||||
int aNumSlices) override;
|
||||
};
|
||||
|
||||
void TestIdleCC::Prepare() { EXPECT_TRUE(!mScheduler.InIncrementalGC()); }
|
||||
|
||||
void TestIdleCC::RunSlice(TimeStamp aCCStartTime, TimeStamp aPrevSliceEnd,
|
||||
int aSliceNum, int aNumSlices) {
|
||||
CCRunnerStep step;
|
||||
TimeStamp idleDeadline = Now() + kTenthSecond;
|
||||
|
||||
// The scheduler should request a CycleCollect slice.
|
||||
step = mScheduler.GetNextCCRunnerAction(idleDeadline);
|
||||
EXPECT_EQ(step.mAction, CCRunnerAction::CycleCollect);
|
||||
|
||||
// nsJSContext::RunCycleCollectorSlice
|
||||
|
||||
EXPECT_FALSE(mScheduler.InIncrementalGC());
|
||||
bool preferShorter;
|
||||
js::SliceBudget budget = mScheduler.ComputeCCSliceBudget(
|
||||
idleDeadline, aCCStartTime, aPrevSliceEnd, &preferShorter);
|
||||
// The scheduler will set the budget to our deadline (0.1sec in the future).
|
||||
EXPECT_NEAR(budget.timeBudget(), kTenthSecond.ToMilliseconds(), 1);
|
||||
EXPECT_FALSE(preferShorter);
|
||||
|
||||
AdvanceTime(kTenthSecond);
|
||||
}
|
||||
|
||||
class TestNonIdleCC : public TestCC {
|
||||
public:
|
||||
explicit TestNonIdleCC(CCGCScheduler& aScheduler) : TestCC(aScheduler) {}
|
||||
|
||||
void Prepare() override;
|
||||
void RunSlice(TimeStamp aCCStartTime, TimeStamp aPrevSliceEnd, int aSliceNum,
|
||||
int aNumSlices) override;
|
||||
};
|
||||
|
||||
void TestNonIdleCC::Prepare() {
|
||||
EXPECT_TRUE(!mScheduler.InIncrementalGC());
|
||||
|
||||
// Advance time by an hour to give time for a user event in the past.
|
||||
AdvanceTime(TimeDuration::FromSeconds(3600));
|
||||
}
|
||||
|
||||
void TestNonIdleCC::RunSlice(TimeStamp aCCStartTime, TimeStamp aPrevSliceEnd,
|
||||
int aSliceNum, int aNumSlices) {
|
||||
CCRunnerStep step;
|
||||
TimeStamp nullDeadline;
|
||||
|
||||
// The scheduler should tell us to run a slice of cycle collection.
|
||||
step = mScheduler.GetNextCCRunnerAction(nullDeadline);
|
||||
EXPECT_EQ(step.mAction, CCRunnerAction::CycleCollect);
|
||||
|
||||
// nsJSContext::RunCycleCollectorSlice
|
||||
|
||||
EXPECT_FALSE(mScheduler.InIncrementalGC());
|
||||
|
||||
bool preferShorter;
|
||||
js::SliceBudget budget = mScheduler.ComputeCCSliceBudget(
|
||||
nullDeadline, aCCStartTime, aPrevSliceEnd, &preferShorter);
|
||||
if (aSliceNum == 0) {
|
||||
// First slice of the CC, so always use the baseBudget which is
|
||||
// kICCSliceBudget (3ms) for a non-idle slice.
|
||||
EXPECT_NEAR(budget.timeBudget(), kICCSliceBudget.ToMilliseconds(), 0.1);
|
||||
} else if (aSliceNum == 1) {
|
||||
// Second slice still uses the baseBudget, since not much time has passed
|
||||
// so none of the lengthening mechanisms have kicked in yet.
|
||||
EXPECT_NEAR(budget.timeBudget(), kICCSliceBudget.ToMilliseconds(), 0.1);
|
||||
} else if (aSliceNum == 2) {
|
||||
// We're not overrunning kMaxICCDuration, so we don't go unlimited.
|
||||
EXPECT_FALSE(budget.isUnlimited());
|
||||
// This slice is delayed by twice the allowed amount. Slice time should be
|
||||
// doubled.
|
||||
EXPECT_NEAR(budget.timeBudget(), kICCSliceBudget.ToMilliseconds() * 2, 0.1);
|
||||
} else {
|
||||
// We're not overrunning kMaxICCDuration, so we don't go unlimited.
|
||||
EXPECT_FALSE(budget.isUnlimited());
|
||||
|
||||
// These slices are not delayed, but enough time has passed that the
|
||||
// dominating factor is now the linear ramp up to max slice time at the
|
||||
// halfway point to kMaxICCDuration.
|
||||
EXPECT_TRUE(budget.timeBudget() > kICCSliceBudget.ToMilliseconds());
|
||||
EXPECT_TRUE(budget.timeBudget() <=
|
||||
MainThreadIdlePeriod::GetLongIdlePeriod());
|
||||
}
|
||||
EXPECT_TRUE(preferShorter); // Non-idle prefers shorter slices
|
||||
|
||||
AdvanceTime(TimeDuration::FromMilliseconds(budget.timeBudget()));
|
||||
if (aSliceNum == 1) {
|
||||
// Delay the third slice (only).
|
||||
AdvanceTime(kICCIntersliceDelay * 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Do a GC then CC then GC.
|
||||
static bool BasicScenario(CCGCScheduler& aScheduler, TestGC* aTestGC,
|
||||
TestCC* aTestCC) {
|
||||
// Run a 10-slice incremental GC.
|
||||
aTestGC->Run(10);
|
||||
|
||||
// After a GC, the scheduler should decide to do a full CC regardless of the
|
||||
// number of purple buffer entries.
|
||||
SetNumSuspected(3);
|
||||
EXPECT_TRUE(aScheduler.IsCCNeeded());
|
||||
|
||||
// Now we should want to CC.
|
||||
EXPECT_TRUE(aScheduler.ShouldScheduleCC());
|
||||
|
||||
// Do a 5-slice CC.
|
||||
aTestCC->Run(5);
|
||||
|
||||
// Not enough suspected objects to deserve a CC.
|
||||
EXPECT_FALSE(aScheduler.IsCCNeeded());
|
||||
EXPECT_FALSE(aScheduler.ShouldScheduleCC());
|
||||
SetNumSuspected(10000);
|
||||
|
||||
// We shouldn't want to CC again yet, it's too soon.
|
||||
EXPECT_FALSE(aScheduler.ShouldScheduleCC());
|
||||
AdvanceTime(mozilla::kCCDelay);
|
||||
|
||||
// *Now* it's time for another CC.
|
||||
EXPECT_TRUE(aScheduler.ShouldScheduleCC());
|
||||
|
||||
// Run a 3-slice incremental GC.
|
||||
EXPECT_TRUE(!aScheduler.InIncrementalGC());
|
||||
aTestGC->Run(3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static CCGCScheduler scheduler;
|
||||
static TestGC gc(scheduler);
|
||||
static TestIdleCC ccIdle(scheduler);
|
||||
static TestNonIdleCC ccNonIdle(scheduler);
|
||||
|
||||
TEST(TestScheduler, Idle)
|
||||
{
|
||||
// Cannot CC until we GC once.
|
||||
EXPECT_FALSE(scheduler.ShouldScheduleCC());
|
||||
|
||||
EXPECT_TRUE(BasicScenario(scheduler, &gc, &ccIdle));
|
||||
}
|
||||
|
||||
TEST(TestScheduler, NonIdle)
|
||||
{ EXPECT_TRUE(BasicScenario(scheduler, &gc, &ccNonIdle)); }
|
@ -6,6 +6,7 @@ UNIFIED_SOURCES += [
|
||||
'TestContentUtils.cpp',
|
||||
'TestMimeType.cpp',
|
||||
'TestPlainTextSerializer.cpp',
|
||||
'TestScheduler.cpp',
|
||||
'TestXPathGenerator.cpp',
|
||||
]
|
||||
|
||||
|
@ -193,7 +193,6 @@ support-files =
|
||||
w3element_traversal.svg
|
||||
wholeTexty-helper.xml
|
||||
referrerHelper.js
|
||||
img_referrer_testserver.sjs
|
||||
file_audioLoop.html
|
||||
file_webaudioLoop.html
|
||||
file_webaudioLoop2.html
|
||||
@ -295,7 +294,7 @@ tags = clipboard
|
||||
skip-if = headless # fails in clipboard mode
|
||||
[test_bug166235.html]
|
||||
tags = clipboard
|
||||
skip-if = toolkit == 'android' || headless # headless != clipboard
|
||||
skip-if = headless # headless != clipboard
|
||||
[test_bug199959.html]
|
||||
[test_bug218236.html]
|
||||
[test_bug218277.html]
|
||||
@ -315,13 +314,12 @@ skip-if = toolkit == 'android' || headless # headless != clipboard
|
||||
[test_bug330925.xhtml]
|
||||
[test_bug331959.html]
|
||||
[test_bug333064.html]
|
||||
skip-if = toolkit == 'android' || headless # Headless: Bug 1405868
|
||||
skip-if = headless # Headless: Bug 1405868
|
||||
[test_bug333198.html]
|
||||
[test_bug333673.html]
|
||||
[test_bug337631.html]
|
||||
[test_bug338541.xhtml]
|
||||
[test_bug338583.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_bug338679.html]
|
||||
[test_bug339494.html]
|
||||
[test_bug339494.xhtml]
|
||||
@ -373,7 +371,6 @@ support-files = test_bug380418.html^headers^
|
||||
support-files = test_bug402150.html^headers^
|
||||
[test_bug403841.html]
|
||||
[test_bug403852.html]
|
||||
skip-if = os == 'android' && !debug # Bug 1519063
|
||||
[test_bug403868.xml]
|
||||
[test_bug405182.html]
|
||||
[test_bug409380.html]
|
||||
@ -437,9 +434,7 @@ support-files = bug444546.sjs
|
||||
[test_bug473162-1.html]
|
||||
[test_bug473162-2.html]
|
||||
[test_bug475156.html]
|
||||
skip-if = toolkit == 'android' #bug 855762
|
||||
[test_bug482935.html]
|
||||
skip-if = toolkit == 'android' #bug 855762
|
||||
[test_bug484396.html]
|
||||
[test_bug493881.html]
|
||||
support-files = test_bug493881.js
|
||||
@ -453,9 +448,7 @@ support-files = test_bug493881.js
|
||||
disabled = Disabled due to making the harness time out
|
||||
support-files = file_bug503473-frame.sjs
|
||||
[test_bug503481.html]
|
||||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_bug503481b.html]
|
||||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_bug513194.html]
|
||||
[test_bug514487.html]
|
||||
[test_bug515401.html]
|
||||
@ -473,7 +466,6 @@ support-files = file_bug518104.js
|
||||
[test_bug558726.html]
|
||||
[test_bug559526.html]
|
||||
[test_bug560780.html]
|
||||
skip-if = (os == "android") # Failure with AccessibleCarets on Android, bug 1230229
|
||||
[test_bug562137.html]
|
||||
[test_bug562169-1.html]
|
||||
[test_bug562169-2.html]
|
||||
@ -489,7 +481,7 @@ skip-if = (verify && (os == 'win'))
|
||||
[test_bug587931.html]
|
||||
[test_bug588990.html]
|
||||
[test_bug590812.html]
|
||||
skip-if = toolkit == 'android' || (verify && !debug && (os == 'linux')) #bug 687032
|
||||
skip-if = (verify && !debug && (os == 'linux')) #bug 687032
|
||||
[test_bug590870.html]
|
||||
[test_bug592366.html]
|
||||
[test_bug592829.html]
|
||||
@ -601,7 +593,6 @@ support-files = test_bug1037687_subframe.html
|
||||
[test_bug1100912.html]
|
||||
support-files = file_bug1100912.html
|
||||
[test_bug1101364.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_bug1118689.html]
|
||||
[test_bug1126851.html]
|
||||
[test_bug1163743.html]
|
||||
@ -646,7 +637,7 @@ tags = clipboard
|
||||
skip-if = toolkit == 'android' || headless #bug 904183
|
||||
[test_copypaste.xhtml]
|
||||
tags = clipboard
|
||||
skip-if = (toolkit == 'android' && !e10s) || headless #bug 904183
|
||||
skip-if = headless #bug 904183
|
||||
[test_copypaste_disabled.html]
|
||||
[test_createHTMLDocument.html]
|
||||
[test_data_uri.html]
|
||||
@ -670,7 +661,6 @@ skip-if = toolkit == 'android' && !is_fennec # Bug 1525959
|
||||
[test_EventSource_redirects.html]
|
||||
[test_eventsource_event_listener_leaks.html]
|
||||
[test_explicit_user_agent.html]
|
||||
skip-if = (toolkit == 'android') # Android: Bug 775227
|
||||
[test_find.html]
|
||||
skip-if = (toolkit == 'android') # Android: Bug 1465387
|
||||
[test_find_nac.html]
|
||||
@ -700,8 +690,6 @@ skip-if = (processor == 'aarch64' && os == 'win') # aarch64 due to 1530895
|
||||
[test_iframe_referrer_changing.html]
|
||||
[test_iframe_referrer_invalid.html]
|
||||
[test_Image_constructor.html]
|
||||
[test_img_referrer.html]
|
||||
skip-if = (verify && debug && (os == 'linux'))
|
||||
[test_innersize_scrollport.html]
|
||||
skip-if = (verify && (os == 'win' || os == 'mac'))
|
||||
[test_integer_attr_with_leading_zero.html]
|
||||
@ -781,7 +769,8 @@ tags = audiochannel
|
||||
[test_openDialogChromeOnly.html]
|
||||
tags = openwindow
|
||||
[test_plugin_freezing.html]
|
||||
skip-if = toolkit == 'android' || (os == 'win' && processor == 'aarch64') #CLICK_TO_PLAY, aarch64 due to 1538785
|
||||
skip-if = (os == 'win' && processor == 'aarch64')
|
||||
reason = Plugins are not supported on Windows/AArch64
|
||||
[test_pluginAudioNotification.html]
|
||||
tags = audiochannel
|
||||
skip-if = toolkit == 'android' # Plugins don't work on Android
|
||||
@ -795,12 +784,9 @@ support-files = worker_postMessages.js
|
||||
support-files = file_receiveMessage.html
|
||||
[test_processing_instruction_update_stylesheet.xhtml]
|
||||
[test_progress_events_for_gzip_data.html]
|
||||
skip-if = tsan # Bug 1621323
|
||||
[test_range_bounds.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_reentrant_flush.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_referrer_redirect.html]
|
||||
skip-if = (verify && debug)
|
||||
[test_root_iframe.html]
|
||||
[test_screen_orientation.html]
|
||||
[test_script_loader_crossorigin_data_url.html]
|
||||
@ -830,13 +816,11 @@ skip-if = debug == false
|
||||
[test_textnode_normalize_in_selection.html]
|
||||
[test_textnode_split_in_selection.html]
|
||||
[test_timeout_clamp.html]
|
||||
skip-if = debug == true && toolkit == 'android' # Timing dependent, skip slow debug android builds
|
||||
[test_timer_flood.html]
|
||||
[test_title.html]
|
||||
support-files = file_title.xul
|
||||
[test_treewalker_nextsibling.xml]
|
||||
[test_user_select.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_viewport_metrics_on_landscape_content.html]
|
||||
support-files =
|
||||
file_viewport_metrics_on_landscape_content.html
|
||||
|
@ -10,11 +10,6 @@
|
||||
<iframe id="target-iframe"></iframe>
|
||||
<script type="application/javascript">
|
||||
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["network.disable.ipc.security", true]] });
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
let iframe = document.querySelector("#target-iframe");
|
||||
|
||||
|
@ -56,6 +56,36 @@ function delayByInterval(iterations) {
|
||||
});
|
||||
}
|
||||
|
||||
function testNestedIntervals() {
|
||||
return new Promise(resolve => {
|
||||
const runCount = 100;
|
||||
let counter = 0;
|
||||
let intervalId = 0;
|
||||
let prevInitTime = performance.now();
|
||||
let totalTime = 0;
|
||||
function intervalCallback() {
|
||||
let now = performance.now();
|
||||
let delay = now - prevInitTime;
|
||||
totalTime += delay;
|
||||
prevInitTime = now;
|
||||
clearInterval(intervalId);
|
||||
if (++counter < runCount) {
|
||||
intervalId = setInterval(intervalCallback, 0);
|
||||
} else {
|
||||
// Delays should be clamped to 4ms after the initial calls, but allow
|
||||
// some fuzziness, so divide by 2.
|
||||
let expectedTime = runCount * 4 / 2;
|
||||
ok(totalTime > expectedTime, "Should not run callbacks too fast.");
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
|
||||
// Use the timeout value defined in the spec, 4ms.
|
||||
SpecialPowers.pushPrefEnv({ 'set': [["dom.min_timeout_value", 4]]},
|
||||
intervalCallback);
|
||||
});
|
||||
}
|
||||
|
||||
// Use a very long clamp delay to make it easier to measure the change
|
||||
// in automation. Some of our test servers are very slow and noisy.
|
||||
const clampDelayMS = 10000;
|
||||
@ -92,7 +122,7 @@ async function runTests() {
|
||||
|
||||
await clearNestingLevel();
|
||||
|
||||
// Verfy a setTimeout() chain will continue to clamp past the first
|
||||
// Verify a setTimeout() chain will continue to clamp past the first
|
||||
// expected iteration.
|
||||
const expectedDelay = (1 + expectedClampIteration) * clampDelayMS;
|
||||
|
||||
@ -105,7 +135,7 @@ async function runTests() {
|
||||
|
||||
await clearNestingLevel();
|
||||
|
||||
// Verfy setInterval() will continue to clamp past the first expected
|
||||
// Verify setInterval() will continue to clamp past the first expected
|
||||
// iteration.
|
||||
start = performance.now();
|
||||
await delayByTimeoutChain(2 * expectedClampIteration);
|
||||
@ -114,6 +144,8 @@ async function runTests() {
|
||||
|
||||
ok(delta >= expectedDelay, "setInterval() continued to clamp: " + stop + " - " + start + " = " + delta);
|
||||
|
||||
await testNestedIntervals();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -799,8 +799,8 @@ static JSObject* CreateInterfaceObject(
|
||||
unsigned ctorNargs, const NamedConstructor* namedConstructors,
|
||||
JS::Handle<JSObject*> proto, const NativeProperties* properties,
|
||||
const NativeProperties* chromeOnlyProperties, const char* name,
|
||||
bool isChrome, bool defineOnGlobal,
|
||||
const char* const* legacyWindowAliases) {
|
||||
bool isChrome, bool defineOnGlobal, const char* const* legacyWindowAliases,
|
||||
bool isNamespace) {
|
||||
JS::Rooted<JSObject*> constructor(cx);
|
||||
MOZ_ASSERT(constructorProto);
|
||||
MOZ_ASSERT(constructorClass);
|
||||
@ -810,21 +810,23 @@ static JSObject* CreateInterfaceObject(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!JS_DefineProperty(cx, constructor, "length", ctorNargs,
|
||||
JSPROP_READONLY)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!isNamespace) {
|
||||
if (!JS_DefineProperty(cx, constructor, "length", ctorNargs,
|
||||
JSPROP_READONLY)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Might as well intern, since we're going to need an atomized
|
||||
// version of name anyway when we stick our constructor on the
|
||||
// global.
|
||||
JS::Rooted<JSString*> nameStr(cx, JS_AtomizeAndPinString(cx, name));
|
||||
if (!nameStr) {
|
||||
return nullptr;
|
||||
}
|
||||
// Might as well intern, since we're going to need an atomized
|
||||
// version of name anyway when we stick our constructor on the
|
||||
// global.
|
||||
JS::Rooted<JSString*> nameStr(cx, JS_AtomizeAndPinString(cx, name));
|
||||
if (!nameStr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!JS_DefineProperty(cx, constructor, "name", nameStr, JSPROP_READONLY)) {
|
||||
return nullptr;
|
||||
if (!JS_DefineProperty(cx, constructor, "name", nameStr, JSPROP_READONLY)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (DOMIfaceAndProtoJSClass::FromJSClass(constructorClass)
|
||||
@ -929,7 +931,7 @@ static JSObject* CreateInterfacePrototypeObject(
|
||||
const NativeProperties* chromeOnlyProperties,
|
||||
const char* const* unscopableNames, bool isGlobal) {
|
||||
JS::Rooted<JSObject*> ourProto(
|
||||
cx, JS_NewObjectWithUniqueType(cx, protoClass, parentProto));
|
||||
cx, JS_NewObjectWithGivenProto(cx, protoClass, parentProto));
|
||||
if (!ourProto ||
|
||||
// We don't try to define properties on the global's prototype; those
|
||||
// properties go on the global itself.
|
||||
@ -1013,7 +1015,7 @@ void CreateInterfaceObjects(
|
||||
JS::Heap<JSObject*>* constructorCache, const NativeProperties* properties,
|
||||
const NativeProperties* chromeOnlyProperties, const char* name,
|
||||
bool defineOnGlobal, const char* const* unscopableNames, bool isGlobal,
|
||||
const char* const* legacyWindowAliases) {
|
||||
const char* const* legacyWindowAliases, bool isNamespace) {
|
||||
MOZ_ASSERT(protoClass || constructorClass, "Need at least one class!");
|
||||
MOZ_ASSERT(
|
||||
!((properties &&
|
||||
@ -1062,7 +1064,7 @@ void CreateInterfaceObjects(
|
||||
interface = CreateInterfaceObject(
|
||||
cx, global, constructorProto, constructorClass, ctorNargs,
|
||||
namedConstructors, proto, properties, chromeOnlyProperties, name,
|
||||
isChrome, defineOnGlobal, legacyWindowAliases);
|
||||
isChrome, defineOnGlobal, legacyWindowAliases, isNamespace);
|
||||
if (!interface) {
|
||||
if (protoCache) {
|
||||
// If we fail we need to make sure to clear the value of protoCache we
|
||||
@ -1136,14 +1138,15 @@ bool TryPreserveWrapper(JS::Handle<JSObject*> obj) {
|
||||
|
||||
// The addProperty hook for WebIDL classes does wrapper preservation, and
|
||||
// nothing else, so call it, if present.
|
||||
const DOMJSClass* domClass = GetDOMClass(obj);
|
||||
const JSClass* clasp = domClass->ToJSClass();
|
||||
JSAddPropertyOp addProperty = clasp->getAddProperty();
|
||||
|
||||
const JSClass* clasp = JS::GetClass(obj);
|
||||
const DOMJSClass* domClass = GetDOMClass(clasp);
|
||||
|
||||
// We expect all proxies to be nsISupports.
|
||||
MOZ_RELEASE_ASSERT(!clasp->isProxy(),
|
||||
MOZ_RELEASE_ASSERT(clasp->isNativeObject(),
|
||||
"Should not call addProperty for proxies.");
|
||||
|
||||
JSAddPropertyOp addProperty = clasp->getAddProperty();
|
||||
if (!addProperty) {
|
||||
return true;
|
||||
}
|
||||
@ -1164,10 +1167,11 @@ bool HasReleasedWrapper(JS::Handle<JSObject*> obj) {
|
||||
if (nsISupports* native = UnwrapDOMObjectToISupports(obj)) {
|
||||
CallQueryInterface(native, &cache);
|
||||
} else {
|
||||
const DOMJSClass* domClass = GetDOMClass(obj);
|
||||
const JSClass* clasp = JS::GetClass(obj);
|
||||
const DOMJSClass* domClass = GetDOMClass(clasp);
|
||||
|
||||
// We expect all proxies to be nsISupports.
|
||||
MOZ_RELEASE_ASSERT(!domClass->ToJSClass()->isProxy(),
|
||||
MOZ_RELEASE_ASSERT(clasp->isNativeObject(),
|
||||
"Should not call getWrapperCache for proxies.");
|
||||
|
||||
WrapperCacheGetter getter = domClass->mWrapperCacheGetter;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user