Bug 1673931 - Avoid including Element.h from header files.

Differential Revision: https://phabricator.services.mozilla.com/D96535

Depends on D96534
This commit is contained in:
Simon Giesecke 2020-11-23 16:08:40 +00:00
Родитель 071c7c035f
Коммит f15895390e
52 изменённых файлов: 286 добавлений и 227 удалений

Просмотреть файл

@ -1462,6 +1462,11 @@ bool aria::HasDefinedARIAHidden(nsIContent* aContent) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AttrIterator class // AttrIterator class
AttrIterator::AttrIterator(nsIContent* aContent)
: mElement(dom::Element::FromNode(aContent)), mAttrIdx(0) {
mAttrCount = mElement ? mElement->GetAttrCount() : 0;
}
bool AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue) { bool AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue) {
while (mAttrIdx < mAttrCount) { while (mAttrIdx < mAttrCount) {
const nsAttrName* attr = mElement->GetAttrNameAt(mAttrIdx); const nsAttrName* attr = mElement->GetAttrNameAt(mAttrIdx);

Просмотреть файл

@ -14,10 +14,13 @@
#include "nsAtom.h" #include "nsAtom.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "mozilla/dom/Element.h"
class nsINode; class nsINode;
namespace mozilla::dom {
class Element;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Value constants // Value constants
@ -276,10 +279,7 @@ bool HasDefinedARIAHidden(nsIContent* aContent);
*/ */
class AttrIterator { class AttrIterator {
public: public:
explicit AttrIterator(nsIContent* aContent) explicit AttrIterator(nsIContent* aContent);
: mElement(dom::Element::FromNode(aContent)), mAttrIdx(0) {
mAttrCount = mElement ? mElement->GetAttrCount() : 0;
}
bool Next(nsAString& aAttrName, nsAString& aAttrValue); bool Next(nsAString& aAttrName, nsAString& aAttrValue);

Просмотреть файл

@ -542,6 +542,12 @@ void nsCoreUtils::ScrollTo(PresShell* aPresShell, nsIContent* aContent,
ScrollFlags::ScrollOverflowHidden); ScrollFlags::ScrollOverflowHidden);
} }
bool nsCoreUtils::IsHTMLTableHeader(nsIContent* aContent) {
return aContent->NodeInfo()->Equals(nsGkAtoms::th) ||
(aContent->IsElement() &&
aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::scope));
}
bool nsCoreUtils::IsWhitespaceString(const nsAString& aString) { bool nsCoreUtils::IsWhitespaceString(const nsAString& aString) {
nsAString::const_char_iterator iterBegin, iterEnd; nsAString::const_char_iterator iterBegin, iterEnd;

Просмотреть файл

@ -7,7 +7,6 @@
#define nsCoreUtils_h_ #define nsCoreUtils_h_
#include "mozilla/EventForwards.h" #include "mozilla/EventForwards.h"
#include "mozilla/dom/Element.h"
#include "nsIAccessibleEvent.h" #include "nsIAccessibleEvent.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "mozilla/FlushType.h" #include "mozilla/FlushType.h"
@ -296,11 +295,7 @@ class nsCoreUtils {
/** /**
* Return true if the given node is table header element. * Return true if the given node is table header element.
*/ */
static bool IsHTMLTableHeader(nsIContent* aContent) { static bool IsHTMLTableHeader(nsIContent* aContent);
return aContent->NodeInfo()->Equals(nsGkAtoms::th) ||
(aContent->IsElement() && aContent->AsElement()->HasAttr(
kNameSpaceID_None, nsGkAtoms::scope));
}
/** /**
* Returns true if the given string is empty or contains whitespace symbols * Returns true if the given string is empty or contains whitespace symbols

Просмотреть файл

@ -2130,6 +2130,10 @@ nsIFrame* Accessible::GetFrame() const {
nsINode* Accessible::GetNode() const { return mContent; } nsINode* Accessible::GetNode() const { return mContent; }
dom::Element* Accessible::Elm() const {
return dom::Element::FromNodeOrNull(mContent);
}
void Accessible::Language(nsAString& aLanguage) { void Accessible::Language(nsAString& aLanguage) {
aLanguage.Truncate(); aLanguage.Truncate();

Просмотреть файл

@ -11,8 +11,6 @@
#include "mozilla/a11y/Role.h" #include "mozilla/a11y/Role.h"
#include "mozilla/a11y/States.h" #include "mozilla/a11y/States.h"
#include "mozilla/dom/Element.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsIContent.h" #include "nsIContent.h"
@ -25,6 +23,10 @@ struct nsRoleMapEntry;
class nsIFrame; class nsIFrame;
class nsIPersistentProperties; class nsIPersistentProperties;
namespace mozilla::dom {
class Element;
}
namespace mozilla { namespace mozilla {
namespace a11y { namespace a11y {
@ -161,7 +163,7 @@ class Accessible : public nsISupports {
virtual nsINode* GetNode() const; virtual nsINode* GetNode() const;
nsIContent* GetContent() const { return mContent; } nsIContent* GetContent() const { return mContent; }
dom::Element* Elm() const { return dom::Element::FromNodeOrNull(mContent); } dom::Element* Elm() const;
/** /**
* Return node type information of DOM node associated with the accessible. * Return node type information of DOM node associated with the accessible.

Просмотреть файл

@ -11,10 +11,13 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/BasePrincipal.h" #include "mozilla/BasePrincipal.h"
#include "nsIWeakReferenceUtils.h" #include "nsIWeakReferenceUtils.h"
#include "mozilla/dom/Element.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsILoadContext.h" #include "nsILoadContext.h"
namespace mozilla::dom {
class Element;
}
namespace mozilla { namespace mozilla {
/** /**

Просмотреть файл

@ -10,13 +10,16 @@
# include "nsCOMPtr.h" # include "nsCOMPtr.h"
#endif #endif
#include "mozilla/HTMLEditor.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
class nsIDocShell; class nsIDocShell;
class nsEditingSession; class nsEditingSession;
namespace mozilla {
class HTMLEditor;
}
class nsDocShellEditorData { class nsDocShellEditorData {
public: public:
explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell); explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);

Просмотреть файл

@ -44,6 +44,11 @@ JSObject* CSSPseudoElement::WrapObject(JSContext* aCx,
return CSSPseudoElement_Binding::Wrap(aCx, this, aGivenProto); return CSSPseudoElement_Binding::Wrap(aCx, this, aGivenProto);
} }
already_AddRefed<dom::Element> CSSPseudoElement::Element() const {
RefPtr<dom::Element> retVal(mOriginatingElement);
return retVal.forget();
}
/* static */ /* static */
already_AddRefed<CSSPseudoElement> CSSPseudoElement::GetCSSPseudoElement( already_AddRefed<CSSPseudoElement> CSSPseudoElement::GetCSSPseudoElement(
dom::Element* aElement, PseudoStyleType aType) { dom::Element* aElement, PseudoStyleType aType) {

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Element.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "nsCSSPseudoElements.h" #include "nsCSSPseudoElements.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
@ -49,10 +48,7 @@ class CSSPseudoElement final : public nsWrapperCache {
aRetVal.Append( aRetVal.Append(
nsDependentAtomString(nsCSSPseudoElements::GetPseudoAtom(mPseudoType))); nsDependentAtomString(nsCSSPseudoElements::GetPseudoAtom(mPseudoType)));
} }
already_AddRefed<dom::Element> Element() const { already_AddRefed<dom::Element> Element() const;
RefPtr<dom::Element> retVal(mOriginatingElement);
return retVal.forget();
}
// Given an element:pseudoType pair, returns the CSSPseudoElement stored as a // Given an element:pseudoType pair, returns the CSSPseudoElement stored as a
// property on |aElement|. If there is no CSSPseudoElement for the specified // property on |aElement|. If there is no CSSPseudoElement for the specified

Просмотреть файл

@ -1090,6 +1090,11 @@ already_AddRefed<KeyframeEffect> KeyframeEffect::Constructor(
return effect.forget(); return effect.forget();
} }
already_AddRefed<Element> KeyframeEffect::GetTarget() const {
RefPtr<Element> ret = mTarget.mElement;
return ret.forget();
}
void KeyframeEffect::SetPseudoElement(const nsAString& aPseudoElement, void KeyframeEffect::SetPseudoElement(const nsAString& aPseudoElement,
ErrorResult& aRv) { ErrorResult& aRv) {
PseudoStyleType pseudoType = PseudoStyleType::NotPseudo; PseudoStyleType pseudoType = PseudoStyleType::NotPseudo;

Просмотреть файл

@ -29,7 +29,6 @@
#include "mozilla/StyleAnimationValue.h" #include "mozilla/StyleAnimationValue.h"
#include "mozilla/dom/AnimationEffect.h" #include "mozilla/dom/AnimationEffect.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Element.h"
struct JSContext; struct JSContext;
class JSObject; class JSObject;
@ -47,6 +46,7 @@ class ComputedStyle;
class PresShell; class PresShell;
namespace dom { namespace dom {
class Element;
class GlobalObject; class GlobalObject;
class UnrestrictedDoubleOrKeyframeAnimationOptions; class UnrestrictedDoubleOrKeyframeAnimationOptions;
class UnrestrictedDoubleOrKeyframeEffectOptions; class UnrestrictedDoubleOrKeyframeEffectOptions;
@ -142,10 +142,7 @@ class KeyframeEffect : public AnimationEffect {
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions, const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
ErrorResult& aRv); ErrorResult& aRv);
already_AddRefed<Element> GetTarget() const { already_AddRefed<Element> GetTarget() const;
RefPtr<Element> ret = mTarget.mElement;
return ret.forget();
}
NonOwningAnimationTarget GetAnimationTarget() const { NonOwningAnimationTarget GetAnimationTarget() const {
return NonOwningAnimationTarget(mTarget.mElement, mTarget.mPseudoType); return NonOwningAnimationTarget(mTarget.mElement, mTarget.mPseudoType);
} }

Просмотреть файл

@ -62,6 +62,10 @@ CharacterData::~CharacterData() {
} }
} }
Element* CharacterData::GetNameSpaceElement() {
return Element::FromNodeOrNull(GetParentNode());
}
NS_IMPL_CYCLE_COLLECTION_CLASS(CharacterData) NS_IMPL_CYCLE_COLLECTION_CLASS(CharacterData)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CharacterData) NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CharacterData)

Просмотреть файл

@ -17,13 +17,13 @@
#include "nsTextFragment.h" #include "nsTextFragment.h"
#include "nsError.h" #include "nsError.h"
#include "mozilla/dom/Element.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/ShadowRoot.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element;
class HTMLSlotElement; class HTMLSlotElement;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla
@ -215,9 +215,7 @@ class CharacterData : public nsIContent {
protected: protected:
virtual ~CharacterData(); virtual ~CharacterData();
Element* GetNameSpaceElement() final { Element* GetNameSpaceElement() final;
return Element::FromNodeOrNull(GetParentNode());
}
nsresult SetTextInternal( nsresult SetTextInternal(
uint32_t aOffset, uint32_t aCount, const char16_t* aBuffer, uint32_t aOffset, uint32_t aCount, const char16_t* aBuffer,

Просмотреть файл

@ -188,6 +188,8 @@ void IDTracker::Unlink() {
mReferencingImage = false; mReferencingImage = false;
} }
void IDTracker::ElementChanged(Element* aFrom, Element* aTo) { mElement = aTo; }
bool IDTracker::Observe(Element* aOldElement, Element* aNewElement, bool IDTracker::Observe(Element* aOldElement, Element* aNewElement,
void* aData) { void* aData) {
IDTracker* p = static_cast<IDTracker*>(aData); IDTracker* p = static_cast<IDTracker*>(aData);
@ -208,6 +210,23 @@ bool IDTracker::Observe(Element* aOldElement, Element* aNewElement,
return keepTracking; return keepTracking;
} }
IDTracker::ChangeNotification::ChangeNotification(IDTracker* aTarget,
Element* aFrom, Element* aTo)
: mozilla::Runnable("IDTracker::ChangeNotification"),
Notification(aTarget),
mFrom(aFrom),
mTo(aTo) {}
IDTracker::ChangeNotification::~ChangeNotification() = default;
void IDTracker::ChangeNotification::SetTo(Element* aTo) { mTo = aTo; }
void IDTracker::ChangeNotification::Clear() {
Notification::Clear();
mFrom = nullptr;
mTo = nullptr;
}
NS_IMPL_ISUPPORTS_INHERITED0(IDTracker::ChangeNotification, mozilla::Runnable) NS_IMPL_ISUPPORTS_INHERITED0(IDTracker::ChangeNotification, mozilla::Runnable)
NS_IMPL_ISUPPORTS(IDTracker::DocumentLoadNotification, nsIObserver) NS_IMPL_ISUPPORTS(IDTracker::DocumentLoadNotification, nsIObserver)

Просмотреть файл

@ -8,7 +8,7 @@
#define mozilla_dom_IDTracker_h_ #define mozilla_dom_IDTracker_h_
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/Element.h" #include "nsIObserver.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
class nsAtom; class nsAtom;
@ -21,6 +21,8 @@ namespace mozilla {
namespace dom { namespace dom {
class Document; class Document;
class DocumentOrShadowRoot;
class Element;
/** /**
* Class to track what element is referenced by a given ID. * Class to track what element is referenced by a given ID.
@ -94,7 +96,7 @@ class IDTracker {
* to call this superclass method to change mElement. This is called * to call this superclass method to change mElement. This is called
* at script-runnable time. * at script-runnable time.
*/ */
virtual void ElementChanged(Element* aFrom, Element* aTo) { mElement = aTo; } virtual void ElementChanged(Element* aFrom, Element* aTo);
/** /**
* Override this to convert from a single-shot notification to * Override this to convert from a single-shot notification to
@ -127,11 +129,7 @@ class IDTracker {
class ChangeNotification : public mozilla::Runnable, public Notification { class ChangeNotification : public mozilla::Runnable, public Notification {
public: public:
ChangeNotification(IDTracker* aTarget, Element* aFrom, Element* aTo) ChangeNotification(IDTracker* aTarget, Element* aFrom, Element* aTo);
: mozilla::Runnable("IDTracker::ChangeNotification"),
Notification(aTarget),
mFrom(aFrom),
mTo(aTo) {}
// We need to actually declare all of nsISupports, because // We need to actually declare all of nsISupports, because
// Notification inherits from it but doesn't declare it. // Notification inherits from it but doesn't declare it.
@ -143,15 +141,11 @@ class IDTracker {
} }
return NS_OK; return NS_OK;
} }
virtual void SetTo(Element* aTo) override { mTo = aTo; } void SetTo(Element* aTo) override;
virtual void Clear() override { void Clear() override;
Notification::Clear();
mFrom = nullptr;
mTo = nullptr;
}
protected: protected:
virtual ~ChangeNotification() = default; virtual ~ChangeNotification();
RefPtr<Element> mFrom; RefPtr<Element> mFrom;
RefPtr<Element> mTo; RefPtr<Element> mTo;

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_PopupBlocker_h #ifndef mozilla_dom_PopupBlocker_h
#define mozilla_dom_PopupBlocker_h #define mozilla_dom_PopupBlocker_h
#include "Element.h"
#include "mozilla/BasicEvents.h" #include "mozilla/BasicEvents.h"
class nsIPrincipal; class nsIPrincipal;

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_RangeUtils_h #ifndef mozilla_RangeUtils_h
#define mozilla_RangeUtils_h #define mozilla_RangeUtils_h
#include "Element.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "mozilla/RangeBoundary.h" #include "mozilla/RangeBoundary.h"
#include "nsIContent.h" #include "nsIContent.h"

Просмотреть файл

@ -172,9 +172,4 @@ class nsDOMAttributeMap final : public nsISupports, public nsWrapperCache {
Attr* GetAttribute(mozilla::dom::NodeInfo* aNodeInfo); Attr* GetAttribute(mozilla::dom::NodeInfo* aNodeInfo);
}; };
// XXX khuey yes this is strange. The bindings code needs to see this include,
// but if we pull it in at the top of the file we get a circular include
// problem.
#include "mozilla/dom/Element.h"
#endif /* nsDOMAttributeMap_h */ #endif /* nsDOMAttributeMap_h */

Просмотреть файл

@ -72,6 +72,36 @@ bool nsMutationReceiverBase::IsObservable(nsIContent* aContent) {
(Observer()->IsChrome() || !aContent->IsInNativeAnonymousSubtree()); (Observer()->IsChrome() || !aContent->IsInNativeAnonymousSubtree());
} }
bool nsMutationReceiverBase::ObservesAttr(nsINode* aRegisterTarget,
mozilla::dom::Element* aElement,
int32_t aNameSpaceID, nsAtom* aAttr) {
if (mParent) {
return mParent->ObservesAttr(aRegisterTarget, aElement, aNameSpaceID,
aAttr);
}
if (!Attributes() || (!Subtree() && aElement != Target()) ||
(Subtree() &&
aRegisterTarget->SubtreeRoot() != aElement->SubtreeRoot()) ||
!IsObservable(aElement)) {
return false;
}
if (AllAttributes()) {
return true;
}
if (aNameSpaceID != kNameSpaceID_None) {
return false;
}
nsTArray<RefPtr<nsAtom>>& filters = AttributeFilter();
for (size_t i = 0; i < filters.Length(); ++i) {
if (filters[i] == aAttr) {
return true;
}
}
return false;
}
NS_IMPL_ADDREF(nsMutationReceiver) NS_IMPL_ADDREF(nsMutationReceiver)
NS_IMPL_RELEASE(nsMutationReceiver) NS_IMPL_RELEASE(nsMutationReceiver)

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/Animation.h" #include "mozilla/dom/Animation.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/MutationEventBinding.h" #include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/dom/MutationObserverBinding.h" #include "mozilla/dom/MutationObserverBinding.h"
#include "mozilla/dom/Nullable.h" #include "mozilla/dom/Nullable.h"
@ -34,6 +33,10 @@ class nsIPrincipal;
class nsDOMMutationObserver; class nsDOMMutationObserver;
using mozilla::dom::MutationObservingInfo; using mozilla::dom::MutationObservingInfo;
namespace mozilla::dom {
class Element;
}
class nsDOMMutationRecord final : public nsISupports, public nsWrapperCache { class nsDOMMutationRecord final : public nsISupports, public nsWrapperCache {
virtual ~nsDOMMutationRecord() = default; virtual ~nsDOMMutationRecord() = default;
@ -247,33 +250,7 @@ class nsMutationReceiverBase : public nsStubAnimationObserver {
bool IsObservable(nsIContent* aContent); bool IsObservable(nsIContent* aContent);
bool ObservesAttr(nsINode* aRegisterTarget, mozilla::dom::Element* aElement, bool ObservesAttr(nsINode* aRegisterTarget, mozilla::dom::Element* aElement,
int32_t aNameSpaceID, nsAtom* aAttr) { int32_t aNameSpaceID, nsAtom* aAttr);
if (mParent) {
return mParent->ObservesAttr(aRegisterTarget, aElement, aNameSpaceID,
aAttr);
}
if (!Attributes() || (!Subtree() && aElement != Target()) ||
(Subtree() &&
aRegisterTarget->SubtreeRoot() != aElement->SubtreeRoot()) ||
!IsObservable(aElement)) {
return false;
}
if (AllAttributes()) {
return true;
}
if (aNameSpaceID != kNameSpaceID_None) {
return false;
}
nsTArray<RefPtr<nsAtom>>& filters = AttributeFilter();
for (size_t i = 0; i < filters.Length(); ++i) {
if (filters[i] == aAttr) {
return true;
}
}
return false;
}
// The target for the MutationObserver.observe() method. // The target for the MutationObserver.observe() method.
nsINode* mTarget; nsINode* mTarget;

Просмотреть файл

@ -16,7 +16,6 @@
#include "nsDOMString.h" #include "nsDOMString.h"
#include "nsWhitespaceTokenizer.h" #include "nsWhitespaceTokenizer.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/DOMTokenListSupportedTokens.h" #include "mozilla/dom/DOMTokenListSupportedTokens.h"
@ -24,6 +23,7 @@ namespace mozilla {
class ErrorResult; class ErrorResult;
namespace dom { namespace dom {
class DocGroup; class DocGroup;
class Element;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -2065,6 +2065,8 @@ bool nsFrameLoader::OwnerIsMozBrowserFrame() {
return browserFrame ? browserFrame->GetReallyIsBrowser() : false; return browserFrame ? browserFrame->GetReallyIsBrowser() : false;
} }
nsIContent* nsFrameLoader::GetParentObject() const { return mOwnerContent; }
void nsFrameLoader::AssertSafeToInit() { void nsFrameLoader::AssertSafeToInit() {
MOZ_DIAGNOSTIC_ASSERT(nsContentUtils::IsSafeToRunScript() || MOZ_DIAGNOSTIC_ASSERT(nsContentUtils::IsSafeToRunScript() ||
mOwnerContent->OwnerDoc()->IsStaticDocument(), mOwnerContent->OwnerDoc()->IsStaticDocument(),
@ -2668,6 +2670,14 @@ bool nsFrameLoader::TryRemoteBrowser() {
return false; return false;
} }
nsIFrame* nsFrameLoader::GetPrimaryFrameOfOwningContent() const {
return mOwnerContent ? mOwnerContent->GetPrimaryFrame() : nullptr;
}
Document* nsFrameLoader::GetOwnerDoc() const {
return mOwnerContent ? mOwnerContent->OwnerDoc() : nullptr;
}
bool nsFrameLoader::IsRemoteFrame() { bool nsFrameLoader::IsRemoteFrame() {
if (mIsRemoteFrame) { if (mIsRemoteFrame) {
MOZ_ASSERT(!GetDocShell(), "Found a remote frame with a DocShell"); MOZ_ASSERT(!GetDocShell(), "Found a remote frame with a DocShell");

Просмотреть файл

@ -21,7 +21,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Nullable.h" #include "mozilla/dom/Nullable.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/WindowProxyHolder.h" #include "mozilla/dom/WindowProxyHolder.h"
@ -61,6 +60,7 @@ namespace dom {
class ChromeMessageSender; class ChromeMessageSender;
class ContentParent; class ContentParent;
class Document; class Document;
class Element;
class TabListener; class TabListener;
class InProcessBrowserChildMessageManager; class InProcessBrowserChildMessageManager;
class MessageSender; class MessageSender;
@ -262,7 +262,7 @@ class nsFrameLoader final : public nsStubMutationObserver,
*/ */
bool OwnerIsMozBrowserFrame(); bool OwnerIsMozBrowserFrame();
nsIContent* GetParentObject() const { return mOwnerContent; } nsIContent* GetParentObject() const;
/** /**
* MessageManagerCallback methods that we override. * MessageManagerCallback methods that we override.
@ -313,17 +313,13 @@ class nsFrameLoader final : public nsStubMutationObserver,
* Return the primary frame for our owning content, or null if it * Return the primary frame for our owning content, or null if it
* can't be found. * can't be found.
*/ */
nsIFrame* GetPrimaryFrameOfOwningContent() const { nsIFrame* GetPrimaryFrameOfOwningContent() const;
return mOwnerContent ? mOwnerContent->GetPrimaryFrame() : nullptr;
}
/** /**
* Return the document that owns this, or null if we don't have * Return the document that owns this, or null if we don't have
* an owner. * an owner.
*/ */
Document* GetOwnerDoc() const { Document* GetOwnerDoc() const;
return mOwnerContent ? mOwnerContent->OwnerDoc() : nullptr;
}
/** /**
* Returns whether this frame is a remote frame. * Returns whether this frame is a remote frame.

Просмотреть файл

@ -16,7 +16,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "nsString.h" #include "nsString.h"
#include "mozilla/dom/Element.h"
namespace mozilla { namespace mozilla {
class DeclarationBlock; class DeclarationBlock;

Просмотреть файл

@ -8,7 +8,6 @@
#include "nsAtom.h" #include "nsAtom.h"
#include "nsHashKeys.h" #include "nsHashKeys.h"
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
#include "mozilla/dom/Element.h"
#include "nsTHashtable.h" #include "nsTHashtable.h"
class nsIContent; class nsIContent;
@ -20,7 +19,8 @@ class DeclarationBlock;
namespace mozilla::dom { namespace mozilla::dom {
class DocumentFragment; class DocumentFragment;
} // namespace mozilla::dom class Element;
}
/** /**
* See the documentation of nsIParserUtils::sanitize for documentation * See the documentation of nsIParserUtils::sanitize for documentation

Просмотреть файл

@ -8,7 +8,6 @@
#define mozilla_dom_Grid_h #define mozilla_dom_Grid_h
#include "GridArea.h" #include "GridArea.h"
#include "mozilla/dom/Element.h"
#include "nsGridContainerFrame.h" #include "nsGridContainerFrame.h"
#include "nsISupports.h" #include "nsISupports.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
@ -16,6 +15,7 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element;
class GridDimension; class GridDimension;
class Grid : public nsISupports, public nsWrapperCache { class Grid : public nsISupports, public nsWrapperCache {

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_HTMLFormControlsCollection_h #ifndef mozilla_dom_HTMLFormControlsCollection_h
#define mozilla_dom_HTMLFormControlsCollection_h #define mozilla_dom_HTMLFormControlsCollection_h
#include "mozilla/dom/Element.h" // DOMProxyHandler::getOwnPropertyDescriptor
#include "nsIHTMLCollection.h" #include "nsIHTMLCollection.h"
#include "nsInterfaceHashtable.h" #include "nsInterfaceHashtable.h"
#include "nsTArray.h" #include "nsTArray.h"
@ -20,6 +19,7 @@ class RefPtr;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element;
class HTMLFormElement; class HTMLFormElement;
class HTMLImageElement; class HTMLImageElement;
class OwningRadioNodeListOrElement; class OwningRadioNodeListOrElement;

Просмотреть файл

@ -707,6 +707,17 @@ nsresult FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
HTMLFormSubmission::HTMLFormSubmission(
nsIURI* aActionURL, const nsAString& aTarget,
mozilla::NotNull<const mozilla::Encoding*> aEncoding, Element* aSubmitter)
: mActionURL(aActionURL),
mTarget(aTarget),
mEncoding(aEncoding),
mSubmitter(aSubmitter),
mInitiatedFromUserInput(UserActivation::IsHandlingUserInput()) {
MOZ_COUNT_CTOR(HTMLFormSubmission);
}
EncodingFormSubmission::EncodingFormSubmission( EncodingFormSubmission::EncodingFormSubmission(
nsIURI* aActionURL, const nsAString& aTarget, nsIURI* aActionURL, const nsAString& aTarget,
NotNull<const Encoding*> aEncoding, Element* aSubmitter) NotNull<const Encoding*> aEncoding, Element* aSubmitter)

Просмотреть файл

@ -8,7 +8,6 @@
#define mozilla_dom_HTMLFormSubmission_h #define mozilla_dom_HTMLFormSubmission_h
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/UserActivation.h" #include "mozilla/dom/UserActivation.h"
#include "mozilla/dom/HTMLDialogElement.h" #include "mozilla/dom/HTMLDialogElement.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -25,6 +24,7 @@ namespace dom {
class Blob; class Blob;
class Directory; class Directory;
class Element;
class HTMLFormElement; class HTMLFormElement;
/** /**
@ -122,14 +122,7 @@ class HTMLFormSubmission {
*/ */
HTMLFormSubmission(nsIURI* aActionURL, const nsAString& aTarget, HTMLFormSubmission(nsIURI* aActionURL, const nsAString& aTarget,
mozilla::NotNull<const mozilla::Encoding*> aEncoding, mozilla::NotNull<const mozilla::Encoding*> aEncoding,
Element* aSubmitter) Element* aSubmitter);
: mActionURL(aActionURL),
mTarget(aTarget),
mEncoding(aEncoding),
mSubmitter(aSubmitter),
mInitiatedFromUserInput(UserActivation::IsHandlingUserInput()) {
MOZ_COUNT_CTOR(HTMLFormSubmission);
}
// The action url. // The action url.
nsCOMPtr<nsIURI> mActionURL; nsCOMPtr<nsIURI> mActionURL;

Просмотреть файл

@ -13,7 +13,6 @@
#include "mozilla/TextControlElement.h" #include "mozilla/TextControlElement.h"
#include "mozilla/TextEditor.h" #include "mozilla/TextEditor.h"
#include "mozilla/WeakPtr.h" #include "mozilla/WeakPtr.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLInputElementBinding.h" #include "mozilla/dom/HTMLInputElementBinding.h"
#include "mozilla/dom/Nullable.h" #include "mozilla/dom/Nullable.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
@ -32,6 +31,7 @@ class TextInputListener;
class TextInputSelectionController; class TextInputSelectionController;
namespace dom { namespace dom {
class Element;
class HTMLInputElement; class HTMLInputElement;
} // namespace dom } // namespace dom

Просмотреть файл

@ -12,7 +12,6 @@
#include "nsTArray.h" #include "nsTArray.h"
#include "nsString.h" #include "nsString.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "mozilla/dom/Element.h"
#include "js/friend/DOMProxy.h" // JS::ExpandoAndGeneration #include "js/friend/DOMProxy.h" // JS::ExpandoAndGeneration
#include "js/RootingAPI.h" // JS::Handle #include "js/RootingAPI.h" // JS::Handle

Просмотреть файл

@ -18,7 +18,6 @@
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/DOMRect.h" #include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/ValidityState.h" #include "mozilla/dom/ValidityState.h"
#include "mozilla/dom/Element.h"
class nsDOMTokenList; class nsDOMTokenList;
class nsIFormControlFrame; class nsIFormControlFrame;

Просмотреть файл

@ -10,7 +10,6 @@
#include "nsXULPrototypeDocument.h" #include "nsXULPrototypeDocument.h"
#include "mozilla/intl/Localization.h" #include "mozilla/intl/Localization.h"
#include "mozilla/dom/DOMLocalizationBinding.h" #include "mozilla/dom/DOMLocalizationBinding.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/L10nMutations.h" #include "mozilla/dom/L10nMutations.h"
#include "mozilla/dom/L10nOverlaysBinding.h" #include "mozilla/dom/L10nOverlaysBinding.h"
#include "mozilla/dom/LocalizationBinding.h" #include "mozilla/dom/LocalizationBinding.h"
@ -21,6 +20,7 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element;
class L10nMutations; class L10nMutations;
class DOMLocalization : public intl::Localization { class DOMLocalization : public intl::Localization {

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_l10n_L10nOverlays_h #ifndef mozilla_dom_l10n_L10nOverlays_h
#define mozilla_dom_l10n_L10nOverlays_h #define mozilla_dom_l10n_L10nOverlays_h
#include "mozilla/dom/Element.h"
#include "mozilla/dom/L10nOverlaysBinding.h" #include "mozilla/dom/L10nOverlaysBinding.h"
#include "mozilla/dom/LocalizationBinding.h" #include "mozilla/dom/LocalizationBinding.h"
@ -17,6 +16,7 @@ namespace mozilla {
namespace dom { namespace dom {
class DocumentFragment; class DocumentFragment;
class Element;
class L10nOverlays { class L10nOverlays {
public: public:

Просмотреть файл

@ -260,6 +260,20 @@ void ScriptLoadRequest::PrioritizeAsPreload() {
} }
} }
nsIScriptElement* ScriptLoadRequest::GetScriptElement() const {
nsCOMPtr<nsIScriptElement> scriptElement =
do_QueryInterface(mFetchOptions->mElement);
return scriptElement;
}
void ScriptLoadRequest::SetIsLoadRequest(nsIScriptElement* aElement) {
MOZ_ASSERT(aElement);
MOZ_ASSERT(!GetScriptElement());
MOZ_ASSERT(IsPreload());
mFetchOptions->mElement = do_QueryInterface(aElement);
mFetchOptions->mIsPreload = false;
}
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// ScriptLoadRequestList // ScriptLoadRequestList
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/Atomics.h" #include "mozilla/Atomics.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/CORSMode.h" #include "mozilla/CORSMode.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/SRIMetadata.h" #include "mozilla/dom/SRIMetadata.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
@ -30,6 +29,7 @@ class nsICacheInfoChannel;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element;
class ModuleLoadRequest; class ModuleLoadRequest;
class ScriptLoadRequestList; class ScriptLoadRequestList;
@ -248,11 +248,7 @@ class ScriptLoadRequest
enum ReferrerPolicy ReferrerPolicy() const { enum ReferrerPolicy ReferrerPolicy() const {
return mFetchOptions->mReferrerPolicy; return mFetchOptions->mReferrerPolicy;
} }
nsIScriptElement* GetScriptElement() const { nsIScriptElement* GetScriptElement() const;
nsCOMPtr<nsIScriptElement> scriptElement =
do_QueryInterface(mFetchOptions->mElement);
return scriptElement;
}
nsIPrincipal* TriggeringPrincipal() const { nsIPrincipal* TriggeringPrincipal() const {
return mFetchOptions->mTriggeringPrincipal; return mFetchOptions->mTriggeringPrincipal;
} }
@ -265,13 +261,7 @@ class ScriptLoadRequest
} }
// Make a preload request into an actual load request for the given element. // Make a preload request into an actual load request for the given element.
void SetIsLoadRequest(nsIScriptElement* aElement) { void SetIsLoadRequest(nsIScriptElement* aElement);
MOZ_ASSERT(aElement);
MOZ_ASSERT(!GetScriptElement());
MOZ_ASSERT(IsPreload());
mFetchOptions->mElement = do_QueryInterface(aElement);
mFetchOptions->mIsPreload = false;
}
FromParser GetParserCreated() const { FromParser GetParserCreated() const {
nsIScriptElement* element = GetScriptElement(); nsIScriptElement* element = GetScriptElement();

Просмотреть файл

@ -15,6 +15,9 @@
class nsIContent; class nsIContent;
namespace mozilla { namespace mozilla {
namespace dom {
class Element;
}
/** /**
* Struct: SMILTargetIdentifier * Struct: SMILTargetIdentifier

Просмотреть файл

@ -14,7 +14,6 @@
#include "nsICSSLoaderObserver.h" #include "nsICSSLoaderObserver.h"
#include "txStack.h" #include "txStack.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/Element.h"
class nsIContent; class nsIContent;
class nsAtom; class nsAtom;
@ -26,6 +25,7 @@ namespace mozilla {
namespace dom { namespace dom {
class Document; class Document;
class DocumentFragment; class DocumentFragment;
class Element;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -64,6 +64,48 @@ namespace mozilla {
namespace dom { namespace dom {
static LazyLogModule sXULBroadCastManager("XULBroadcastManager"); static LazyLogModule sXULBroadCastManager("XULBroadcastManager");
class XULBroadcastManager::nsDelayedBroadcastUpdate {
public:
nsDelayedBroadcastUpdate(Element* aBroadcaster, Element* aListener,
const nsAString& aAttr)
: mBroadcaster(aBroadcaster),
mListener(aListener),
mAttr(aAttr),
mSetAttr(false),
mNeedsAttrChange(false) {}
nsDelayedBroadcastUpdate(Element* aBroadcaster, Element* aListener,
nsAtom* aAttrName, const nsAString& aAttr,
bool aSetAttr, bool aNeedsAttrChange)
: mBroadcaster(aBroadcaster),
mListener(aListener),
mAttr(aAttr),
mAttrName(aAttrName),
mSetAttr(aSetAttr),
mNeedsAttrChange(aNeedsAttrChange) {}
nsDelayedBroadcastUpdate(const nsDelayedBroadcastUpdate& aOther) = delete;
nsDelayedBroadcastUpdate(nsDelayedBroadcastUpdate&& aOther) = default;
nsCOMPtr<Element> mBroadcaster;
nsCOMPtr<Element> mListener;
// Note if mAttrName isn't used, this is the name of the attr, otherwise
// this is the value of the attribute.
nsString mAttr;
RefPtr<nsAtom> mAttrName;
bool mSetAttr;
bool mNeedsAttrChange;
class Comparator {
public:
static bool Equals(const nsDelayedBroadcastUpdate& a,
const nsDelayedBroadcastUpdate& b) {
return a.mBroadcaster == b.mBroadcaster && a.mListener == b.mListener &&
a.mAttrName == b.mAttrName;
}
};
};
/* static */ /* static */
bool XULBroadcastManager::MayNeedListener(const Element& aElement) { bool XULBroadcastManager::MayNeedListener(const Element& aElement) {
if (aElement.NodeInfo()->Equals(nsGkAtoms::observes, kNameSpaceID_XUL)) { if (aElement.NodeInfo()->Equals(nsGkAtoms::observes, kNameSpaceID_XUL)) {

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_XULBroadcastManager_h #ifndef mozilla_dom_XULBroadcastManager_h
#define mozilla_dom_XULBroadcastManager_h #define mozilla_dom_XULBroadcastManager_h
#include "mozilla/dom/Element.h"
#include "nsAtom.h" #include "nsAtom.h"
#include "nsTArray.h" #include "nsTArray.h"
@ -75,47 +74,7 @@ class XULBroadcastManager final {
*/ */
PLDHashTable* mBroadcasterMap; PLDHashTable* mBroadcasterMap;
class nsDelayedBroadcastUpdate { class nsDelayedBroadcastUpdate;
public:
nsDelayedBroadcastUpdate(Element* aBroadcaster, Element* aListener,
const nsAString& aAttr)
: mBroadcaster(aBroadcaster),
mListener(aListener),
mAttr(aAttr),
mSetAttr(false),
mNeedsAttrChange(false) {}
nsDelayedBroadcastUpdate(Element* aBroadcaster, Element* aListener,
nsAtom* aAttrName, const nsAString& aAttr,
bool aSetAttr, bool aNeedsAttrChange)
: mBroadcaster(aBroadcaster),
mListener(aListener),
mAttr(aAttr),
mAttrName(aAttrName),
mSetAttr(aSetAttr),
mNeedsAttrChange(aNeedsAttrChange) {}
nsDelayedBroadcastUpdate(const nsDelayedBroadcastUpdate& aOther) = delete;
nsDelayedBroadcastUpdate(nsDelayedBroadcastUpdate&& aOther) = default;
nsCOMPtr<Element> mBroadcaster;
nsCOMPtr<Element> mListener;
// Note if mAttrName isn't used, this is the name of the attr, otherwise
// this is the value of the attribute.
nsString mAttr;
RefPtr<nsAtom> mAttrName;
bool mSetAttr;
bool mNeedsAttrChange;
class Comparator {
public:
static bool Equals(const nsDelayedBroadcastUpdate& a,
const nsDelayedBroadcastUpdate& b) {
return a.mBroadcaster == b.mBroadcaster && a.mListener == b.mListener &&
a.mAttrName == b.mAttrName;
}
};
};
nsTArray<nsDelayedBroadcastUpdate> mDelayedBroadcasters; nsTArray<nsDelayedBroadcastUpdate> mDelayedBroadcasters;
nsTArray<nsDelayedBroadcastUpdate> mDelayedAttrChangeBroadcasts; nsTArray<nsDelayedBroadcastUpdate> mDelayedAttrChangeBroadcasts;
bool mHandlingDelayedAttrChange; bool mHandlingDelayedAttrChange;

Просмотреть файл

@ -12,7 +12,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
@ -20,6 +19,7 @@ class nsIContent;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element;
class MouseEvent; class MouseEvent;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -14,7 +14,6 @@
#include "nsISerializable.h" #include "nsISerializable.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include <functional> #include <functional>
#include "mozilla/dom/Element.h"
class nsAtom; class nsAtom;
class nsIPrincipal; class nsIPrincipal;
@ -23,6 +22,10 @@ class nsNodeInfoManager;
class nsXULPrototypeElement; class nsXULPrototypeElement;
class nsXULPrototypePI; class nsXULPrototypePI;
namespace mozilla::dom {
class Element;
}
/** /**
* A "prototype" document that stores shared document information * A "prototype" document that stores shared document information
* for the XUL cache. * for the XUL cache.

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/EditorDOMPoint.h" #include "mozilla/EditorDOMPoint.h"
#include "mozilla/EditTransactionBase.h" #include "mozilla/EditTransactionBase.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/dom/Element.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
@ -19,6 +18,9 @@ class nsAtom;
* A transaction that creates a new node in the content tree. * A transaction that creates a new node in the content tree.
*/ */
namespace mozilla { namespace mozilla {
namespace dom {
class Element;
}
class EditorBase; class EditorBase;

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/AnonymousContent.h" #include "mozilla/dom/AnonymousContent.h"
#include "mozilla/dom/Element.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
#include "nsIFrame.h" // for WeakFrame only #include "nsIFrame.h" // for WeakFrame only
@ -26,6 +25,7 @@ struct nsPoint;
namespace mozilla { namespace mozilla {
class PresShell; class PresShell;
namespace dom { namespace dom {
class Element;
class Event; class Event;
} // namespace dom } // namespace dom

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/TextControlElement.h" #include "mozilla/TextControlElement.h"
#include "mozilla/dom/Element.h"
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
#include "nsIAnonymousContentCreator.h" #include "nsIAnonymousContentCreator.h"
#include "nsIContent.h" #include "nsIContent.h"

Просмотреть файл

@ -128,6 +128,14 @@ AnimationCollection<AnimationType>::GetPropertyAtomForPseudoType(
return propName; return propName;
} }
template <class AnimationType>
void AnimationCollection<AnimationType>::Destroy() {
mCalledDestroy = true;
// This will call our destructor.
mElement->RemoveProperty(mElementProperty);
}
// Explicit class instantiations // Explicit class instantiations
template class AnimationCollection<dom::CSSAnimation>; template class AnimationCollection<dom::CSSAnimation>;

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_AnimationCollection_h #ifndef mozilla_AnimationCollection_h
#define mozilla_AnimationCollection_h #define mozilla_AnimationCollection_h
#include "mozilla/dom/Element.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
@ -19,6 +18,9 @@ class nsIFrame;
class nsPresContext; class nsPresContext;
namespace mozilla { namespace mozilla {
namespace dom {
class Element;
}
// Traits class to define the specific atoms used when storing specializations // Traits class to define the specific atoms used when storing specializations
// of AnimationCollection as a property on an Element (e.g. which atom // of AnimationCollection as a property on an Element (e.g. which atom
@ -46,12 +48,7 @@ class AnimationCollection
LinkedListElement<SelfType>::remove(); LinkedListElement<SelfType>::remove();
} }
void Destroy() { void Destroy();
mCalledDestroy = true;
// This will call our destructor.
mElement->RemoveProperty(mElementProperty);
}
static void PropertyDtor(void* aObject, nsAtom* aPropertyName, static void PropertyDtor(void* aObject, nsAtom* aPropertyName,
void* aPropertyValue, void* aData); void* aPropertyValue, void* aData);

Просмотреть файл

@ -38,4 +38,50 @@ void ServoElementSnapshot::AddOtherPseudoClassState(const Element& aElement) {
mContains |= Flags::OtherPseudoClassState; mContains |= Flags::OtherPseudoClassState;
} }
void ServoElementSnapshot::AddAttrs(const Element& aElement,
int32_t aNameSpaceID, nsAtom* aAttribute) {
if (aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::_class) {
if (mClassAttributeChanged) {
return;
}
mClassAttributeChanged = true;
} else if (aAttribute == nsGkAtoms::id) {
if (mIdAttributeChanged) {
return;
}
mIdAttributeChanged = true;
}
}
if (!mChangedAttrNames.Contains(aAttribute)) {
mChangedAttrNames.AppendElement(aAttribute);
}
if (HasAttrs()) {
return;
}
uint32_t attrCount = aElement.GetAttrCount();
mAttrs.SetCapacity(attrCount);
for (uint32_t i = 0; i < attrCount; ++i) {
const BorrowedAttrInfo info = aElement.GetAttrInfoAt(i);
MOZ_ASSERT(info);
mAttrs.AppendElement(AttrArray::InternalAttr{*info.mName, *info.mValue});
}
mContains |= Flags::Attributes;
if (aElement.HasID()) {
mContains |= Flags::Id;
}
if (const nsAttrValue* classValue = aElement.GetClasses()) {
// FIXME(emilio): It's pretty unfortunate that this is only relevant for
// SVG, yet it's a somewhat expensive copy. We should be able to do
// better!
mClass = *classValue;
mContains |= Flags::MaybeClass;
}
}
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/EventStates.h" #include "mozilla/EventStates.h"
#include "mozilla/TypedEnumBits.h" #include "mozilla/TypedEnumBits.h"
#include "mozilla/dom/BorrowedAttrInfo.h" #include "mozilla/dom/BorrowedAttrInfo.h"
#include "mozilla/dom/Element.h"
#include "nsAttrName.h" #include "nsAttrName.h"
#include "nsAttrValue.h" #include "nsAttrValue.h"
#include "nsChangeHint.h" #include "nsChangeHint.h"
@ -19,6 +18,9 @@
#include "nsAtom.h" #include "nsAtom.h"
namespace mozilla { namespace mozilla {
namespace dom {
class Element;
}
/** /**
* A bitflags enum class used to determine what data does a ServoElementSnapshot * A bitflags enum class used to determine what data does a ServoElementSnapshot
@ -80,8 +82,7 @@ class ServoElementSnapshot {
* The attribute name and namespace are used to note which kind of attribute * The attribute name and namespace are used to note which kind of attribute
* has changed. * has changed.
*/ */
inline void AddAttrs(const Element&, int32_t aNameSpaceID, void AddAttrs(const Element&, int32_t aNameSpaceID, nsAtom* aAttribute);
nsAtom* aAttribute);
/** /**
* Captures some other pseudo-class matching state not included in * Captures some other pseudo-class matching state not included in
@ -167,53 +168,6 @@ class ServoElementSnapshot {
bool mIdAttributeChanged : 1; bool mIdAttributeChanged : 1;
}; };
inline void ServoElementSnapshot::AddAttrs(const Element& aElement,
int32_t aNameSpaceID,
nsAtom* aAttribute) {
if (aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::_class) {
if (mClassAttributeChanged) {
return;
}
mClassAttributeChanged = true;
} else if (aAttribute == nsGkAtoms::id) {
if (mIdAttributeChanged) {
return;
}
mIdAttributeChanged = true;
}
}
if (!mChangedAttrNames.Contains(aAttribute)) {
mChangedAttrNames.AppendElement(aAttribute);
}
if (HasAttrs()) {
return;
}
uint32_t attrCount = aElement.GetAttrCount();
mAttrs.SetCapacity(attrCount);
for (uint32_t i = 0; i < attrCount; ++i) {
const BorrowedAttrInfo info = aElement.GetAttrInfoAt(i);
MOZ_ASSERT(info);
mAttrs.AppendElement(AttrArray::InternalAttr{*info.mName, *info.mValue});
}
mContains |= Flags::Attributes;
if (aElement.HasID()) {
mContains |= Flags::Id;
}
if (const nsAttrValue* classValue = aElement.GetClasses()) {
// FIXME(emilio): It's pretty unfortunate that this is only relevant for
// SVG, yet it's a somewhat expensive copy. We should be able to do
// better!
mClass = *classValue;
mContains |= Flags::MaybeClass;
}
}
} // namespace mozilla } // namespace mozilla
#endif #endif

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/StyleColorInlines.h" #include "mozilla/StyleColorInlines.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "mozilla/dom/Element.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nscore.h" #include "nscore.h"

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/IDTracker.h" #include "mozilla/dom/IDTracker.h"
#include "FrameProperties.h" #include "FrameProperties.h"
#include "mozilla/dom/Element.h"
#include "nsID.h" #include "nsID.h"
#include "nsIFrame.h" // only for LayoutFrameType #include "nsIFrame.h" // only for LayoutFrameType
#include "nsIMutationObserver.h" #include "nsIMutationObserver.h"
@ -35,6 +34,7 @@ class SVGPaintServerFrame;
namespace dom { namespace dom {
class CanvasRenderingContext2D; class CanvasRenderingContext2D;
class Element;
class SVGGeometryElement; class SVGGeometryElement;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla