Skip to content

Commit

Permalink
68.14.2 - dom
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor committed Jun 1, 2024
1 parent 0d60764 commit e85fc6b
Show file tree
Hide file tree
Showing 268 changed files with 4,743 additions and 3,119 deletions.
6 changes: 3 additions & 3 deletions dom/animation/KeyframeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#include "jsapi.h" // For most JSAPI
#include "mozilla/ComputedStyle.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Move.h"
#include <utility>
#include "mozilla/RangedArray.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/ServoCSSParser.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/TimingParams.h"
#include "mozilla/dom/BaseKeyframeTypesBinding.h" // For FastBaseKeyframe etc.
#include "mozilla/dom/BindingCallContext.h"
Expand Down
1 change: 1 addition & 0 deletions dom/base/AnonymousContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "mozilla/PresShell.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/AnonymousContentBinding.h"
#include "nsComputedDOMStyle.h"
#include "nsCycleCollectionParticipant.h"
Expand Down
15 changes: 11 additions & 4 deletions dom/base/AnonymousContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@
#ifndef mozilla_dom_AnonymousContent_h
#define mozilla_dom_AnonymousContent_h

#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "nsCycleCollectionParticipant.h"
#include "nsICSSDeclaration.h"
#include "mozilla/dom/Document.h"

class nsIPrincipal;

namespace mozilla {
class ErrorResult;

namespace dom {

class Animation;
class DOMRect;
class DOMString;
class Element;
class Event;
template <typename T>
class Sequence;
class UnrestrictedDoubleOrAnonymousKeyframeAnimationOptions;
class UnrestrictedDoubleOrKeyframeAnimationOptions;

class AnonymousContent final {
public:
Expand Down
3 changes: 3 additions & 0 deletions dom/base/BodyConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "BodyConsumer.h"

#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/BlobImpl.h"
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "mozilla/dom/BodyUtil.h"
#include "mozilla/dom/File.h"
Expand All @@ -19,6 +20,8 @@
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "nsComponentManagerUtils.h"
#include "nsIFile.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsIStreamLoader.h"
#include "nsNetUtil.h"
Expand Down
6 changes: 2 additions & 4 deletions dom/base/BorrowedAttrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

#include "mozilla/dom/BorrowedAttrInfo.h"

namespace mozilla {
namespace dom {
namespace mozilla::dom {

BorrowedAttrInfo::BorrowedAttrInfo(const nsAttrName* aName,
const nsAttrValue* aValue)
Expand All @@ -18,5 +17,4 @@ BorrowedAttrInfo::BorrowedAttrInfo(const BorrowedAttrInfo& aOther)
MOZ_ASSERT_IF(mName, mValue);
}

} // namespace dom
} // namespace mozilla
} // namespace mozilla::dom
41 changes: 33 additions & 8 deletions dom/base/CustomElementRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/CustomElementRegistryBinding.h"
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/HTMLElementBinding.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/ShadowIncludingTreeIterator.h"
#include "mozilla/dom/XULElementBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/WebComponentsBinding.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/CustomEvent.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/AutoRestore.h"
#include "nsHTMLTags.h"
#include "jsapi.h"
#include "js/ForOfIterator.h" // JS::ForOfIterator
Expand Down Expand Up @@ -843,13 +846,15 @@ void CustomElementRegistry::Define(
auto callbacksHolder = MakeUnique<LifecycleCallbacks>();
nsTArray<RefPtr<nsAtom>> observedAttributes;
AutoTArray<RefPtr<nsAtom>, 2> disabledFeatures;
bool formAssociated = false;
bool disableInternals = false;
bool disableShadow = false;
{ // Set mIsCustomDefinitionRunning.
/**
* 9. Set this CustomElementRegistry's element definition is running flag.
*/
AutoSetRunningFlag as(this);
AutoRestore<bool> restoreRunning(mIsCustomDefinitionRunning);
mIsCustomDefinitionRunning = true;

/**
* 14.1. Let prototype be Get(constructor, "prototype"). Rethrow any
Expand Down Expand Up @@ -918,7 +923,7 @@ void CustomElementRegistry::Define(
* disabledFeaturesIterable to a sequence<DOMString>.
* Rethrow any exceptions from the conversion.
*/
if (StaticPrefs::dom_webcomponents_elementInternals_enabled()) {
if (StaticPrefs::dom_webcomponents_formAssociatedCustomElement_enabled()) {
if (!JSObjectToAtomArray(aCx, constructor,
NS_LITERAL_STRING("disabledFeatures"),
disabledFeatures, aRv)) {
Expand All @@ -934,6 +939,24 @@ void CustomElementRegistry::Define(
// "shadow".
disableShadow = disabledFeatures.Contains(
static_cast<nsStaticAtom*>(nsGkAtoms::shadow));

// 14.11. Let formAssociatedValue be Get(constructor, "formAssociated").
// Rethrow any exceptions.
JS::Rooted<JS::Value> formAssociatedValue(aCx);
if (!JS_GetProperty(aCx, constructor, "formAssociated",
&formAssociatedValue)) {
aRv.NoteJSContextException(aCx);
return;
}

// 14.12. Set formAssociated to the result of converting
// formAssociatedValue to a boolean. Rethrow any exceptions from
// the conversion.
if (!ValueToPrimitive<bool, eDefault>(
aCx, formAssociatedValue, "formAssociated", &formAssociated)) {
aRv.NoteJSContextException(aCx);
return;
}
}
} // Unset mIsCustomDefinitionRunning

Expand All @@ -956,7 +979,7 @@ void CustomElementRegistry::Define(

RefPtr<CustomElementDefinition> definition = new CustomElementDefinition(
nameAtom, localNameAtom, nameSpaceID, &aFunctionConstructor,
std::move(observedAttributes), std::move(callbacksHolder),
std::move(observedAttributes), std::move(callbacksHolder), formAssociated,
disableInternals, disableShadow);

CustomElementDefinition* def = definition.get();
Expand All @@ -981,7 +1004,7 @@ void CustomElementRegistry::Define(
RefPtr<Promise> promise;
mWhenDefinedPromiseMap.Remove(nameAtom, getter_AddRefs(promise));
if (promise) {
promise->MaybeResolveWithUndefined();
promise->MaybeResolve(def->mConstructor);
}

// Dispatch a "customelementdefined" event for DevTools.
Expand Down Expand Up @@ -1075,8 +1098,9 @@ already_AddRefed<Promise> CustomElementRegistry::WhenDefined(
return promise.forget();
}

if (mCustomDefinitions.GetWeak(nameAtom)) {
promise->MaybeResolve(JS::UndefinedHandleValue);
if (CustomElementDefinition* definition =
mCustomDefinitions.GetWeak(nameAtom)) {
promise->MaybeResolve(definition->mConstructor);
return promise.forget();
}

Expand Down Expand Up @@ -1459,14 +1483,15 @@ CustomElementDefinition::CustomElementDefinition(
nsAtom* aType, nsAtom* aLocalName, int32_t aNamespaceID,
CustomElementConstructor* aConstructor,
nsTArray<RefPtr<nsAtom>>&& aObservedAttributes,
UniquePtr<LifecycleCallbacks>&& aCallbacks, bool aDisableInternals,
bool aDisableShadow)
UniquePtr<LifecycleCallbacks>&& aCallbacks, bool aFormAssociated,
bool aDisableInternals, bool aDisableShadow)
: mType(aType),
mLocalName(aLocalName),
mNamespaceID(aNamespaceID),
mConstructor(aConstructor),
mObservedAttributes(std::move(aObservedAttributes)),
mCallbacks(std::move(aCallbacks)),
mFormAssociated(aFormAssociated),
mDisableInternals(aDisableInternals),
mDisableShadow(aDisableShadow) {}

Expand Down
22 changes: 6 additions & 16 deletions dom/base/CustomElementRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ struct CustomElementDefinition {
CustomElementConstructor* aConstructor,
nsTArray<RefPtr<nsAtom>>&& aObservedAttributes,
UniquePtr<LifecycleCallbacks>&& aCallbacks,
bool aDisableInternals, bool aDisableShadow);
bool aFormAssociated, bool aDisableInternals,
bool aDisableShadow);

// The type (name) for this custom element, for <button is="x-foo"> or <x-foo>
// this would be x-foo.
Expand All @@ -160,6 +161,10 @@ struct CustomElementDefinition {
// The lifecycle callbacks to call for this custom element.
UniquePtr<LifecycleCallbacks> mCallbacks;

// If this is true, user agent treats elements associated to this custom
// element definition as form-associated custom elements.
bool mFormAssociated = false;

// Determine whether to allow to attachInternals() for this custom element.
bool mDisableInternals = false;

Expand Down Expand Up @@ -537,21 +542,6 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
bool mIsCustomDefinitionRunning;

private:
class MOZ_RAII AutoSetRunningFlag final {
public:
explicit AutoSetRunningFlag(CustomElementRegistry* aRegistry)
: mRegistry(aRegistry) {
MOZ_ASSERT(!mRegistry->mIsCustomDefinitionRunning,
"IsCustomDefinitionRunning flag should be initially false");
mRegistry->mIsCustomDefinitionRunning = true;
}

~AutoSetRunningFlag() { mRegistry->mIsCustomDefinitionRunning = false; }

private:
CustomElementRegistry* mRegistry;
};

int32_t InferNamespace(JSContext* aCx, JS::Handle<JSObject*> constructor);

public:
Expand Down
20 changes: 11 additions & 9 deletions dom/base/DOMMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,12 @@ already_AddRefed<DOMMatrix> DOMMatrixReadOnly::FlipX() const {
if (mMatrix3D) {
gfx::Matrix4x4Double m;
m._11 = -1;
retval->mMatrix3D = new gfx::Matrix4x4Double(m * *mMatrix3D);
retval->mMatrix3D = MakeUnique<gfx::Matrix4x4Double>(m * *mMatrix3D);
} else {
gfx::MatrixDouble m;
m._11 = -1;
retval->mMatrix2D = new gfx::MatrixDouble(mMatrix2D ? m * *mMatrix2D : m);
retval->mMatrix2D =
MakeUnique<gfx::MatrixDouble>(mMatrix2D ? m * *mMatrix2D : m);
}

return retval.forget();
Expand All @@ -372,11 +373,12 @@ already_AddRefed<DOMMatrix> DOMMatrixReadOnly::FlipY() const {
if (mMatrix3D) {
gfx::Matrix4x4Double m;
m._22 = -1;
retval->mMatrix3D = new gfx::Matrix4x4Double(m * *mMatrix3D);
retval->mMatrix3D = MakeUnique<gfx::Matrix4x4Double>(m * *mMatrix3D);
} else {
gfx::MatrixDouble m;
m._22 = -1;
retval->mMatrix2D = new gfx::MatrixDouble(mMatrix2D ? m * *mMatrix2D : m);
retval->mMatrix2D =
MakeUnique<gfx::MatrixDouble>(mMatrix2D ? m * *mMatrix2D : m);
}

return retval.forget();
Expand Down Expand Up @@ -748,8 +750,8 @@ already_AddRefed<DOMMatrix> DOMMatrix::ReadStructuredClone(

void DOMMatrixReadOnly::Ensure3DMatrix() {
if (!mMatrix3D) {
mMatrix3D =
new gfx::Matrix4x4Double(gfx::Matrix4x4Double::From2D(*mMatrix2D));
mMatrix3D = MakeUnique<gfx::Matrix4x4Double>(
gfx::Matrix4x4Double::From2D(*mMatrix2D));
mMatrix2D = nullptr;
}
}
Expand Down Expand Up @@ -964,7 +966,7 @@ DOMMatrix* DOMMatrix::InvertSelf() {
} else if (!mMatrix2D->Invert()) {
mMatrix2D = nullptr;

mMatrix3D = new gfx::Matrix4x4Double();
mMatrix3D = MakeUnique<gfx::Matrix4x4Double>();
mMatrix3D->SetNAN();
}

Expand All @@ -989,7 +991,7 @@ DOMMatrixReadOnly* DOMMatrixReadOnly::SetMatrixValue(
if (!contains3dTransform) {
mMatrix3D = nullptr;
if (!mMatrix2D) {
mMatrix2D = new gfx::MatrixDouble();
mMatrix2D = MakeUnique<gfx::MatrixDouble>();
}

SetA(transform._11);
Expand All @@ -999,7 +1001,7 @@ DOMMatrixReadOnly* DOMMatrixReadOnly::SetMatrixValue(
SetE(transform._41);
SetF(transform._42);
} else {
mMatrix3D = new gfx::Matrix4x4Double(transform);
mMatrix3D = MakeUnique<gfx::Matrix4x4Double>(transform);
mMatrix2D = nullptr;
}

Expand Down
19 changes: 10 additions & 9 deletions dom/base/DOMMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "nsCycleCollectionParticipant.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/UniquePtr.h"
#include "nsCOMPtr.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/TypedArray.h"
Expand All @@ -37,20 +38,20 @@ class DOMMatrixReadOnly : public nsWrapperCache {
DOMMatrixReadOnly(nsISupports* aParent, const DOMMatrixReadOnly& other)
: mParent(aParent) {
if (other.mMatrix2D) {
mMatrix2D = new gfx::MatrixDouble(*other.mMatrix2D);
mMatrix2D = MakeUnique<gfx::MatrixDouble>(*other.mMatrix2D);
} else {
mMatrix3D = new gfx::Matrix4x4Double(*other.mMatrix3D);
mMatrix3D = MakeUnique<gfx::Matrix4x4Double>(*other.mMatrix3D);
}
}

DOMMatrixReadOnly(nsISupports* aParent, const gfx::Matrix4x4& aMatrix)
: mParent(aParent) {
mMatrix3D = new gfx::Matrix4x4Double(aMatrix);
mMatrix3D = MakeUnique<gfx::Matrix4x4Double>(aMatrix);
}

DOMMatrixReadOnly(nsISupports* aParent, const gfx::Matrix& aMatrix)
: mParent(aParent) {
mMatrix2D = new gfx::MatrixDouble(aMatrix);
mMatrix2D = MakeUnique<gfx::MatrixDouble>(aMatrix);
}

NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMMatrixReadOnly)
Expand Down Expand Up @@ -218,15 +219,15 @@ class DOMMatrixReadOnly : public nsWrapperCache {
JSStructuredCloneWriter* aWriter) const;
const gfx::MatrixDouble* GetInternal2D() const {
if (Is2D()) {
return mMatrix2D;
return mMatrix2D.get();
}
return nullptr;
}

protected:
nsCOMPtr<nsISupports> mParent;
nsAutoPtr<gfx::MatrixDouble> mMatrix2D;
nsAutoPtr<gfx::Matrix4x4Double> mMatrix3D;
UniquePtr<gfx::MatrixDouble> mMatrix2D;
UniquePtr<gfx::Matrix4x4Double> mMatrix3D;

virtual ~DOMMatrixReadOnly() = default;

Expand All @@ -243,9 +244,9 @@ class DOMMatrixReadOnly : public nsWrapperCache {

DOMMatrixReadOnly(nsISupports* aParent, bool is2D) : mParent(aParent) {
if (is2D) {
mMatrix2D = new gfx::MatrixDouble();
mMatrix2D = MakeUnique<gfx::MatrixDouble>();
} else {
mMatrix3D = new gfx::Matrix4x4Double();
mMatrix3D = MakeUnique<gfx::Matrix4x4Double>();
}
}

Expand Down
Loading

0 comments on commit e85fc6b

Please sign in to comment.