From ea44e60b7ed5f674b6de65fad669ac43a45438cc Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 18 Aug 2017 13:39:37 +0200 Subject: HTML - implement the labels attribute (follow up) --- dom/html/HTMLAllCollection.cpp | 7 ++++--- dom/html/HTMLDataListElement.cpp | 6 +++--- dom/html/HTMLDataListElement.h | 4 ++-- dom/html/HTMLFieldSetElement.cpp | 4 ++-- dom/html/HTMLFieldSetElement.h | 4 ++-- dom/html/HTMLSelectElement.cpp | 4 ++-- dom/html/HTMLSelectElement.h | 2 +- dom/html/HTMLTableRowElement.cpp | 4 ++-- dom/html/nsHTMLDocument.cpp | 36 ++++++++++++++++++------------------ dom/html/nsHTMLDocument.h | 11 ++++++----- 10 files changed, 42 insertions(+), 40 deletions(-) (limited to 'dom/html') diff --git a/dom/html/HTMLAllCollection.cpp b/dom/html/HTMLAllCollection.cpp index afa160e0c..6305cce31 100644 --- a/dom/html/HTMLAllCollection.cpp +++ b/dom/html/HTMLAllCollection.cpp @@ -8,6 +8,7 @@ #include "mozilla/dom/HTMLAllCollectionBinding.h" #include "mozilla/dom/Nullable.h" +#include "mozilla/dom/Element.h" #include "nsHTMLDocument.h" namespace mozilla { @@ -86,14 +87,14 @@ IsAllNamedElement(nsIContent* aContent) } static bool -DocAllResultMatch(nsIContent* aContent, int32_t aNamespaceID, nsIAtom* aAtom, +DocAllResultMatch(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - if (aContent->GetID() == aAtom) { + if (aElement->GetID() == aAtom) { return true; } - nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent); + nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aElement); if (!elm) { return false; } diff --git a/dom/html/HTMLDataListElement.cpp b/dom/html/HTMLDataListElement.cpp index d9ad4da09..5aa772645 100644 --- a/dom/html/HTMLDataListElement.cpp +++ b/dom/html/HTMLDataListElement.cpp @@ -35,11 +35,11 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement) NS_IMPL_ELEMENT_CLONE(HTMLDataListElement) bool -HTMLDataListElement::MatchOptions(nsIContent* aContent, int32_t aNamespaceID, +HTMLDataListElement::MatchOptions(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - return aContent->NodeInfo()->Equals(nsGkAtoms::option, kNameSpaceID_XHTML) && - !aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); + return aElement->NodeInfo()->Equals(nsGkAtoms::option, kNameSpaceID_XHTML) && + !aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); } } // namespace dom diff --git a/dom/html/HTMLDataListElement.h b/dom/html/HTMLDataListElement.h index e0aff818b..ba2a2e0b4 100644 --- a/dom/html/HTMLDataListElement.h +++ b/dom/html/HTMLDataListElement.h @@ -37,8 +37,8 @@ public: virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override; // This function is used to generate the nsContentList (option elements). - static bool MatchOptions(nsIContent* aContent, int32_t aNamespaceID, - nsIAtom* aAtom, void* aData); + static bool MatchOptions(Element* aElement, int32_t aNamespaceID, + nsIAtom* aAtom, void* aData); NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLDataListElement, nsGenericHTMLElement) diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp index 865d3c9cf..d72fd1061 100644 --- a/dom/html/HTMLFieldSetElement.cpp +++ b/dom/html/HTMLFieldSetElement.cpp @@ -120,10 +120,10 @@ HTMLFieldSetElement::GetType(nsAString& aType) /* static */ bool -HTMLFieldSetElement::MatchListedElements(nsIContent* aContent, int32_t aNamespaceID, +HTMLFieldSetElement::MatchListedElements(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - nsCOMPtr formControl = do_QueryInterface(aContent); + nsCOMPtr formControl = do_QueryInterface(aElement); return formControl; } diff --git a/dom/html/HTMLFieldSetElement.h b/dom/html/HTMLFieldSetElement.h index d169434ae..96fff4582 100644 --- a/dom/html/HTMLFieldSetElement.h +++ b/dom/html/HTMLFieldSetElement.h @@ -124,8 +124,8 @@ private: void NotifyElementsForFirstLegendChange(bool aNotify); // This function is used to generate the nsContentList (listed form elements). - static bool MatchListedElements(nsIContent* aContent, int32_t aNamespaceID, - nsIAtom* aAtom, void* aData); + static bool MatchListedElements(Element* aElement, int32_t aNamespaceID, + nsIAtom* aAtom, void* aData); // listed form controls elements. RefPtr mElements; diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp index 24ddabb65..53f42317a 100644 --- a/dom/html/HTMLSelectElement.cpp +++ b/dom/html/HTMLSelectElement.cpp @@ -735,12 +735,12 @@ HTMLSelectElement::SetLength(uint32_t aLength, ErrorResult& aRv) /* static */ bool -HTMLSelectElement::MatchSelectedOptions(nsIContent* aContent, +HTMLSelectElement::MatchSelectedOptions(Element* aElement, int32_t /* unused */, nsIAtom* /* unused */, void* /* unused*/) { - HTMLOptionElement* option = HTMLOptionElement::FromContent(aContent); + HTMLOptionElement* option = HTMLOptionElement::FromContent(aElement); return option && option->Selected(); } diff --git a/dom/html/HTMLSelectElement.h b/dom/html/HTMLSelectElement.h index d7e4350b4..8a25385de 100644 --- a/dom/html/HTMLSelectElement.h +++ b/dom/html/HTMLSelectElement.h @@ -247,7 +247,7 @@ public: mOptions->IndexedSetter(aIndex, aOption, aRv); } - static bool MatchSelectedOptions(nsIContent* aContent, int32_t, nsIAtom*, + static bool MatchSelectedOptions(Element* aElement, int32_t, nsIAtom*, void*); nsIHTMLCollection* SelectedOptions(); diff --git a/dom/html/HTMLTableRowElement.cpp b/dom/html/HTMLTableRowElement.cpp index 2dec9c883..ac2463400 100644 --- a/dom/html/HTMLTableRowElement.cpp +++ b/dom/html/HTMLTableRowElement.cpp @@ -120,10 +120,10 @@ HTMLTableRowElement::SectionRowIndex() const } static bool -IsCell(nsIContent *aContent, int32_t aNamespaceID, +IsCell(Element *aElement, int32_t aNamespaceID, nsIAtom* aAtom, void *aData) { - return aContent->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th); + return aElement->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th); } nsIHTMLCollection* diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 7d66aab04..fea78dc37 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1100,31 +1100,31 @@ nsHTMLDocument::Applets() } bool -nsHTMLDocument::MatchLinks(nsIContent *aContent, int32_t aNamespaceID, +nsHTMLDocument::MatchLinks(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - nsIDocument* doc = aContent->GetUncomposedDoc(); + nsIDocument* doc = aElement->GetUncomposedDoc(); if (doc) { - NS_ASSERTION(aContent->IsInUncomposedDoc(), + NS_ASSERTION(aElement->IsInUncomposedDoc(), "This method should never be called on content nodes that " "are not in a document!"); #ifdef DEBUG { nsCOMPtr htmldoc = - do_QueryInterface(aContent->GetUncomposedDoc()); + do_QueryInterface(aElement->GetUncomposedDoc()); NS_ASSERTION(htmldoc, "Huh, how did this happen? This should only be used with " "HTML documents!"); } #endif - mozilla::dom::NodeInfo *ni = aContent->NodeInfo(); + mozilla::dom::NodeInfo *ni = aElement->NodeInfo(); nsIAtom *localName = ni->NameAtom(); if (ni->NamespaceID() == kNameSpaceID_XHTML && (localName == nsGkAtoms::a || localName == nsGkAtoms::area)) { - return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::href); + return aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::href); } } @@ -1148,24 +1148,24 @@ nsHTMLDocument::Links() } bool -nsHTMLDocument::MatchAnchors(nsIContent *aContent, int32_t aNamespaceID, +nsHTMLDocument::MatchAnchors(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - NS_ASSERTION(aContent->IsInUncomposedDoc(), + NS_ASSERTION(aElement->IsInUncomposedDoc(), "This method should never be called on content nodes that " "are not in a document!"); #ifdef DEBUG { nsCOMPtr htmldoc = - do_QueryInterface(aContent->GetUncomposedDoc()); + do_QueryInterface(aElement->GetUncomposedDoc()); NS_ASSERTION(htmldoc, "Huh, how did this happen? This should only be used with " "HTML documents!"); } #endif - if (aContent->NodeInfo()->Equals(nsGkAtoms::a, kNameSpaceID_XHTML)) { - return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::name); + if (aElement->IsHTMLElement(nsGkAtoms::a)) { + return aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::name); } return false; @@ -1952,14 +1952,14 @@ nsHTMLDocument::Writeln(JSContext* cx, const Sequence& aText, } bool -nsHTMLDocument::MatchNameAttribute(nsIContent* aContent, int32_t aNamespaceID, +nsHTMLDocument::MatchNameAttribute(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - NS_PRECONDITION(aContent, "Must have content node to work with!"); + NS_PRECONDITION(aElement, "Must have element to work with!"); nsString* elementName = static_cast(aData); return - aContent->GetNameSpaceID() == kNameSpaceID_XHTML && - aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, + aElement->GetNameSpaceID() == kNameSpaceID_XHTML && + aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, *elementName, eCaseMatters); } @@ -2279,10 +2279,10 @@ nsHTMLDocument::GetForms() return mForms; } -static bool MatchFormControls(nsIContent* aContent, int32_t aNamespaceID, - nsIAtom* aAtom, void* aData) +static bool MatchFormControls(Element* aElement, int32_t aNamespaceID, + nsIAtom* aAtom, void* aData) { - return aContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL); + return aElement->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL); } nsContentList* diff --git a/dom/html/nsHTMLDocument.h b/dom/html/nsHTMLDocument.h index 2dbbf2b57..426ebddc5 100644 --- a/dom/html/nsHTMLDocument.h +++ b/dom/html/nsHTMLDocument.h @@ -261,12 +261,13 @@ protected: nsIContent *MatchId(nsIContent *aContent, const nsAString& aId); - static bool MatchLinks(nsIContent *aContent, int32_t aNamespaceID, + static bool MatchLinks(mozilla::dom::Element* aElement, int32_t aNamespaceID, + nsIAtom* aAtom, void* aData); + static bool MatchAnchors(mozilla::dom::Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData); - static bool MatchAnchors(nsIContent *aContent, int32_t aNamespaceID, - nsIAtom* aAtom, void* aData); - static bool MatchNameAttribute(nsIContent* aContent, int32_t aNamespaceID, - nsIAtom* aAtom, void* aData); + static bool MatchNameAttribute(mozilla::dom::Element* aElement, + int32_t aNamespaceID, + nsIAtom* aAtom, void* aData); static void* UseExistingNameString(nsINode* aRootNode, const nsString* aName); static void DocumentWriteTerminationFunc(nsISupports *aRef); -- cgit v1.2.3