Bug 1449669 - Remove IsNodeOfType. r=longsonr

Depends on D172893

Differential Revision: https://phabricator.services.mozilla.com/D172894
This commit is contained in:
Emilio Cobos Álvarez
2023-03-17 19:22:14 +00:00
parent f2b5cf8ba5
commit f69a397491
27 changed files with 25 additions and 85 deletions

View File

@@ -202,8 +202,6 @@ void Attr::SetTextContentInternal(const nsAString& aTextContent,
SetNodeValueInternal(aTextContent, aError);
}
bool Attr::IsNodeOfType(uint32_t aFlags) const { return false; }
void Attr::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
aVisitor.mCanHandle = true;
}

View File

@@ -67,8 +67,7 @@ class Attr final : public nsINode {
nsresult SetOwnerDocument(Document* aDocument);
// nsINode interface
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
nsIURI* GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
static void Initialize();

View File

@@ -163,8 +163,6 @@ class CharacterData : public nsIContent {
void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override {}
#endif
bool IsNodeOfType(uint32_t aFlags) const override { return false; }
nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const override {
RefPtr<CharacterData> result = CloneDataNode(aNodeInfo, true);
result.forget(aResult);

View File

@@ -7135,8 +7135,6 @@ Element* Document::GetEmbedderElement() const {
return nullptr;
}
bool Document::IsNodeOfType(uint32_t aFlags) const { return false; }
Element* Document::GetRootElement() const {
return (mCachedRootElement && mCachedRootElement->GetParentNode() == this)
? mCachedRootElement

View File

@@ -727,7 +727,6 @@ class Document : public nsINode,
virtual bool SuppressParserErrorConsoleMessages() { return false; }
// nsINode
bool IsNodeOfType(uint32_t aFlags) const final;
void InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify, ErrorResult& aRv) override;
void RemoveChildNode(nsIContent* aKid, bool aNotify) final;

View File

@@ -28,8 +28,6 @@ JSObject* DocumentFragment::WrapNode(JSContext* aCx,
return DocumentFragment_Binding::Wrap(aCx, this, aGivenProto);
}
bool DocumentFragment::IsNodeOfType(uint32_t aFlags) const { return false; }
#ifdef MOZ_DOM_LIST
void DocumentFragment::List(FILE* out, int32_t aIndent) const {
int32_t indent;

View File

@@ -59,8 +59,6 @@ class DocumentFragment : public FragmentOrElement {
virtual JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
virtual bool IsNodeOfType(uint32_t aFlags) const override;
nsresult BindToTree(BindContext&, nsINode& aParent) override {
NS_ASSERTION(false, "Trying to bind a fragment to a tree");
return NS_ERROR_NOT_IMPLEMENTED;
@@ -70,7 +68,7 @@ class DocumentFragment : public FragmentOrElement {
NS_ASSERTION(false, "Trying to unbind a fragment from a tree");
}
virtual Element* GetNameSpaceElement() override { return nullptr; }
Element* GetNameSpaceElement() override { return nullptr; }
Element* GetHost() const { return mHost; }

View File

@@ -55,8 +55,6 @@ DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
DocumentType::~DocumentType() = default;
bool DocumentType::IsNodeOfType(uint32_t aFlags) const { return false; }
const nsTextFragment* DocumentType::GetText() { return nullptr; }
void DocumentType::GetName(nsAString& aName) const { aName = NodeName(); }

View File

@@ -34,12 +34,11 @@ class DocumentType final : public CharacterData {
NS_INLINE_DECL_REFCOUNTING_INHERITED(DocumentType, CharacterData)
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual void GetNodeValueInternal(nsAString& aNodeValue) override {
void GetNodeValueInternal(nsAString& aNodeValue) override {
SetDOMStringToNull(aNodeValue);
}
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
mozilla::ErrorResult& aError) override {}
void SetNodeValueInternal(const nsAString& aNodeValue,
mozilla::ErrorResult& aError) override {}
// nsIContent overrides
virtual const nsTextFragment* GetText() override;

View File

@@ -2191,8 +2191,6 @@ bool Element::ShouldBlur(nsIContent* aContent) {
return false;
}
bool Element::IsNodeOfType(uint32_t aFlags) const { return false; }
/* static */
nsresult Element::DispatchEvent(nsPresContext* aPresContext,
WidgetEvent* aEvent, nsIContent* aTarget,

View File

@@ -1073,8 +1073,6 @@ class Element : public FragmentOrElement {
*/
uint32_t GetAttrCount() const { return mAttrs.AttrCount(); }
virtual bool IsNodeOfType(uint32_t aFlags) const override;
/**
* Get the class list of this element (this corresponds to the value of the
* class attribute). This may be null if there are no classes, but that's not

View File

@@ -7326,8 +7326,6 @@ void nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
// firstChild is either text or a <br> (hence an element).
MOZ_ASSERT_IF(firstChild, firstChild->IsText() || firstChild->IsElement());
#endif
// Testing IsElement() is faster than testing IsNodeOfType(), since it's
// non-virtual.
if (!firstChild || firstChild->IsElement()) {
// No text node, so everything is 0
startOffset = endOffset = 0;

View File

@@ -3883,7 +3883,7 @@ nsDOMWindowUtils::IsNodeDisabledForEvents(nsINode* aNode, bool* aRetVal) {
*aRetVal = false;
nsINode* node = aNode;
while (node) {
if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
if (node->IsHTMLFormControlElement()) {
nsGenericHTMLElement* element = nsGenericHTMLElement::FromNode(node);
WidgetEvent event(true, eVoidEvent);
if (element && element->IsDisabledForEvents(&event)) {

View File

@@ -3106,7 +3106,7 @@ void nsFocusManager::MoveCaretToFocus(PresShell* aPresShell,
newRange->SelectNodeContents(*aContent, IgnoreErrors());
if (!aContent->GetFirstChild() ||
aContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
aContent->IsHTMLFormControlElement()) {
// If current focus node is a leaf, set range to before the
// node by using the parent as a container.
// This prevents it from appearing as selected.
@@ -3236,10 +3236,8 @@ nsresult nsFocusManager::GetSelectionLocation(Document* aDocument,
nsAutoString nodeValue;
startContent->GetAsText()->AppendTextTo(nodeValue);
bool isFormControl =
startContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL);
if (nodeValue.Length() == startOffset && !isFormControl &&
if (nodeValue.Length() == startOffset &&
!startContent->IsHTMLFormControlElement() &&
startContent != aDocument->GetRootElement()) {
// Yes, indeed we were at the end of the last node
nsCOMPtr<nsIFrameEnumerator> frameTraversal;

View File

@@ -389,24 +389,6 @@ class nsINode : public mozilla::dom::EventTarget {
virtual ~nsINode();
/**
* Bit-flags to pass (or'ed together) to IsNodeOfType()
*/
enum {
/** form control elements */
eHTML_FORM_CONTROL = 1 << 6,
};
/**
* API for doing a quick check if a content is of a given
* type, such as Text, Document, Comment ... Use this when you can instead of
* checking the tag.
*
* @param aFlags what types you want to test for (see above)
* @return whether the content matches ALL flags passed in
*/
virtual bool IsNodeOfType(uint32_t aFlags) const = 0;
bool IsContainerNode() const {
return IsElement() || IsDocument() || IsDocumentFragment();
}
@@ -441,6 +423,8 @@ class nsINode : public mozilla::dom::EventTarget {
return NodeType() == DOCUMENT_FRAGMENT_NODE;
}
virtual bool IsHTMLFormControlElement() const { return false; }
/**
* https://dom.spec.whatwg.org/#concept-tree-inclusive-descendant
*

View File

@@ -90,8 +90,6 @@ JSObject* nsTextNode::WrapNode(JSContext* aCx,
return Text_Binding::Wrap(aCx, this, aGivenProto);
}
bool nsTextNode::IsNodeOfType(uint32_t aFlags) const { return false; }
already_AddRefed<CharacterData> nsTextNode::CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
RefPtr<nsTextNode> it =

View File

@@ -41,13 +41,11 @@ class nsTextNode : public mozilla::dom::Text {
NS_DECL_ISUPPORTS_INHERITED
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual already_AddRefed<CharacterData> CloneDataNode(
already_AddRefed<CharacterData> CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;
nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength,
bool aNotify, nsIContent* aNextSibling);

View File

@@ -2497,10 +2497,6 @@ nsINode* nsGenericHTMLFormControlElement::GetScopeChainParent() const {
return mForm ? mForm : nsGenericHTMLElement::GetScopeChainParent();
}
bool nsGenericHTMLFormControlElement::IsNodeOfType(uint32_t aFlags) const {
return !(aFlags & ~eHTML_FORM_CONTROL);
}
void nsGenericHTMLFormControlElement::SaveSubtreeState() {
SaveState();

View File

@@ -1138,11 +1138,11 @@ class nsGenericHTMLFormControlElement : public nsGenericHTMLFormElement,
NS_DECL_ISUPPORTS_INHERITED
NS_IMPL_FROMNODE_HELPER(nsGenericHTMLFormControlElement,
IsNodeOfType(nsINode::eHTML_FORM_CONTROL))
IsHTMLFormControlElement())
// nsINode
nsINode* GetScopeChainParent() const override;
virtual bool IsNodeOfType(uint32_t aFlags) const override;
bool IsHTMLFormControlElement() const final { return true; }
// nsIContent
void SaveSubtreeState() override;

View File

@@ -611,7 +611,7 @@ void nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames) {
bool nsHTMLDocument::MatchFormControls(Element* aElement, int32_t aNamespaceID,
nsAtom* aAtom, void* aData) {
return aElement->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL);
return aElement->IsHTMLFormControlElement();
}
nsresult nsHTMLDocument::Clone(dom::NodeInfo* aNodeInfo,

View File

@@ -622,8 +622,6 @@ ElementState MathMLElement::IntrinsicState() const {
: ElementState());
}
bool MathMLElement::IsNodeOfType(uint32_t aFlags) const { return false; }
void MathMLElement::SetIncrementScriptLevel(bool aIncrementScriptLevel,
bool aNotify) {
if (aIncrementScriptLevel == mIncrementScriptLevel) return;

View File

@@ -64,8 +64,7 @@ class MathMLElement final : public MathMLElementBase,
MOZ_CAN_RUN_SCRIPT
nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const override;
virtual mozilla::dom::ElementState IntrinsicState() const override;
virtual bool IsNodeOfType(uint32_t aFlags) const override;
mozilla::dom::ElementState IntrinsicState() const override;
// Set during reflow as necessary. Does a style change notification,
// aNotify must be true.

View File

@@ -17,8 +17,6 @@ JSObject* CDATASection::WrapNode(JSContext* aCx,
return CDATASection_Binding::Wrap(aCx, this, aGivenProto);
}
bool CDATASection::IsNodeOfType(uint32_t aFlags) const { return false; }
already_AddRefed<CharacterData> CDATASection::CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;

View File

@@ -38,20 +38,17 @@ class CDATASection final : public Text {
NS_INLINE_DECL_REFCOUNTING_INHERITED(CDATASection, Text)
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual already_AddRefed<CharacterData> CloneDataNode(
already_AddRefed<CharacterData> CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override;
#ifdef MOZ_DOM_LIST
virtual void List(FILE* out, int32_t aIndent) const override;
virtual void DumpContent(FILE* out, int32_t aIndent,
bool aDumpAll) const override;
void List(FILE* out, int32_t aIndent) const override;
void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override;
#endif
protected:
virtual JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace mozilla::dom

View File

@@ -1087,8 +1087,6 @@ void nsXULElement::DoCommand() {
}
}
bool nsXULElement::IsNodeOfType(uint32_t aFlags) const { return false; }
nsresult nsXULElement::AddPopupListener(nsAtom* aName) {
// Add a popup listener to the element
bool isContext =

View File

@@ -371,9 +371,7 @@ class nsXULElement : public nsStyledElement {
MOZ_CAN_RUN_SCRIPT void ClickWithInputSource(uint16_t aInputSource,
bool aIsTrustedEvent);
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual bool IsFocusableInternal(int32_t* aTabIndex,
bool aWithMouse) override;
bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override;
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;

View File

@@ -333,8 +333,7 @@ struct MOZ_STACK_CLASS BidiParagraphData {
*/
for (nsIContent* content = aBlockFrame->GetContent(); content;
content = content->GetParent()) {
if (content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL) ||
content->IsXULElement()) {
if (content->IsXULElement() || content->IsHTMLFormControlElement()) {
mIsVisual = false;
break;
}