Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-09-06 09:18:37 +08:00
commit 8a8546f49f
12 changed files with 75 additions and 17 deletions

View file

@ -715,8 +715,6 @@ var interfaceNamesInGlobalScope =
"NodeList",
// IMPORTANT: Do not change this list without review from a DOM peer!
"Notification",
// IMPORTANT: Do not change this list without review from a DOM peer!
"NotifyPaintEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "OffscreenCanvas", disabled: true},
// IMPORTANT: Do not change this list without review from a DOM peer!

View file

@ -6,13 +6,18 @@
* For more information about this interface see nsIDOMNotifyPaintEvent.idl
*/
[ChromeOnly]
interface NotifyPaintEvent : Event
{
[ChromeOnly]
readonly attribute DOMRectList clientRects;
[ChromeOnly]
readonly attribute DOMRect boundingClientRect;
[ChromeOnly]
readonly attribute PaintRequestList paintRequests;
[ChromeOnly]
readonly attribute unsigned long long transactionId;
};

View file

@ -4143,8 +4143,15 @@ Parser<ParseHandler>::statementList(YieldHandling yieldHandling)
return null();
bool canHaveDirectives = pc->atBodyLevel();
if (canHaveDirectives)
if (canHaveDirectives) {
tokenStream.clearSawOctalEscape();
}
bool canHaveHashbangComment = pc->atTopLevel();
if (canHaveHashbangComment) {
tokenStream.consumeOptionalHashbangComment();
}
bool afterReturn = false;
bool warnedAboutStatementsAfterReturn = false;
uint32_t statementBegin = 0;

View file

@ -470,6 +470,12 @@ class ParseContext : public Nestable<ParseContext>
return atBodyLevel() && sc_->isModuleContext();
}
// True if we are at the topmost level of an entire script or module. For
// example, in the comment on |atBodyLevel()| above, we would encounter |f1|
// and the outermost |if (cond)| at top level, and everything else would not
// be at top level.
bool atTopLevel() { return atBodyLevel() && sc_->isTopLevelContext(); }
void setIsStandaloneFunctionBody() {
isStandaloneFunctionBody_ = true;
}

View file

@ -289,6 +289,16 @@ class SharedContext
bool isEvalContext() { return kind_ == Kind::Eval; }
inline EvalSharedContext* asEvalContext();
bool isTopLevelContext() const {
switch (kind_) {
case Kind::Module:
case Kind::Global:
case Kind::Eval:
return true;
}
return false;
}
ThisBinding thisBinding() const { return thisBinding_; }
bool hasModuleGoal() const { return hasModuleGoal_; }

View file

@ -1300,6 +1300,21 @@ TokenStream::putIdentInTokenbuf(const char16_t* identStart)
return true;
}
void
TokenStream::consumeOptionalHashbangComment() {
int c = userbuf.getRawChar();
if (c == '#') {
if (matchChar('!')) {
// Hashbang; ignore rest of line as comment.
while ((c = getChar()) != EOF && c != '\n')
continue;
}
}
ungetChar(c);
cursor = (cursor - 1) & ntokensMask;
}
enum FirstCharKind {
// A char16_t has the 'OneChar' kind if it, by itself, constitutes a valid
// token that cannot also be a prefix of a longer token. E.g. ';' has the

View file

@ -428,6 +428,13 @@ class MOZ_STACK_CLASS TokenStream
// asm.js reporter
void reportAsmJSError(uint32_t offset, unsigned errorNumber, ...);
/**
* Consume any hashbang comment at the start of a Script or Module, if one is
* present. Stops consuming just before any terminating LineTerminator or
* before an encoding error is encountered.
*/
void consumeOptionalHashbangComment();
JSAtom* getRawTemplateStringAtom() {
MOZ_ASSERT(currentToken().type == TOK_TEMPLATE_HEAD ||
currentToken().type == TOK_NO_SUBS_TEMPLATE);

View file

@ -188,21 +188,19 @@ FetchName(JSContext* cx, HandleObject obj, HandleObject obj2, HandlePropertyName
}
/* Take the slow path if shape was not found in a native object. */
if (!obj->isNative() || !obj2->isNative()) {
if (!obj->isNative() || !obj2->isNative() ||
obj->is<WithEnvironmentObject>()) {
Rooted<jsid> id(cx, NameToId(name));
if (!GetProperty(cx, obj, obj, id, vp))
return false;
} else {
RootedShape shape(cx, prop.shape());
RootedObject normalized(cx, obj);
if (normalized->is<WithEnvironmentObject>() && !shape->hasDefaultGetter())
normalized = &normalized->as<WithEnvironmentObject>().object();
if (shape->isDataDescriptor() && shape->hasDefaultGetter()) {
/* Fast path for Object instance properties. */
MOZ_ASSERT(shape->hasSlot());
vp.set(obj2->as<NativeObject>().getSlot(shape->slot()));
} else {
if (!NativeGetExistingProperty(cx, normalized, obj2.as<NativeObject>(), shape, vp))
if (!NativeGetExistingProperty(cx, obj, obj2.as<NativeObject>(), shape, vp))
return false;
}
}

View file

@ -1264,7 +1264,10 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
// about:memory may use that information
xpc::SetLocationForGlobal(sandbox, options.sandboxName);
xpc::SetSandboxMetadata(cx, sandbox, options.metadata);
nsresult rv = xpc::SetSandboxMetadata(cx, sandbox, options.metadata);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
JS_FireOnNewGlobalObject(cx, sandbox);

View file

@ -3111,7 +3111,7 @@ nsresult
GetSandboxMetadata(JSContext* cx, JS::HandleObject sandboxArg,
JS::MutableHandleValue rval);
nsresult
[[nodiscard]] nsresult
SetSandboxMetadata(JSContext* cx, JS::HandleObject sandboxArg,
JS::HandleValue metadata);

View file

@ -24,14 +24,19 @@ window.addEventListener("load", step0, false);
is(SpecialPowers.getBoolPref("dom.send_after_paint_to_content"), true, "pref defaults to true in mochitest harness");
function print_rect(rect) {
if (!rect) {
rect = { top: 0, left: 0, width: 0, right: 0 };
}
return "(top=" + rect.top + ",left=" + rect.left + ",width=" + rect.width + ",height=" + rect.height + ")";
}
function print_event(event) {
var res = "boundingClientRect=" + print_rect(event.boundingClientRect);
var rects = event.clientRects;
for (var i = 0; i < rects.length; ++i) {
res += " clientRects[" + i + "]=" + print_rect(rects[i]);
if (rects) {
for (var i = 0; i < rects.length; ++i) {
res += " clientRects[" + i + "]=" + print_rect(rects[i]);
}
}
return res;
}

View file

@ -10,11 +10,15 @@
function paintListener(event) {
if (event.target != window)
return;
var eventRect =
[ event.boundingClientRect.left,
event.boundingClientRect.top,
event.boundingClientRect.right,
event.boundingClientRect.bottom ];
var clientRect = event.boundingClientRect;
var eventRect;
if (clientRect) {
eventRect =
[ clientRect.left, clientRect.top,
clientRect.right, clientRect.bottom ];
} else {
eventRect = [ 0, 0, 0, 0 ];
}
if (debug) {
dump("got MozAfterPaint: " + eventRect.join(",") + "\n");
}