From 2affc5b4f0a2c83536ab8c7d1d1c0096f4f261f2 Mon Sep 17 00:00:00 2001 From: "jst%mozilla.jstenback.com" Date: Wed, 19 Nov 2003 01:20:56 +0000 Subject: [PATCH] Fixing bug 225837. DeCOMtaminating nsIContent more, making GetTag() return a weak raw pointer, and renaming GetTag() to Tag(), and making GetRangeList() return an const nsVoidArray*, and changing GetContentID() to return the id, and renaming it to ContentID(). r=jonas@sicking.cc, sr=bryner@brianryner.com. git-svn-id: svn://10.0.0.236/trunk@149527 18797224-902f-48f8-a5cc-f745e15eee43 --- .../accessible/src/msaa/nsAccessNodeWrap.cpp | 9 +- mozilla/content/base/public/nsContentCID.h | 5 - mozilla/content/base/public/nsIContent.h | 28 +- .../base/src/mozSanitizingSerializer.cpp | 50 +- .../base/src/mozSanitizingSerializer.h | 2 +- mozilla/content/base/src/nsCommentNode.cpp | 10 +- mozilla/content/base/src/nsContentUtils.cpp | 10 +- mozilla/content/base/src/nsCopySupport.cpp | 8 +- .../content/base/src/nsDOMDocumentType.cpp | 31 +- mozilla/content/base/src/nsDOMDocumentType.h | 13 +- mozilla/content/base/src/nsDocument.cpp | 7 +- .../content/base/src/nsDocumentEncoder.cpp | 103 ++--- mozilla/content/base/src/nsFrameLoader.cpp | 5 +- .../content/base/src/nsGenericDOMDataNode.cpp | 15 +- .../content/base/src/nsGenericDOMDataNode.h | 4 +- mozilla/content/base/src/nsGenericElement.cpp | 40 +- mozilla/content/base/src/nsGenericElement.h | 6 +- .../base/src/nsHTMLContentSerializer.cpp | 56 ++- .../base/src/nsPlainTextSerializer.cpp | 40 +- .../content/base/src/nsPlainTextSerializer.h | 2 +- mozilla/content/base/src/nsPrintEngine.cpp | 14 +- mozilla/content/base/src/nsRange.cpp | 15 +- mozilla/content/base/src/nsSelection.cpp | 81 ++-- mozilla/content/base/src/nsTextNode.cpp | 10 +- mozilla/content/base/src/nsTreeWalker.cpp | 2 +- .../base/src/nsXMLContentSerializer.cpp | 4 +- .../events/src/nsEventStateManager.cpp | 305 ++++++------ .../html/content/src/nsAttributeContent.cpp | 45 +- .../html/document/src/nsHTMLContentSink.cpp | 38 +- .../html/document/src/nsHTMLDocument.cpp | 26 +- .../html/style/src/nsCSSStyleSheet.cpp | 6 +- mozilla/content/xbl/src/nsBindingManager.cpp | 15 +- mozilla/content/xbl/src/nsXBLBinding.cpp | 22 +- .../content/xbl/src/nsXBLPrototypeBinding.cpp | 38 +- mozilla/content/xbl/src/nsXBLService.cpp | 33 +- .../xml/content/src/nsXMLCDATASection.cpp | 10 +- .../src/nsXMLProcessingInstruction.cpp | 8 +- .../content/src/nsXMLProcessingInstruction.h | 2 +- .../xml/document/src/nsXMLContentSink.cpp | 14 +- .../xml/document/src/nsXMLDocument.cpp | 2 +- .../content/xul/content/src/nsXULElement.cpp | 97 ++-- .../content/xul/content/src/nsXULElement.h | 6 +- .../xul/content/src/nsXULPopupListener.cpp | 22 +- .../content/xul/document/src/nsElementMap.cpp | 48 +- .../xul/document/src/nsXULDocument.cpp | 64 +-- .../templates/src/nsContentTagTestNode.cpp | 6 +- .../xul/templates/src/nsContentTestNode.cpp | 19 +- .../xul/templates/src/nsXULContentBuilder.cpp | 129 ++---- .../xul/templates/src/nsXULSortService.cpp | 126 ++--- .../templates/src/nsXULTemplateBuilder.cpp | 28 +- .../composer/src/nsComposeTxtSrvFilter.cpp | 39 +- mozilla/editor/libeditor/base/nsEditor.cpp | 36 +- mozilla/editor/libeditor/base/nsEditor.h | 7 +- .../editor/libeditor/html/nsHTMLCSSUtils.cpp | 8 +- .../editor/libeditor/html/nsHTMLEditor.cpp | 38 +- .../editor/libeditor/html/nsTableEditor.cpp | 8 +- .../txtsvc/src/nsTextServicesDocument.cpp | 67 ++- .../browser/webBrowser/nsContextMenuInfo.cpp | 31 +- .../webBrowser/nsDocShellTreeOwner.cpp | 433 ++++++++++-------- .../embedding/components/find/src/nsFind.cpp | 78 ++-- .../source/xpath/txMozillaXPathTreeWalker.cpp | 4 +- .../source/xslt/txMozillaXMLOutput.cpp | 6 +- .../typeaheadfind/src/nsTypeAheadFind.cpp | 8 +- mozilla/gfx/src/gtk/nsNativeThemeGTK.cpp | 8 +- mozilla/layout/base/nsCSSFrameConstructor.cpp | 164 +++---- mozilla/layout/base/nsCSSRendering.cpp | 109 +++-- mozilla/layout/base/nsFrameManager.cpp | 4 +- mozilla/layout/base/nsPresShell.cpp | 5 +- mozilla/layout/base/src/nsCopySupport.cpp | 8 +- mozilla/layout/build/nsLayoutModule.cpp | 6 - mozilla/layout/forms/nsFileControlFrame.cpp | 19 +- .../layout/forms/nsGfxButtonControlFrame.cpp | 21 +- mozilla/layout/forms/nsTextControlFrame.cpp | 20 +- mozilla/layout/generic/nsAreaFrame.cpp | 15 +- mozilla/layout/generic/nsFrame.cpp | 24 +- mozilla/layout/generic/nsFrame.h | 8 +- mozilla/layout/generic/nsFrameFrame.cpp | 12 +- mozilla/layout/generic/nsFrameSetFrame.cpp | 15 +- mozilla/layout/generic/nsHTMLReflowState.cpp | 6 +- mozilla/layout/generic/nsImageFrame.cpp | 11 +- mozilla/layout/generic/nsInlineFrame.cpp | 8 +- mozilla/layout/generic/nsLineLayout.cpp | 30 +- mozilla/layout/generic/nsObjectFrame.cpp | 76 ++- mozilla/layout/generic/nsSelection.cpp | 81 ++-- mozilla/layout/html/base/src/nsAreaFrame.cpp | 15 +- mozilla/layout/html/base/src/nsFrame.cpp | 24 +- mozilla/layout/html/base/src/nsFrame.h | 8 +- .../layout/html/base/src/nsFrameManager.cpp | 4 +- .../html/base/src/nsHTMLReflowState.cpp | 6 +- mozilla/layout/html/base/src/nsImageFrame.cpp | 11 +- .../layout/html/base/src/nsInlineFrame.cpp | 8 +- mozilla/layout/html/base/src/nsLineLayout.cpp | 30 +- .../layout/html/base/src/nsObjectFrame.cpp | 76 ++- mozilla/layout/html/base/src/nsPresShell.cpp | 5 +- .../layout/html/document/src/nsFrameFrame.cpp | 12 +- .../html/document/src/nsFrameSetFrame.cpp | 15 +- .../html/forms/src/nsFileControlFrame.cpp | 19 +- .../forms/src/nsGfxButtonControlFrame.cpp | 21 +- .../html/forms/src/nsTextControlFrame.cpp | 20 +- .../html/style/src/nsCSSFrameConstructor.cpp | 164 +++---- .../layout/html/style/src/nsCSSRendering.cpp | 109 +++-- .../base/src/nsMathMLContainerFrame.cpp | 18 +- .../layout/mathml/base/src/nsMathMLFrame.cpp | 5 +- .../mathml/base/src/nsMathMLTokenFrame.cpp | 8 +- .../base/src/nsMathMLmmultiscriptsFrame.cpp | 9 +- mozilla/layout/printing/nsPrintEngine.cpp | 14 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 6 +- mozilla/layout/xul/base/src/nsBoxFrame.cpp | 11 +- .../layout/xul/base/src/nsFrameNavigator.cpp | 18 +- .../layout/xul/base/src/nsFrameNavigator.h | 2 - .../xul/base/src/nsListBoxBodyFrame.cpp | 36 +- .../layout/xul/base/src/nsListBoxObject.cpp | 4 +- .../layout/xul/base/src/nsMenuBarFrame.cpp | 11 +- mozilla/layout/xul/base/src/nsMenuFrame.cpp | 11 +- .../layout/xul/base/src/nsMenuPopupFrame.cpp | 42 +- .../xul/base/src/nsNativeScrollbarFrame.cpp | 6 +- .../layout/xul/base/src/nsPopupSetFrame.cpp | 23 +- .../xul/base/src/nsScrollbarButtonFrame.cpp | 18 +- .../layout/xul/base/src/nsSplitterFrame.cpp | 4 +- .../xul/base/src/nsXULTooltipListener.cpp | 13 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 50 +- .../xul/base/src/tree/src/nsTreeBoxObject.cpp | 9 +- .../xul/base/src/tree/src/nsTreeColFrame.cpp | 5 +- .../base/src/tree/src/nsTreeContentView.cpp | 155 +++---- .../xul/base/src/tree/src/nsTreeUtils.cpp | 8 +- .../webshell/tests/viewer/nsWebCrawler.cpp | 3 +- mozilla/widget/src/cocoa/nsMenuBarX.cpp | 5 +- mozilla/widget/src/cocoa/nsMenuX.cpp | 9 +- mozilla/widget/src/mac/nsMenu.cpp | 10 +- mozilla/widget/src/mac/nsMenuBar.cpp | 5 +- mozilla/widget/src/mac/nsMenuBarX.cpp | 5 +- mozilla/widget/src/mac/nsMenuX.cpp | 10 +- 132 files changed, 1831 insertions(+), 2341 deletions(-) diff --git a/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp b/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp index 96a68fc1b4d..805db38599f 100644 --- a/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -154,10 +154,11 @@ STDMETHODIMP nsAccessNodeWrap::get_nodeInfo( *aUniqueID = 0; // magic value of 0 means we're on the document node. if (content) { content->GetNameSpaceID(&nameSpaceID); - // This is a unique ID for every content node. - // The 3rd party accessibility application can compare this to the childID we return for - // events such as focus events, to correlate back to data nodes in their internal object model. - content->GetContentID(NS_STATIC_CAST(PRUint32*, aUniqueID)); + // This is a unique ID for every content node. The 3rd party + // accessibility application can compare this to the childID we + // return for events such as focus events, to correlate back to + // data nodes in their internal object model. + *aUniqueID = content->ContentID(); } *aNameSpaceID = NS_STATIC_CAST(short, nameSpaceID); diff --git a/mozilla/content/base/public/nsContentCID.h b/mozilla/content/base/public/nsContentCID.h index e6a138b3aaa..12ce7c286b1 100644 --- a/mozilla/content/base/public/nsContentCID.h +++ b/mozilla/content/base/public/nsContentCID.h @@ -163,11 +163,6 @@ #define NS_RANGE_CID \ {/* {56AD2981-8A87-11d2-918C-0080C8E44DB5}*/ \ 0x56ad2981, 0x8a87, 0x11d2, { 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } } - -// {A1FDE868-E802-11d4-9885-00C04FA0CF4B} -#define NS_ATTRIBUTECONTENT_CID \ -{ 0xa1fde868, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } - #define NS_CONTENTITERATOR_CID \ {/* {a6cf90e3-15b3-11d2-932e-00805f8add32}*/ \ 0xa6cf90e3, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index 8dc5a0cb681..bbe8e199d4a 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -88,7 +88,8 @@ public: * @param aCompileEventHandlers whether to initialize the event handlers in * the document (used by nsXULElement) */ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers) { mDocument = aDocument; return NS_OK; @@ -135,10 +136,10 @@ public: NS_IMETHOD GetNameSpaceID(PRInt32* aResult) const = 0; /** - * Get the tag for this element - * @param aResult the tag [OUT] + * Get the tag for this element. This will always return a non-null + * atom pointer (as implied by the naming of the method). */ - NS_IMETHOD GetTag(nsIAtom** aResult) const = 0; + virtual nsIAtom *Tag() const = 0; /** * Get the NodeInfo for this element @@ -305,7 +306,6 @@ public: * @throws NS_CONTENT_ATTR_HAS_VALUE if the attribute exists and has a * non-empty value (==NS_OK) */ - NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom** aPrefix, nsAString& aResult) const = 0; @@ -316,7 +316,6 @@ public: * @param aAttr the attribute name * @return whether an attribute exists */ - NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const = 0; /** @@ -348,7 +347,7 @@ public: /** * Get the number of all specified attributes. * - * @param aCountResult the number of attributes [OUT] + * @returns the number of attributes */ NS_IMETHOD_(PRUint32) GetAttrCount() const = 0; @@ -371,11 +370,14 @@ public: */ NS_IMETHOD RangeRemove(nsIDOMRange* aRange) = 0; /** - * Get the list of ranges that have either endpoint in this content item - * @param aResult the list of ranges owned partially by this content [OUT] + * Get the list of ranges that have either endpoint in this content + * item. + * @returns the list of ranges owned partially by this content. The + * nsVoidArray is owned by the content object and its lifetime is + * controlled completely by the content object. */ - NS_IMETHOD GetRangeList(nsVoidArray** aResult) const = 0; - + virtual const nsVoidArray *GetRangeList() const = 0; + /** * Handle a DOM event for this piece of content. This method is responsible * for handling and controlling all three stages of events, capture, local @@ -423,12 +425,10 @@ public: * An opaque pointer to this dictionary is passed to the session * history as a handle associated with the current document's state * - * @param aID the unique ID for this content [OUT] - * * These methods are DEPRECATED, DON'T USE THEM!!! * */ - NS_IMETHOD GetContentID(PRUint32 *aId) = 0; + virtual PRUint32 ContentID() const = 0; /** * Set the unique content ID for this content. * @param aID the ID to set diff --git a/mozilla/content/base/src/mozSanitizingSerializer.cpp b/mozilla/content/base/src/mozSanitizingSerializer.cpp index c35ca9110cc..062e53a98e6 100644 --- a/mozilla/content/base/src/mozSanitizingSerializer.cpp +++ b/mozilla/content/base/src/mozSanitizingSerializer.cpp @@ -122,6 +122,9 @@ NS_IMETHODIMP mozSanitizingHTMLSerializer::Init(PRUint32 aFlags, PRUint32 dummy, const char* aCharSet, PRBool aIsCopying) { + NS_ENSURE_TRUE(nsContentUtils::GetParserServiceWeakRef(), + NS_ERROR_UNEXPECTED); + return NS_OK; } @@ -202,31 +205,21 @@ mozSanitizingHTMLSerializer::IsContainer(PRInt32 aId) so that at least these methods that none of us understand only have to be written once?" */ -nsresult -mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent, - PRInt32* aID) +// static +PRInt32 +mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent) { - nsCOMPtr htmlcontent = do_QueryInterface(aContent); - if (!htmlcontent) { - *aID = eHTMLTag_unknown; - return NS_OK; + if (!aContent->IsContentOfType(nsIContent::eHTML)) { + return eHTMLTag_unknown; } - nsCOMPtr tagname; - mContent->GetTag(getter_AddRefs(tagname)); - if (!tagname) - return NS_ERROR_FAILURE; - nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef(); - if (!parserService) - return NS_ERROR_OUT_OF_MEMORY; - nsresult rv; - rv = parserService->HTMLAtomTagToId(tagname, aID); - if (NS_FAILED(rv)) - return rv; + PRInt32 id; + nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id); + NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!"); - return NS_OK; + return id; } NS_IMETHODIMP @@ -253,23 +246,20 @@ mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement, NS_ENSURE_ARG(aElement); mContent = do_QueryInterface(aElement); - if (!mContent) return NS_ERROR_FAILURE; + NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE); mOutputString = &aStr; - nsresult rv; - PRInt32 id; - rv = GetIdForContent(mContent, &id); - if (NS_FAILED(rv)) return rv; + PRInt32 id = GetIdForContent(mContent); PRBool isContainer = IsContainer(id); + nsresult rv; if (isContainer) { rv = DoOpenContainer(id); } else { - nsAutoString empty; - rv = DoAddLeaf(id, empty); + rv = DoAddLeaf(id, nsString()); } mContent = 0; @@ -285,14 +275,12 @@ mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement, NS_ENSURE_ARG(aElement); mContent = do_QueryInterface(aElement); - if (!mContent) return NS_ERROR_FAILURE; + NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE); mOutputString = &aStr; - nsresult rv; - PRInt32 id; - rv = GetIdForContent(mContent, &id); - if (NS_FAILED(rv)) return rv; + nsresult rv = NS_OK; + PRInt32 id = GetIdForContent(mContent); PRBool isContainer = IsContainer(id); diff --git a/mozilla/content/base/src/mozSanitizingSerializer.h b/mozilla/content/base/src/mozSanitizingSerializer.h index dd992ec85d4..0694fa1f650 100644 --- a/mozilla/content/base/src/mozSanitizingSerializer.h +++ b/mozilla/content/base/src/mozSanitizingSerializer.h @@ -146,7 +146,7 @@ protected: nsString& value /*inout*/); nsresult SanitizeTextNode(nsString& value /*inout*/); PRBool IsContainer(PRInt32 aId); - nsresult GetIdForContent(nsIContent* aContent, PRInt32* aID); + static PRInt32 GetIdForContent(nsIContent* aContent); nsresult GetParserService(nsIParserService** aParserService); nsresult DoOpenContainer(PRInt32 aTag); nsresult DoCloseContainer(PRInt32 aTag); diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 88c53f164cd..f337b30e174 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -63,7 +63,7 @@ public: // Empty interface // nsIContent - NS_IMETHOD GetTag(nsIAtom** aResult) const; + virtual nsIAtom *Tag() const; #ifdef DEBUG NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; @@ -112,12 +112,10 @@ NS_IMPL_ADDREF_INHERITED(nsCommentNode, nsGenericDOMDataNode) NS_IMPL_RELEASE_INHERITED(nsCommentNode, nsGenericDOMDataNode) -NS_IMETHODIMP -nsCommentNode::GetTag(nsIAtom** aResult) const +nsIAtom * +nsCommentNode::Tag() const { - NS_ADDREF(*aResult = nsLayoutAtoms::commentTagName); - - return NS_OK; + return nsLayoutAtoms::commentTagName; } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index cb2699d681a..f37a820ccbe 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -1391,8 +1391,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent, NS_ENSURE_TRUE(aContent, NS_ERROR_FAILURE); // Don't capture state for anonymous content - PRUint32 contentID; - aContent->GetContentID(&contentID); + PRUint32 contentID = aContent->ContentID(); if (!contentID) { return NS_OK; } @@ -1565,11 +1564,8 @@ nsContentUtils::BelongsInForm(nsIDOMHTMLFormElement *aForm, return PR_TRUE; } - nsCOMPtr tag; - - content->GetTag(getter_AddRefs(tag)); - - if (tag == nsHTMLAtoms::form) { + if (content->Tag() == nsHTMLAtoms::form && + content->IsContentOfType(nsIContent::eHTML)) { // The child is contained within a form, but not the right form // so we ignore it. diff --git a/mozilla/content/base/src/nsCopySupport.cpp b/mozilla/content/base/src/nsCopySupport.cpp index 37d2cf14ac0..7eed6dc6b70 100644 --- a/mozilla/content/base/src/nsCopySupport.cpp +++ b/mozilla/content/base/src/nsCopySupport.cpp @@ -359,8 +359,12 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc selContent = selContent->GetParent()) { // checking for selection inside a plaintext form widget - nsCOMPtr atom; - selContent->GetTag(getter_AddRefs(atom)); + + if (!selContent->IsContentOfType(nsIContent::eHTML)) { + continue; + } + + nsIAtom *atom = selContent->Tag(); if (atom == nsHTMLAtoms::input || atom == nsHTMLAtoms::textarea) diff --git a/mozilla/content/base/src/nsDOMDocumentType.cpp b/mozilla/content/base/src/nsDOMDocumentType.cpp index 229317e75e0..85b26a512a3 100644 --- a/mozilla/content/base/src/nsDOMDocumentType.cpp +++ b/mozilla/content/base/src/nsDOMDocumentType.cpp @@ -46,7 +46,7 @@ nsresult NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, - const nsAString& aName, + nsIAtom *aName, nsIDOMNamedNodeMap *aEntities, nsIDOMNamedNodeMap *aNotations, const nsAString& aPublicId, @@ -54,6 +54,7 @@ NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, const nsAString& aInternalSubset) { NS_ENSURE_ARG_POINTER(aDocType); + NS_ENSURE_ARG_POINTER(aName); *aDocType = new nsDOMDocumentType(aName, aEntities, aNotations, aPublicId, aSystemId, aInternalSubset); @@ -66,29 +67,23 @@ NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, return NS_OK; } -nsDOMDocumentType::nsDOMDocumentType(const nsAString& aName, +nsDOMDocumentType::nsDOMDocumentType(nsIAtom *aName, nsIDOMNamedNodeMap *aEntities, nsIDOMNamedNodeMap *aNotations, const nsAString& aPublicId, const nsAString& aSystemId, const nsAString& aInternalSubset) : mName(aName), + mEntities(aEntities), + mNotations(aNotations), mPublicId(aPublicId), mSystemId(aSystemId), mInternalSubset(aInternalSubset) { - - mEntities = aEntities; - mNotations = aNotations; - - NS_IF_ADDREF(mEntities); - NS_IF_ADDREF(mNotations); } nsDOMDocumentType::~nsDOMDocumentType() { - NS_IF_RELEASE(mEntities); - NS_IF_RELEASE(mNotations); } @@ -110,9 +105,7 @@ NS_IMPL_RELEASE(nsDOMDocumentType) NS_IMETHODIMP nsDOMDocumentType::GetName(nsAString& aName) { - aName=mName; - - return NS_OK; + return mName->ToString(aName); } NS_IMETHODIMP @@ -164,20 +157,16 @@ nsDOMDocumentType::GetInternalSubset(nsAString& aInternalSubset) return NS_OK; } -NS_IMETHODIMP -nsDOMDocumentType::GetTag(nsIAtom** aResult) const +nsIAtom * +nsDOMDocumentType::Tag() const { - *aResult = NS_NewAtom(mName); - - return NS_OK; + return mName; } NS_IMETHODIMP nsDOMDocumentType::GetNodeName(nsAString& aNodeName) { - aNodeName=mName; - - return NS_OK; + return mName->ToString(aNodeName); } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsDOMDocumentType.h b/mozilla/content/base/src/nsDOMDocumentType.h index f85625ce4a0..5f5b2e3fb9e 100644 --- a/mozilla/content/base/src/nsDOMDocumentType.h +++ b/mozilla/content/base/src/nsDOMDocumentType.h @@ -39,6 +39,7 @@ #ifndef nsDOMDocumentType_h___ #define nsDOMDocumentType_h___ +#include "nsCOMPtr.h" #include "nsIDOMDocumentType.h" #include "nsIContent.h" #include "nsGenericDOMDataNode.h" @@ -53,7 +54,7 @@ class nsDOMDocumentType : public nsGenericDOMDataNode, public nsIDOMDocumentType { public: - nsDOMDocumentType(const nsAString& aName, + nsDOMDocumentType(nsIAtom *aName, nsIDOMNamedNodeMap *aEntities, nsIDOMNamedNodeMap *aNotations, const nsAString& aPublicId, @@ -72,12 +73,12 @@ public: NS_DECL_NSIDOMDOCUMENTTYPE // nsIContent - NS_IMETHOD GetTag(nsIAtom** aResult) const; + virtual nsIAtom *Tag() const; protected: - nsString mName; - nsIDOMNamedNodeMap* mEntities; - nsIDOMNamedNodeMap* mNotations; + nsCOMPtr mName; + nsCOMPtr mEntities; + nsCOMPtr mNotations; nsString mPublicId; nsString mSystemId; nsString mInternalSubset; @@ -85,7 +86,7 @@ protected: nsresult NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, - const nsAString& aName, + nsIAtom *aName, nsIDOMNamedNodeMap *aEntities, nsIDOMNamedNodeMap *aNotations, const nsAString& aPublicId, diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 555df906e17..eeecdb323c3 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -343,7 +343,10 @@ nsDOMImplementation::CreateDocumentType(const nsAString& aQualifiedName, { NS_ENSURE_ARG_POINTER(aReturn); - return NS_NewDOMDocumentType(aReturn, aQualifiedName, nsnull, nsnull, + nsCOMPtr name = do_GetAtom(aQualifiedName); + NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); + + return NS_NewDOMDocumentType(aReturn, name, nsnull, nsnull, aPublicId, aSystemId, nsString()); } @@ -1602,7 +1605,7 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) mScriptGlobalObject = aScriptGlobalObject; } -nsIScriptLoader* +nsIScriptLoader * nsDocument::GetScriptLoader() { if (!mScriptLoader) { diff --git a/mozilla/content/base/src/nsDocumentEncoder.cpp b/mozilla/content/base/src/nsDocumentEncoder.cpp index 2217e523915..78a7e840431 100644 --- a/mozilla/content/base/src/nsDocumentEncoder.cpp +++ b/mozilla/content/base/src/nsDocumentEncoder.cpp @@ -388,21 +388,8 @@ nsDocumentEncoder::SerializeToStringRecursive(nsIDOMNode* aNode, PRBool nsDocumentEncoder::IsTag(nsIDOMNode* aNode, nsIAtom* aAtom) { - if (aNode) - { - nsCOMPtr atom; - nsCOMPtr content = do_QueryInterface(aNode); - if (content) - content->GetTag(getter_AddRefs(atom)); - if (atom) - { - if (atom.get() == aAtom) - { - return PR_TRUE; - } - } - } - return PR_FALSE; + nsCOMPtr content = do_QueryInterface(aNode); + return content && content->Tag() == aAtom; } static nsresult @@ -683,7 +670,7 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange, } else { - if (aNode != mCommonParent.get()) + if (aNode != mCommonParent) { if (IncludeInContext(aNode)) { @@ -723,7 +710,7 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange, // to add one here in order to include it in the children we serialize. nsCOMPtr endParent; aRange->GetEndContainer(getter_AddRefs(endParent)); - if (aNode != endParent.get()) + if (aNode != endParent) { endOffset++; } @@ -742,7 +729,7 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange, } // serialize the end of this node - if (aNode != mCommonParent.get()) + if (aNode != mCommonParent) { rv = SerializeNodeEnd(aNode, aString); NS_ENSURE_SUCCESS(rv, rv); @@ -1117,15 +1104,14 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection) selContent = selContent->GetParent()) { // checking for selection inside a plaintext form widget - nsCOMPtr atom; - selContent->GetTag(getter_AddRefs(atom)); - if (atom.get() == nsHTMLAtoms::input || - atom.get() == nsHTMLAtoms::textarea) + nsIAtom *atom = selContent->Tag(); + if (atom == nsHTMLAtoms::input || + atom == nsHTMLAtoms::textarea) { mIsTextWidget = PR_TRUE; break; } - else if (atom.get() == nsHTMLAtoms::body) + else if (atom == nsHTMLAtoms::body) { // check for moz prewrap style on body. If it's there we are // in a plaintext editor. This is pretty cheezy but I haven't @@ -1264,41 +1250,34 @@ nsHTMLCopyEncoder::IncludeInContext(nsIDOMNode *aNode) if (!content) return PR_FALSE; - nsCOMPtr tag; + nsIAtom *tag = content->Tag(); - content->GetTag(getter_AddRefs(tag)); - - if (tag.get() == nsHTMLAtoms::b || - tag.get() == nsHTMLAtoms::i || - tag.get() == nsHTMLAtoms::u || - tag.get() == nsHTMLAtoms::a || - tag.get() == nsHTMLAtoms::tt || - tag.get() == nsHTMLAtoms::s || - tag.get() == nsHTMLAtoms::big || - tag.get() == nsHTMLAtoms::small || - tag.get() == nsHTMLAtoms::strike || - tag.get() == nsHTMLAtoms::em || - tag.get() == nsHTMLAtoms::strong || - tag.get() == nsHTMLAtoms::dfn || - tag.get() == nsHTMLAtoms::code || - tag.get() == nsHTMLAtoms::cite || - tag.get() == nsHTMLAtoms::variable || - tag.get() == nsHTMLAtoms::abbr || - tag.get() == nsHTMLAtoms::font || - tag.get() == nsHTMLAtoms::script || - tag.get() == nsHTMLAtoms::span || - tag.get() == nsHTMLAtoms::pre || - tag.get() == nsHTMLAtoms::h1 || - tag.get() == nsHTMLAtoms::h2 || - tag.get() == nsHTMLAtoms::h3 || - tag.get() == nsHTMLAtoms::h4 || - tag.get() == nsHTMLAtoms::h5 || - tag.get() == nsHTMLAtoms::h6) - { - return PR_TRUE; - } - - return PR_FALSE; + return (tag == nsHTMLAtoms::b || + tag == nsHTMLAtoms::i || + tag == nsHTMLAtoms::u || + tag == nsHTMLAtoms::a || + tag == nsHTMLAtoms::tt || + tag == nsHTMLAtoms::s || + tag == nsHTMLAtoms::big || + tag == nsHTMLAtoms::small || + tag == nsHTMLAtoms::strike || + tag == nsHTMLAtoms::em || + tag == nsHTMLAtoms::strong || + tag == nsHTMLAtoms::dfn || + tag == nsHTMLAtoms::code || + tag == nsHTMLAtoms::cite || + tag == nsHTMLAtoms::variable || + tag == nsHTMLAtoms::abbr || + tag == nsHTMLAtoms::font || + tag == nsHTMLAtoms::script || + tag == nsHTMLAtoms::span || + tag == nsHTMLAtoms::pre || + tag == nsHTMLAtoms::h1 || + tag == nsHTMLAtoms::h2 || + tag == nsHTMLAtoms::h3 || + tag == nsHTMLAtoms::h4 || + tag == nsHTMLAtoms::h5 || + tag == nsHTMLAtoms::h6); } @@ -1457,11 +1436,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32 nsCOMPtr content = do_QueryInterface(parent); if (content) { - nsCOMPtr atom; - content->GetTag(getter_AddRefs(atom)); - PRInt32 id; - parserService->HTMLAtomTagToId(atom, &id); + parserService->HTMLAtomTagToId(content->Tag(), &id); PRBool isBlock = PR_FALSE; parserService->IsBlock(id, isBlock); @@ -1546,11 +1522,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32 nsCOMPtr content = do_QueryInterface(parent); if (content) { - nsCOMPtr atom; - content->GetTag(getter_AddRefs(atom)); - PRInt32 id; - parserService->HTMLAtomTagToId(atom, &id); + parserService->HTMLAtomTagToId(content->Tag(), &id); PRBool isBlock = PR_FALSE; parserService->IsBlock(id, isBlock); diff --git a/mozilla/content/base/src/nsFrameLoader.cpp b/mozilla/content/base/src/nsFrameLoader.cpp index 833422ae3e5..9ce1a0e918a 100644 --- a/mozilla/content/base/src/nsFrameLoader.cpp +++ b/mozilla/content/base/src/nsFrameLoader.cpp @@ -587,10 +587,7 @@ nsFrameLoader::GetURL(nsAString& aURI) { aURI.Truncate(); - nsCOMPtr type; - mOwnerContent->GetTag(getter_AddRefs(type)); - - if (type == nsHTMLAtoms::object) { + if (mOwnerContent->Tag() == nsHTMLAtoms::object) { mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, aURI); } else { mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, aURI); diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 66f3ee60866..be2613e9048 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -834,11 +834,10 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext, return ret; } -NS_IMETHODIMP -nsGenericDOMDataNode::GetContentID(PRUint32* aID) +PRUint32 +nsGenericDOMDataNode::ContentID() const { - *aID = 0; - return NS_OK; + return 0; } NS_IMETHODIMP @@ -987,12 +986,10 @@ nsGenericDOMDataNode::RangeRemove(nsIDOMRange* aRange) return NS_ERROR_FAILURE; } - -NS_IMETHODIMP -nsGenericDOMDataNode::GetRangeList(nsVoidArray** aResult) const +const nsVoidArray * +nsGenericDOMDataNode::GetRangeList() const { - *aResult = LookupRangeList(); - return NS_OK; + return LookupRangeList(); } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 3cc46b5cffd..ae437816af6 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -197,11 +197,11 @@ public: NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, nsEventStatus* aEventStatus); - NS_IMETHOD GetContentID(PRUint32* aID); + virtual PRUint32 ContentID() const; NS_IMETHOD SetContentID(PRUint32 aID); NS_IMETHOD RangeAdd(nsIDOMRange* aRange); NS_IMETHOD RangeRemove(nsIDOMRange* aRange); - NS_IMETHOD GetRangeList(nsVoidArray** aResult) const; + virtual const nsVoidArray *GetRangeList() const; NS_IMETHOD SetFocus(nsIPresContext *aPresContext); NS_IMETHOD RemoveFocus(nsIPresContext *aPresContext); diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 9ed5408536d..92f42c93bb7 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1768,12 +1768,10 @@ nsGenericElement::GetNameSpaceID(PRInt32* aNameSpaceID) const return NS_OK; } -nsresult -nsGenericElement::GetTag(nsIAtom** aResult) const +nsIAtom * +nsGenericElement::Tag() const { - NS_ADDREF(*aResult = mNodeInfo->NameAtom()); - - return NS_OK; + return mNodeInfo->NameAtom(); } NS_IMETHODIMP_(nsINodeInfo *) @@ -2019,20 +2017,18 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, return ret; } -NS_IMETHODIMP -nsGenericElement::GetContentID(PRUint32* aID) +PRUint32 +nsGenericElement::ContentID() const { nsDOMSlots *slots = GetExistingDOMSlots(); if (slots) { - *aID = slots->mContentID; - } else { - PtrBits flags = GetFlags(); - - *aID = flags >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET; + return slots->mContentID; } - return NS_OK; + PtrBits flags = GetFlags(); + + return flags >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET; } NS_IMETHODIMP @@ -2326,13 +2322,11 @@ nsGenericElement::RangeRemove(nsIDOMRange* aRange) return NS_OK; } -nsresult -nsGenericElement::GetRangeList(nsVoidArray** aResult) const +const nsVoidArray * +nsGenericElement::GetRangeList() const { - *aResult = nsnull; - if (!HasRangeList()) { - return NS_OK; + return nsnull; } RangeListMapEntry *entry = @@ -2344,12 +2338,10 @@ nsGenericElement::GetRangeList(nsVoidArray** aResult) const NS_ERROR("Huh, our bit says we have a range list, but there's nothing " "in the hash!?!!"); - return NS_ERROR_UNEXPECTED; + return nsnull; } - *aResult = entry->mRangeList; - - return NS_OK; + return entry->mRangeList; } nsresult @@ -2422,8 +2414,8 @@ nsGenericElement::GetListenerManager(nsIEventListenerManager** aResult) *aResult = nsnull; if (!sEventListenerManagersHash.ops) { - // We''re already shut down, don't bother creating a event - // listener manager. + // We're already shut down, don't bother creating a event listener + // manager. return NS_OK; } diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 1ce0884b9e3..0ba0c47585e 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -368,19 +368,19 @@ public: NS_IMETHOD_(PRBool) IsNativeAnonymous() const; NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous); NS_IMETHOD GetNameSpaceID(PRInt32* aNameSpaceID) const; - NS_IMETHOD GetTag(nsIAtom** aResult) const; + virtual nsIAtom *Tag() const; NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const; NS_IMETHOD_(nsIAtom*) GetIDAttributeName() const; NS_IMETHOD_(nsIAtom*) GetClassAttributeName() const; NS_IMETHOD RangeAdd(nsIDOMRange* aRange); NS_IMETHOD RangeRemove(nsIDOMRange* aRange); - NS_IMETHOD GetRangeList(nsVoidArray** aResult) const; + virtual const nsVoidArray *GetRangeList() const; NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, nsEventStatus* aEventStatus); - NS_IMETHOD GetContentID(PRUint32* aID); + virtual PRUint32 ContentID() const; NS_IMETHOD SetContentID(PRUint32 aID); NS_IMETHOD SetFocus(nsIPresContext* aContext); NS_IMETHOD RemoveFocus(nsIPresContext* aContext); diff --git a/mozilla/content/base/src/nsHTMLContentSerializer.cpp b/mozilla/content/base/src/nsHTMLContentSerializer.cpp index d36403b8256..bdaef60d464 100644 --- a/mozilla/content/base/src/nsHTMLContentSerializer.cpp +++ b/mozilla/content/base/src/nsHTMLContentSerializer.cpp @@ -461,7 +461,7 @@ nsHTMLContentSerializer::IsJavaScript(nsIAtom* aAttrNameAtom, const nsAString& a aAttrNameAtom == nsHTMLAtoms::src) { static const char kJavaScript[] = "javascript"; PRInt32 pos = aValueString.FindChar(':'); - if ( pos < (PRInt32)(sizeof kJavaScript - 1) ) + if (pos < (PRInt32)(sizeof kJavaScript - 1)) return PR_FALSE; nsAutoString scheme(Substring(aValueString, 0, pos)); scheme.StripWhitespace(); @@ -602,21 +602,21 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent, // XXX: This special cased textarea code should be // removed when bug #17003 is fixed. - if ( (aTagName == nsHTMLAtoms::textarea) && - ((attrName.get() == nsHTMLAtoms::value) || - (attrName.get() == nsHTMLAtoms::defaultvalue)) ){ + if ((aTagName == nsHTMLAtoms::textarea) && + ((attrName == nsHTMLAtoms::value) || + (attrName == nsHTMLAtoms::defaultvalue))){ continue; } - if ( mIsCopying && mIsFirstChildOfOL && (aTagName == nsHTMLAtoms::li) && - (attrName.get() == nsHTMLAtoms::value)){ + if (mIsCopying && mIsFirstChildOfOL && (aTagName == nsHTMLAtoms::li) && + (attrName == nsHTMLAtoms::value)){ // This is handled separately in SerializeLIValueAttribute() continue; } PRBool isJS = IsJavaScript(attrName, valueStr); - if (((attrName.get() == nsHTMLAtoms::href) || - (attrName.get() == nsHTMLAtoms::src))) { + if (((attrName == nsHTMLAtoms::href) || + (attrName == nsHTMLAtoms::src))) { // Make all links absolute when converting only the selection: if (mFlags & nsIDocumentEncoder::OutputAbsoluteLinks) { // Would be nice to handle OBJECT and APPLET tags, @@ -677,10 +677,9 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, // even if we're not in pretty printing mode PRBool hasDirtyAttr = HasDirtyAttr(content); - nsCOMPtr name; - content->GetTag(getter_AddRefs(name)); + nsIAtom *name = content->Tag(); - if (name.get() == nsHTMLAtoms::br && mPreLevel > 0 + if (name == nsHTMLAtoms::br && mPreLevel > 0 && (mFlags & nsIDocumentEncoder::OutputNoFormattingInPre)) { AppendToString(mLineBreak, aStr); mMayIgnoreLineBreakSequence = PR_TRUE; @@ -688,7 +687,7 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, return NS_OK; } - if (name.get() == nsHTMLAtoms::body) { + if (name == nsHTMLAtoms::body) { mInBody = PR_TRUE; } @@ -711,9 +710,9 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, StartIndentation(name, hasDirtyAttr, aStr); - if ((name.get() == nsHTMLAtoms::pre) || - (name.get() == nsHTMLAtoms::script) || - (name.get() == nsHTMLAtoms::style)) { + if (name == nsHTMLAtoms::pre || + name == nsHTMLAtoms::script || + name == nsHTMLAtoms::style) { mPreLevel++; } @@ -725,7 +724,7 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, // Need to keep track of OL and LI elements in order to get ordinal number // for the LI. - if (mIsCopying && name.get() == nsHTMLAtoms::ol){ + if (mIsCopying && name == nsHTMLAtoms::ol){ // We are copying and current node is an OL; // Store it's start attribute value in olState->startVal. nsAutoString start; @@ -747,7 +746,7 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, mOLStateStack.AppendElement(state); } - if (mIsCopying && name.get() == nsHTMLAtoms::li) { + if (mIsCopying && name == nsHTMLAtoms::li) { mIsFirstChildOfOL = IsFirstChildOfOL(aElement); if (mIsFirstChildOfOL){ // If OL is parent of this LI, serialize attributes in different manner. @@ -769,17 +768,17 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, // XXX: This special cased textarea code should be // removed when bug #17003 is fixed. - if (name.get() == nsHTMLAtoms::textarea) + if (name == nsHTMLAtoms::textarea) { nsAutoString valueStr; content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, valueStr); AppendToString(valueStr, aStr); } - if ((name.get() == nsHTMLAtoms::script) || - (name.get() == nsHTMLAtoms::style) || - (name.get() == nsHTMLAtoms::noscript) || - (name.get() == nsHTMLAtoms::noframes)) { + if (name == nsHTMLAtoms::script || + name == nsHTMLAtoms::style || + name == nsHTMLAtoms::noscript || + name == nsHTMLAtoms::noframes) { mInCDATA = PR_TRUE; } @@ -797,16 +796,15 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement, PRBool hasDirtyAttr = HasDirtyAttr(content); - nsCOMPtr name; - content->GetTag(getter_AddRefs(name)); + nsIAtom *name = content->Tag(); - if ((name.get() == nsHTMLAtoms::pre) || - (name.get() == nsHTMLAtoms::script) || - (name.get() == nsHTMLAtoms::style)) { + if (name == nsHTMLAtoms::pre || + name == nsHTMLAtoms::script || + name == nsHTMLAtoms::style) { mPreLevel--; } - if (mIsCopying && (name.get() == nsHTMLAtoms::ol)){ + if (mIsCopying && (name == nsHTMLAtoms::ol)){ NS_ASSERTION((mOLStateStack.Count() > 0), "Cannot have an empty OL Stack"); /* Though at this point we must always have an state to be deleted as all the OL opening tags are supposed to push an olState object to the stack*/ @@ -819,7 +817,7 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement, nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef(); - if (parserService && (name.get() != nsHTMLAtoms::style)) { + if (parserService && (name != nsHTMLAtoms::style)) { PRBool isContainer; PRInt32 id; diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index 5a2472b4f7e..91921f3582c 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -164,7 +164,10 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn, "Can't do formatted and preformatted output at the same time!"); } #endif - + + NS_ENSURE_TRUE(nsContentUtils::GetParserServiceWeakRef(), + NS_ERROR_UNEXPECTED); + nsresult rv; mFlags = aFlags; @@ -388,9 +391,7 @@ nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement, if (!mContent) return NS_ERROR_FAILURE; nsresult rv; - PRInt32 id; - rv = GetIdForContent(mContent, &id); - if (NS_FAILED(rv)) return rv; + PRInt32 id = GetIdForContent(mContent); PRBool isContainer = IsContainer(id); @@ -423,9 +424,7 @@ nsPlainTextSerializer::AppendElementEnd(nsIDOMElement *aElement, if (!mContent) return NS_ERROR_FAILURE; nsresult rv; - PRInt32 id; - rv = GetIdForContent(mContent, &id); - if (NS_FAILED(rv)) return rv; + PRInt32 id = GetIdForContent(mContent); PRBool isContainer = IsContainer(id); @@ -1849,26 +1848,21 @@ nsPlainTextSerializer::IsCurrentNodeConverted(const nsIParserNode* aNode) } -nsresult -nsPlainTextSerializer::GetIdForContent(nsIContent* aContent, - PRInt32* aID) +// static +PRInt32 +nsPlainTextSerializer::GetIdForContent(nsIContent* aContent) { - nsCOMPtr htmlcontent = do_QueryInterface(aContent); - if (!htmlcontent) { - *aID = eHTMLTag_unknown; - return NS_OK; + if (!aContent->IsContentOfType(nsIContent::eHTML)) { + return eHTMLTag_unknown; } - nsCOMPtr tagname; - mContent->GetTag(getter_AddRefs(tagname)); - if (!tagname) return NS_ERROR_FAILURE; - - nsIParserService* parserService = - nsContentUtils::GetParserServiceWeakRef(); - if (!parserService) - return NS_ERROR_FAILURE; + nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef(); - return parserService->HTMLAtomTagToId(tagname, aID); + PRInt32 id; + nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id); + NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!"); + + return id; } /** diff --git a/mozilla/content/base/src/nsPlainTextSerializer.h b/mozilla/content/base/src/nsPlainTextSerializer.h index afa8f4bdfca..9d4a6627ddb 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.h +++ b/mozilla/content/base/src/nsPlainTextSerializer.h @@ -148,7 +148,7 @@ protected: PRBool IsInPre(); PRBool IsInOL(); PRBool IsCurrentNodeConverted(const nsIParserNode* aNode); - nsresult GetIdForContent(nsIContent* aContent, PRInt32* aID); + static PRInt32 GetIdForContent(nsIContent* aContent); nsresult DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag); nsresult DoCloseContainer(PRInt32 aTag); nsresult DoAddLeaf(const nsIParserNode* aNode, diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 9284c7000ee..491301fed41 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -3662,15 +3662,11 @@ nsPrintEngine::FindFrameByType(nsIPresContext* aPresContext, aParentFrame->FirstChild(aPresContext, nsnull, &child); while (child) { nsIContent* content = child->GetContent(); - if (content) { - nsCOMPtr type; - content->GetTag(getter_AddRefs(type)); - if (type.get() == aType) { - nsRect r = child->GetRect(); - aChildRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height); - aRect -= aParentFrame->GetPosition(); - return child; - } + if (content && content->Tag() == aType) { + nsRect r = child->GetRect(); + aChildRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height); + aRect -= aParentFrame->GetPosition(); + return child; } nsIFrame * fndFrame = FindFrameByType(aPresContext, child, aType, aRect, aChildRect); if (fndFrame != nsnull) { diff --git a/mozilla/content/base/src/nsRange.cpp b/mozilla/content/base/src/nsRange.cpp index 3b18ea79759..b5666038050 100644 --- a/mozilla/content/base/src/nsRange.cpp +++ b/mozilla/content/base/src/nsRange.cpp @@ -873,12 +873,12 @@ nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent* iter->Init(aSourceNode); nsCOMPtr cN; - nsVoidArray* theRangeList; + const nsVoidArray* theRangeList; iter->CurrentNode(getter_AddRefs(cN)); while (cN && (NS_ENUMERATOR_FALSE == iter->IsDone())) { - cN->GetRangeList(&theRangeList); + theRangeList = cN->GetRangeList(); if (theRangeList) { nsRange* theRange; @@ -910,7 +910,7 @@ nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent* } } // must refresh theRangeList - it might have gone away! - cN->GetRangeList(&theRangeList); + theRangeList = cN->GetRangeList(); if (theRangeList) theCount = theRangeList->Count(); else @@ -2331,8 +2331,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset) nsCOMPtr parent( do_QueryInterface(aParentNode) ); // quick return if no range list - nsVoidArray *theRangeList; - parent->GetRangeList(&theRangeList); + const nsVoidArray *theRangeList = parent->GetRangeList(); if (!theRangeList) return NS_OK; nsresult res; @@ -2384,8 +2383,7 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns nsresult res = PopRanges(domNode, aOffset, removed); // quick return if no range list - nsVoidArray *theRangeList; - parent->GetRangeList(&theRangeList); + const nsVoidArray *theRangeList = parent->GetRangeList(); if (!theRangeList) return NS_OK; PRInt32 count = theRangeList->Count(); @@ -2444,8 +2442,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged, if (!aTextNode) return NS_ERROR_UNEXPECTED; nsCOMPtr textNode( do_QueryInterface(aTextNode) ); - nsVoidArray *theRangeList; - aTextNode->GetRangeList(&theRangeList); + const nsVoidArray *theRangeList = aTextNode->GetRangeList(); // the caller already checked to see if there was a range list nsCOMPtr domNode(do_QueryInterface(textNode)); diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 0b3c58f6e1f..6ab0ffa917c 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -148,7 +148,7 @@ struct nsScrollSelectionIntoViewEvent; PRBool IsValidSelectionPoint(nsSelection *aFrameSel, nsIContent *aContent); PRBool IsValidSelectionPoint(nsSelection *aFrameSel, nsIDOMNode *aDomNode); -static nsCOMPtr GetTag(nsIDOMNode *aNode); +static nsIAtom *GetTag(nsIDOMNode *aNode); static nsresult ParentOffset(nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset); static nsIDOMNode *GetCellParent(nsIDOMNode *aDomNode); @@ -1330,21 +1330,17 @@ void printRange(nsIDOMRange *aDomRange) } #endif /* PRINT_RANGE */ -nsCOMPtr GetTag(nsIDOMNode *aNode) +static +nsIAtom *GetTag(nsIDOMNode *aNode) { - nsCOMPtr atom; - - if (!aNode) + nsCOMPtr content = do_QueryInterface(aNode); + if (!content) { - NS_NOTREACHED("null node passed to GetTag()"); - return atom; + NS_NOTREACHED("bad node passed to GetTag()"); + return nsnull; } - nsCOMPtr content = do_QueryInterface(aNode); - if (content) - content->GetTag(getter_AddRefs(atom)); - - return atom; + return content->Tag(); } nsresult @@ -1376,7 +1372,7 @@ GetCellParent(nsIDOMNode *aDomNode) nsCOMPtr parent(aDomNode); nsCOMPtr current(aDomNode); PRInt32 childOffset; - nsCOMPtr tag; + nsIAtom *tag; // Start with current node and look for a table cell while(current) { @@ -3289,9 +3285,8 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe static PRBool IsCell(nsIContent *aContent) { - nsCOMPtr tag; - aContent->GetTag(getter_AddRefs(tag)); - return (tag == nsHTMLAtoms::td); + return (aContent->Tag() == nsHTMLAtoms::td && + aContent->IsContentOfType(nsIContent::eHTML)); } nsITableCellLayout* @@ -4057,11 +4052,10 @@ nsSelection::GetParentTable(nsIContent *aCell, nsIContent **aTable) return NS_ERROR_NULL_POINTER; } - nsCOMPtr tag; for (nsIContent* parent = aCell->GetParent(); parent; parent = parent->GetParent()) { - parent->GetTag(getter_AddRefs(tag)); - if (tag == nsHTMLAtoms::table) { + if (parent->Tag() == nsHTMLAtoms::table && + parent->IsContentOfType(nsIContent::eHTML)) { *aTable = parent; NS_ADDREF(*aTable); @@ -4259,11 +4253,13 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele if ((endOffset - startOffset) != 1) return NS_OK; - nsCOMPtr atom; - content->GetTag(getter_AddRefs(atom)); - if (!atom) return NS_ERROR_FAILURE; + if (!content->IsContentOfType(nsIContent::eHTML)) { + return NS_OK; + } - if (atom == nsHTMLAtoms::tr) + nsIAtom *tag = content->Tag(); + + if (tag == nsHTMLAtoms::tr) { *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL; } @@ -4273,13 +4269,14 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele if (!child) return NS_ERROR_FAILURE; - child->GetTag(getter_AddRefs(atom)); + tag = child->Tag(); - if (atom == nsHTMLAtoms::table) + if (tag == nsHTMLAtoms::table) *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE; - else if (atom == nsHTMLAtoms::tr) + else if (tag == nsHTMLAtoms::tr) *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW; } + return result; } @@ -5945,16 +5942,10 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) content = do_QueryInterface(aParentNode); if (!content) return NS_ERROR_FAILURE; - nsCOMPtr tag; - content->GetTag(getter_AddRefs(tag)); - if (tag) - { - nsAutoString tagString; - tag->ToString(tagString); - char * tagCString = ToNewCString(tagString); - printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset); - delete [] tagCString; - } + + const char *tagString; + content->Tag()->GetUTF8String(&tagString); + printf ("Sel. Collapse to %p %s %d\n", content, tagString, aOffset); } else { printf ("Sel. Collapse set to null parent.\n"); @@ -6135,8 +6126,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir, return NS_ERROR_FAILURE; // if end node is a tbody then all bets are off we cannot select "rows" - nsCOMPtr atom; - atom = GetTag(endNode); + nsIAtom *atom = GetTag(endNode); if (atom == nsHTMLAtoms::tbody) return NS_ERROR_FAILURE; //cannot select INTO row node ony cells @@ -6719,7 +6709,6 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) res = CopyRangeToAnchorFocus(range); if (NS_FAILED(res)) return res; - } DEBUG_OUT_RANGE(range); @@ -6735,16 +6724,10 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsCOMPtrcontent; content = do_QueryInterface(aParentNode); - nsCOMPtr tag; - content->GetTag(getter_AddRefs(tag)); - if (tag) - { - nsAutoString tagString; - tag->ToString(tagString); - char * tagCString = ToNewCString(tagString); - printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset); - delete [] tagCString; - } + + const char *tagString; + content->Tag()->GetUTF8String(&tagString); + printf ("Sel. Extend to %p %s %d\n", content, tagString, aOffset); } else { printf ("Sel. Extend set to null parent.\n"); diff --git a/mozilla/content/base/src/nsTextNode.cpp b/mozilla/content/base/src/nsTextNode.cpp index b43dba42ddc..d252ca69859 100644 --- a/mozilla/content/base/src/nsTextNode.cpp +++ b/mozilla/content/base/src/nsTextNode.cpp @@ -62,7 +62,7 @@ public: NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::) // nsIContent - NS_IMETHOD GetTag(nsIAtom** aResult) const; + nsIAtom *Tag() const; NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags); #ifdef DEBUG NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; @@ -105,12 +105,10 @@ NS_INTERFACE_MAP_BEGIN(nsTextNode) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Text) NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) -NS_IMETHODIMP -nsTextNode::GetTag(nsIAtom** aResult) const +nsIAtom * +nsTextNode::Tag() const { - NS_ADDREF(*aResult = nsLayoutAtoms::textTagName); - - return NS_OK; + return nsLayoutAtoms::textTagName; } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsTreeWalker.cpp b/mozilla/content/base/src/nsTreeWalker.cpp index 59dc2034bee..6cefc09bebb 100644 --- a/mozilla/content/base/src/nsTreeWalker.cpp +++ b/mozilla/content/base/src/nsTreeWalker.cpp @@ -99,7 +99,7 @@ nsTreeWalker::~nsTreeWalker() * nsISupports stuff */ -// QueryInterface implementation for nsDOMDocumentType +// QueryInterface implementation for nsTreeWalker NS_INTERFACE_MAP_BEGIN(nsTreeWalker) NS_INTERFACE_MAP_ENTRY(nsIDOMTreeWalker) NS_INTERFACE_MAP_ENTRY(nsISupports) diff --git a/mozilla/content/base/src/nsXMLContentSerializer.cpp b/mozilla/content/base/src/nsXMLContentSerializer.cpp index b7b690876d0..c60e94962be 100644 --- a/mozilla/content/base/src/nsXMLContentSerializer.cpp +++ b/mozilla/content/base/src/nsXMLContentSerializer.cpp @@ -580,9 +580,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, PRInt32 elementNsID; content->GetNameSpaceID(&elementNsID); if (elementNsID == kNameSpaceID_XHTML) { - nsCOMPtr elementName; - content->GetTag(getter_AddRefs(elementName)); - if (IsShorthandAttr(attrName, elementName) && + if (IsShorthandAttr(attrName, content->Tag()) && valueStr.IsEmpty()) { valueStr = nameStr; } diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 7bce708dd89..49f952fc2ab 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -879,31 +879,24 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, if (mAccessKeys->Exists(&key)) { nsCOMPtr content = dont_AddRef(NS_STATIC_CAST(nsIContent*, mAccessKeys->Get(&key))); - PRBool isXUL = content->IsContentOfType(nsIContent::eXUL); - // if it's a XUL element... - if (isXUL) { - + if (content->IsContentOfType(nsIContent::eXUL)) { // find out what type of content node this is - nsCOMPtr atom; - nsresult rv = content->GetTag(getter_AddRefs(atom)); - if (NS_SUCCEEDED(rv) && atom) { - if (atom == nsXULAtoms::label) { - // If anything fails, this will be null ... - nsCOMPtr element; + if (content->Tag() == nsXULAtoms::label) { + // If anything fails, this will be null ... + nsCOMPtr element; - nsAutoString control; - content->GetAttr(kNameSpaceID_None, nsXULAtoms::control, control); - if (!control.IsEmpty()) { - nsCOMPtr domDocument = - do_QueryInterface(content->GetDocument()); - if (domDocument) - domDocument->GetElementById(control, getter_AddRefs(element)); - } - // ... that here we'll either change |content| to the element - // referenced by |element|, or clear it. - content = do_QueryInterface(element); + nsAutoString control; + content->GetAttr(kNameSpaceID_None, nsXULAtoms::control, control); + if (!control.IsEmpty()) { + nsCOMPtr domDocument = + do_QueryInterface(content->GetDocument()); + if (domDocument) + domDocument->GetElementById(control, getter_AddRefs(element)); } + // ... that here we'll either change |content| to the element + // referenced by |element|, or clear it. + content = do_QueryInterface(element); } if (!content) @@ -929,22 +922,19 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, element) { // find out what type of content node this is - nsCOMPtr atom; - nsresult rv = content->GetTag(getter_AddRefs(atom)); + nsIAtom *atom = content->Tag(); - if (NS_SUCCEEDED(rv) && atom) { - // define behavior for each type of XUL element: - if (atom == nsXULAtoms::textbox || atom == nsXULAtoms::menulist) { - // if it's a text box or menulist, give it focus - element->Focus(); - } else if (atom == nsXULAtoms::toolbarbutton) { - // if it's a toolbar button, just click - element->Click(); - } else { - // otherwise, focus and click in it - element->Focus(); - element->Click(); - } + // define behavior for each type of XUL element: + if (atom == nsXULAtoms::textbox || atom == nsXULAtoms::menulist) { + // if it's a text box or menulist, give it focus + element->Focus(); + } else if (atom == nsXULAtoms::toolbarbutton) { + // if it's a toolbar button, just click + element->Click(); + } else { + // otherwise, focus and click in it + element->Focus(); + element->Click(); } } } @@ -1078,36 +1068,36 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, // a drag. // void -nsEventStateManager :: CreateClickHoldTimer ( nsIPresContext* inPresContext, nsGUIEvent* inMouseDownEvent ) +nsEventStateManager::CreateClickHoldTimer(nsIPresContext* inPresContext, + nsGUIEvent* inMouseDownEvent) { // just to be anal (er, safe) - if ( mClickHoldTimer ) { + if (mClickHoldTimer) { mClickHoldTimer->Cancel(); mClickHoldTimer = nsnull; } - + // if content clicked on has a popup, don't even start the timer // since we'll end up conflicting and both will show. - if ( mGestureDownFrame ) { + if (mGestureDownFrame) { nsIContent* clickedContent = mGestureDownFrame->GetContent(); - if ( clickedContent ) { + if (clickedContent) { // check for the |popup| attribute nsAutoString popup; clickedContent->GetAttr(kNameSpaceID_None, nsXULAtoms::popup, popup); - if ( popup != NS_LITERAL_STRING("") ) + if (popup != NS_LITERAL_STRING("")) return; // check for a like bookmarks - nsCOMPtr tag; - clickedContent->GetTag ( getter_AddRefs(tag) ); - if ( tag == nsXULAtoms::menubutton ) + if (clickedContent->Tag() == nsXULAtoms::menubutton) return; } } mClickHoldTimer = do_CreateInstance("@mozilla.org/timer;1"); if ( mClickHoldTimer ) - mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this, kClickHoldDelay, + mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this, + kClickHoldDelay, nsITimer::TYPE_ONE_SHOT); mEventPoint = inMouseDownEvent->point; @@ -1125,9 +1115,9 @@ nsEventStateManager :: CreateClickHoldTimer ( nsIPresContext* inPresContext, nsG // Stop the timer that would show the context menu dead in its tracks // void -nsEventStateManager :: KillClickHoldTimer ( ) +nsEventStateManager::KillClickHoldTimer() { - if ( mClickHoldTimer ) { + if (mClickHoldTimer) { mClickHoldTimer->Cancel(); mClickHoldTimer = nsnull; } @@ -1144,7 +1134,7 @@ nsEventStateManager :: KillClickHoldTimer ( ) // This fires after the mouse has been down for a certain length of time. // void -nsEventStateManager :: sClickHoldCallback ( nsITimer *aTimer, void* aESM ) +nsEventStateManager::sClickHoldCallback(nsITimer *aTimer, void* aESM) { nsEventStateManager* self = NS_STATIC_CAST(nsEventStateManager*, aESM); if ( self ) @@ -1170,7 +1160,7 @@ nsEventStateManager :: sClickHoldCallback ( nsITimer *aTimer, void* aESM ) // _not_ what we want. // void -nsEventStateManager :: FireContextClick ( ) +nsEventStateManager::FireContextClick() { if ( !mEventDownWidget || !mEventPresContext ) return; @@ -1205,47 +1195,54 @@ nsEventStateManager :: FireContextClick ( ) mCurrentTarget = mGestureDownFrame; if ( mGestureDownFrame ) { nsIContent* lastContent = mGestureDownFrame->GetContent(); - + if ( lastContent ) { - // before dispatching, check that we're not on something that doesn't get a context menu + // before dispatching, check that we're not on something that + // doesn't get a context menu + nsIAtom *tag = lastContent->Tag(); PRBool allowedToDispatch = PR_TRUE; - nsCOMPtr tag; - lastContent->GetTag ( getter_AddRefs(tag) ); - nsCOMPtr inputElm ( do_QueryInterface(lastContent) ); - PRBool isFormControl = - lastContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL); - if ( inputElm ) { - // of all input elements, only ones dealing with text are allowed to have context menus - if ( tag == nsHTMLAtoms::input ) { - nsAutoString type; - lastContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type); - if ( type != NS_LITERAL_STRING("") && type != NS_LITERAL_STRING("text") && - type != NS_LITERAL_STRING("password") && type != NS_LITERAL_STRING("file") ) + if (lastContent->IsContentOfType(nsIContent::eXUL)) { + if (tag == nsXULAtoms::scrollbar || + tag == nsXULAtoms::scrollbarbutton || + tag == nsXULAtoms::button) + allowedToDispatch = PR_FALSE; + else if (tag == nsXULAtoms::toolbarbutton) { + // a that has the container attribute set + // will already have its own dropdown. + nsAutoString container; + lastContent->GetAttr(kNameSpaceID_None, nsXULAtoms::container, + container); + if (!container.IsEmpty()) allowedToDispatch = PR_FALSE; } } - else if ( isFormControl && tag != nsHTMLAtoms::textarea ) - // catches combo-boxes, - allowedToDispatch = PR_FALSE; - else if ( tag == nsXULAtoms::scrollbar || tag == nsXULAtoms::scrollbarbutton || tag == nsXULAtoms::button ) - allowedToDispatch = PR_FALSE; - else if ( tag == nsHTMLAtoms::applet || tag == nsHTMLAtoms::embed ) - allowedToDispatch = PR_FALSE; - else if ( tag == nsXULAtoms::toolbarbutton ) { - // a that has the container attribute set will already have its - // own dropdown. - nsAutoString container; - lastContent->GetAttr(kNameSpaceID_None, nsXULAtoms::container, container); - if ( container.Length() ) + else if (lastContent->IsContentOfType(eHTML)) { + nsCOMPtr formCtrl(do_QueryInterface(lastContent)); + + if (formCtrl) { + // of all form controls, only ones dealing with text are + // allowed to have context menus + PRInt32 formCtrlType = formCtrl->GetType(); + + allowedToDispatch = (type == NS_FORM_INPUT_TEXT || + type == NS_FORM_INPUT_PASSWORD || + type == NS_FORM_INPUT_FILE || + type == NS_FORM_TEXTAREA); + } + else if (tag == nsHTMLAtoms::applet || + tag == nsHTMLAtoms::embed || + tag == nsHTMLAtoms::object) { allowedToDispatch = PR_FALSE; + } } - - if ( allowedToDispatch ) { + + if (allowedToDispatch) { // stop selection tracking, we're in control now nsCOMPtr frameSel; - GetSelection ( mGestureDownFrame, mEventPresContext, getter_AddRefs(frameSel) ); - if ( frameSel ) { + GetSelection(mGestureDownFrame, mEventPresContext, + getter_AddRefs(frameSel)); + if (frameSel) { PRBool mouseDownState = PR_TRUE; frameSel->GetMouseDownState(&mouseDownState); if (mouseDownState) @@ -1253,14 +1250,15 @@ nsEventStateManager :: FireContextClick ( ) } // dispatch to DOM - lastContent->HandleDOMEvent(mEventPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); - + lastContent->HandleDOMEvent(mEventPresContext, &event, nsnull, + NS_EVENT_FLAG_INIT, &status); + // Firing the DOM event could have caused mGestureDownFrame to // be destroyed. So, null-check it again. if (mGestureDownFrame) { // dispatch to the frame - mGestureDownFrame->HandleEvent(mEventPresContext, &event, &status); + mGestureDownFrame->HandleEvent(mEventPresContext, &event, &status); } } } @@ -1290,7 +1288,9 @@ nsEventStateManager :: FireContextClick ( ) // want to cancel the drag gesture if the context-click event is handled. // void -nsEventStateManager :: BeginTrackingDragGesture ( nsIPresContext* aPresContext, nsGUIEvent* inDownEvent, nsIFrame* inDownFrame ) +nsEventStateManager::BeginTrackingDragGesture(nsIPresContext* aPresContext, + nsGUIEvent* inDownEvent, + nsIFrame* inDownFrame) { mIsTrackingDragGesture = PR_TRUE; mGestureDownPoint = inDownEvent->point; @@ -1312,7 +1312,7 @@ nsEventStateManager :: BeginTrackingDragGesture ( nsIPresContext* aPresContext, // state of d&d gesture tracker and return to the START state. // void -nsEventStateManager :: StopTrackingDragGesture ( ) +nsEventStateManager::StopTrackingDragGesture() { mIsTrackingDragGesture = PR_FALSE; mGestureDownPoint = nsPoint(0,0); @@ -1327,7 +1327,9 @@ nsEventStateManager :: StopTrackingDragGesture ( ) // Helper routine to get an nsIFrameSelection from the given frame // void -nsEventStateManager :: GetSelection ( nsIFrame* inFrame, nsIPresContext* inPresContext, nsIFrameSelection** outSelection ) +nsEventStateManager::GetSelection(nsIFrame* inFrame, + nsIPresContext* inPresContext, + nsIFrameSelection** outSelection) { *outSelection = nsnull; @@ -1371,7 +1373,8 @@ nsEventStateManager :: GetSelection ( nsIFrame* inFrame, nsIPresContext* inPresC // Do we need to do anything about this? Let's wait and see. // void -nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUIEvent *aEvent ) +nsEventStateManager::GenerateDragGesture(nsIPresContext* aPresContext, + nsGUIEvent *aEvent) { NS_WARN_IF_FALSE(aPresContext, "This shouldn't happen."); if ( IsTrackingDragGesture() ) { @@ -2276,13 +2279,15 @@ nsEventStateManager::GetNearestScrollingView(nsIView* aView) PRBool nsEventStateManager::CheckDisabled(nsIContent* aContent) { - nsCOMPtr tag; - aContent->GetTag(getter_AddRefs(tag)); + nsIAtom *tag = aContent->Tag(); - if (tag == nsHTMLAtoms::input || - tag == nsHTMLAtoms::select || - tag == nsHTMLAtoms::textarea || - tag == nsHTMLAtoms::button) { + if (((tag == nsHTMLAtoms::input || + tag == nsHTMLAtoms::select || + tag == nsHTMLAtoms::textarea || + tag == nsHTMLAtoms::button) && + (aContent->IsContentOfType(nsIContent::eHTML))) || + (tag == nsHTMLAtoms::button && + aContent->IsContentOfType(nsIContent::eXUL))) { return aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled); } @@ -2519,9 +2524,7 @@ nsEventStateManager::MaybeDispatchMouseEventToIframe( if (parentDoc) { nsIContent *docContent = parentDoc->FindContentForSubDocument(mDocument); if (docContent) { - nsCOMPtr tag; - docContent->GetTag(getter_AddRefs(tag)); - if (tag == nsHTMLAtoms::iframe) { + if (docContent->Tag() == nsHTMLAtoms::iframe) { // We're an IFRAME. Send an event to our IFRAME tag. nsIPresShell *parentShell = parentDoc->GetShellAt(0); if (parentShell) { @@ -2548,7 +2551,8 @@ nsEventStateManager::MaybeDispatchMouseEventToIframe( void -nsEventStateManager::GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent) +nsEventStateManager::GenerateMouseEnterExit(nsIPresContext* aPresContext, + nsGUIEvent* aEvent) { // Hold onto old target content through the event and reset after. nsCOMPtr targetBeforeEvent = mCurrentTargetContent; @@ -2664,7 +2668,8 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIE } void -nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent) +nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext* aPresContext, + nsGUIEvent* aEvent) { //Hold onto old target content through the event and reset after. nsCOMPtr targetBeforeEvent = mCurrentTargetContent; @@ -2943,7 +2948,8 @@ nsEventStateManager::CheckForAndDispatchClick(nsIPresContext* aPresContext, } PRBool -nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, PRInt32 aFocusedWith) +nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, + PRInt32 aFocusedWith) { aFocusContent->SetFocus(mPresContext); if (aFocusedWith != eEventFocusedByMouse) { @@ -3310,13 +3316,19 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) return NS_OK; } -void nsEventStateManager::TabIndexFrom(nsIContent *aFrom, PRInt32 *aOutIndex) +void +nsEventStateManager::TabIndexFrom(nsIContent *aFrom, PRInt32 *aOutIndex) { if (aFrom->IsContentOfType(nsIContent::eHTML)) { - nsCOMPtr tag; - aFrom->GetTag(getter_AddRefs(tag)); - if (nsHTMLAtoms::a != tag && nsHTMLAtoms::area != tag && nsHTMLAtoms::button != tag && - nsHTMLAtoms::input != tag && nsHTMLAtoms::object != tag && nsHTMLAtoms::select != tag && nsHTMLAtoms::textarea != tag) + nsIAtom *tag = aFrom->Tag(); + + if (tag != nsHTMLAtoms::a && + tag != nsHTMLAtoms::area && + tag != nsHTMLAtoms::button && + tag != nsHTMLAtoms::input && + tag != nsHTMLAtoms::object && + tag != nsHTMLAtoms::select && + tag != nsHTMLAtoms::textarea) return; } @@ -3366,9 +3378,8 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, //Need to do special check in case we're in an imagemap which has multiple content per frame if (mCurrentFocus) { - nsCOMPtr tag; - mCurrentFocus->GetTag(getter_AddRefs(tag)); - if (nsHTMLAtoms::area==tag) { + if (mCurrentFocus->Tag() == nsHTMLAtoms::area && + mCurrentFocus->IsContentOfType(nsIContent::eHTML)) { //Focus is in an imagemap area if (aFrame == mCurrentFocusFrame) { //The current focus map area is in the current frame, don't skip over it. @@ -3413,7 +3424,6 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, (vis->mVisible != NS_STYLE_VISIBILITY_HIDDEN) && (ui->mUserFocus != NS_STYLE_USER_FOCUS_IGNORE) && (ui->mUserFocus != NS_STYLE_USER_FOCUS_NONE) && element) { - nsCOMPtr tag; PRInt32 tabIndex = -1; PRBool disabled = PR_TRUE; PRBool hidden = PR_FALSE; @@ -3428,9 +3438,9 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, mPrefBranch->GetIntPref("accessibility.tabfocus", &tabFocusModel); } - child->GetTag(getter_AddRefs(tag)); + nsIAtom *tag = child->Tag(); if (child->IsContentOfType(nsIContent::eHTML)) { - if (nsHTMLAtoms::input==tag) { + if (tag == nsHTMLAtoms::input) { nsCOMPtr nextInput(do_QueryInterface(child)); if (nextInput) { nextInput->GetDisabled(&disabled); @@ -3457,7 +3467,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, } } } - else if (nsHTMLAtoms::select==tag) { + else if (tag == nsHTMLAtoms::select) { // Select counts as form but not as text disabled = !(tabFocusModel & eTabFocus_formElementsMask); if (!disabled) { @@ -3468,7 +3478,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, } } } - else if (nsHTMLAtoms::textarea==tag) { + else if (tag == nsHTMLAtoms::textarea) { // it's a textarea disabled = PR_FALSE; if (!disabled) { @@ -3479,7 +3489,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, } } } - else if (nsHTMLAtoms::a==tag) { + else if (tag == nsHTMLAtoms::a) { // it's a link disabled = !(tabFocusModel & eTabFocus_linksMask); nsCOMPtr nextAnchor(do_QueryInterface(child)); @@ -3495,7 +3505,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, } } } - else if (nsHTMLAtoms::button==tag) { + else if (tag == nsHTMLAtoms::button) { // Button counts as a form element but not as text disabled = !(tabFocusModel & eTabFocus_formElementsMask); if (!disabled) { @@ -3506,7 +3516,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, } } } - else if (nsHTMLAtoms::img==tag) { + else if (tag == nsHTMLAtoms::img) { // Don't need to set disabled here, because if we // match an imagemap, we'll return from there. if (tabFocusModel & eTabFocus_linksMask) { @@ -3564,7 +3574,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, } } } - else if (nsHTMLAtoms::object==tag) { + else if (tag == nsHTMLAtoms::object) { // OBJECT is treated as a form element. disabled = !(tabFocusModel & eTabFocus_formElementsMask); if (!disabled) { @@ -3574,7 +3584,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, disabled = PR_FALSE; } } - else if (nsHTMLAtoms::iframe==tag || nsHTMLAtoms::frame==tag) { + else if (tag == nsHTMLAtoms::iframe || tag == nsHTMLAtoms::frame) { disabled = PR_TRUE; if (child) { nsCOMPtr doc = child->GetDocument(); @@ -3620,7 +3630,6 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, else disabled = PR_FALSE; } - } //TabIndex not set (-1) treated at same level as set to 0 @@ -3741,7 +3750,8 @@ nsEventStateManager::GetEventTarget(nsIFrame **aFrame) } NS_IMETHODIMP -nsEventStateManager::GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) +nsEventStateManager::GetEventTargetContent(nsEvent* aEvent, + nsIContent** aContent) { if (aEvent && (aEvent->message == NS_FOCUS_CONTENT || @@ -4071,7 +4081,9 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) } nsresult -nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent, PRBool aEnsureWindowHasFocus) +nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, + nsIContent *aContent, + PRBool aEnsureWindowHasFocus) { nsCOMPtr presShell; aPresContext->GetShell(getter_AddRefs(presShell)); @@ -4428,7 +4440,8 @@ nsEventStateManager::UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey) return NS_OK; } -void nsEventStateManager::ForceViewUpdate(nsIView* aView) +void +nsEventStateManager::ForceViewUpdate(nsIView* aView) { // force the update to happen now, otherwise multiple scrolls can // occur before the update is processed. (bug #7354) @@ -4505,7 +4518,9 @@ nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent, return ret; } -void nsEventStateManager::EnsureDocument(nsIPresContext* aPresContext) { +void +nsEventStateManager::EnsureDocument(nsIPresContext* aPresContext) +{ if (!mDocument) { nsCOMPtr presShell; aPresContext->GetShell(getter_AddRefs(presShell)); @@ -4513,12 +4528,16 @@ void nsEventStateManager::EnsureDocument(nsIPresContext* aPresContext) { } } -void nsEventStateManager::EnsureDocument(nsIPresShell* aPresShell) { +void +nsEventStateManager::EnsureDocument(nsIPresShell* aPresShell) +{ if (!mDocument && aPresShell) aPresShell->GetDocument(getter_AddRefs(mDocument)); } -void nsEventStateManager::FlushPendingEvents(nsIPresContext* aPresContext) { +void +nsEventStateManager::FlushPendingEvents(nsIPresContext* aPresContext) +{ NS_PRECONDITION(nsnull != aPresContext, "nsnull ptr"); nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); @@ -4677,7 +4696,8 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, return rv; } -void nsEventStateManager::FocusElementButNotDocument(nsIContent *aContent) +void +nsEventStateManager::FocusElementButNotDocument(nsIContent *aContent) { // Focus an element in the current document, but don't switch document/window focus! @@ -4726,7 +4746,9 @@ void nsEventStateManager::FocusElementButNotDocument(nsIContent *aContent) } -NS_IMETHODIMP nsEventStateManager::MoveFocusToCaret(PRBool aCanFocusDoc, PRBool *aIsSelectionWithFocus) +NS_IMETHODIMP +nsEventStateManager::MoveFocusToCaret(PRBool aCanFocusDoc, + PRBool *aIsSelectionWithFocus) { // mBrowseWithCaret equals the pref accessibility.browsewithcaret // When it's true, the user can arrow around the browser as if it's a @@ -4754,7 +4776,6 @@ NS_IMETHODIMP nsEventStateManager::MoveFocusToCaret(PRBool aCanFocusDoc, PRBool // We could end the loop earlier, such as when we're no longer // in the same frame, by comparing getPrimaryFrameFor(selectionContent) // with a variable holding the starting selectionContent - nsCOMPtr tag; while (testContent) { // Keep testing while selectionContent is equal to something, // eventually we'll run out of ancestors @@ -4764,10 +4785,11 @@ NS_IMETHODIMP nsEventStateManager::MoveFocusToCaret(PRBool aCanFocusDoc, PRBool return NS_OK; // already focused on this node, this whole thing's moot } - testContent->GetTag(getter_AddRefs(tag)); + nsIAtom *tag = testContent->Tag(); // Add better focusable test here later if necessary ... - if (nsHTMLAtoms::a == tag.get()) { + if (tag == nsHTMLAtoms::a && + testContent->IsContentOfType(nsIContent::eHTML)) { *aIsSelectionWithFocus = PR_TRUE; } else { @@ -4812,8 +4834,8 @@ NS_IMETHODIMP nsEventStateManager::MoveFocusToCaret(PRBool aCanFocusDoc, PRBool // Right now we only look for elements with the tag. // Add better focusable test here later if necessary ... if (testContent) { - testContent->GetTag(getter_AddRefs(tag)); - if (nsHTMLAtoms::a == tag.get()) { + if (testContent->Tag() == nsHTMLAtoms::a && + testContent->IsContentOfType(nsIContent::eHTML)) { *aIsSelectionWithFocus = PR_TRUE; FocusElementButNotDocument(testContent); return NS_OK; @@ -4856,7 +4878,8 @@ NS_IMETHODIMP nsEventStateManager::MoveFocusToCaret(PRBool aCanFocusDoc, PRBool -NS_IMETHODIMP nsEventStateManager::MoveCaretToFocus() +NS_IMETHODIMP +nsEventStateManager::MoveCaretToFocus() { // If in HTML content and the pref accessibility.browsewithcaret is TRUE, // then always move the caret to beginning of a new focus @@ -4936,7 +4959,8 @@ NS_IMETHODIMP nsEventStateManager::MoveCaretToFocus() return NS_OK; } -nsresult nsEventStateManager::SetCaretEnabled(nsIPresShell *aPresShell, PRBool aEnabled) +nsresult +nsEventStateManager::SetCaretEnabled(nsIPresShell *aPresShell, PRBool aEnabled) { nsCOMPtr caret; aPresShell->GetCaret(getter_AddRefs(caret)); @@ -4959,8 +4983,11 @@ nsresult nsEventStateManager::SetCaretEnabled(nsIPresShell *aPresShell, PRBool a return NS_OK; } -nsresult nsEventStateManager::SetContentCaretVisible(nsIPresShell* aPresShell, nsIContent *aFocusedContent, PRBool aVisible) -{ +nsresult +nsEventStateManager::SetContentCaretVisible(nsIPresShell* aPresShell, + nsIContent *aFocusedContent, + PRBool aVisible) +{ // When browsing with caret, make sure caret is visible after new focus nsCOMPtr caret; aPresShell->GetCaret(getter_AddRefs(caret)); @@ -5127,10 +5154,8 @@ nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell) if (!docContent) return PR_FALSE; - - nsCOMPtr tag; - docContent->GetTag(getter_AddRefs(tag)); - return (tag == nsHTMLAtoms::iframe); + + return docContent->Tag() == nsHTMLAtoms::iframe; } //------------------------------------------------------- diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index df6cb78f0c1..4dbdbc13793 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -48,7 +48,6 @@ #include "nsISelection.h" #include "nsIEnumerator.h" - #include "nsCRT.h" #include "nsIEventStateManager.h" #include "nsIPrivateDOMEvent.h" @@ -58,19 +57,18 @@ #include "prprf.h" #include "nsCOMPtr.h" - #include "nsIContent.h" #include "nsTextFragment.h" #include "nsVoidArray.h" #include "nsINameSpaceManager.h" #include "nsITextContent.h" #include "nsIURI.h" +#include "nsLayoutAtoms.h" // XXX share all id's in this dir - - -class nsAttributeContent : public nsITextContent, public nsIAttributeContent { +class nsAttributeContent : public nsITextContent, public nsIAttributeContent +{ public: friend nsresult NS_NewAttributeContent(nsAttributeContent** aNewFrame); @@ -92,10 +90,9 @@ public: return NS_OK; } - NS_IMETHOD GetTag(nsIAtom** aResult) const + nsIAtom *Tag() const { - *aResult = nsnull; - return NS_OK; + return nsLayoutAtoms::textTagName; } NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const @@ -171,9 +168,9 @@ public: PRUint32 aFlags, nsEventStatus* aEventStatus); - NS_IMETHOD GetContentID(PRUint32* aID) { - *aID = 0; - return NS_ERROR_NOT_IMPLEMENTED; + virtual PRUint32 ContentID() const { + NS_ERROR("nsAttributeContent::ContentID() not implemented!"); + return 0; } NS_IMETHOD SetContentID(PRUint32 aID) { @@ -182,7 +179,7 @@ public: NS_IMETHOD RangeAdd(nsIDOMRange* aRange); NS_IMETHOD RangeRemove(nsIDOMRange* aRange); - NS_IMETHOD GetRangeList(nsVoidArray** aResult) const; + const nsVoidArray * GetRangeList() const; // Implementation for nsIContent NS_IMETHOD_(PRBool) CanContainChildren() const { return PR_FALSE; } @@ -237,8 +234,7 @@ public: nsTextFragment mText; PRInt32 mNameSpaceID; - nsIAtom* mAttrName; - + nsCOMPtr mAttrName; }; @@ -247,7 +243,7 @@ NS_NewAttributeContent(nsIContent** aContent) { NS_ENSURE_ARG_POINTER(aContent); - nsAttributeContent* it = new nsAttributeContent; + nsAttributeContent* it = new nsAttributeContent(); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -261,27 +257,24 @@ nsAttributeContent::nsAttributeContent() : mText() { mContent = nsnull; - mAttrName = nsnull; } //---------------------------------------------------------------------- nsAttributeContent::~nsAttributeContent() { - NS_IF_RELEASE(mAttrName); - //NS_IF_RELEASE(mDocument); } //---------------------------------------------------------------------- NS_IMETHODIMP -nsAttributeContent::Init(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttrName) +nsAttributeContent::Init(nsIContent* aContent, PRInt32 aNameSpaceID, + nsIAtom* aAttrName) { - NS_ASSERTION((nsnull == mContent) && (nsnull != aContent), "null ptr"); + NS_ENSURE_TRUE(aAttrName && aContent, NS_ERROR_NULL_POINTER); + mContent = aContent; - NS_IF_RELEASE(mAttrName); mNameSpaceID = aNameSpaceID; mAttrName = aAttrName; - NS_ADDREF(mAttrName); return NS_OK; } @@ -292,7 +285,7 @@ nsAttributeContent::Init(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aA * @param _classiiddef The name of the #define symbol that defines the IID * for the class (e.g. NS_ISUPPORTS_IID) * -*/ + */ NS_INTERFACE_MAP_BEGIN(nsAttributeContent) NS_INTERFACE_MAP_ENTRY(nsIContent) @@ -343,10 +336,10 @@ nsAttributeContent::RangeRemove(nsIDOMRange* aRange) } -nsresult -nsAttributeContent::GetRangeList(nsVoidArray** aResult) const +const nsVoidArray * +nsAttributeContent::GetRangeList() const { - return NS_ERROR_FAILURE; + return nsnull; } NS_IMETHODIMP diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 5dd957cd988..446a847ebe5 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1430,17 +1430,17 @@ SinkContext::CloseContainer(const nsHTMLTag aTag) if (mStack[mStackPos].mNumFlushed < content->GetChildCount()) { #ifdef NS_DEBUG - // Tracing code - nsCOMPtr tag; - mStack[mStackPos].mContent->GetTag(getter_AddRefs(tag)); - const char *tagStr; - tag->GetUTF8String(&tagStr); + { + // Tracing code + const char *tagStr; + mStack[mStackPos].mContent->Tag()->GetUTF8String(&tagStr); - SINK_TRACE(SINK_TRACE_REFLOW, - ("SinkContext::CloseContainer: reflow on notifyImmediate " - "tag=%s newIndex=%d stackPos=%d", - tagStr, - mStack[mStackPos].mNumFlushed, mStackPos)); + SINK_TRACE(SINK_TRACE_REFLOW, + ("SinkContext::CloseContainer: reflow on notifyImmediate " + "tag=%s newIndex=%d stackPos=%d", + tagStr, + mStack[mStackPos].mNumFlushed, mStackPos)); + } #endif mSink->NotifyAppend(content, mStack[mStackPos].mNumFlushed); } @@ -1846,16 +1846,16 @@ SinkContext::FlushTags(PRBool aNotify) if (!flushed && (mStack[stackPos].mNumFlushed < childCount)) { #ifdef NS_DEBUG - // Tracing code - nsCOMPtr tag; - mStack[stackPos].mContent->GetTag(getter_AddRefs(tag)); - const char* tagStr; - tag->GetUTF8String(&tagStr); + { + // Tracing code + const char* tagStr; + mStack[stackPos].mContent->Tag()->GetUTF8String(&tagStr); - SINK_TRACE(SINK_TRACE_REFLOW, - ("SinkContext::FlushTags: tag=%s from newindex=%d at " - "stackPos=%d", tagStr, - mStack[stackPos].mNumFlushed, stackPos)); + SINK_TRACE(SINK_TRACE_REFLOW, + ("SinkContext::FlushTags: tag=%s from newindex=%d at " + "stackPos=%d", tagStr, + mStack[stackPos].mNumFlushed, stackPos)); + } #endif if ((mStack[stackPos].mInsertionPoint != -1) && (mStackPos > (stackPos + 1))) { diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 5f011836f0c..77e323430bb 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1426,12 +1426,9 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID, if (!IsXHTML() && aAttribute == nsHTMLAtoms::name && aNameSpaceID == kNameSpaceID_None) { - nsCOMPtr tag; nsAutoString value; - aContent->GetTag(getter_AddRefs(tag)); - - if (IsNamedItem(aContent, tag, value)) { + if (IsNamedItem(aContent, aContent->Tag(), value)) { nsresult rv = RemoveFromNameTable(value, aContent); if (NS_FAILED(rv)) { @@ -1459,12 +1456,9 @@ nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, if (!IsXHTML() && aAttribute == nsHTMLAtoms::name && aNameSpaceID == kNameSpaceID_None) { - nsCOMPtr tag; nsAutoString value; - aContent->GetTag(getter_AddRefs(tag)); - - if (IsNamedItem(aContent, tag, value)) { + if (IsNamedItem(aContent, aContent->Tag(), value)) { nsresult rv = UpdateNameTableEntry(value, aContent); if (NS_FAILED(rv)) { @@ -3499,9 +3493,7 @@ nsHTMLDocument::RemoveFromIdTable(nsIContent *aContent) nsresult nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent) { - nsCOMPtr tag; - - aContent->GetTag(getter_AddRefs(tag)); + nsIAtom *tag = aContent->Tag(); if (tag == nsLayoutAtoms::textTagName) { // Text nodes are not named items nor can they have children. @@ -3538,9 +3530,7 @@ nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent) nsresult nsHTMLDocument::RegisterNamedItems(nsIContent *aContent) { - nsCOMPtr tag; - - aContent->GetTag(getter_AddRefs(tag)); + nsIAtom *tag = aContent->Tag(); if (tag == nsLayoutAtoms::textTagName) { // Text nodes are not named items nor can they have children. @@ -3582,8 +3572,7 @@ FindNamedItems(const nsAString& aName, nsIContent *aContent, NS_ASSERTION(aEntry.mContentList, "Entry w/o content list passed to FindNamedItems()!"); - nsCOMPtr tag; - aContent->GetTag(getter_AddRefs(tag)); + nsIAtom *tag = aContent->Tag(); if (tag == nsLayoutAtoms::textTagName) { // Text nodes are not named items nor can they have children. @@ -3734,9 +3723,8 @@ nsHTMLDocument::ResolveName(const nsAString& aName, nsIContent *e = entry->mIdContent; - if (e && e != ID_NOT_IN_DOCUMENT) { - nsCOMPtr tag; - e->GetTag(getter_AddRefs(tag)); + if (e && e != ID_NOT_IN_DOCUMENT && e->IsContentOfType(nsIContent::eHTML)) { + nsIAtom *tag = e->Tag(); if (tag == nsHTMLAtoms::embed || tag == nsHTMLAtoms::img || diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index b5db2bd961a..20e22d9a1aa 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -3153,7 +3153,7 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, aContent->GetNameSpaceID(&mNameSpaceID); // get the tag and parent - aContent->GetTag(&mContentTag); + mContentTag = aContent->Tag(); mParentContent = aContent->GetParent(); // get the event state @@ -3218,7 +3218,6 @@ RuleProcessorData::~RuleProcessorData() if (mParentData) mParentData->Destroy(mPresContext); - NS_IF_RELEASE(mContentTag); NS_IF_RELEASE(mContentID); NS_IF_RELEASE(mStyledContent); @@ -3330,8 +3329,7 @@ inline PRBool IsQuirkEventSensitive(nsIAtom *aContentTag) static PRBool IsSignificantChild(nsIContent* aChild, PRBool aAcceptNonWhitespaceText) { - nsCOMPtr tag; - aChild->GetTag(getter_AddRefs(tag)); // skip text & comments + nsIAtom *tag = aChild->Tag(); // skip text, comments, and PIs if ((tag != nsLayoutAtoms::textTagName) && (tag != nsLayoutAtoms::commentTagName) && (tag != nsLayoutAtoms::processingInstructionTagName)) { diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 074a607cea2..12afb819c1f 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -594,23 +594,24 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum } NS_IMETHODIMP -nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult) +nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, + nsIAtom** aResult) { nsCOMPtr binding; GetBinding(aContent, getter_AddRefs(binding)); if (binding) { - nsCOMPtr tag; - binding->GetBaseTag(aNameSpaceID, getter_AddRefs(tag)); - if (tag) { - *aResult = tag; - NS_ADDREF(*aResult); + binding->GetBaseTag(aNameSpaceID, aResult); + + if (*aResult) { return NS_OK; } } aContent->GetNameSpaceID(aNameSpaceID); - return aContent->GetTag(aResult); + NS_ADDREF(*aResult = aContent->Tag()); + + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index daf925c79ad..de89cff3975 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -553,9 +553,11 @@ nsXBLBinding::GenerateAnonymousContent() for (PRUint32 i = 0; i < length; i++) { children->Item(i, getter_AddRefs(node)); childContent = do_QueryInterface(node); - nsCOMPtr tag; - childContent->GetTag(getter_AddRefs(tag)); - if (tag != nsXULAtoms::observes && tag != nsXULAtoms::templateAtom) { + + nsINodeInfo *ni = childContent->GetNodeInfo(); + + if (!ni || (!ni->Equals(nsXULAtoms::observes, kNameSpaceID_XUL) && + !ni->Equals(nsXULAtoms::templateAtom, kNameSpaceID_XUL))) { hasContent = PR_FALSE; break; } @@ -631,9 +633,12 @@ nsXBLBinding::GenerateAnonymousContent() else { // We were unable to place this child. All anonymous content // should be thrown out. Special-case template and observes. - nsCOMPtr tag; - childContent->GetTag(getter_AddRefs(tag)); - if (tag != nsXULAtoms::observes && tag != nsXULAtoms::templateAtom) { + + nsINodeInfo *ni = childContent->GetNodeInfo(); + + if (!ni || + (!ni->Equals(nsXULAtoms::observes, kNameSpaceID_XUL) && + !ni->Equals(nsXULAtoms::templateAtom, kNameSpaceID_XUL))) { // Kill all anonymous content. mContent = nsnull; bindingManager->SetContentListFor(mBoundElement, nsnull); @@ -1233,9 +1238,8 @@ nsXBLBinding::GetImmediateChild(nsIAtom* aTag, nsIContent** aResult) for (PRUint32 i = 0; i < childCount; i++) { nsIContent *child = binding->GetChildAt(i); - nsCOMPtr tag; - child->GetTag(getter_AddRefs(tag)); - if (aTag == tag) { + + if (aTag == child->Tag()) { *aResult = child; NS_ADDREF(*aResult); return; diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index 9f2889bbf59..5d21077ce16 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -499,9 +499,11 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, // See if we're the tag in XUL, and see if value is being // set or unset on us. We may also be a tag that is having // xbl:text set on us. - nsCOMPtr tag; - realElement->GetTag(getter_AddRefs(tag)); - if (dstAttr == nsXBLAtoms::xbltext || (tag == nsHTMLAtoms::html) && (dstAttr == nsHTMLAtoms::value)) { + + if (dstAttr == nsXBLAtoms::xbltext || + (realElement->Tag() == nsHTMLAtoms::html && + realElement->IsContentOfType(nsIContent::eHTML)) && + dstAttr == nsHTMLAtoms::value) { // Flush out all our kids. PRUint32 childCount = realElement->GetChildCount(); for (PRUint32 i = 0; i < childCount; i++) @@ -606,9 +608,7 @@ nsXBLPrototypeBinding::GetInsertionPoint(nsIContent* aBoundElement, nsIContent** aDefaultContent) { if (mInsertionPointTable) { - nsCOMPtr tag; - aChild->GetTag(getter_AddRefs(tag)); - nsISupportsKey key(tag); + nsISupportsKey key(aChild->Tag()); nsXBLInsertionPointEntry* entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key)); if (!entry) { nsISupportsKey key2(nsXBLAtoms::children); @@ -726,9 +726,8 @@ nsXBLPrototypeBinding::GetImmediateChild(nsIAtom* aTag) for (PRUint32 i = 0; i < childCount; i++) { nsIContent *child = mBinding->GetChildAt(i); - nsCOMPtr tag; - child->GetTag(getter_AddRefs(tag)); - if (aTag == tag) { + + if (aTag == child->Tag()) { NS_ADDREF(child); return child; } @@ -769,9 +768,9 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement, nsCOMPtr childPoint; if (aBoundElement) { - nsCOMPtr tag; - templParent->GetTag(getter_AddRefs(tag)); - if (tag == nsXBLAtoms::children) { + nsINodeInfo *ni = templParent->GetNodeInfo(); + + if (ni->Equals(nsXBLAtoms::children, kNameSpaceID_XBL)) { childPoint = templParent; templParent = childPoint->GetParent(); } @@ -897,13 +896,14 @@ PRBool PR_CALLBACK SetAttrs(nsHashKey* aKey, void* aData, void* aClosure) element); if (realElement) { realElement->SetAttr(kNameSpaceID_None, dst, value, PR_FALSE); - nsCOMPtr tag; - realElement->GetTag(getter_AddRefs(tag)); + if (dst == nsXBLAtoms::xbltext || - (tag == nsHTMLAtoms::html) && (dst == nsHTMLAtoms::value) && !value.IsEmpty()) { + (realElement->Tag() == nsHTMLAtoms::html && + realElement->IsContentOfType(nsIContent::eHTML) && + dst == nsHTMLAtoms::value && !value.IsEmpty())) { nsCOMPtr textNode; - nsCOMPtr domDoc( - do_QueryInterface(changeData->mBoundElement->GetDocument())); + nsCOMPtr domDoc = + do_QueryInterface(changeData->mBoundElement->GetDocument()); domDoc->CreateTextNode(value, getter_AddRefs(textNode)); nsCOMPtr dummy; nsCOMPtr domElement(do_QueryInterface(realElement)); @@ -1233,9 +1233,7 @@ nsXBLPrototypeBinding::GetNestedChildren(nsIAtom* aTag, nsIContent* aContent, for (PRUint32 i = 0; i < childCount; i++) { nsIContent *child = aContent->GetChildAt(i); - nsCOMPtr tag; - child->GetTag(getter_AddRefs(tag)); - if (aTag == tag) { + if (aTag == child->Tag()) { if (!*aList) NS_NewISupportsArray(aList); // Addref happens here. (*aList)->AppendElement(child); diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 8c53d242c20..483d164c106 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -673,7 +673,8 @@ nsXBLService::FlushStyleBindings(nsIContent* aContent) } NS_IMETHODIMP -nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult) +nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, + nsIAtom** aResult) { nsIDocument* document = aContent->GetDocument(); if (document) { @@ -684,7 +685,8 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** } aContent->GetNameSpaceID(aNameSpaceID); - aContent->GetTag(aResult); // Addref happens here. + NS_ADDREF(*aResult = aContent->Tag()); + return NS_OK; } @@ -1057,14 +1059,17 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, bindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); } - nsCOMPtr tagName; + nsINodeInfo *ni = nsnull; if (aBoundElement) - aBoundElement->GetTag(getter_AddRefs(tagName)); + ni = aBoundElement->GetNodeInfo(); + if (!info && bindingManager && - (tagName != nsXULAtoms::scrollbar) && - (tagName != nsXULAtoms::thumb) && - (tagName != nsHTMLAtoms::input) && - (tagName != nsHTMLAtoms::select) && !aForceSyncLoad) { + (!ni || (!ni->Equals(nsXULAtoms::scrollbar, kNameSpaceID_XUL) && + !ni->Equals(nsXULAtoms::thumb, kNameSpaceID_XUL))) && + (!ni || (!ni->Equals(nsHTMLAtoms::input) && + !ni->Equals(nsHTMLAtoms::select) && + !aBoundElement->IsContentOfType(nsIContent::eHTML))) && + !aForceSyncLoad) { // The third line of defense is to investigate whether or not the // document is currently being loaded asynchronously. If so, there's no // document yet, but we need to glom on our request so that it will be @@ -1146,13 +1151,15 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun if (aBoundDocument) loadGroup = aBoundDocument->GetDocumentLoadGroup(); - nsCOMPtr tagName; + nsINodeInfo *ni = nsnull; if (aBoundElement) - aBoundElement->GetTag(getter_AddRefs(tagName)); + ni = aBoundElement->GetNodeInfo(); - if (tagName == nsXULAtoms::scrollbar || - tagName == nsXULAtoms::thumb || - tagName == nsHTMLAtoms::select || IsResourceURI(aDocumentURI)) + if (ni && (ni->Equals(nsXULAtoms::scrollbar, kNameSpaceID_XUL) || + ni->Equals(nsXULAtoms::thumb, kNameSpaceID_XUL) || + (ni->Equals(nsHTMLAtoms::select) && + aBoundElement->IsContentOfType(nsIContent::eHTML))) || + IsResourceURI(aDocumentURI)) aForceSyncLoad = PR_TRUE; if(!aForceSyncLoad) { diff --git a/mozilla/content/xml/content/src/nsXMLCDATASection.cpp b/mozilla/content/xml/content/src/nsXMLCDATASection.cpp index 90baa5ae9dd..86017ce9de3 100644 --- a/mozilla/content/xml/content/src/nsXMLCDATASection.cpp +++ b/mozilla/content/xml/content/src/nsXMLCDATASection.cpp @@ -66,7 +66,7 @@ public: // Empty interface // nsIContent - NS_IMETHOD GetTag(nsIAtom** aResult) const; + virtual nsIAtom *Tag() const; NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags); #ifdef DEBUG NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; @@ -113,12 +113,10 @@ NS_IMPL_ADDREF_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode) NS_IMPL_RELEASE_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode) -NS_IMETHODIMP -nsXMLCDATASection::GetTag(nsIAtom** aResult) const +nsIAtom * +nsXMLCDATASection::Tag() const { - *aResult = nsLayoutAtoms::textTagName; - NS_ADDREF(*aResult); - return NS_OK; + return nsLayoutAtoms::textTagName; } NS_IMETHODIMP_(PRBool) diff --git a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp index f562de0727d..db81ccf5de1 100644 --- a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp +++ b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp @@ -112,12 +112,10 @@ nsXMLProcessingInstruction::GetAttrValue(const nsAString& aAttr, return nsParserUtils::GetQuotedAttributeValue(data, aAttr, aValue); } -NS_IMETHODIMP -nsXMLProcessingInstruction::GetTag(nsIAtom** aResult) const +nsIAtom * +nsXMLProcessingInstruction::Tag() const { - *aResult = nsLayoutAtoms::processingInstructionTagName; - NS_ADDREF(*aResult); - return NS_OK; + return nsLayoutAtoms::processingInstructionTagName; } NS_IMETHODIMP_(PRBool) diff --git a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.h b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.h index a3424e07b11..64ffde0e0f1 100644 --- a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.h +++ b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.h @@ -64,7 +64,7 @@ public: NS_DECL_NSIDOMPROCESSINGINSTRUCTION // nsIContent - NS_IMETHOD GetTag(nsIAtom** aResult) const; + virtual nsIAtom *Tag() const; NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags); #ifdef DEBUG diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 477b347d37c..c91d690e622 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -536,9 +536,8 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, PRBool* aAppendContent) if (!aContent->IsContentOfType(nsIContent::eHTML)) { return NS_OK; } - - nsCOMPtr tagAtom; - aContent->GetTag(getter_AddRefs(tagAtom)); + + nsIAtom *tagAtom = aContent->Tag(); nsresult rv = NS_OK; @@ -1304,11 +1303,12 @@ nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset, if (!doc) return NS_OK; - nsCOMPtr docType; - + nsCOMPtr name = do_GetAtom(aName); + NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); + // Create a new doctype node - rv = NS_NewDOMDocumentType(getter_AddRefs(docType), - aName, nsnull, nsnull, + nsCOMPtr docType; + rv = NS_NewDOMDocumentType(getter_AddRefs(docType), name, nsnull, nsnull, aPublicId, aSystemId, aSubset); if (NS_FAILED(rv) || !docType) { return rv; diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 5b4bb0d6043..1525e302c96 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -607,7 +607,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, } else if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) { aCommand = kLoadAsData; // XBL, for example, needs scripts and styles } - + if (nsCRT::strcmp(aCommand, kLoadAsData) == 0) { mLoadedAsData = PR_TRUE; } diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 43c6a1b67eb..dad30637cc1 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -2068,7 +2068,6 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) // On the removal of a , , or element, // the possibility exists that some of the items in the removed subtree // are selected (and therefore need to be deselected). We need to account for this. - nsCOMPtr tag; nsCOMPtr controlElement; nsCOMPtr listBox; PRBool fireSelectionHandler = PR_FALSE; @@ -2077,8 +2076,8 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) // anything else = index to re-set as current PRInt32 newCurrentIndex = -1; - oldKid->GetTag(getter_AddRefs(tag)); - if (tag == nsXULAtoms::listitem) { + nsINodeInfo *ni = oldKid->GetNodeInfo(); + if (ni && ni->Equals(nsXULAtoms::listitem, kNameSpaceID_XUL)) { // This is the nasty case. We have (potentially) a slew of selected items // and cells going away. // First, retrieve the tree. @@ -2186,12 +2185,10 @@ nsXULElement::GetNameSpaceID(PRInt32* aNameSpaceID) const return NS_OK; } -NS_IMETHODIMP -nsXULElement::GetTag(nsIAtom** aResult) const +nsIAtom * +nsXULElement::Tag() const { - NS_ADDREF(*aResult = NodeInfo()->NameAtom()); - - return NS_OK; + return NodeInfo()->NameAtom(); } NS_IMETHODIMP_(already_AddRefed) @@ -2237,17 +2234,14 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue) PRBool validElement = PR_TRUE; // find out what type of content node this is - nsCOMPtr atom; - nsresult rv = GetTag(getter_AddRefs(atom)); - if (NS_SUCCEEDED(rv) && atom) { - if (atom == nsXULAtoms::label) { - // XXXjag a side-effect is that we filter out anonymous