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
This commit is contained in:
jst%mozilla.jstenback.com 2003-11-19 01:20:56 +00:00
parent 19a3086422
commit 2affc5b4f0
132 changed files with 1831 additions and 2341 deletions

View File

@ -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);

View File

@ -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 } }

View File

@ -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,10 +370,13 @@ 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
@ -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

View File

@ -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<nsIHTMLContent> htmlcontent = do_QueryInterface(aContent);
if (!htmlcontent) {
*aID = eHTMLTag_unknown;
return NS_OK;
if (!aContent->IsContentOfType(nsIContent::eHTML)) {
return eHTMLTag_unknown;
}
nsCOMPtr<nsIAtom> 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);

View File

@ -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);

View File

@ -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

View File

@ -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<nsIAtom> 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.

View File

@ -359,8 +359,12 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
selContent = selContent->GetParent())
{
// checking for selection inside a plaintext form widget
nsCOMPtr<nsIAtom> atom;
selContent->GetTag(getter_AddRefs(atom));
if (!selContent->IsContentOfType(nsIContent::eHTML)) {
continue;
}
nsIAtom *atom = selContent->Tag();
if (atom == nsHTMLAtoms::input ||
atom == nsHTMLAtoms::textarea)

View File

@ -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

View File

@ -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<nsIAtom> mName;
nsCOMPtr<nsIDOMNamedNodeMap> mEntities;
nsCOMPtr<nsIDOMNamedNodeMap> 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,

View File

@ -343,7 +343,10 @@ nsDOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
{
NS_ENSURE_ARG_POINTER(aReturn);
return NS_NewDOMDocumentType(aReturn, aQualifiedName, nsnull, nsnull,
nsCOMPtr<nsIAtom> name = do_GetAtom(aQualifiedName);
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
return NS_NewDOMDocumentType(aReturn, name, nsnull, nsnull,
aPublicId, aSystemId, nsString());
}

View File

@ -388,21 +388,8 @@ nsDocumentEncoder::SerializeToStringRecursive(nsIDOMNode* aNode,
PRBool
nsDocumentEncoder::IsTag(nsIDOMNode* aNode, nsIAtom* aAtom)
{
if (aNode)
{
nsCOMPtr<nsIAtom> atom;
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content)
content->GetTag(getter_AddRefs(atom));
if (atom)
{
if (atom.get() == aAtom)
{
return PR_TRUE;
}
}
}
return PR_FALSE;
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<nsIDOMNode> 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<nsIAtom> 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<nsIAtom> 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<nsIContent> content = do_QueryInterface(parent);
if (content)
{
nsCOMPtr<nsIAtom> 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<nsIContent> content = do_QueryInterface(parent);
if (content)
{
nsCOMPtr<nsIAtom> 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);

View File

@ -587,10 +587,7 @@ nsFrameLoader::GetURL(nsAString& aURI)
{
aURI.Truncate();
nsCOMPtr<nsIAtom> 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);

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -603,20 +603,20 @@ 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)) ){
((attrName == nsHTMLAtoms::value) ||
(attrName == nsHTMLAtoms::defaultvalue))){
continue;
}
if (mIsCopying && mIsFirstChildOfOL && (aTagName == nsHTMLAtoms::li) &&
(attrName.get() == nsHTMLAtoms::value)){
(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<nsIAtom> 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<nsIAtom> 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;

View File

@ -165,6 +165,9 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn,
}
#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<nsIHTMLContent> htmlcontent = do_QueryInterface(aContent);
if (!htmlcontent) {
*aID = eHTMLTag_unknown;
return NS_OK;
if (!aContent->IsContentOfType(nsIContent::eHTML)) {
return eHTMLTag_unknown;
}
nsCOMPtr<nsIAtom> tagname;
mContent->GetTag(getter_AddRefs(tagname));
if (!tagname) return NS_ERROR_FAILURE;
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
nsIParserService* parserService =
nsContentUtils::GetParserServiceWeakRef();
if (!parserService)
return NS_ERROR_FAILURE;
PRInt32 id;
nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id);
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!");
return parserService->HTMLAtomTagToId(tagname, aID);
return id;
}
/**

View File

@ -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,

View File

@ -3662,16 +3662,12 @@ nsPrintEngine::FindFrameByType(nsIPresContext* aPresContext,
aParentFrame->FirstChild(aPresContext, nsnull, &child);
while (child) {
nsIContent* content = child->GetContent();
if (content) {
nsCOMPtr<nsIAtom> type;
content->GetTag(getter_AddRefs(type));
if (type.get() == aType) {
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) {
return fndFrame;

View File

@ -873,12 +873,12 @@ nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent*
iter->Init(aSourceNode);
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIDOMNode> domNode(do_QueryInterface(textNode));

View File

@ -148,7 +148,7 @@ struct nsScrollSelectionIntoViewEvent;
PRBool IsValidSelectionPoint(nsSelection *aFrameSel, nsIContent *aContent);
PRBool IsValidSelectionPoint(nsSelection *aFrameSel, nsIDOMNode *aDomNode);
static nsCOMPtr<nsIAtom> 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<nsIAtom> GetTag(nsIDOMNode *aNode)
static
nsIAtom *GetTag(nsIDOMNode *aNode)
{
nsCOMPtr<nsIAtom> atom;
if (!aNode)
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIDOMNode> parent(aDomNode);
nsCOMPtr<nsIDOMNode> current(aDomNode);
PRInt32 childOffset;
nsCOMPtr<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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)
{
nsCOMPtr<nsIContent>content;
content = do_QueryInterface(aParentNode);
nsCOMPtr<nsIAtom> 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");

View File

@ -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

View File

@ -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)

View File

@ -580,9 +580,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
PRInt32 elementNsID;
content->GetNameSpaceID(&elementNsID);
if (elementNsID == kNameSpaceID_XHTML) {
nsCOMPtr<nsIAtom> elementName;
content->GetTag(getter_AddRefs(elementName));
if (IsShorthandAttr(attrName, elementName) &&
if (IsShorthandAttr(attrName, content->Tag()) &&
valueStr.IsEmpty()) {
valueStr = nameStr;
}

View File

@ -879,16 +879,10 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext,
if (mAccessKeys->Exists(&key)) {
nsCOMPtr<nsIContent> 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<nsIAtom> atom;
nsresult rv = content->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(rv) && atom) {
if (atom == nsXULAtoms::label) {
if (content->Tag() == nsXULAtoms::label) {
// If anything fails, this will be null ...
nsCOMPtr<nsIDOMElement> element;
@ -904,7 +898,6 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext,
// referenced by |element|, or clear it.
content = do_QueryInterface(element);
}
}
if (!content)
return;
@ -929,10 +922,8 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext,
element) {
// find out what type of content node this is
nsCOMPtr<nsIAtom> 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
@ -947,7 +938,6 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext,
}
}
}
}
} else { // otherwise, it must be HTML
// It's hard to say what HTML4 wants us to do in all cases.
// So for now we'll settle for A) Set focus
@ -1078,7 +1068,8 @@ 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) {
@ -1098,16 +1089,15 @@ nsEventStateManager :: CreateClickHoldTimer ( nsIPresContext* inPresContext, nsG
return;
// check for a <menubutton> like bookmarks
nsCOMPtr<nsIAtom> 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;
@ -1207,44 +1197,51 @@ nsEventStateManager :: FireContextClick ( )
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<nsIAtom> tag;
lastContent->GetTag ( getter_AddRefs(tag) );
nsCOMPtr<nsIDOMHTMLInputElement> 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") )
allowedToDispatch = PR_FALSE;
}
}
else if ( isFormControl && tag != nsHTMLAtoms::textarea )
// catches combo-boxes, <object>
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 )
if (lastContent->IsContentOfType(nsIContent::eXUL)) {
if (tag == nsXULAtoms::scrollbar ||
tag == nsXULAtoms::scrollbarbutton ||
tag == nsXULAtoms::button)
allowedToDispatch = PR_FALSE;
else if (tag == nsXULAtoms::toolbarbutton) {
// a <toolbarbutton> that has the container attribute set will already have its
// own dropdown.
// a <toolbarbutton> that has the container attribute set
// will already have its own dropdown.
nsAutoString container;
lastContent->GetAttr(kNameSpaceID_None, nsXULAtoms::container, container);
if ( container.Length() )
lastContent->GetAttr(kNameSpaceID_None, nsXULAtoms::container,
container);
if (!container.IsEmpty())
allowedToDispatch = PR_FALSE;
}
}
else if (lastContent->IsContentOfType(eHTML)) {
nsCOMPtr<nsIFormControl> 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) {
// stop selection tracking, we're in control now
nsCOMPtr<nsIFrameSelection> frameSel;
GetSelection ( mGestureDownFrame, mEventPresContext, getter_AddRefs(frameSel) );
GetSelection(mGestureDownFrame, mEventPresContext,
getter_AddRefs(frameSel));
if (frameSel) {
PRBool mouseDownState = PR_TRUE;
frameSel->GetMouseDownState(&mouseDownState);
@ -1253,7 +1250,8 @@ 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.
@ -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;
@ -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<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsIAtom *tag = aContent->Tag();
if (tag == nsHTMLAtoms::input ||
if (((tag == nsHTMLAtoms::input ||
tag == nsHTMLAtoms::select ||
tag == nsHTMLAtoms::textarea ||
tag == nsHTMLAtoms::button) {
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<nsIAtom> 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<nsIContent> 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<nsIContent> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIDOMHTMLInputElement> 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<nsIDOMHTMLAnchorElement> 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<nsIDocument> 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<nsIPresShell> 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<nsIPresShell> 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<nsIPresShell> 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<nsIAtom> 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 <a> 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<nsICaret> caret;
aPresShell->GetCaret(getter_AddRefs(caret));
@ -4959,7 +4983,10 @@ 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<nsICaret> caret;
@ -5128,9 +5155,7 @@ nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell)
if (!docContent)
return PR_FALSE;
nsCOMPtr<nsIAtom> tag;
docContent->GetTag(getter_AddRefs(tag));
return (tag == nsHTMLAtoms::iframe);
return docContent->Tag() == nsHTMLAtoms::iframe;
}
//-------------------------------------------------------

View File

@ -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<nsIAtom> 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;
}
@ -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

View File

@ -1430,17 +1430,17 @@ SinkContext::CloseContainer(const nsHTMLTag aTag)
if (mStack[mStackPos].mNumFlushed < content->GetChildCount()) {
#ifdef NS_DEBUG
{
// Tracing code
nsCOMPtr<nsIAtom> tag;
mStack[mStackPos].mContent->GetTag(getter_AddRefs(tag));
const char *tagStr;
tag->GetUTF8String(&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));
}
#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<nsIAtom> tag;
mStack[stackPos].mContent->GetTag(getter_AddRefs(tag));
const char* tagStr;
tag->GetUTF8String(&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));
}
#endif
if ((mStack[stackPos].mInsertionPoint != -1) &&
(mStackPos > (stackPos + 1))) {

View File

@ -1426,12 +1426,9 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID,
if (!IsXHTML() && aAttribute == nsHTMLAtoms::name &&
aNameSpaceID == kNameSpaceID_None) {
nsCOMPtr<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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 ||

View File

@ -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<nsIAtom> 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)) {

View File

@ -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<nsIXBLBinding> binding;
GetBinding(aContent, getter_AddRefs(binding));
if (binding) {
nsCOMPtr<nsIAtom> 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

View File

@ -553,9 +553,11 @@ nsXBLBinding::GenerateAnonymousContent()
for (PRUint32 i = 0; i < length; i++) {
children->Item(i, getter_AddRefs(node));
childContent = do_QueryInterface(node);
nsCOMPtr<nsIAtom> 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<nsIAtom> 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<nsIAtom> tag;
child->GetTag(getter_AddRefs(tag));
if (aTag == tag) {
if (aTag == child->Tag()) {
*aResult = child;
NS_ADDREF(*aResult);
return;

View File

@ -499,9 +499,11 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
// See if we're the <html> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIContent> childPoint;
if (aBoundElement) {
nsCOMPtr<nsIAtom> 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<nsIAtom> 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<nsIDOMText> textNode;
nsCOMPtr<nsIDOMDocument> domDoc(
do_QueryInterface(changeData->mBoundElement->GetDocument()));
nsCOMPtr<nsIDOMDocument> domDoc =
do_QueryInterface(changeData->mBoundElement->GetDocument());
domDoc->CreateTextNode(value, getter_AddRefs(textNode));
nsCOMPtr<nsIDOMNode> dummy;
nsCOMPtr<nsIDOMElement> 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<nsIAtom> tag;
child->GetTag(getter_AddRefs(tag));
if (aTag == tag) {
if (aTag == child->Tag()) {
if (!*aList)
NS_NewISupportsArray(aList); // Addref happens here.
(*aList)->AppendElement(child);

View File

@ -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<nsIAtom> 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<nsIAtom> 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) {

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -537,8 +537,7 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, PRBool* aAppendContent)
return NS_OK;
}
nsCOMPtr<nsIAtom> 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<nsIDOMDocumentType> docType;
nsCOMPtr<nsIAtom> 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<nsIDOMDocumentType> docType;
rv = NS_NewDOMDocumentType(getter_AddRefs(docType), name, nsnull, nsnull,
aPublicId, aSystemId, aSubset);
if (NS_FAILED(rv) || !docType) {
return rv;

View File

@ -2068,7 +2068,6 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
// On the removal of a <treeitem>, <treechildren>, or <treecell> 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<nsIAtom> tag;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> controlElement;
nsCOMPtr<nsIListBoxObject> 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<nsINodeInfo>)
@ -2237,18 +2234,15 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
PRBool validElement = PR_TRUE;
// find out what type of content node this is
nsCOMPtr<nsIAtom> 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 <label>s
// in e.g. <menu>, <menuitem>, <button>. These <label>s inherit
// |accesskey| and would otherwise register themselves, overwriting
if (NodeInfo()->Equals(nsXULAtoms::label)) {
// XXXjag a side-effect is that we filter out
// anonymous <label>s in e.g. <menu>, <menuitem>,
// <button>. These <label>s inherit |accesskey| and
// would otherwise register themselves, overwriting
// the content we really meant to be registered.
if (!HasAttr(kNameSpaceID_None, nsXULAtoms::control))
validElement = PR_FALSE;
}
}
if (validElement) {
nsCOMPtr<nsIPresContext> presContext;
@ -2323,10 +2317,7 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
Attributes()->UpdateStyleRule(baseURL, aValue);
}
nsCOMPtr<nsIAtom> tag;
GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::window &&
if (NodeInfo()->Equals(nsXULAtoms::window) &&
aNodeInfo->Equals(nsXULAtoms::hidechrome)) {
nsAutoString val(aValue);
HideWindowChrome(val.Equals(NS_LITERAL_STRING("true")));
@ -2600,10 +2591,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID,
}
}
nsCOMPtr<nsIAtom> tag;
GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::window &&
if (NodeInfo()->Equals(nsXULAtoms::window) &&
aName == nsXULAtoms::hidechrome)
HideWindowChrome(PR_FALSE);
@ -3188,11 +3176,10 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
NS_IMETHODIMP
nsXULElement::GetContentID(PRUint32* aID)
PRUint32
nsXULElement::ContentID() const
{
*aID = 0;
return NS_OK;
return 0;
}
NS_IMETHODIMP
@ -3230,12 +3217,11 @@ nsXULElement::RangeRemove(nsIDOMRange* aRange)
}
NS_IMETHODIMP
nsXULElement::GetRangeList(nsVoidArray** aResult) const
const nsVoidArray *
nsXULElement::GetRangeList() const
{
// XUL content does not yet support DOM ranges
*aResult = nsnull;
return NS_OK;
return nsnull;
}
@ -3568,17 +3554,20 @@ nsXULElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
aHint = NS_STYLE_HINT_NONE;
if (aAttribute == nsXULAtoms::value &&
(aModType == nsIDOMMutationEvent::REMOVAL || aModType == nsIDOMMutationEvent::ADDITION)) {
nsCOMPtr<nsIAtom> tag;
GetTag(getter_AddRefs(tag));
(aModType == nsIDOMMutationEvent::REMOVAL ||
aModType == nsIDOMMutationEvent::ADDITION)) {
nsIAtom *tag = Tag();
if (tag == nsXULAtoms::label || tag == nsXULAtoms::description)
// Label and description dynamically morph between a normal block and a cropping single-line
// XUL text frame. If the value attribute is being added or removed, then we need to return
// a hint of frame change. (See bugzilla bug 95475 for details.)
// Label and description dynamically morph between a normal
// block and a cropping single-line XUL text frame. If the
// value attribute is being added or removed, then we need to
// return a hint of frame change. (See bugzilla bug 95475 for
// details.)
aHint = NS_STYLE_HINT_FRAMECHANGE;
} else {
// if left or top changes we reflow. This will happen in xul containers that
// manage positioned children such as a bulletinboard.
// if left or top changes we reflow. This will happen in xul
// containers that manage positioned children such as a
// bulletinboard.
if (nsXULAtoms::left == aAttribute || nsXULAtoms::top == aAttribute)
aHint = NS_STYLE_HINT_REFLOW;
}
@ -4115,16 +4104,18 @@ nsXULElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
NS_IMETHODIMP
nsXULElement::GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement)
{
for (nsIContent* current = GetParent(); current; current = current->GetParent()) {
nsCOMPtr<nsIAtom> tag;
current->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::listbox) {
for (nsIContent* current = GetParent(); current;
current = current->GetParent()) {
if (current->GetNodeInfo()->Equals(nsXULAtoms::listbox,
kNameSpaceID_XUL)) {
CallQueryInterface(current, aTreeElement);
// XXX returning NS_OK because that's what the code used to do;
// is that the right thing, though?
return NS_OK;
}
}
return NS_OK;
}

View File

@ -432,7 +432,7 @@ public:
PRBool aDeepSetDocument);
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
NS_IMETHOD GetNameSpaceID(PRInt32* aNameSpeceID) 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;
@ -457,12 +457,12 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD DoneCreatingElement();
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);

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@ -238,9 +238,8 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent)
// submenu of an already-showing popup. We don't need to do anything at all.
if (popupType == eXULPopupType_popup) {
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(target);
nsCOMPtr<nsIAtom> tag;
targetContent->GetTag(getter_AddRefs(tag));
if (tag && (tag.get() == nsXULAtoms::menu || tag.get() == nsXULAtoms::menuitem))
nsIAtom *tag = targetContent->Tag();
if (tag == nsXULAtoms::menu || tag == nsXULAtoms::menuitem)
return NS_OK;
}
@ -406,9 +405,7 @@ GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult)
PRInt32 childCount = aContent->GetChildCount();
for (PRInt32 i = 0; i < childCount; i++) {
nsIContent *child = aContent->GetChildAt(i);
nsCOMPtr<nsIAtom> tag;
child->GetTag(getter_AddRefs(tag));
if (aTag == tag.get()) {
if (child->Tag() == aTag) {
*aResult = child;
NS_ADDREF(*aResult);
return;
@ -521,9 +518,7 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
if (identifier == NS_LITERAL_STRING("_child")) {
nsCOMPtr<nsIContent> popup;
nsIAtom* tag = nsXULAtoms::menupopup;
GetImmediateChild(content, tag, getter_AddRefs(popup));
GetImmediateChild(content, nsXULAtoms::menupopup, getter_AddRefs(popup));
if (popup)
popupContent = do_QueryInterface(popup);
else {
@ -537,9 +532,10 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
for (ctr = 0; ctr < listLength; ctr++) {
list->Item(ctr, getter_AddRefs(node));
nsCOMPtr<nsIContent> childContent(do_QueryInterface(node));
nsCOMPtr<nsIAtom> childTag;
childContent->GetTag(getter_AddRefs(childTag));
if (childTag.get() == tag) {
nsINodeInfo *ni = childContent->GetNodeInfo();
if (ni && ni->Equals(nsXULAtoms::menupopup, kNameSpaceID_XUL)) {
popupContent = do_QueryInterface(childContent);
break;
}

View File

@ -199,23 +199,15 @@ nsElementMap::Add(const nsAString& aID, nsIContent* aContent)
//NS_ERROR("element was already in the map");
#ifdef PR_LOGGING
if (PR_LOG_TEST(gMapLog, PR_LOG_ALWAYS)) {
nsresult rv;
const char *tagname;
aContent->Tag()->GetUTF8String(&tagname);
nsCOMPtr<nsIAtom> tag;
rv = aContent->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
nsAutoString tagname;
rv = tag->ToString(tagname);
if (NS_FAILED(rv)) return rv;
nsCAutoString tagnameC, aidC;
tagnameC.AssignWithConversion(tagname);
nsCAutoString aidC;
aidC.AssignWithConversion(id, aID.Length());
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) dup %s[%p] <-- %s\n",
this,
tagnameC.get(),
tagname,
aContent,
aidC.get()));
}
@ -236,23 +228,15 @@ nsElementMap::Add(const nsAString& aID, nsIContent* aContent)
#ifdef PR_LOGGING
if (PR_LOG_TEST(gMapLog, PR_LOG_ALWAYS)) {
nsresult rv;
const char *tagname;
aContent->Tag()->GetUTF8String(&tagname);
nsCOMPtr<nsIAtom> tag;
rv = aContent->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
nsAutoString tagname;
rv = tag->ToString(tagname);
if (NS_FAILED(rv)) return rv;
nsCAutoString tagnameC, aidC;
tagnameC.AssignWithConversion(tagname);
nsCAutoString aidC;
aidC.AssignWithConversion(id, aID.Length());
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) add %s[%p] <-- %s\n",
this,
tagnameC.get(),
tagname,
aContent,
aidC.get()));
}
@ -274,23 +258,15 @@ nsElementMap::Remove(const nsAString& aID, nsIContent* aContent)
#ifdef PR_LOGGING
if (PR_LOG_TEST(gMapLog, PR_LOG_ALWAYS)) {
nsresult rv;
const char *tagname;
aContent->Tag()->GetUTF8String(&tagname);
nsCOMPtr<nsIAtom> tag;
rv = aContent->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
nsAutoString tagname;
rv = tag->ToString(tagname);
if (NS_FAILED(rv)) return rv;
nsCAutoString tagnameC, aidC;
tagnameC.AssignWithConversion(tagname);
nsCAutoString aidC;
aidC.AssignWithConversion(id);
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) remove %s[%p] <-- %s\n",
this,
tagnameC.get(),
tagname,
aContent,
aidC.get()));
}

View File

@ -1879,10 +1879,10 @@ nsXULDocument::AddElementToDocumentPre(nsIContent* aElement)
nsresult
nsXULDocument::AddElementToDocumentPost(nsIContent* aElement)
{
nsINodeInfo *ni = aElement->GetNodeInfo();
// We need to pay special attention to the keyset tag to set up a listener
nsCOMPtr<nsIAtom> tag;
aElement->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::keyset) {
if (ni && ni->Equals(nsXULAtoms::keyset, kNameSpaceID_XUL)) {
// Create our XUL key listener and hook it up.
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
if (xblService) {
@ -2660,17 +2660,14 @@ nsXULDocument::ContextStack::IsInsideXULTemplate()
if (mDepth) {
for (nsIContent* element = mTop->mElement; element;
element = element->GetParent()) {
PRInt32 nameSpaceID;
element->GetNameSpaceID(&nameSpaceID);
if (nameSpaceID == kNameSpaceID_XUL) {
nsCOMPtr<nsIAtom> tag;
element->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::Template) {
nsINodeInfo *ni = element->GetNodeInfo();
if (ni && ni->Equals(nsXULAtoms::Template, kNameSpaceID_XUL)) {
return PR_TRUE;
}
}
}
}
return PR_FALSE;
}
@ -3588,8 +3585,9 @@ nsXULDocument::CreateTemplateBuilder(nsIContent* aElement)
xblService->ResolveTag(aElement, &nameSpaceID, getter_AddRefs(baseTag));
}
else {
aElement->GetNameSpaceID(&nameSpaceID);
aElement->GetTag(getter_AddRefs(baseTag));
nsINodeInfo *ni = aElement->GetNodeInfo();
nameSpaceID = ni->NamespaceID();
baseTag = ni->NameAtom();
}
if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsXULAtoms::tree)) {
@ -3963,14 +3961,12 @@ nsXULDocument::BroadcasterHookup::~BroadcasterHookup()
// Tell the world we failed
nsresult rv;
nsCOMPtr<nsIAtom> tag;
rv = mObservesElement->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return;
nsIAtom *tag = mObservesElement->Tag();
nsAutoString broadcasterID;
nsAutoString attribute;
if (tag.get() == nsXULAtoms::observes) {
if (tag == nsXULAtoms::observes) {
rv = mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::element, broadcasterID);
if (NS_FAILED(rv)) return;
@ -4041,19 +4037,13 @@ nsXULDocument::CheckBroadcasterHookup(nsXULDocument* aDocument,
*aDidResolve = PR_FALSE;
PRInt32 nameSpaceID;
rv = aElement->GetNameSpaceID(&nameSpaceID);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIAtom> tag;
rv = aElement->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> listener;
nsAutoString broadcasterID;
nsAutoString attribute;
if ((nameSpaceID == kNameSpaceID_XUL) && (tag.get() == nsXULAtoms::observes)) {
nsINodeInfo *ni = aElement->GetNodeInfo();
if (ni && ni->Equals(nsXULAtoms::observes, kNameSpaceID_XUL)) {
// It's an <observes> element, which means that the actual
// listener is the _parent_ node. This element should have an
// 'element' attribute that specifies the ID of the
@ -4061,13 +4051,9 @@ nsXULDocument::CheckBroadcasterHookup(nsXULDocument* aDocument,
// specifies the name of the attribute to observe.
nsIContent* parent = aElement->GetParent();
nsCOMPtr<nsIAtom> parentTag;
rv = parent->GetTag(getter_AddRefs(parentTag));
if (NS_FAILED(rv)) return rv;
// If we're still parented by an 'overlay' tag, then we haven't
// made it into the real document yet. Defer hookup.
if (parentTag == nsXULAtoms::overlay) {
if (parent->GetNodeInfo()->Equals(nsXULAtoms::overlay, kNameSpaceID_XUL)) {
*aNeedsHookup = PR_TRUE;
return NS_OK;
}
@ -4095,11 +4081,13 @@ nsXULDocument::CheckBroadcasterHookup(nsXULDocument* aDocument,
if (NS_FAILED(rv)) return rv;
if (rv == NS_CONTENT_ATTR_HAS_VALUE && !broadcasterID.IsEmpty()) {
// We've got something in the command attribute. We only treat this as
// a normal broadcaster if we are not a menuitem or a key.
// We've got something in the command attribute. We
// only treat this as a normal broadcaster if we are
// not a menuitem or a key.
aElement->GetTag(getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::menuitem || tag.get() == nsXULAtoms::key) {
nsINodeInfo *ni = aElement->GetNodeInfo();
if (ni->Equals(nsXULAtoms::menuitem, kNameSpaceID_XUL) ||
ni->Equals(nsXULAtoms::key, kNameSpaceID_XUL)) {
*aNeedsHookup = PR_FALSE;
return NS_OK;
}
@ -4146,12 +4134,8 @@ nsXULDocument::CheckBroadcasterHookup(nsXULDocument* aDocument,
if (! content)
return rv;
nsCOMPtr<nsIAtom> tag2;
rv = content->GetTag(getter_AddRefs(tag2));
if (NS_FAILED(rv)) return rv;
nsAutoString tagStr;
rv = tag2->ToString(tagStr);
rv = content->Tag()->ToString(tagStr);
if (NS_FAILED(rv)) return rv;
nsCAutoString tagstrC, attributeC,broadcasteridC;

View File

@ -85,11 +85,7 @@ nsContentTagTestNode::FilterInstantiations(InstantiationSet& aInstantiations, vo
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIAtom> tag;
rv = VALUE_TO_ICONTENT(value)->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
if (tag != mTag) {
if (VALUE_TO_ICONTENT(value)->Tag() != mTag) {
aInstantiations.Erase(inst--);
}
}

View File

@ -86,11 +86,7 @@ nsContentTestNode::nsContentTestNode(InnerNode* aParent,
static void
ElementToString(nsIContent *aContent, nsString &aResult)
{
aResult.Truncate();
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
tag->ToString(aResult);
aContent->Tag()->ToString(aResult);
aResult.Append(PRUnichar('@'));
aResult.AppendInt(NS_PTR_TO_INT32(aContent), 16);
@ -138,10 +134,7 @@ nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations, void*
if (mTag) {
// If we're supposed to be checking the tag, do it now.
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag != mTag)
if (content->Tag() != mTag)
consistent = PR_FALSE;
}
@ -178,8 +171,7 @@ nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations, void*
if (mTag) {
// If we're supposed to be checking the tag, do it now.
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
nsIAtom *tag = content->Tag();
if (tag != mTag) {
consistent = PR_FALSE;
@ -249,10 +241,7 @@ nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations, void*
if (mTag) {
// If we've got a tag, check it to ensure
// we're consistent.
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag != mTag)
if (content->Tag() != mTag)
continue;
}

View File

@ -437,26 +437,21 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
// Dump out the template node's tag, the template ID, and the RDF
// resource that is being used as the index into the graph.
if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {
nsCOMPtr<nsIAtom> tag;
rv = aTemplateNode->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString resourceCStr;
rv = aChild->GetValue(getter_Copies(resourceCStr));
if (NS_FAILED(rv)) return rv;
nsAutoString tagstr;
tag->ToString(tagstr);
const char *tagstr;
aTemplateNode->Tag()->GetUTF8String(&tagstr);
nsAutoString templatestr;
aTemplateNode->GetAttr(kNameSpaceID_None, nsXULAtoms::id, templatestr);
nsCAutoString templatestrC,tagstrC;
tagstrC.AssignWithConversion(tagstr);
nsCAutoString templatestrC;
templatestrC.AssignWithConversion(templatestr);
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
("xultemplate[%p] build-content-from-template %s (template='%s') [%s]",
this,
tagstrC.get(),
tagstr,
templatestrC.get(),
resourceCStr.get()));
}
@ -540,19 +535,15 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
}
nsCOMPtr<nsIAtom> tag;
rv = tmplKid->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return rv;
nsIAtom *tag = tmplKid->Tag();
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {
nsAutoString tagname;
tag->ToString(tagname);
nsCAutoString tagstrC;
tagstrC.AssignWithConversion(tagname);
const char *tagname;
tag->GetUTF8String(&tagname);
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
("xultemplate[%p] building %s %s %s",
this, tagstrC.get(),
this, tagname,
(isResourceElement ? "[resource]" : ""),
(isUnique ? "[unique]" : "")));
}
@ -667,7 +658,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
}
}
else if ((tag.get() == nsXULAtoms::textnode) && (nameSpaceID == kNameSpaceID_XUL)) {
else if (tag == nsXULAtoms::textnode &&
nameSpaceID == kNameSpaceID_XUL) {
// <xul:text value="..."> is replaced by text of the
// actual value of the 'rdf:resource' attribute for the
// given node.
@ -901,7 +893,8 @@ nsXULContentBuilder::AddPersistentAttributes(nsIContent* aTemplateNode,
rv = value->GetValueConst(&valueStr);
if (NS_FAILED(rv)) return rv;
rv = aRealNode->SetAttr(nameSpaceID, tag, nsAutoString(valueStr), PR_FALSE);
rv = aRealNode->SetAttr(nameSpaceID, tag, nsDependentString(valueStr),
PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
@ -1012,7 +1005,7 @@ nsXULContentBuilder::IsDirectlyContainedBy(nsIContent* aChild, nsIContent* aPare
// Now walk up the template subtree in parallel with the generated
// subtree.
nsCOMPtr<nsIAtom> tag;
nsINodeInfo *ni;
nsCOMPtr<nsIContent> generated(aChild);
do {
@ -1035,10 +1028,10 @@ nsXULContentBuilder::IsDirectlyContainedBy(nsIContent* aChild, nsIContent* aPare
// The content within a template ends when we hit the
// <template> or <rule> element in the simple syntax, or the
// <action> element in the extended syntax.
tmpl->GetTag(getter_AddRefs(tag));
} while (tag != nsXULAtoms::templateAtom &&
tag != nsXULAtoms::rule &&
tag != nsXULAtoms::action);
ni = tmpl->GetNodeInfo();
} while (!ni->Equals(nsXULAtoms::templateAtom, kNameSpaceID_XUL) &&
!ni->Equals(nsXULAtoms::rule, kNameSpaceID_XUL) &&
!ni->Equals(nsXULAtoms::action, kNameSpaceID_XUL));
// Did we find the generated parent?
return PRBool(generated.get() == aParent);
@ -1097,34 +1090,21 @@ nsXULContentBuilder::RemoveMember(nsIContent* aContainerElement,
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_ALWAYS)) {
nsCOMPtr<nsIAtom> parentTag;
rv = parent->GetTag(getter_AddRefs(parentTag));
if (NS_FAILED(rv)) return rv;
const char *parentTagStr;
parent->Tag()->GetUTF8String(&parentTagStr);
nsAutoString parentTagStr;
rv = parentTag->ToString(parentTagStr);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIAtom> childTag;
rv = child->GetTag(getter_AddRefs(childTag));
if (NS_FAILED(rv)) return rv;
nsAutoString childTagStr;
rv = childTag->ToString(childTagStr);
if (NS_FAILED(rv)) return rv;
const char *childTagStr;
child->Tag()->GetUTF8String(&childTagStr);
const char* resourceCStr;
rv = aMember->GetValueConst(&resourceCStr);
if (NS_FAILED(rv)) return rv;
nsCAutoString childtagstrC,parenttagstrC;
parenttagstrC.AssignWithConversion(parentTagStr);
childtagstrC.AssignWithConversion(childTagStr);
PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,
("xultemplate[%p] remove-member %s->%s [%s]",
this,
parenttagstrC.get(),
childtagstrC.get(),
parentTagStr,
childTagStr,
resourceCStr));
}
#endif
@ -1377,30 +1357,23 @@ nsXULContentBuilder::IsOpen(nsIContent* aElement)
// XXXhyatt - use XBL service to obtain base tag.
nsCOMPtr<nsIAtom> tag;
rv = aElement->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return PR_FALSE;
nsIAtom *tag = aElement->Tag();
// Treat the 'root' element as always open, -unless- it's a
// menu/menupopup. We don't need to "fake" these as being open.
if ((aElement == mRoot) && (tag.get() != nsXULAtoms::menu) &&
(tag.get() != nsXULAtoms::menubutton) &&
(tag.get() != nsXULAtoms::toolbarbutton) &&
(tag.get() != nsXULAtoms::button))
if ((aElement == mRoot) && aElement->IsContentOfType(nsIContent::eXUL) &&
(tag != nsXULAtoms::menu) &&
(tag != nsXULAtoms::menubutton) &&
(tag != nsXULAtoms::toolbarbutton) &&
(tag != nsXULAtoms::button))
return PR_TRUE;
nsAutoString value;
rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::open, value);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get open attribute");
if (NS_FAILED(rv)) return PR_FALSE;
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
if (value == NS_LITERAL_STRING("true"))
return PR_TRUE;
}
return PR_FALSE;
return (rv == NS_CONTENT_ATTR_HAS_VALUE &&
value == NS_LITERAL_STRING("true"));
}
@ -1427,9 +1400,8 @@ nsXULContentBuilder::RemoveGeneratedContent(nsIContent* aElement)
// Optimize for the <template> element, because we *know*
// it won't have any generated content: there's no reason
// to even check this subtree.
nsCOMPtr<nsIAtom> tag;
element->GetTag(getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::templateAtom)
nsINodeInfo *ni = element->GetNodeInfo();
if (!ni || ni->Equals(nsXULAtoms::templateAtom, kNameSpaceID_XUL))
continue;
// If the element is in the template map, then we
@ -1468,32 +1440,26 @@ PRBool
nsXULContentBuilder::IsLazyWidgetItem(nsIContent* aElement)
{
// Determine if this is a <tree>, <treeitem>, or <menu> element
nsresult rv;
PRInt32 nameSpaceID;
rv = aElement->GetNameSpaceID(&nameSpaceID);
if (NS_FAILED(rv)) return PR_FALSE;
if (!aElement->IsContentOfType(nsIContent::eXUL)) {
return PR_FALSE;
}
// XXXhyatt Use the XBL service to obtain a base tag.
nsCOMPtr<nsIAtom> tag;
rv = aElement->GetTag(getter_AddRefs(tag));
if (NS_FAILED(rv)) return PR_FALSE;
if (nameSpaceID != kNameSpaceID_XUL)
return PR_FALSE;
if ((tag.get() == nsXULAtoms::menu) || (tag.get() == nsXULAtoms::menulist) ||
(tag.get() == nsXULAtoms::menubutton) || (tag.get() == nsXULAtoms::toolbarbutton) ||
(tag.get() == nsXULAtoms::button) || (tag == nsXULAtoms::treeitem))
return PR_TRUE;
return PR_FALSE;
nsIAtom *tag = aElement->Tag();
return (tag == nsXULAtoms::menu ||
tag == nsXULAtoms::menulist ||
tag == nsXULAtoms::menubutton ||
tag == nsXULAtoms::toolbarbutton ||
tag == nsXULAtoms::button ||
tag == nsXULAtoms::treeitem);
}
nsresult
nsXULContentBuilder::GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements)
nsXULContentBuilder::GetElementsForResource(nsIRDFResource* aResource,
nsISupportsArray* aElements)
{
const char *uri;
aResource->GetValueConst(&uri);
@ -1876,12 +1842,11 @@ nsXULContentBuilder::OpenContainer(nsIContent* aElement)
nsresult
nsXULContentBuilder::CloseContainer(nsIContent* aElement)
{
#if 0 // Um, what was this really supposed to do?
// See if we're responsible for this element
if (! IsElementInBuilder(aElement, this))
return NS_OK;
nsCOMPtr<nsIAtom> tag;
aElement->GetTag(getter_AddRefs(tag));
#endif
return NS_OK;
}

View File

@ -283,20 +283,25 @@ nsresult
XULSortServiceImpl::FindSortableContainer(nsIContent *aRoot,
nsIContent **aContainer)
{
*aContainer = nsnull;
nsresult rv;
nsCOMPtr<nsIAtom> tag;
if (NS_FAILED(rv = aRoot->GetTag(getter_AddRefs(tag)))) return rv;
nsIAtom *tag = aRoot->Tag();
if (aRoot->IsContentOfType(nsIContent::eXUL)) {
if (tag == nsXULAtoms::templateAtom) // ignore content within templates
return NS_OK;
if (tag == nsXULAtoms::listbox || tag == nsXULAtoms::treechildren || tag == nsXULAtoms::menupopup)
{
if (tag == nsXULAtoms::listbox ||
tag == nsXULAtoms::treechildren ||
tag == nsXULAtoms::menupopup) {
*aContainer = aRoot;
NS_ADDREF(*aContainer);
return NS_OK;
}
}
PRUint32 numChildren = aRoot->GetChildCount();
@ -361,25 +366,33 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content,
nsIContent *child = content->GetChildAt(childIndex);
if (child->IsContentOfType(nsIContent::eXUL)) {
nsCOMPtr<nsIAtom> tag;
if (NS_FAILED(rv = child->GetTag(getter_AddRefs(tag)))) return rv;
nsIAtom *tag = child->Tag();
if (tag == nsXULAtoms::treecols || tag == nsXULAtoms::listcols || tag == nsXULAtoms::listhead) {
if (tag == nsXULAtoms::treecols ||
tag == nsXULAtoms::listcols ||
tag == nsXULAtoms::listhead) {
rv = SetSortColumnHints(child, sortResource, sortDirection);
} else if (tag == nsXULAtoms::treecol ||
tag == nsXULAtoms::listcol || tag == nsXULAtoms::listheader) {
tag == nsXULAtoms::listcol ||
tag == nsXULAtoms::listheader) {
nsAutoString value;
if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, nsXULAtoms::resource, value))
if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None,
nsXULAtoms::resource, value))
&& rv == NS_CONTENT_ATTR_HAS_VALUE)
{
if (value == sortResource) {
child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, *kTrueStr, PR_TRUE);
child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, sortDirection, PR_TRUE);
// Note: don't break out of loop; want to set/unset attribs on ALL sort columns
child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortActive,
*kTrueStr, PR_TRUE);
child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection,
sortDirection, PR_TRUE);
// Note: don't break out of loop; want to set/unset
// attribs on ALL sort columns
} else {
child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, PR_TRUE);
child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, PR_TRUE);
child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortActive,
PR_TRUE);
child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection,
PR_TRUE);
}
}
}
@ -390,30 +403,39 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content,
}
nsresult
XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsAString &sortResource,
nsAString &sortDirection, nsAString &sortResource2,
XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree,
nsAString &sortResource,
nsAString &sortDirection,
nsAString &sortResource2,
PRBool &inbetweenSeparatorSort)
{
nsresult rv = NS_ERROR_FAILURE;
inbetweenSeparatorSort = PR_FALSE;
nsAutoString value;
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, value))
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None,
nsXULAtoms::sortActive, value))
&& (rv == NS_CONTENT_ATTR_HAS_VALUE))
{
if (value.Equals(NS_LITERAL_STRING("true")))
{
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource, sortResource))
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None,
nsXULAtoms::sortResource,
sortResource))
&& (rv == NS_CONTENT_ATTR_HAS_VALUE))
{
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, sortDirection))
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None,
nsXULAtoms::sortDirection,
sortDirection))
&& (rv == NS_CONTENT_ATTR_HAS_VALUE))
{
rv = NS_OK;
// sort separator flag is optional
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortSeparators,
value)) && (rv == NS_CONTENT_ATTR_HAS_VALUE))
if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None,
nsXULAtoms::sortSeparators,
value)) &&
(rv == NS_CONTENT_ATTR_HAS_VALUE))
{
if (value.Equals(NS_LITERAL_STRING("true")))
{
@ -422,8 +444,10 @@ XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsAString &sortResource,
}
// secondary sort info is optional
if (NS_FAILED(rv = tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource2, sortResource2))
|| (rv != NS_CONTENT_ATTR_HAS_VALUE))
if (NS_FAILED(rv = tree->GetAttr(kNameSpaceID_None,
nsXULAtoms::sortResource2,
sortResource2)) ||
(rv != NS_CONTENT_ATTR_HAS_VALUE))
{
sortResource2.Truncate();
}
@ -1100,7 +1124,6 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo,
// (since we also skip over non XUL:treeitem nodes)
nsresult rv;
nsCOMPtr<nsIAtom> tag;
currentElement = numChildren;
PRUint32 childIndex;
// childIndex is unsigned, so childIndex >= 0 would always test true
@ -1109,9 +1132,12 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo,
nsIContent *child = container->GetChildAt(childIndex);
if (child->IsContentOfType(nsIContent::eXUL)) {
if (NS_FAILED(rv = child->GetTag(getter_AddRefs(tag)))) continue;
if (tag == nsXULAtoms::listitem || tag == nsXULAtoms::treeitem
|| tag == nsXULAtoms::menu || tag == nsXULAtoms::menuitem) {
nsIAtom *tag = child->Tag();
if (tag == nsXULAtoms::listitem ||
tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::menu ||
tag == nsXULAtoms::menuitem) {
--currentElement;
nsCOMPtr<nsIRDFResource> resource;
@ -1171,9 +1197,12 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo,
nsIContent *child = container->GetChildAt(childIndex);
if (child->IsContentOfType(nsIContent::eXUL)) {
if (NS_FAILED(rv = child->GetTag(getter_AddRefs(tag)))) continue;
if (tag == nsXULAtoms::listitem || tag == nsXULAtoms::treeitem
|| tag == nsXULAtoms::menu || tag == nsXULAtoms::menuitem) {
nsIAtom *tag = child->Tag();
if (tag == nsXULAtoms::listitem ||
tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::menu ||
tag == nsXULAtoms::menuitem) {
// immediately remove the child node, and ignore any errors
container->RemoveChildAt(childIndex, PR_FALSE);
}
@ -1202,17 +1231,16 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo,
for (childIndex = 0; childIndex < numChildren; childIndex++) {
nsIContent *child = parentNode->GetChildAt(childIndex);
if (!child->IsContentOfType(nsIContent::eXUL))
continue;
if (NS_FAILED(rv = child->GetTag(getter_AddRefs(tag)))) continue;
if (tag != nsXULAtoms::treechildren && tag != nsXULAtoms::menupopup) continue;
nsINodeInfo *ni = child->GetNodeInfo();
if (ni && (ni->Equals(nsXULAtoms::treechildren, kNameSpaceID_XUL) ||
ni->Equals(nsXULAtoms::menupopup, kNameSpaceID_XUL))) {
sortInfo->parentContainer = parentNode;
SortContainer(child, sortInfo, merelyInvertFlag);
}
}
}
}
delete [] contentSortInfoArray;
contentSortInfoArray = nsnull;
@ -1377,10 +1405,6 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort
if (parent) {
nsAutoString id;
nsCOMPtr<nsIAtom> tag;
if (NS_FAILED(rv = trueParent->GetTag(getter_AddRefs(tag))))
return rv;
rv = trueParent->GetAttr(kNameSpaceID_None, nsXULAtoms::ref, id);
if (id.IsEmpty())
@ -1627,9 +1651,7 @@ XULSortServiceImpl::Sort(nsIDOMNode* node, const nsAString& sortResource, const
// store sort info in attributes on content
SetSortHints(dbNode, sortResource, sortDirection, sortResource2, sortInfo.inbetweenSeparatorSort, PR_TRUE);
// start sorting the content depending on the tag
nsCOMPtr<nsIAtom> dbNodeTag;
dbNode->GetTag(getter_AddRefs(dbNodeTag));
// start sorting the content
nsCOMPtr<nsIContent> container;
if (NS_FAILED(rv = FindSortableContainer(dbNode, getter_AddRefs(container)))) return rv;
SortContainer(container, &sortInfo, invertTreeFlag);

View File

@ -1379,18 +1379,9 @@ nsXULTemplateBuilder::ComputeContainmentProperties()
PRBool
nsXULTemplateBuilder::IsTemplateElement(nsIContent* aContent)
{
PRInt32 nameSpaceID;
aContent->GetNameSpaceID(&nameSpaceID);
nsINodeInfo *ni = aContent->GetNodeInfo();
if (nameSpaceID == kNameSpaceID_XUL) {
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::Template)
return PR_TRUE;
}
return PR_FALSE;
return ni && ni->Equals(nsXULAtoms::Template, kNameSpaceID_XUL);
}
nsresult
@ -1545,14 +1536,9 @@ nsXULTemplateBuilder::CompileRules()
for (PRUint32 i = 0; i < count; i++) {
nsIContent *rule = tmpl->GetChildAt(i);
nsINodeInfo *ni = rule->GetNodeInfo();
if (!rule->IsContentOfType(nsIContent::eXUL))
continue;
nsCOMPtr<nsIAtom> tag;
rule->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::rule) {
if (ni && ni->Equals(nsXULAtoms::rule, kNameSpaceID_XUL)) {
++nrules;
// If the <rule> has a <conditions> element, then
@ -1737,11 +1723,9 @@ nsXULTemplateBuilder::CompileConditions(nsTemplateRule* aRule,
for (PRUint32 i = 0; i < count; ++i) {
nsIContent *condition = aConditions->GetChildAt(i);
nsCOMPtr<nsIAtom> tag;
condition->GetTag(getter_AddRefs(tag));
TestNode* testnode = nsnull;
rv = CompileCondition(tag, aRule, condition, aParentNode, &testnode);
rv = CompileCondition(condition->Tag(), aRule, condition,
aParentNode, &testnode);
if (NS_FAILED(rv)) return rv;
// XXXwaterson proably wrong to just drill it straight down

View File

@ -69,9 +69,7 @@ nsComposeTxtSrvFilter::Skip(nsIDOMNode* aNode, PRBool *_retval)
// their type is "cite"
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag) {
nsIAtom *tag = content->Tag();
if (tag == mBlockQuoteAtom) {
if (mIsForMail) {
nsAutoString cite;
@ -93,7 +91,6 @@ nsComposeTxtSrvFilter::Skip(nsIDOMNode* aNode, PRBool *_retval)
*_retval = PR_TRUE;
}
}
}
return NS_OK;
}

View File

@ -3785,22 +3785,19 @@ NS_IMETHODIMP nsEditor::ResetModificationCount()
///////////////////////////////////////////////////////////////////////////
// GetTag: digs out the atom for the tag of this node
//
nsCOMPtr<nsIAtom>
nsIAtom *
nsEditor::GetTag(nsIDOMNode *aNode)
{
nsCOMPtr<nsIAtom> atom;
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (!aNode)
if (!content)
{
NS_NOTREACHED("null node passed to nsEditor::GetTag()");
return atom;
NS_ASSERTION(aNode, "null node passed to nsEditor::Tag()");
return nsnull;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content)
content->GetTag(getter_AddRefs(atom));
return atom;
return content->Tag();
}
@ -3816,14 +3813,14 @@ nsEditor::GetTagString(nsIDOMNode *aNode, nsAString& outString)
return NS_ERROR_NULL_POINTER;
}
nsCOMPtr<nsIAtom> atom = GetTag(aNode);
if (atom)
nsIAtom *atom = GetTag(aNode);
if (!atom)
{
atom->ToString(outString);
return NS_OK;
return NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
atom->ToString(outString);
return NS_OK;
}
@ -3839,10 +3836,7 @@ nsEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2)
return PR_FALSE;
}
nsCOMPtr<nsIAtom> atom1 = GetTag(aNode1);
nsCOMPtr<nsIAtom> atom2 = GetTag(aNode2);
return (atom1 == atom2);
return GetTag(aNode1) == GetTag(aNode2);
}

View File

@ -457,14 +457,13 @@ public:
/** returns PR_TRUE if aNode is of the type implied by aTag */
static inline PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
{
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(aNode);
return (nodeAtom == aTag);
return GetTag(aNode) == aTag;
}
// we should get rid of this method if we can
static inline PRBool NodeIsTypeString(nsIDOMNode *aNode, const nsAString &aTag)
{
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(aNode);
nsIAtom *nodeAtom = GetTag(aNode);
return nodeAtom && nodeAtom->Equals(aTag);
}
@ -509,7 +508,7 @@ public:
/** from html rules code - migration in progress */
static nsresult GetTagString(nsIDOMNode *aNode, nsAString& outString);
static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode);
static nsIAtom *GetTag(nsIDOMNode *aNode);
virtual PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
static PRBool IsTextOrElementNode(nsIDOMNode *aNode);
static PRBool IsTextNode(nsIDOMNode *aNode);

View File

@ -343,8 +343,7 @@ nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode * aNode,
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
if (!content) return PR_FALSE;
nsCOMPtr<nsIAtom> tagName;
content->GetTag(getter_AddRefs(tagName));
nsIAtom *tagName = content->Tag();
// brade: should the above use nsEditor::GetTag(aNode)?
// brade: shouldn't some of the above go below the next block?
@ -918,10 +917,7 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
}
if (!node) return;
// brade: use nsEditor::GetTag instead??
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
nsCOMPtr<nsIAtom> tagName;
content->GetTag(getter_AddRefs(tagName));
nsIAtom *tagName = nsEditor::GetTag(node);
if (nsEditProperty::b == aHTMLProperty) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, boldEquivTable, aValue, aGetOrRemoveRequest);

View File

@ -576,7 +576,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
return NS_OK;
}
nsCOMPtr<nsIAtom> tagAtom = nsEditor::GetTag(aNode);
nsIAtom *tagAtom = GetTag(aNode);
if (!tagAtom) return NS_ERROR_NULL_POINTER;
if (!sParserService) {
@ -886,10 +886,8 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
nsCOMPtr<nsIDOMNode>currentNode = do_QueryInterface(currentContent);
if (currentNode)
{
nsCOMPtr<nsIAtom> currentContentTag;
currentContent->GetTag(getter_AddRefs(currentContentTag));
// <BR> divides block content ranges. We can achieve this by nulling out lastRange
if (nsEditProperty::br==currentContentTag)
if (currentContent->Tag() == nsEditProperty::br)
{
lastRange = nsnull;
}
@ -4591,15 +4589,14 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
if (content)
{
nsCOMPtr<nsIAtom> atom;
content->GetTag(getter_AddRefs(atom));
if (atom.get() == nsEditProperty::table ||
atom.get() == nsEditProperty::tbody ||
atom.get() == nsEditProperty::thead ||
atom.get() == nsEditProperty::tfoot ||
atom.get() == nsEditProperty::caption ||
atom.get() == nsEditProperty::tr ||
atom.get() == nsEditProperty::td )
nsIAtom *atom = content->Tag();
if (atom == nsEditProperty::table ||
atom == nsEditProperty::tbody ||
atom == nsEditProperty::thead ||
atom == nsEditProperty::tfoot ||
atom == nsEditProperty::caption ||
atom == nsEditProperty::tr ||
atom == nsEditProperty::td )
{
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
nsCOMPtr<nsIDOMNode> parent;
@ -4795,7 +4792,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
if (text && node && IsEditable(node))
{
textNodes.AppendElement((void*)(node.get()));
textNodes.AppendElement(node.get());
}
iter->Next();
iter->CurrentNode(getter_AddRefs(content));
@ -4858,9 +4855,7 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
if (NS_FAILED(res)) return res;
if (!nextNode) break;
nsCOMPtr<nsIAtom> atom = GetTag(currentNode);
if (tagAtom == atom)
if (GetTag(currentNode) == tagAtom)
{
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(currentNode);
if (!element) return NS_ERROR_NULL_POINTER;
@ -5902,11 +5897,10 @@ nsHTMLEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2)
PRBool useCSS;
GetIsCSSEnabled(&useCSS);
nsCOMPtr<nsIAtom> atom1 = GetTag(aNode1);
nsCOMPtr<nsIAtom> atom2 = GetTag(aNode2);
nsIAtom *tag1 = GetTag(aNode1);
if (atom1.get() == atom2.get()) {
if (useCSS && atom1 == nsEditProperty::span) {
if (tag1 == GetTag(aNode2)) {
if (useCSS && tag1 == nsEditProperty::span) {
if (mHTMLCSSUtils->ElementsSameStyle(aNode1, aNode2)) {
return PR_TRUE;
}

View File

@ -264,12 +264,12 @@ nsHTMLEditor::GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode)
nsCOMPtr<nsIContent> content = do_QueryInterface(tableChild);
if (content)
{
nsCOMPtr<nsIAtom> atom;
content->GetTag(getter_AddRefs(atom));
nsIAtom *atom = content->Tag();
if (atom == nsEditProperty::tr)
{
// Found a row directly under <table>
*aRowNode = tableChild.get();
*aRowNode = tableChild;
NS_ADDREF(*aRowNode);
return NS_OK;
}

View File

@ -3183,42 +3183,35 @@ nsTextServicesDocument::ClearDidSkip(nsIContentIterator* aFilteredIter)
PRBool
nsTextServicesDocument::IsBlockNode(nsIContent *aContent)
{
nsCOMPtr<nsIAtom> atom;
nsIAtom *atom = aContent->Tag();
aContent->GetTag(getter_AddRefs(atom));
if (!atom)
return PR_TRUE;
nsIAtom *atomPtr = atom.get();
return (sAAtom != atomPtr &&
sAddressAtom != atomPtr &&
sBigAtom != atomPtr &&
sBlinkAtom != atomPtr &&
sBAtom != atomPtr &&
sCiteAtom != atomPtr &&
sCodeAtom != atomPtr &&
sDfnAtom != atomPtr &&
sEmAtom != atomPtr &&
sFontAtom != atomPtr &&
sIAtom != atomPtr &&
sKbdAtom != atomPtr &&
sKeygenAtom != atomPtr &&
sNobrAtom != atomPtr &&
sSAtom != atomPtr &&
sSampAtom != atomPtr &&
sSmallAtom != atomPtr &&
sSpacerAtom != atomPtr &&
sSpanAtom != atomPtr &&
sStrikeAtom != atomPtr &&
sStrongAtom != atomPtr &&
sSubAtom != atomPtr &&
sSupAtom != atomPtr &&
sTtAtom != atomPtr &&
sUAtom != atomPtr &&
sVarAtom != atomPtr &&
sWbrAtom != atomPtr);
return (sAAtom != atom &&
sAddressAtom != atom &&
sBigAtom != atom &&
sBlinkAtom != atom &&
sBAtom != atom &&
sCiteAtom != atom &&
sCodeAtom != atom &&
sDfnAtom != atom &&
sEmAtom != atom &&
sFontAtom != atom &&
sIAtom != atom &&
sKbdAtom != atom &&
sKeygenAtom != atom &&
sNobrAtom != atom &&
sSAtom != atom &&
sSampAtom != atom &&
sSmallAtom != atom &&
sSpacerAtom != atom &&
sSpanAtom != atom &&
sStrikeAtom != atom &&
sStrongAtom != atom &&
sSubAtom != atom &&
sSupAtom != atom &&
sTtAtom != atom &&
sUAtom != atom &&
sVarAtom != atom &&
sWbrAtom != atom);
}
PRBool
@ -4989,11 +4982,9 @@ void
nsTextServicesDocument::PrintContentNode(nsIContent *aContent)
{
nsString tmpStr, str;
nsCOMPtr<nsIAtom> atom;
nsresult result;
aContent->GetTag(getter_AddRefs(atom));
atom->ToString(tmpStr);
aContent->Tag()->ToString(tmpStr);
printf("%s", NS_LossyConvertUCS2toASCII(tmpStr).get());
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aContent);

View File

@ -52,7 +52,8 @@ nsContextMenuInfo::~nsContextMenuInfo()
}
/* readonly attribute nsIDOMEvent mouseEvent; */
NS_IMETHODIMP nsContextMenuInfo::GetMouseEvent(nsIDOMEvent **aEvent)
NS_IMETHODIMP
nsContextMenuInfo::GetMouseEvent(nsIDOMEvent **aEvent)
{
NS_ENSURE_ARG_POINTER(aEvent);
NS_IF_ADDREF(*aEvent = mMouseEvent);
@ -60,7 +61,8 @@ NS_IMETHODIMP nsContextMenuInfo::GetMouseEvent(nsIDOMEvent **aEvent)
}
/* readonly attribute nsIDOMNode targetNode; */
NS_IMETHODIMP nsContextMenuInfo::GetTargetNode(nsIDOMNode **aNode)
NS_IMETHODIMP
nsContextMenuInfo::GetTargetNode(nsIDOMNode **aNode)
{
NS_ENSURE_ARG_POINTER(aNode);
NS_IF_ADDREF(*aNode = mDOMNode);
@ -135,7 +137,8 @@ nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef)
}
/* readonly attribute imgIContainer imageContainer; */
NS_IMETHODIMP nsContextMenuInfo::GetImageContainer(imgIContainer **aImageContainer)
NS_IMETHODIMP
nsContextMenuInfo::GetImageContainer(imgIContainer **aImageContainer)
{
NS_ENSURE_ARG_POINTER(aImageContainer);
NS_ENSURE_STATE(mDOMNode);
@ -149,7 +152,8 @@ NS_IMETHODIMP nsContextMenuInfo::GetImageContainer(imgIContainer **aImageContain
}
/* readonly attribute nsIURI imageSrc; */
NS_IMETHODIMP nsContextMenuInfo::GetImageSrc(nsIURI **aURI)
NS_IMETHODIMP
nsContextMenuInfo::GetImageSrc(nsIURI **aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_STATE(mDOMNode);
@ -336,7 +340,10 @@ nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode * aDOMNode, imgIRequest
// The check is a bit expensive, however until the canvas frame is somehow cached on the
// body frame, or the root element, we need to walk the frames up until we find the canvas
//
nsresult nsContextMenuInfo::GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame)
nsresult
nsContextMenuInfo::GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,
nsIFrame *aFrame,
nsIFrame **aBGFrame)
{
NS_ASSERTION(aFrame && aBGFrame, "illegal null parameter");
@ -348,13 +355,13 @@ nsresult nsContextMenuInfo::GetFrameForBackgroundUpdate(nsIPresContext *aPresCon
nsIContent* pContent = aFrame->GetContent();
if (pContent) {
// make sure that this is the HTML or BODY element
nsCOMPtr<nsIAtom> tag;
pContent->GetTag(getter_AddRefs(tag));
nsCOMPtr<nsIAtom> mTag_html = do_GetAtom("html");
nsCOMPtr<nsIAtom> mTag_body = do_GetAtom("body");
nsIAtom *tag = pContent->Tag();
nsCOMPtr<nsIAtom> tag_html = do_GetAtom("html");
nsCOMPtr<nsIAtom> tag_body = do_GetAtom("body");
if (tag &&
tag.get() == mTag_html ||
tag.get() == mTag_body) {
tag == tag_html ||
tag == tag_body) {
// the frame is the body frame, so we provide the canvas frame
nsIFrame *pCanvasFrame = aFrame->GetParent();
while (pCanvasFrame) {

View File

@ -146,7 +146,8 @@ NS_INTERFACE_MAP_END
// nsDocShellTreeOwner::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
NS_IMETHODIMP
nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
{
NS_ENSURE_ARG_POINTER(aSink);
@ -190,8 +191,10 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
// nsDocShellTreeOwner::nsIDocShellTreeOwner
//*****************************************************************************
NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
NS_IMETHODIMP
nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem** aFoundItem)
{
NS_ENSURE_ARG(aName);
NS_ENSURE_ARG_POINTER(aFoundItem);
@ -253,8 +256,9 @@ NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
return NS_OK; // failed
}
nsresult nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName,
PRBool aRecurse, nsIDocShellTreeItem* aRequestor,
nsresult
nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName, PRBool aRecurse,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem **aFoundItem)
{
if (!mWebBrowser)
@ -296,8 +300,8 @@ nsresult nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName,
return rv;
}
nsresult nsDocShellTreeOwner::FindItemWithNameAcrossWindows(
const PRUnichar* aName,
nsresult
nsDocShellTreeOwner::FindItemWithNameAcrossWindows(const PRUnichar* aName,
nsIDocShellTreeItem** aFoundItem)
{
// search for the item across the list of top-level windows
@ -339,7 +343,8 @@ nsresult nsDocShellTreeOwner::FindItemWithNameAcrossWindows(
return rv;
}
void nsDocShellTreeOwner::EnsurePrompter()
void
nsDocShellTreeOwner::EnsurePrompter()
{
if (mPrompter)
return;
@ -353,7 +358,8 @@ void nsDocShellTreeOwner::EnsurePrompter()
}
}
void nsDocShellTreeOwner::EnsureAuthPrompter()
void
nsDocShellTreeOwner::EnsureAuthPrompter()
{
if (mAuthPrompter)
return;
@ -367,8 +373,9 @@ void nsDocShellTreeOwner::EnsureAuthPrompter()
}
}
void nsDocShellTreeOwner::AddToWatcher() {
void
nsDocShellTreeOwner::AddToWatcher()
{
if (mWebBrowser) {
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
@ -380,8 +387,9 @@ void nsDocShellTreeOwner::AddToWatcher() {
}
}
void nsDocShellTreeOwner::RemoveFromWatcher() {
void
nsDocShellTreeOwner::RemoveFromWatcher()
{
if (mWebBrowser) {
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
@ -394,7 +402,8 @@ void nsDocShellTreeOwner::RemoveFromWatcher() {
}
NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
NS_IMETHODIMP
nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
PRBool aPrimary, const PRUnichar* aID)
{
if(mTreeOwner)
@ -405,7 +414,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aConte
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
NS_IMETHODIMP
nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
{
NS_ENSURE_ARG_POINTER(aShell);
@ -418,7 +428,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem**
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
NS_IMETHODIMP
nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
PRInt32 aCX, PRInt32 aCY)
{
NS_ENSURE_STATE(mTreeOwner || mWebBrowserChrome);
@ -490,27 +501,33 @@ nsDocShellTreeOwner::GetPersistence(PRBool* aPersistPosition,
//*****************************************************************************
NS_IMETHODIMP nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* aParentWidget, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* aParentWidget, PRInt32 aX,
PRInt32 aY, PRInt32 aCX, PRInt32 aCY)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::Create()
NS_IMETHODIMP
nsDocShellTreeOwner::Create()
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::Destroy()
NS_IMETHODIMP
nsDocShellTreeOwner::Destroy()
{
if (mOwnerWin)
{
return mWebBrowserChrome->DestroyBrowserWindow();
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY)
NS_IMETHODIMP
nsDocShellTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY)
{
if (mOwnerWin)
{
@ -520,7 +537,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY)
NS_IMETHODIMP
nsDocShellTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY)
{
if (mOwnerWin)
{
@ -530,7 +548,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
NS_IMETHODIMP
nsDocShellTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
{
if (mOwnerWin)
{
@ -540,7 +559,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRep
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY)
{
if (mOwnerWin)
{
@ -550,8 +570,9 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
NS_IMETHODIMP
nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX,
PRInt32 aCY, PRBool aRepaint)
{
if (mOwnerWin)
{
@ -562,8 +583,9 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
PRInt32* aCX, PRInt32* aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY, PRInt32* aCX,
PRInt32* aCY)
{
if (mOwnerWin)
{
@ -574,22 +596,26 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::Repaint(PRBool aForce)
NS_IMETHODIMP
nsDocShellTreeOwner::Repaint(PRBool aForce)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
NS_IMETHODIMP
nsDocShellTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
NS_IMETHODIMP
nsDocShellTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
NS_IMETHODIMP
nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
{
if (mOwnerWin)
{
@ -598,12 +624,14 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNa
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
NS_IMETHODIMP
nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetVisibility(PRBool* aVisibility)
NS_IMETHODIMP
nsDocShellTreeOwner::GetVisibility(PRBool* aVisibility)
{
if (mOwnerWin)
{
@ -612,7 +640,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetVisibility(PRBool* aVisibility)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetVisibility(PRBool aVisibility)
NS_IMETHODIMP
nsDocShellTreeOwner::SetVisibility(PRBool aVisibility)
{
if (mOwnerWin)
{
@ -621,14 +650,16 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetVisibility(PRBool aVisibility)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetEnabled(PRBool *aEnabled)
NS_IMETHODIMP
nsDocShellTreeOwner::GetEnabled(PRBool *aEnabled)
{
NS_ENSURE_ARG_POINTER(aEnabled);
*aEnabled = PR_TRUE;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetEnabled(PRBool aEnabled)
NS_IMETHODIMP
nsDocShellTreeOwner::SetEnabled(PRBool aEnabled)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -647,12 +678,14 @@ nsDocShellTreeOwner::SetBlurSuppression(PRBool aBlurSuppression)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
NS_IMETHODIMP
nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetFocus()
NS_IMETHODIMP
nsDocShellTreeOwner::SetFocus()
{
if (mOwnerWin)
{
@ -661,7 +694,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetFocus()
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle)
NS_IMETHODIMP
nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle)
{
if (mOwnerWin)
{
@ -670,7 +704,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetTitle(const PRUnichar* aTitle)
NS_IMETHODIMP
nsDocShellTreeOwner::SetTitle(const PRUnichar* aTitle)
{
if (mOwnerWin)
{
@ -708,7 +743,8 @@ nsDocShellTreeOwner::OnStateChange(nsIWebProgress* aProgress,
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP
nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aURI)
{
@ -741,7 +777,8 @@ nsDocShellTreeOwner::OnSecurityChange(nsIWebProgress *aWebProgress,
// nsDocShellTreeOwner: Accessors
//*****************************************************************************
void nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
void
nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
{
if ( !aWebBrowser )
RemoveChromeListeners();
@ -753,12 +790,14 @@ void nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
mWebBrowser = aWebBrowser;
}
nsWebBrowser* nsDocShellTreeOwner::WebBrowser()
nsWebBrowser *
nsDocShellTreeOwner::WebBrowser()
{
return mWebBrowser;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
NS_IMETHODIMP
nsDocShellTreeOwner::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
{
if(aTreeOwner) {
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome(do_GetInterface(aTreeOwner));
@ -776,15 +815,14 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome)
NS_IMETHODIMP
nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome)
{
if(!aWebBrowserChrome) {
mWebBrowserChrome = nsnull;
mOwnerWin = nsnull;
mOwnerRequestor = nsnull;
}
else
{
} else {
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin(do_QueryInterface(aWebBrowserChrome));
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(aWebBrowserChrome));
@ -905,7 +943,9 @@ DefaultTooltipTextProvider::DefaultTooltipTextProvider()
}
/* void getNodeText (in nsIDOMNode aNode, out wstring aText); */
NS_IMETHODIMP DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText, PRBool *_retval)
NS_IMETHODIMP
DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(aNode);
NS_ENSURE_ARG_POINTER(aText);
@ -919,8 +959,7 @@ NS_IMETHODIMP DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnich
if ( currElement ) {
nsCOMPtr<nsIContent> content(do_QueryInterface(currElement));
if (content) {
nsCOMPtr<nsIAtom> tagAtom;
content->GetTag(getter_AddRefs(tagAtom));
nsIAtom *tagAtom = content->Tag();
if (tagAtom != mTag_dialog &&
tagAtom != mTag_dialogheader &&
tagAtom != mTag_window) {
@ -969,7 +1008,8 @@ NS_INTERFACE_MAP_END
// ChromeTooltipListener ctor
//
ChromeTooltipListener :: ChromeTooltipListener ( nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome )
ChromeTooltipListener::ChromeTooltipListener(nsWebBrowser* inBrowser,
nsIWebBrowserChrome* inChrome)
: mWebBrowser(inBrowser), mWebBrowserChrome(inChrome),
mTooltipListenerInstalled(PR_FALSE),
mMouseClientX(0), mMouseClientY(0),
@ -1097,7 +1137,6 @@ nsresult
ChromeTooltipListener::KeyDown(nsIDOMEvent* aMouseEvent)
{
return HideTooltip();
} // KeyDown
@ -1232,7 +1271,8 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
// Tell the registered chrome that they should show the tooltip
//
NS_IMETHODIMP
ChromeTooltipListener :: ShowTooltip ( PRInt32 inXCoords, PRInt32 inYCoords, const nsAString & inTipText )
ChromeTooltipListener::ShowTooltip(PRInt32 inXCoords, PRInt32 inYCoords,
const nsAString & inTipText)
{
nsresult rv = NS_OK;
@ -1300,7 +1340,8 @@ ChromeTooltipListener :: HideTooltip ( )
// -- the dom node the user hovered over (mPossibleTooltipNode)
//
void
ChromeTooltipListener :: sTooltipCallback (nsITimer *aTimer, void *aChromeTooltipListener)
ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer,
void *aChromeTooltipListener)
{
ChromeTooltipListener* self = NS_STATIC_CAST(ChromeTooltipListener*, aChromeTooltipListener);
if ( self && self->mPossibleTooltipNode ) {
@ -1402,7 +1443,6 @@ ChromeContextMenuListener :: ChromeContextMenuListener ( nsWebBrowser* inBrowser
//
ChromeContextMenuListener::~ChromeContextMenuListener()
{
} // dtor
@ -1532,24 +1572,23 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
PRUint32 flags = nsIContextMenuListener::CONTEXT_NONE;
PRUint32 flags2 = nsIContextMenuListener2::CONTEXT_NONE;
nsCOMPtr<nsIDOMHTMLElement> element;
nsCOMPtr<nsIContent> content;
do {
// XXX test for selected text
element = do_QueryInterface(node);
if (element)
{
nsAutoString tag;
element->GetTagName(tag);
content = do_QueryInterface(node);
if (content && content->IsContentOfType(nsIContent::eHTML)) {
const char *tagStr;
content->Tag()->GetUTF8String(&tagStr);
// Test what kind of element we're dealing with here
if (tag.Equals(NS_LITERAL_STRING("img"), nsCaseInsensitiveStringComparator()))
if (strcmp(tagStr, "img") == 0)
{
flags |= nsIContextMenuListener::CONTEXT_IMAGE;
flags2 |= nsIContextMenuListener2::CONTEXT_IMAGE;
targetDOMnode = node;
// if we see an image, keep searching for a possible anchor
}
else if (tag.Equals(NS_LITERAL_STRING("input"), nsCaseInsensitiveStringComparator()))
else if (strcmp(tagStr, "input") == 0)
{
// INPUT element - button, combo, checkbox, text etc.
flags |= nsIContextMenuListener::CONTEXT_INPUT;
@ -1568,7 +1607,7 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
}
break; // exit do-while
}
else if (tag.Equals(NS_LITERAL_STRING("textarea"), nsCaseInsensitiveStringComparator()))
else if (strcmp(tagStr, "textarea") == 0)
{
// text area
flags |= nsIContextMenuListener::CONTEXT_TEXT;
@ -1576,7 +1615,7 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
targetDOMnode = node;
break; // exit do-while
}
else if (tag.Equals(NS_LITERAL_STRING("html"), nsCaseInsensitiveStringComparator()))
else if (strcmp(tagStr, "html") == 0)
{
if (!flags && !flags2) {
// only care about this if no other context was found.
@ -1593,21 +1632,20 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
}
break; // exit do-while
}
else if ( tag.EqualsWithConversion("object", PR_TRUE) || /* XXX what about images and documents? */
tag.EqualsWithConversion("embed", PR_TRUE) ||
tag.EqualsWithConversion("applet", PR_TRUE) )
else if (strcmp(tagStr, "object") == 0 || /* XXX what about images and documents? */
strcmp(tagStr, "embed") == 0 ||
strcmp(tagStr, "applet") == 0)
{ // always consume events for plugins and Java
return NS_OK; // who may throw their own context menus
}
// Test if the element has an associated link
nsCOMPtr<nsIDOMNamedNodeMap> attributes;
node->GetAttributes(getter_AddRefs(attributes));
if (attributes)
{
nsCOMPtr<nsIDOMNode> hrefNode;
attributes->GetNamedItem(NS_LITERAL_STRING("href"), getter_AddRefs(hrefNode));
if (hrefNode)
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(node));
PRBool hasAttr = PR_FALSE;
res = element->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr);
if (NS_SUCCEEDED(res) && hasAttr)
{
flags |= nsIContextMenuListener::CONTEXT_LINK;
flags2 |= nsIContextMenuListener2::CONTEXT_LINK;
@ -1618,7 +1656,6 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
break; // exit do-while
}
}
}
// walk-up-the-tree
nsCOMPtr<nsIDOMNode> parentNode;
@ -1662,5 +1699,3 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
return NS_OK;
} // MouseDown

View File

@ -431,17 +431,22 @@ nsFind::NextNode(nsIDOMRange* aSearchRange,
PRBool nsFind::IsBlockNode(nsIContent* aContent)
{
nsCOMPtr<nsIAtom> atom;
aContent->GetTag(getter_AddRefs(atom));
if (!aContent->IsContentOfType(nsIContent::eHTML)) {
return PR_FALSE;
}
if (atom.get() == sImgAtom || atom.get() == sHRAtom
|| atom.get() == sThAtom || atom.get() == sTdAtom)
nsIAtom *atom = aContent->Tag();
if (atom == sImgAtom ||
atom == sHRAtom ||
atom == sThAtom ||
atom == sTdAtom)
return PR_TRUE;
if (!mParserService) {
nsresult rv;
mParserService = do_GetService(kParserServiceCID, &rv);
if (NS_FAILED(rv) || !mParserService) return PR_FALSE;
mParserService = do_GetService(kParserServiceCID);
if (!mParserService)
return PR_FALSE;
}
PRInt32 id;
@ -457,12 +462,8 @@ PRBool nsFind::IsTextNode(nsIDOMNode* aNode)
// Can't just QI for nsITextContent, because nsCommentNode
// also implements that interface.
nsCOMPtr<nsIContent> content (do_QueryInterface(aNode));
if (!content) return PR_FALSE;
nsCOMPtr<nsIAtom> atom;
content->GetTag(getter_AddRefs(atom));
if (atom.get() == sTextAtom)
return PR_TRUE;
return PR_FALSE;
return content && content->Tag() == sTextAtom;
}
PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
@ -491,19 +492,20 @@ PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
PRBool nsFind::SkipNode(nsIContent* aContent)
{
nsCOMPtr<nsIAtom> atom;
nsIAtom *atom;
#ifdef HAVE_BIDI_ITERATOR
aContent->GetTag(getter_AddRefs(atom));
if (!atom)
return PR_TRUE;
nsIAtom *atomPtr = atom.get();
atom = aContent->Tag();
// We may not need to skip comment nodes,
// now that IsTextNode distinguishes them from real text nodes.
return (sScriptAtom == atomPtr || sCommentAtom == atomPtr
|| sNoframesAtom == atomPtr
|| sSelectAtom == atomPtr || sTextareaAtom == atomPtr)
return (atom == sCommentAtom ||
(aContent->IsContentOfType(nsIContent::eHTML) &&
(atom == sScriptAtom ||
atom == sCommentAtom ||
atom == sNoframesAtom ||
atom == sSelectAtom ||
atom == sTextareaAtom)));
#else /* HAVE_BIDI_ITERATOR */
// Temporary: eventually we will have an iterator to do this,
@ -511,39 +513,33 @@ PRBool nsFind::SkipNode(nsIContent* aContent)
// and see whether any parent is a skipped node,
// and take the performance hit.
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(aContent));
while (node)
nsIContent *content = aContent;
while (content)
{
nsCOMPtr<nsIContent> content (do_QueryInterface(node));
if (!content) return PR_FALSE;
content->GetTag(getter_AddRefs(atom));
if (!atom)
return PR_FALSE;
nsAutoString atomName;
atom->ToString(atomName);
//printf("Atom name is %s\n",
// NS_LossyConvertUCS2toASCII(atomName).get());
nsIAtom *atomPtr = atom.get();
if (atomPtr == sScriptAtom || atomPtr == sCommentAtom
|| sNoframesAtom == atomPtr
|| sSelectAtom == atomPtr || sTextareaAtom == atomPtr)
atom = content->Tag();
if (atom == sCommentAtom ||
(content->IsContentOfType(nsIContent::eHTML) &&
(atom == sScriptAtom ||
atom == sNoframesAtom ||
atom == sSelectAtom ||
atom == sTextareaAtom)))
{
#ifdef DEBUG_FIND
printf("Skipping node: ");
DumpNode(node);
#endif
return PR_TRUE;
}
// Only climb to the nearest block node
if (IsBlockNode(content))
return PR_FALSE;
nsCOMPtr<nsIDOMNode> parent;
nsresult rv = node->GetParentNode(getter_AddRefs(parent));
if (NS_FAILED(rv)) return PR_FALSE;
node = parent;
content = content->GetParent();
}
return PR_FALSE;
#endif /* HAVE_BIDI_ITERATOR */
}

View File

@ -367,8 +367,8 @@ txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
if (aNode.isContent()) {
if (aNode.mContent->IsContentOfType(nsIContent::eELEMENT)) {
nsIAtom* localName;
aNode.mContent->GetTag(&localName);
nsIAtom* localName = aNode.mContent->Tag();
NS_ADDREF(localName);
return localName;
}

View File

@ -511,9 +511,8 @@ void txMozillaXMLOutput::closePrevious(PRInt8 aAction)
void txMozillaXMLOutput::startHTMLElement(nsIDOMElement* aElement, PRBool aXHTML)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIAtom> atom;
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
content->GetTag(getter_AddRefs(atom));
nsIAtom *atom = content->Tag();
mDontAddCurrent = (atom == txHTMLAtoms::script);
@ -587,8 +586,7 @@ void txMozillaXMLOutput::endHTMLElement(nsIDOMElement* aElement)
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
NS_ASSERTION(content, "Can't QI to nsIContent");
nsCOMPtr<nsIAtom> atom;
content->GetTag(getter_AddRefs(atom));
nsIAtom *atom = content->Tag();
if (mTableState == ADDED_TBODY) {
NS_ASSERTION(atom == txHTMLAtoms::tbody,

View File

@ -2431,11 +2431,9 @@ nsTypeAheadFind::IsTargetContentOkay(nsIContent *aContent)
// not support nsIFormControl or eHTML_FORM_CONTROL, and it's not worth
// having a table of atoms just for it. Instead, we're paying for 1 extra
// string compare per keystroke, which isn't too bad.
nsCOMPtr<nsIAtom> targetTagAtom;
aContent->GetTag(getter_AddRefs(targetTagAtom));
nsAutoString targetTagString;
targetTagAtom->ToString(targetTagString);
if (targetTagString.Equals(NS_LITERAL_STRING("isindex"))) {
const char *tagStr;
aContent->Tag()->GetUTF8String(&tagStr);
if (strcmp(tagStr, "isindex") == 0) {
return PR_FALSE;
}
}

View File

@ -266,13 +266,9 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
nsIContent* content = aFrame->GetContent();
if (content->IsContentOfType(nsIContent::eXUL))
aFrame = aFrame->GetParent();
else {
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag == mInputAtom)
else if (content->Tag() == mInputAtom)
atom = mInputCheckedAtom;
}
}
if (!atom)
atom = (aWidgetType == NS_THEME_CHECKBOX) ? mCheckedAtom : mSelectedAtom;

View File

@ -121,7 +121,6 @@
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
static NS_DEFINE_CID(kAttributeContentCID, NS_ATTRIBUTECONTENT_CID);
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
@ -1438,23 +1437,24 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex
// Creates the content and frame and return if successful
nsresult rv = NS_ERROR_FAILURE;
if (nsnull != attrName) {
if (attrName) {
nsIFrame* textFrame = nsnull;
nsCOMPtr<nsIContent> content(do_CreateInstance(kAttributeContentCID));
if (content) {
nsCOMPtr<nsIContent> content;
rv = NS_NewAttributeContent(getter_AddRefs(content));
nsCOMPtr<nsIAttributeContent> attrContent(do_QueryInterface(content));
if (attrContent) {
attrContent->Init(aContent, attrNameSpace, attrName);
}
// Set aContent as the parent content and set the document object. This
// way event handling works
// Set aContent as the parent content and set the document
// object. This way event handling works
content->SetParent(aContent);
content->SetDocument(aDocument, PR_TRUE, PR_TRUE);
// Create a text frame and initialize it
NS_NewTextFrame(shell, &textFrame);
textFrame->Init(aPresContext, content, aParentFrame, aStyleContext, nsnull);
textFrame->Init(aPresContext, content, aParentFrame, aStyleContext,
nsnull);
// Return the text frame
*aFrame = textFrame;
@ -2980,13 +2980,15 @@ nsCSSFrameConstructor::ConstructTableForeignFrame(nsIPresShell* aPres
nsIFrame* parentFrame = nsnull;
aIsPseudoParent = PR_FALSE;
// XXX form code needs to be fixed so that the forms can work without a frame.
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
// XXX form code needs to be fixed so that the forms can work
// without a frame.
nsIAtom *tag = aContent->Tag();
// Do not construct pseudo frames for trees
if (MustGeneratePseudoParent(aPresContext, aParentFrameIn, tag.get(), aContent, aStyleContext)) {
// this frame may have a pseudo parent, use block frame type to trigger foreign
if (MustGeneratePseudoParent(aPresContext, aParentFrameIn, tag, aContent,
aStyleContext)) {
// this frame may have a pseudo parent, use block frame type to
// trigger foreign
GetParentFrame(aPresShell, aPresContext, aTableCreator, *aParentFrameIn,
nsLayoutAtoms::blockFrame, aState, parentFrame, aIsPseudoParent);
if (!aIsPseudoParent && !aState.mPseudoFrames.IsEmpty()) {
@ -5087,9 +5089,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell
#ifdef MOZ_XUL
// Only cut XUL scrollbars off if they're not in a XUL document. This allows
// scrollbars to be styled from XUL (although not from XML or HTML).
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::scrollbar) {
if (content->Tag() == nsXULAtoms::scrollbar) {
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(aDocument));
if (xulDoc)
content->SetBindingParent(aParent);
@ -6165,10 +6165,8 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_TRUE,
childItems, PR_TRUE);
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, newFrame, PR_FALSE, childItems);
// Set the scrolled frame's initial child lists
scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
@ -6228,10 +6226,8 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE,
childItems, PR_TRUE);
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, newFrame, PR_FALSE, childItems);
// Set the frame's initial child list(s)
newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
@ -6577,15 +6573,11 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext,
if (aContent->IsContentOfType(nsIContent::eELEMENT)) {
return aPresContext->ResolveStyleContextFor(aContent, parentStyleContext);
} else {
#ifdef DEBUG
{
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
NS_ASSERTION(tag == nsLayoutAtoms::textTagName,
NS_ASSERTION(aContent->Tag() == nsLayoutAtoms::textTagName,
"shouldn't waste time creating style contexts for "
"comments and processing instructions");
}
#endif
return aPresContext->ResolveStyleContextForNonElement(parentStyleContext);
}
}
@ -7023,8 +7015,7 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresShell* aPresShell,
}
// Get the element's tag
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsIAtom *tag = aContent->Tag();
// never create frames for comments on PIs
if (tag == nsLayoutAtoms::commentTagName ||
@ -7104,7 +7095,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe
PRInt32 nameSpaceID;
xblService->ResolveTag(aContent, &nameSpaceID, getter_AddRefs(baseTag));
if (baseTag.get() != aTag || aNameSpaceID != nameSpaceID) {
if (baseTag != aTag || aNameSpaceID != nameSpaceID) {
// Construct the frame using the XBL base tag.
rv = ConstructFrameInternal( aPresShell,
aPresContext,
@ -7612,7 +7603,7 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell,
nodeList->Item(PRUint32(index), getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
if (child.get() == aChild)
if (child == aChild)
break;
}
@ -7694,7 +7685,7 @@ FindNextAnonymousSibling(nsIPresShell* aPresShell,
nodeList->Item(PRUint32(index), getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
if (child.get() == aChild)
if (child == aChild)
break;
}
@ -7935,8 +7926,7 @@ inline PRBool
ShouldIgnoreSelectChild(nsIContent* aContainer)
{
// Ignore options and optgroups inside a select (size > 1)
nsCOMPtr<nsIAtom> containerTag;
aContainer->GetTag(getter_AddRefs(containerTag));
nsIAtom *containerTag = aContainer->Tag();
if (containerTag == nsHTMLAtoms::optgroup ||
containerTag == nsHTMLAtoms::select) {
@ -7947,7 +7937,7 @@ ShouldIgnoreSelectChild(nsIContent* aContainer)
if (!selectContent) {
break;
}
selectContent->GetTag(getter_AddRefs(containerTag));
containerTag = selectContent->Tag();
}
nsCOMPtr<nsISelectElement> selectElement = do_QueryInterface(selectContent);
@ -8097,7 +8087,8 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
if (tag == nsXULAtoms::treechildren ||
tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::treerow ||
(UseXBLForms() && ShouldIgnoreSelectChild(aContainer)))
(namespaceID == kNameSpaceID_XUL && UseXBLForms() &&
ShouldIgnoreSelectChild(aContainer)))
return NS_OK;
}
@ -8656,10 +8647,7 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext,
if (!aContainer)
return PR_FALSE;
nsCOMPtr<nsIAtom> tag;
aChild->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::listitem) {
if (aChild->Tag() == nsXULAtoms::listitem) {
nsListBoxBodyFrame* listBoxBody = nsnull;
if (aChildFrame) {
// There is a frame for the removed content, so its parent frame is the listboxbody
@ -8693,6 +8681,7 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext,
return PR_TRUE;
}
nsCOMPtr<nsIAtom> tag;
PRInt32 namespaceID;
aDocument->GetBindingManager()->ResolveTag(aContainer, &namespaceID,
getter_AddRefs(tag));
@ -8701,7 +8690,8 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext,
if (tag == nsXULAtoms::treechildren ||
tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::treerow ||
(aUseXBLForms && ShouldIgnoreSelectChild(aContainer)))
(namespaceID == kNameSpaceID_XUL && aUseXBLForms &&
ShouldIgnoreSelectChild(aContainer)))
return PR_TRUE;
return PR_FALSE;
@ -10178,7 +10168,9 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
mDocument->GetBindingManager()->ResolveTag(aContent, &namespaceID,
getter_AddRefs(tag));
if (tag && (tag.get() == nsXULAtoms::listitem || tag.get() == nsXULAtoms::listcell))
if (namespaceID == kNameSpaceID_XUL &&
(tag == nsXULAtoms::listitem ||
tag == nsXULAtoms::listcell))
return NS_OK;
}
@ -10312,9 +10304,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell,
aFrame = nsnull;
// Get the alternate text to use
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
GetAlternateTextFor(aContent, tag, altText);
GetAlternateTextFor(aContent, aContent->Tag(), altText);
// Create a text content element for the alternate text
nsCOMPtr<nsIContent> altTextContent(do_CreateInstance(kTextNodeCID,&rv));
@ -10437,12 +10427,12 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
// Get aFrame's content object and the tag name
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> tag;
nsIAtom* tag;
nsIContent* content = aFrame->GetContent();
NS_ASSERTION(content, "null content object");
content->GetNameSpaceID(&nameSpaceID);
content->GetTag(getter_AddRefs(tag));
tag = content->Tag();
// Get the child list name that the frame is contained in
nsCOMPtr<nsIAtom> listName;
@ -10464,8 +10454,8 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
// See whether it's an IMG or an INPUT element (for image buttons)
// or if it is an applet with no displayable children
// XXX need to check nameSpaceID in these spots
if (nsHTMLAtoms::img == tag.get() || nsHTMLAtoms::input == tag.get() ||
(nsHTMLAtoms::applet == tag.get() && !HasDisplayableChildren(aPresContext, aFrame))) {
if (nsHTMLAtoms::img == tag || nsHTMLAtoms::input == tag ||
(nsHTMLAtoms::applet == tag && !HasDisplayableChildren(aPresContext, aFrame))) {
// Try and construct an alternate frame to use when the
// image can't be rendered
nsIFrame* newFrame;
@ -10508,9 +10498,9 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
}
}
} else if ((nsHTMLAtoms::object == tag.get()) ||
(nsHTMLAtoms::embed == tag.get()) ||
(nsHTMLAtoms::applet == tag.get())) {
} else if ((nsHTMLAtoms::object == tag) ||
(nsHTMLAtoms::embed == tag) ||
(nsHTMLAtoms::applet == tag)) {
// It's an OBJECT, EMBED, or APPLET, so we should display the contents
// instead
nsIFrame* absoluteContainingBlock;
@ -10529,10 +10519,10 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
#ifdef NS_DEBUG
// Verify that we calculated the same containing block
if (listName.get() == nsLayoutAtoms::absoluteList) {
if (listName == nsLayoutAtoms::absoluteList) {
NS_ASSERTION(absoluteContainingBlock == parentFrame,
"wrong absolute containing block");
} else if (listName.get() == nsLayoutAtoms::floatList) {
} else if (listName == nsLayoutAtoms::floatList) {
NS_ASSERTION(floatContainingBlock == parentFrame,
"wrong float containing block");
}
@ -10610,13 +10600,13 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
// block frame.
SplitToContainingBlock(aPresContext, state, parentFrame, list1, list2, list3, PR_FALSE);
}
} else if (listName.get() == nsLayoutAtoms::absoluteList) {
} else if (listName == nsLayoutAtoms::absoluteList) {
newFrame = state.mAbsoluteItems.childList;
state.mAbsoluteItems.childList = nsnull;
} else if (listName.get() == nsLayoutAtoms::fixedList) {
} else if (listName == nsLayoutAtoms::fixedList) {
newFrame = state.mFixedItems.childList;
state.mFixedItems.childList = nsnull;
} else if (listName.get() == nsLayoutAtoms::floatList) {
} else if (listName == nsLayoutAtoms::floatList) {
newFrame = state.mFloatedItems.childList;
state.mFloatedItems.childList = nsnull;
}
@ -10631,7 +10621,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
InsertOutOfFlowFrames(state, aPresContext);
}
} else if (nsHTMLAtoms::input == tag.get()) {
} else if (nsHTMLAtoms::input == tag) {
// XXX image INPUT elements are also image frames, but don't throw away the
// image frame, because the frame class has extra logic that is specific to
// INPUT elements
@ -11216,7 +11206,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
while (parentFrame) {
// Search the child frames for a match
*aFrame = FindFrameWithContent(aPresContext, aFrameManager, parentFrame,
parentContent.get(), aContent, aHint);
parentContent, aContent, aHint);
#ifdef NOISY_FINDFRAME
printf("FindFrameWithContent returned %p\n", *aFrame);
#endif
@ -11233,7 +11223,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
#endif
nsIFrame *verifyTestFrame =
FindFrameWithContent(aPresContext, aFrameManager, parentFrame,
parentContent.get(), aContent, nsnull);
parentContent, aContent, nsnull);
#ifdef NOISY_FINDFRAME
printf("VERIFY returned %p\n", verifyTestFrame);
#endif
@ -11263,9 +11253,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
if (aHint && !*aFrame)
{ // if we had a hint, and we didn't get a frame, see if we should try the slow way
nsCOMPtr<nsIAtom>tag;
aContent->GetTag(getter_AddRefs(tag));
if (nsLayoutAtoms::textTagName == tag.get())
if (aContent->Tag() == nsLayoutAtoms::textTagName)
{
#ifdef NOISY_FINDFRAME
FFWC_slowSearchForText++;
@ -12244,11 +12232,11 @@ nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
// Take the old textFrame out of the inline parents child list
DeletingFrameSubtree(aPresContext, aState.mPresShell,
aState.mFrameManager, textFrame);
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell.get(),
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell,
nsnull, textFrame);
// Insert in the letter frame(s)
parentFrame->InsertFrames(aPresContext, *aState.mPresShell.get(),
parentFrame->InsertFrames(aPresContext, *aState.mPresShell,
nsnull, prevFrame, letterFrames.childList);
}
}
@ -12552,16 +12540,16 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsIPresShell* aPresShell, nsIPresCont
// Take the old textFrame out of the parents child list
DeletingFrameSubtree(aPresContext, aState.mPresShell,
aState.mFrameManager, textFrame);
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell.get(),
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell,
nsnull, textFrame);
// Insert in the letter frame(s)
parentFrame->InsertFrames(aPresContext, *aState.mPresShell.get(),
parentFrame->InsertFrames(aPresContext, *aState.mPresShell,
nsnull, prevFrame, letterFrames.childList);
// Insert in floats too if needed
if (aState.mFloatedItems.childList) {
aBlockFrame->AppendFrames(aPresContext, *aState.mPresShell.get(),
aBlockFrame->AppendFrames(aPresContext, *aState.mPresShell,
nsLayoutAtoms::floatList,
aState.mFloatedItems.childList);
}
@ -12608,13 +12596,11 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext,
return NS_OK;
}
nsCOMPtr<nsIAtom> tag;
aChild->GetTag(getter_AddRefs(tag));
PRInt32 namespaceID;
aChild->GetNameSpaceID(&namespaceID);
rv = ConstructFrameInternal(shell, aPresContext, state, aChild, aParentFrame, tag, namespaceID,
rv = ConstructFrameInternal(shell, aPresContext, state, aChild,
aParentFrame, aChild->Tag(), namespaceID,
styleContext, frameItems, PR_FALSE);
nsIFrame* newFrame = frameItems.childList;
@ -12688,10 +12674,8 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell,
nsresult rv = ProcessChildren(aPresShell, aPresContext, aState, aContent,
aNewFrame, PR_TRUE, childItems, PR_TRUE);
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, aNewFrame, PR_FALSE, childItems);
// Set the frame's initial child list
aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
@ -12762,10 +12746,8 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell,
aNewFrame, PR_TRUE, childItems, &kidsAllInline);
if (kidsAllInline) {
// Set the inline frame's initial child list
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, aNewFrame, PR_FALSE, childItems);
aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);

View File

@ -194,7 +194,7 @@ protected:
static InlineBackgroundData gInlineBGData;
static void GetPath(nsFloatPoint aPoints[],nsPoint aPolyPath[],PRInt32 *aCurIndex,ePathTypes aPathType,PRInt32 &aC1Index,float aFrac=0);
static nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame);
static void GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame);
// FillRect or InvertRect depending on the renderingaInvert parameter
static void FillOrInvertRect(nsIRenderingContext& aRC,nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aInvert);
@ -1555,15 +1555,14 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,
nsIContent *pContent;
if ((pContent = doc->GetRootContent())) {
// make sure that this is the HTML element
nsCOMPtr<nsIAtom> tag;
pContent->GetTag(getter_AddRefs(tag));
nsIAtom *tag = pContent->Tag();
NS_ASSERTION(tag, "Tag could not be retrieved from root content element");
if (tag) {
if (tag == nsHTMLAtoms::html ||
tag == nsHTMLAtoms::body) {
// use this guy's color
nsIFrame *pFrame = nsnull;
if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) && pFrame) {
if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) &&
pFrame) {
nsStyleContext *pContext = pFrame->GetStyleContext();
if (pContext) {
const nsStyleBackground* color = pContext->GetStyleBackground();
@ -1580,7 +1579,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,
printf( "Root Content is not HTML or BODY: cannot get bgColor of HTML or BODY\n");
}
#endif
}// if tag
}// if content
NS_RELEASE(doc);
}// if doc
@ -1599,23 +1597,25 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,
// The check is a bit expensive, however until the canvas frame is somehow cached on the
// body frame, or the root element, we need to walk the frames up until we find the canvas
//
nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame)
void
GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame,
nsIFrame **aBGFrame)
{
NS_ASSERTION(aFrame && aBGFrame, "illegal null parameter");
if (!aFrame || !aBGFrame) {
NS_ERROR("illegal null parameter");
nsresult rv = NS_OK;
return;
}
if (aFrame && aBGFrame) {
*aBGFrame = aFrame; // default to the frame passed in
nsIContent* pContent = aFrame->GetContent();
if (pContent) {
// make sure that this is the HTML or BODY element
nsCOMPtr<nsIAtom> tag;
pContent->GetTag(getter_AddRefs(tag));
if (tag) {
if (tag.get() == nsHTMLAtoms::html ||
tag.get() == nsHTMLAtoms::body) {
nsIAtom *tag = pContent->Tag();
if (tag == nsHTMLAtoms::html ||
tag == nsHTMLAtoms::body) {
// the frame is the body frame, so we provide the canvas frame
nsIFrame *pCanvasFrame = aFrame->GetParent();
while (pCanvasFrame) {
@ -1626,12 +1626,7 @@ nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFra
pCanvasFrame = pCanvasFrame->GetParent();
}
}// if tag == html or body
}// if tag
}
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
// helper macro to determine if the borderstyle 'a' is a MOZ-BG-XXX style
@ -2744,9 +2739,7 @@ FindElementBackground(nsIPresContext* aPresContext,
if (!parentFrame)
return PR_TRUE; // no parent to look at
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag != nsHTMLAtoms::body)
if (content->Tag() != nsHTMLAtoms::body)
return PR_TRUE; // not frame for <BODY> element
// We should only look at the <html> background if we're in an HTML document

View File

@ -621,10 +621,10 @@ FrameManager::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aResult)
if (index > 0) // no use looking if it's the first child
{
nsIContent *prevSibling;
nsCOMPtr<nsIAtom> tag;
nsIAtom *tag;
do {
prevSibling = parent->GetChildAt(--index);
prevSibling->GetTag(getter_AddRefs(tag));
tag = prevSibling->Tag();
} while (index &&
(tag == nsLayoutAtoms::textTagName ||
tag == nsLayoutAtoms::commentTagName ||

View File

@ -4014,9 +4014,8 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
// Ensure it's an anchor element
content = do_QueryInterface(node);
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::a) {
if (content->Tag() == nsHTMLAtoms::a &&
content->IsContentOfType(nsIContent::eHTML)) {
break;
}
content = nsnull;

View File

@ -359,8 +359,12 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
selContent = selContent->GetParent())
{
// checking for selection inside a plaintext form widget
nsCOMPtr<nsIAtom> atom;
selContent->GetTag(getter_AddRefs(atom));
if (!selContent->IsContentOfType(nsIContent::eHTML)) {
continue;
}
nsIAtom *atom = selContent->Tag();
if (atom == nsHTMLAtoms::input ||
atom == nsHTMLAtoms::textarea)

View File

@ -481,7 +481,6 @@ MAKE_CTOR(CreateCSSLoader, nsICSSLoader, NS_NewCSS
MAKE_CTOR(CreateHTMLElementFactory, nsIElementFactory, NS_NewHTMLElementFactory)
MAKE_CTOR(CreateTextNode, nsITextContent, NS_NewTextNode)
//MAKE_CTOR(CreateAnonymousElement, nsIContent, NS_NewAnonymousElement)
MAKE_CTOR(CreateAttributeContent, nsIContent, NS_NewAttributeContent)
MAKE_CTOR(CreateXMLElementFactory, nsIElementFactory, NS_NewXMLElementFactory)
//MAKE_CTOR(CreateSelection, nsISelection, NS_NewSelection)
MAKE_CTOR(CreateDOMSelection, nsISelection, NS_NewDomSelection)
@ -882,11 +881,6 @@ static const nsModuleComponentInfo gComponents[] = {
CreateAnonymousElement },
#endif
{ "Attribute Content",
NS_ATTRIBUTECONTENT_CID,
nsnull,
CreateAttributeContent },
{ "XML element factory",
NS_XML_ELEMENT_FACTORY_CID,
NS_XML_ELEMENT_FACTORY_CONTRACTID,

View File

@ -447,23 +447,12 @@ nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame*
while (childFrame) {
// see if the child is a text control
nsIContent* content = childFrame->GetContent();
if (content) {
nsCOMPtr<nsIAtom> atom;
nsresult res = content->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(res) && atom) {
if (atom.get() == nsHTMLAtoms::input) {
nsCOMPtr<nsIFormControl> formCtrl =
do_QueryInterface(childFrame->GetContent());
// It's an input, is it a text input?
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
if (value.EqualsIgnoreCase("text")) {
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_TEXT) {
result = (nsNewFrame*)childFrame;
}
}
}
}
}
// if not continue looking
nsNewFrame* frame = GetTextControlFrame(aPresContext, childFrame);

View File

@ -104,27 +104,14 @@ nsGfxButtonControlFrame::IsFileBrowseButton(PRInt32 type)
rv = PR_TRUE;
}
else if (NS_FORM_INPUT_BUTTON == type) {
// Check to see if parent is a file input
nsresult result;
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAtom> atom;
result = parentContent->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(result) && atom) {
if (atom == nsHTMLAtoms::input) {
nsCOMPtr<nsIFormControl> formCtrl =
do_QueryInterface(mContent->GetParent());
// It's an input, is it a file input?
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == parentContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
if (value.EqualsIgnoreCase("file")) {
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_FILE) {
rv = PR_TRUE;
}
}
}
}
}
}
return rv;
}

View File

@ -793,9 +793,8 @@ nsTextInputSelectionImpl::CompleteMove(PRBool aForward, PRBool aExtend)
if (offset > 0)
{
nsIContent *child = parentDIV->GetChildAt(offset - 1);
nsCOMPtr<nsIAtom> tagName;
child->GetTag(getter_AddRefs(tagName));
if (tagName == nsHTMLAtoms::br)
if (child->Tag() == nsHTMLAtoms::br)
{
--offset;
hint = HINTRIGHT; // for Bug 106855
@ -1329,16 +1328,7 @@ PRBool nsTextControlFrame::IsSingleLineTextControl() const
PRBool nsTextControlFrame::IsTextArea() const
{
if (!mContent)
return PR_FALSE;
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
if (nsHTMLAtoms::textarea == tag)
return PR_TRUE;
return PR_FALSE;
return mContent && mContent->Tag() == nsHTMLAtoms::textarea;
}
// XXX: wouldn't it be nice to get this from the style context!
@ -2297,9 +2287,7 @@ nsTextControlFrame::SelectAllContents()
// br under the root node!
nsIContent *child = rootContent->GetChildAt(numChildren - 1);
if (child) {
nsCOMPtr<nsIAtom> tagName;
child->GetTag(getter_AddRefs(tagName));
if (tagName == nsHTMLAtoms::br)
if (child->Tag() == nsHTMLAtoms::br)
--numChildren;
}
}

View File

@ -40,6 +40,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIViewManager.h"
#include "nsINodeInfo.h"
#include "nsHTMLAtoms.h"
#include "nsIView.h"
#include "nsHTMLValue.h"
@ -87,18 +88,10 @@ nsAreaFrame::RegUnregAccessKey(nsIPresContext* aPresContext,
if (!mContent)
return NS_ERROR_FAILURE;
PRBool isXUL = mContent->IsContentOfType(nsIContent::eXUL);
if (!isXUL)
return NS_OK;
// find out what type of element this is
nsCOMPtr<nsIAtom> atom;
nsresult rv = mContent->GetTag(getter_AddRefs(atom));
if (NS_FAILED(rv))
return rv;
nsINodeInfo *ni = mContent->GetNodeInfo();
// only support accesskeys for the following elements
if (atom != nsXULAtoms::label)
if (!ni || !ni->Equals(nsXULAtoms::label, kNameSpaceID_XUL))
return NS_OK;
// To filter out <label>s without a control attribute.
@ -120,7 +113,7 @@ nsAreaFrame::RegUnregAccessKey(nsIPresContext* aPresContext,
nsCOMPtr<nsIEventStateManager> esm;
aPresContext->GetEventStateManager(getter_AddRefs(esm));
rv = NS_OK;
nsresult rv = NS_OK;
if (esm) {
PRUint32 key = accessKey.First();

View File

@ -2632,6 +2632,8 @@ NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
return NS_OK;
}
#ifdef NS_DEBUG
PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
{
PRInt32 result = -1;
@ -2647,8 +2649,6 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
return result;
}
#ifdef NS_DEBUG
#ifdef DEBUG_waterson
/**
@ -2707,10 +2707,9 @@ nsresult
nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
{
aResult = aType;
if (nsnull != mContent) {
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
if (tag && tag != nsLayoutAtoms::textTagName) {
if (mContent) {
nsIAtom *tag = mContent->Tag();
if (tag != nsLayoutAtoms::textTagName) {
nsAutoString buf;
tag->ToString(buf);
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
@ -4756,18 +4755,11 @@ static void
GetTagName(nsFrame* aFrame, nsIContent* aContent, PRIntn aResultSize,
char* aResult)
{
char namebuf[40];
namebuf[0] = 0;
const char *nameStr = "";
if (aContent) {
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
if (tag) {
nsAutoString tmp;
tag->ToString(tmp);
tmp.ToCString(namebuf, sizeof(namebuf));
aContent->Tag()->GetUTF8String(&nameStr);
}
}
PR_snprintf(aResult, aResultSize, "%s@%p", namebuf, aFrame);
PR_snprintf(aResult, aResultSize, "%s@%p", nameStr, aFrame);
}
void

View File

@ -335,10 +335,6 @@ public:
const nsRect& aDamageRect,
PRBool aImmediate = PR_FALSE) const;
// Helper function to return the index in parent of the frame's content
// object. Returns -1 on error or if the frame doesn't have a content object
static PRInt32 ContentIndexInContainer(const nsIFrame* aFrame);
// Helper function that tests if the frame tree is too deep; if it
// is it marks the frame as "unflowable" and zeros out the metrics
// and returns PR_TRUE. Otherwise, the frame is unmarked
@ -420,6 +416,10 @@ public:
// NS_FRAME_IS_DIRTY bit set
static void VerifyDirtyBitSet(nsIFrame* aFrameList);
// Helper function to return the index in parent of the frame's content
// object. Returns -1 on error or if the frame doesn't have a content object
static PRInt32 ContentIndexInContainer(const nsIFrame* aFrame);
void ListTag(FILE* out) const {
ListTag(out, (nsIFrame*)this);
}

View File

@ -605,8 +605,7 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsCOMPtr<nsIAtom> type;
aChild->GetTag(getter_AddRefs(type));
nsIAtom *type = aChild->Tag();
if ((type != nsHTMLAtoms::object && aAttribute == nsHTMLAtoms::src) ||
(type == nsHTMLAtoms::object && aAttribute == nsHTMLAtoms::data)) {
@ -619,10 +618,7 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
}
// If the noResize attribute changes, dis/allow frame to be resized
else if (aAttribute == nsHTMLAtoms::noresize) {
nsCOMPtr<nsIAtom> parentTag;
mContent->GetParent()->GetTag(getter_AddRefs(parentTag));
if (parentTag == nsHTMLAtoms::frameset) {
if (mContent->GetParent()->Tag() == nsHTMLAtoms::frameset) {
nsIFrame* parentFrame = GetParent();
if (parentFrame) {
@ -750,10 +746,8 @@ nsHTMLFrameInnerFrame::Destroy(nsIPresContext* aPresContext)
PRBool nsHTMLFrameInnerFrame::GetURL(nsIContent* aContent, nsString& aResult)
{
aResult.SetLength(0);
nsCOMPtr<nsIAtom> type;
aContent->GetTag(getter_AddRefs(type));
if (type.get() == nsHTMLAtoms::object) {
if (aContent->Tag() == nsHTMLAtoms::object) {
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, aResult)))
if (!aResult.IsEmpty())
return PR_TRUE;

View File

@ -399,8 +399,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
if (!child->IsContentOfType(nsIContent::eHTML))
continue;
nsCOMPtr<nsIAtom> tag;
child->GetTag(getter_AddRefs(tag));
nsIAtom *tag = child->Tag();
if (tag == nsHTMLAtoms::frameset || tag == nsHTMLAtoms::frame) {
nsRefPtr<nsStyleContext> kidSC;
nsresult result;
@ -719,16 +718,12 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
if (content) {
nsCOMPtr<nsIContent> contentParent = content->GetParent();
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML)) {
nsCOMPtr<nsIAtom> tag;
contentParent->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::frameset) {
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML) &&
contentParent->Tag() == nsHTMLAtoms::frameset) {
nsIFrame* fptr = aChild->GetParent();
parent = (nsHTMLFramesetFrame*) fptr;
}
}
}
return parent;
}

View File

@ -1451,16 +1451,14 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState)
if (firstAncestorRS) {
nsIContent* frameContent = firstAncestorRS->frame->GetContent();
if (frameContent) {
nsCOMPtr<nsIAtom> contentTag;
frameContent->GetTag(getter_AddRefs(contentTag));
nsIAtom *contentTag = frameContent->Tag();
NS_ASSERTION(contentTag == nsHTMLAtoms::html, "First ancestor is not HTML");
}
}
if (secondAncestorRS) {
nsIContent* frameContent = secondAncestorRS->frame->GetContent();
if (frameContent) {
nsCOMPtr<nsIAtom> contentTag;
frameContent->GetTag(getter_AddRefs(contentTag));
nsIAtom *contentTag = frameContent->Tag();
NS_ASSERTION(contentTag == nsHTMLAtoms::body, "Second ancestor is not BODY");
}
}

View File

@ -1211,15 +1211,12 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
if (!inner.IsEmpty()) {
nsIContent* content = GetContent();
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag) {
nsAutoString altText;
nsCSSFrameConstructor::GetAlternateTextFor(content, tag, altText);
nsCSSFrameConstructor::GetAlternateTextFor(content, content->Tag(),
altText);
DisplayAltText(aPresContext, aRenderingContext, altText, inner);
}
}
}
aRenderingContext.PopState(clipState);
}

View File

@ -882,10 +882,10 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
// Broken image accessibles are created here, because layout
// replaces the image or image control frame with an inline frame
*aAccessible = nsnull;
nsCOMPtr<nsIAtom> tagAtom;
mContent->GetTag(getter_AddRefs(tagAtom));
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input ||
tagAtom == nsHTMLAtoms::label || tagAtom == nsHTMLAtoms::hr) {
nsIAtom *tagAtom = mContent->Tag();
if ((tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input ||
tagAtom == nsHTMLAtoms::label || tagAtom == nsHTMLAtoms::hr) &&
mContent->IsContentOfType(nsIContent::eHTML)) {
// Only get accessibility service if we're going to use it
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
if (!accService)

View File

@ -2464,12 +2464,11 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
if (!applyMinLH && (isFirstLine || isLastLine)) {
nsIContent* blockContent = mRootSpan->mFrame->mFrame->GetContent();
if (blockContent) {
nsCOMPtr<nsIAtom> blockTagAtom;
nsresult result = blockContent->GetTag(getter_AddRefs(blockTagAtom));
if ( NS_SUCCEEDED(result) && blockTagAtom) {
nsIAtom *blockTagAtom = blockContent->Tag();
// (2) above, if the first line of LI
if (isFirstLine && blockTagAtom.get() == nsHTMLAtoms::li) {
// if the line is empty, then don't force the min height (see bug 75963)
if (isFirstLine && blockTagAtom == nsHTMLAtoms::li) {
// if the line is empty, then don't force the min height
// (see bug 75963)
if (!IsZeroHeight()) {
applyMinLH = PR_TRUE;
foundLI = PR_TRUE;
@ -2477,14 +2476,13 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
}
// (3) above, if the last line of LI, DT, or DD
else if (!applyMinLH && isLastLine &&
((blockTagAtom.get() == nsHTMLAtoms::li) ||
(blockTagAtom.get() == nsHTMLAtoms::dt) ||
(blockTagAtom.get() == nsHTMLAtoms::dd))) {
((blockTagAtom == nsHTMLAtoms::li) ||
(blockTagAtom == nsHTMLAtoms::dt) ||
(blockTagAtom == nsHTMLAtoms::dd))) {
applyMinLH = PR_TRUE;
}
}
}
}
if (applyMinLH) {
if ((psd->mX != psd->mLeftEdge) || preMode || foundLI) {
#ifdef NOISY_VERTICAL_ALIGN

View File

@ -492,13 +492,11 @@ PRBool nsObjectFrame::IsSupportedImage(nsIContent* aContent)
PRBool haveType = (rv == NS_CONTENT_ATTR_HAS_VALUE) && (!type.IsEmpty());
if (!haveType)
{
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsAutoString data;
// If this is an OBJECT tag, we should look for a DATA attribute.
// If not, it's an EMBED tag, and so we should look for a SRC attribute.
if (tag == nsHTMLAtoms::object)
if (aContent->Tag() == nsHTMLAtoms::object)
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data);
else
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data);
@ -635,13 +633,11 @@ nsObjectFrame::Init(nsIPresContext* aPresContext,
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsAutoString data;
// If this is an OBJECT tag, we should look for a DATA attribute.
// If not, it's an EMBED tag, and so we should look for a SRC attribute.
if (tag == nsHTMLAtoms::object)
if (aContent->Tag() == nsHTMLAtoms::object)
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data);
else
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data);
@ -671,9 +667,8 @@ nsObjectFrame::Init(nsIPresContext* aPresContext,
// only do the following for the object tag
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
if (tag.get() != nsHTMLAtoms::object) return rv;
if (aContent->Tag() != nsHTMLAtoms::object)
return rv;
// for now, we should try to do the same for "document" types and create
// and IFrame-like sub-frame
@ -915,8 +910,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext,
aMetrics.height = aReflowState.mComputedHeight;
// for EMBED and APPLET, default to 240x200 for compatibility
nsCOMPtr<nsIAtom> atom;
mContent->GetTag(getter_AddRefs(atom));
nsIAtom *atom = mContent->Tag();
if (atom == nsHTMLAtoms::applet || atom == nsHTMLAtoms::embed) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
@ -1116,9 +1110,8 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
mInstanceOwner->SetPluginHost(pluginHost);
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
if (tag.get() == nsHTMLAtoms::applet) {
nsIAtom *tag = mContent->Tag();
if (tag == nsHTMLAtoms::applet) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, src)) {
// Create an absolute URL
rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL);
@ -1409,25 +1402,29 @@ nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const
return PR_TRUE;
}
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
// only <embed> tags support the HIDDEN attribute
if (tag.get() == nsHTMLAtoms::embed) {
if (mContent->Tag() == nsHTMLAtoms::embed) {
nsAutoString hidden;
nsresult result = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden);
// Yes, these are really the kooky ways that you could tell 4.x
// not to hide the <embed> once you'd put the 'hidden' attribute
// on the tag...
// these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s until |EqualsIgnoreCase| get's fixed
// HIDDEN w/ no attributes gets translated as we are hidden for compatibility
// w/ 4.x and IE so we don't create a non-painting widget in layout. See bug 188959.
// these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s
// until |EqualsIgnoreCase| get's fixed
// HIDDEN w/ no attributes gets translated as we are hidden for
// compatibility w/ 4.x and IE so we don't create a non-painting
// widget in layout. See bug 188959.
if (NS_CONTENT_ATTR_NOT_THERE != result &&
(hidden.IsEmpty() ||
!hidden.Equals(NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("no"), nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("off"), nsCaseInsensitiveStringComparator()))) {
!hidden.Equals(NS_LITERAL_STRING("false"),
nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("no"),
nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("off"),
nsCaseInsensitiveStringComparator()))) {
return PR_TRUE;
}
}
@ -2520,11 +2517,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
nsIContent* cont = mOwner->GetContent();
if (cont)
{
nsCOMPtr<nsIAtom> atom;
cont->GetTag(getter_AddRefs(atom));
nsIAtom *atom = cont->Tag();
if (atom)
{
if (atom == nsHTMLAtoms::applet)
*result = nsPluginTagType_Applet;
else if (atom == nsHTMLAtoms::embed)
@ -2535,7 +2529,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
rv = NS_OK;
}
}
}
return rv;
}
@ -3030,9 +3023,8 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// to the bottom of the array if there isn't already a "src" specified.
PRInt16 numRealAttrs = mNumCachedAttrs;
nsAutoString data;
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (nsHTMLAtoms::object == tag.get()
nsIAtom *tag = content->Tag();
if (nsHTMLAtoms::object == tag
&& !content->HasAttr(kNameSpaceID_None, nsHTMLAtoms::src)
&& NS_CONTENT_ATTR_NOT_THERE != content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data)) {
mNumCachedAttrs++;

View File

@ -148,7 +148,7 @@ struct nsScrollSelectionIntoViewEvent;
PRBool IsValidSelectionPoint(nsSelection *aFrameSel, nsIContent *aContent);
PRBool IsValidSelectionPoint(nsSelection *aFrameSel, nsIDOMNode *aDomNode);
static nsCOMPtr<nsIAtom> 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<nsIAtom> GetTag(nsIDOMNode *aNode)
static
nsIAtom *GetTag(nsIDOMNode *aNode)
{
nsCOMPtr<nsIAtom> atom;
if (!aNode)
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIDOMNode> parent(aDomNode);
nsCOMPtr<nsIDOMNode> current(aDomNode);
PRInt32 childOffset;
nsCOMPtr<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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<nsIAtom> 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)
{
nsCOMPtr<nsIContent>content;
content = do_QueryInterface(aParentNode);
nsCOMPtr<nsIAtom> 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");

View File

@ -40,6 +40,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIViewManager.h"
#include "nsINodeInfo.h"
#include "nsHTMLAtoms.h"
#include "nsIView.h"
#include "nsHTMLValue.h"
@ -87,18 +88,10 @@ nsAreaFrame::RegUnregAccessKey(nsIPresContext* aPresContext,
if (!mContent)
return NS_ERROR_FAILURE;
PRBool isXUL = mContent->IsContentOfType(nsIContent::eXUL);
if (!isXUL)
return NS_OK;
// find out what type of element this is
nsCOMPtr<nsIAtom> atom;
nsresult rv = mContent->GetTag(getter_AddRefs(atom));
if (NS_FAILED(rv))
return rv;
nsINodeInfo *ni = mContent->GetNodeInfo();
// only support accesskeys for the following elements
if (atom != nsXULAtoms::label)
if (!ni || !ni->Equals(nsXULAtoms::label, kNameSpaceID_XUL))
return NS_OK;
// To filter out <label>s without a control attribute.
@ -120,7 +113,7 @@ nsAreaFrame::RegUnregAccessKey(nsIPresContext* aPresContext,
nsCOMPtr<nsIEventStateManager> esm;
aPresContext->GetEventStateManager(getter_AddRefs(esm));
rv = NS_OK;
nsresult rv = NS_OK;
if (esm) {
PRUint32 key = accessKey.First();

View File

@ -2632,6 +2632,8 @@ NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
return NS_OK;
}
#ifdef NS_DEBUG
PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
{
PRInt32 result = -1;
@ -2647,8 +2649,6 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
return result;
}
#ifdef NS_DEBUG
#ifdef DEBUG_waterson
/**
@ -2707,10 +2707,9 @@ nsresult
nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
{
aResult = aType;
if (nsnull != mContent) {
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
if (tag && tag != nsLayoutAtoms::textTagName) {
if (mContent) {
nsIAtom *tag = mContent->Tag();
if (tag != nsLayoutAtoms::textTagName) {
nsAutoString buf;
tag->ToString(buf);
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
@ -4756,18 +4755,11 @@ static void
GetTagName(nsFrame* aFrame, nsIContent* aContent, PRIntn aResultSize,
char* aResult)
{
char namebuf[40];
namebuf[0] = 0;
const char *nameStr = "";
if (aContent) {
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
if (tag) {
nsAutoString tmp;
tag->ToString(tmp);
tmp.ToCString(namebuf, sizeof(namebuf));
aContent->Tag()->GetUTF8String(&nameStr);
}
}
PR_snprintf(aResult, aResultSize, "%s@%p", namebuf, aFrame);
PR_snprintf(aResult, aResultSize, "%s@%p", nameStr, aFrame);
}
void

View File

@ -335,10 +335,6 @@ public:
const nsRect& aDamageRect,
PRBool aImmediate = PR_FALSE) const;
// Helper function to return the index in parent of the frame's content
// object. Returns -1 on error or if the frame doesn't have a content object
static PRInt32 ContentIndexInContainer(const nsIFrame* aFrame);
// Helper function that tests if the frame tree is too deep; if it
// is it marks the frame as "unflowable" and zeros out the metrics
// and returns PR_TRUE. Otherwise, the frame is unmarked
@ -420,6 +416,10 @@ public:
// NS_FRAME_IS_DIRTY bit set
static void VerifyDirtyBitSet(nsIFrame* aFrameList);
// Helper function to return the index in parent of the frame's content
// object. Returns -1 on error or if the frame doesn't have a content object
static PRInt32 ContentIndexInContainer(const nsIFrame* aFrame);
void ListTag(FILE* out) const {
ListTag(out, (nsIFrame*)this);
}

View File

@ -621,10 +621,10 @@ FrameManager::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aResult)
if (index > 0) // no use looking if it's the first child
{
nsIContent *prevSibling;
nsCOMPtr<nsIAtom> tag;
nsIAtom *tag;
do {
prevSibling = parent->GetChildAt(--index);
prevSibling->GetTag(getter_AddRefs(tag));
tag = prevSibling->Tag();
} while (index &&
(tag == nsLayoutAtoms::textTagName ||
tag == nsLayoutAtoms::commentTagName ||

View File

@ -1451,16 +1451,14 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState)
if (firstAncestorRS) {
nsIContent* frameContent = firstAncestorRS->frame->GetContent();
if (frameContent) {
nsCOMPtr<nsIAtom> contentTag;
frameContent->GetTag(getter_AddRefs(contentTag));
nsIAtom *contentTag = frameContent->Tag();
NS_ASSERTION(contentTag == nsHTMLAtoms::html, "First ancestor is not HTML");
}
}
if (secondAncestorRS) {
nsIContent* frameContent = secondAncestorRS->frame->GetContent();
if (frameContent) {
nsCOMPtr<nsIAtom> contentTag;
frameContent->GetTag(getter_AddRefs(contentTag));
nsIAtom *contentTag = frameContent->Tag();
NS_ASSERTION(contentTag == nsHTMLAtoms::body, "Second ancestor is not BODY");
}
}

View File

@ -1211,15 +1211,12 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
if (!inner.IsEmpty()) {
nsIContent* content = GetContent();
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag) {
nsAutoString altText;
nsCSSFrameConstructor::GetAlternateTextFor(content, tag, altText);
nsCSSFrameConstructor::GetAlternateTextFor(content, content->Tag(),
altText);
DisplayAltText(aPresContext, aRenderingContext, altText, inner);
}
}
}
aRenderingContext.PopState(clipState);
}

View File

@ -882,10 +882,10 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
// Broken image accessibles are created here, because layout
// replaces the image or image control frame with an inline frame
*aAccessible = nsnull;
nsCOMPtr<nsIAtom> tagAtom;
mContent->GetTag(getter_AddRefs(tagAtom));
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input ||
tagAtom == nsHTMLAtoms::label || tagAtom == nsHTMLAtoms::hr) {
nsIAtom *tagAtom = mContent->Tag();
if ((tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input ||
tagAtom == nsHTMLAtoms::label || tagAtom == nsHTMLAtoms::hr) &&
mContent->IsContentOfType(nsIContent::eHTML)) {
// Only get accessibility service if we're going to use it
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
if (!accService)

View File

@ -2464,12 +2464,11 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
if (!applyMinLH && (isFirstLine || isLastLine)) {
nsIContent* blockContent = mRootSpan->mFrame->mFrame->GetContent();
if (blockContent) {
nsCOMPtr<nsIAtom> blockTagAtom;
nsresult result = blockContent->GetTag(getter_AddRefs(blockTagAtom));
if ( NS_SUCCEEDED(result) && blockTagAtom) {
nsIAtom *blockTagAtom = blockContent->Tag();
// (2) above, if the first line of LI
if (isFirstLine && blockTagAtom.get() == nsHTMLAtoms::li) {
// if the line is empty, then don't force the min height (see bug 75963)
if (isFirstLine && blockTagAtom == nsHTMLAtoms::li) {
// if the line is empty, then don't force the min height
// (see bug 75963)
if (!IsZeroHeight()) {
applyMinLH = PR_TRUE;
foundLI = PR_TRUE;
@ -2477,14 +2476,13 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
}
// (3) above, if the last line of LI, DT, or DD
else if (!applyMinLH && isLastLine &&
((blockTagAtom.get() == nsHTMLAtoms::li) ||
(blockTagAtom.get() == nsHTMLAtoms::dt) ||
(blockTagAtom.get() == nsHTMLAtoms::dd))) {
((blockTagAtom == nsHTMLAtoms::li) ||
(blockTagAtom == nsHTMLAtoms::dt) ||
(blockTagAtom == nsHTMLAtoms::dd))) {
applyMinLH = PR_TRUE;
}
}
}
}
if (applyMinLH) {
if ((psd->mX != psd->mLeftEdge) || preMode || foundLI) {
#ifdef NOISY_VERTICAL_ALIGN

View File

@ -492,13 +492,11 @@ PRBool nsObjectFrame::IsSupportedImage(nsIContent* aContent)
PRBool haveType = (rv == NS_CONTENT_ATTR_HAS_VALUE) && (!type.IsEmpty());
if (!haveType)
{
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsAutoString data;
// If this is an OBJECT tag, we should look for a DATA attribute.
// If not, it's an EMBED tag, and so we should look for a SRC attribute.
if (tag == nsHTMLAtoms::object)
if (aContent->Tag() == nsHTMLAtoms::object)
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data);
else
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data);
@ -635,13 +633,11 @@ nsObjectFrame::Init(nsIPresContext* aPresContext,
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsAutoString data;
// If this is an OBJECT tag, we should look for a DATA attribute.
// If not, it's an EMBED tag, and so we should look for a SRC attribute.
if (tag == nsHTMLAtoms::object)
if (aContent->Tag() == nsHTMLAtoms::object)
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data);
else
rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data);
@ -671,9 +667,8 @@ nsObjectFrame::Init(nsIPresContext* aPresContext,
// only do the following for the object tag
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
if (tag.get() != nsHTMLAtoms::object) return rv;
if (aContent->Tag() != nsHTMLAtoms::object)
return rv;
// for now, we should try to do the same for "document" types and create
// and IFrame-like sub-frame
@ -915,8 +910,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext,
aMetrics.height = aReflowState.mComputedHeight;
// for EMBED and APPLET, default to 240x200 for compatibility
nsCOMPtr<nsIAtom> atom;
mContent->GetTag(getter_AddRefs(atom));
nsIAtom *atom = mContent->Tag();
if (atom == nsHTMLAtoms::applet || atom == nsHTMLAtoms::embed) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
@ -1116,9 +1110,8 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
mInstanceOwner->SetPluginHost(pluginHost);
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
if (tag.get() == nsHTMLAtoms::applet) {
nsIAtom *tag = mContent->Tag();
if (tag == nsHTMLAtoms::applet) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, src)) {
// Create an absolute URL
rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL);
@ -1409,25 +1402,29 @@ nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const
return PR_TRUE;
}
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
// only <embed> tags support the HIDDEN attribute
if (tag.get() == nsHTMLAtoms::embed) {
if (mContent->Tag() == nsHTMLAtoms::embed) {
nsAutoString hidden;
nsresult result = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden);
// Yes, these are really the kooky ways that you could tell 4.x
// not to hide the <embed> once you'd put the 'hidden' attribute
// on the tag...
// these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s until |EqualsIgnoreCase| get's fixed
// HIDDEN w/ no attributes gets translated as we are hidden for compatibility
// w/ 4.x and IE so we don't create a non-painting widget in layout. See bug 188959.
// these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s
// until |EqualsIgnoreCase| get's fixed
// HIDDEN w/ no attributes gets translated as we are hidden for
// compatibility w/ 4.x and IE so we don't create a non-painting
// widget in layout. See bug 188959.
if (NS_CONTENT_ATTR_NOT_THERE != result &&
(hidden.IsEmpty() ||
!hidden.Equals(NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("no"), nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("off"), nsCaseInsensitiveStringComparator()))) {
!hidden.Equals(NS_LITERAL_STRING("false"),
nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("no"),
nsCaseInsensitiveStringComparator()) &&
!hidden.Equals(NS_LITERAL_STRING("off"),
nsCaseInsensitiveStringComparator()))) {
return PR_TRUE;
}
}
@ -2520,11 +2517,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
nsIContent* cont = mOwner->GetContent();
if (cont)
{
nsCOMPtr<nsIAtom> atom;
cont->GetTag(getter_AddRefs(atom));
nsIAtom *atom = cont->Tag();
if (atom)
{
if (atom == nsHTMLAtoms::applet)
*result = nsPluginTagType_Applet;
else if (atom == nsHTMLAtoms::embed)
@ -2535,7 +2529,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
rv = NS_OK;
}
}
}
return rv;
}
@ -3030,9 +3023,8 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// to the bottom of the array if there isn't already a "src" specified.
PRInt16 numRealAttrs = mNumCachedAttrs;
nsAutoString data;
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (nsHTMLAtoms::object == tag.get()
nsIAtom *tag = content->Tag();
if (nsHTMLAtoms::object == tag
&& !content->HasAttr(kNameSpaceID_None, nsHTMLAtoms::src)
&& NS_CONTENT_ATTR_NOT_THERE != content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data)) {
mNumCachedAttrs++;

View File

@ -4014,9 +4014,8 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
// Ensure it's an anchor element
content = do_QueryInterface(node);
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::a) {
if (content->Tag() == nsHTMLAtoms::a &&
content->IsContentOfType(nsIContent::eHTML)) {
break;
}
content = nsnull;

View File

@ -605,8 +605,7 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsCOMPtr<nsIAtom> type;
aChild->GetTag(getter_AddRefs(type));
nsIAtom *type = aChild->Tag();
if ((type != nsHTMLAtoms::object && aAttribute == nsHTMLAtoms::src) ||
(type == nsHTMLAtoms::object && aAttribute == nsHTMLAtoms::data)) {
@ -619,10 +618,7 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
}
// If the noResize attribute changes, dis/allow frame to be resized
else if (aAttribute == nsHTMLAtoms::noresize) {
nsCOMPtr<nsIAtom> parentTag;
mContent->GetParent()->GetTag(getter_AddRefs(parentTag));
if (parentTag == nsHTMLAtoms::frameset) {
if (mContent->GetParent()->Tag() == nsHTMLAtoms::frameset) {
nsIFrame* parentFrame = GetParent();
if (parentFrame) {
@ -750,10 +746,8 @@ nsHTMLFrameInnerFrame::Destroy(nsIPresContext* aPresContext)
PRBool nsHTMLFrameInnerFrame::GetURL(nsIContent* aContent, nsString& aResult)
{
aResult.SetLength(0);
nsCOMPtr<nsIAtom> type;
aContent->GetTag(getter_AddRefs(type));
if (type.get() == nsHTMLAtoms::object) {
if (aContent->Tag() == nsHTMLAtoms::object) {
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, aResult)))
if (!aResult.IsEmpty())
return PR_TRUE;

View File

@ -399,8 +399,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
if (!child->IsContentOfType(nsIContent::eHTML))
continue;
nsCOMPtr<nsIAtom> tag;
child->GetTag(getter_AddRefs(tag));
nsIAtom *tag = child->Tag();
if (tag == nsHTMLAtoms::frameset || tag == nsHTMLAtoms::frame) {
nsRefPtr<nsStyleContext> kidSC;
nsresult result;
@ -719,16 +718,12 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
if (content) {
nsCOMPtr<nsIContent> contentParent = content->GetParent();
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML)) {
nsCOMPtr<nsIAtom> tag;
contentParent->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::frameset) {
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML) &&
contentParent->Tag() == nsHTMLAtoms::frameset) {
nsIFrame* fptr = aChild->GetParent();
parent = (nsHTMLFramesetFrame*) fptr;
}
}
}
return parent;
}

View File

@ -447,23 +447,12 @@ nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame*
while (childFrame) {
// see if the child is a text control
nsIContent* content = childFrame->GetContent();
if (content) {
nsCOMPtr<nsIAtom> atom;
nsresult res = content->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(res) && atom) {
if (atom.get() == nsHTMLAtoms::input) {
nsCOMPtr<nsIFormControl> formCtrl =
do_QueryInterface(childFrame->GetContent());
// It's an input, is it a text input?
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
if (value.EqualsIgnoreCase("text")) {
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_TEXT) {
result = (nsNewFrame*)childFrame;
}
}
}
}
}
// if not continue looking
nsNewFrame* frame = GetTextControlFrame(aPresContext, childFrame);

View File

@ -104,27 +104,14 @@ nsGfxButtonControlFrame::IsFileBrowseButton(PRInt32 type)
rv = PR_TRUE;
}
else if (NS_FORM_INPUT_BUTTON == type) {
// Check to see if parent is a file input
nsresult result;
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAtom> atom;
result = parentContent->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(result) && atom) {
if (atom == nsHTMLAtoms::input) {
nsCOMPtr<nsIFormControl> formCtrl =
do_QueryInterface(mContent->GetParent());
// It's an input, is it a file input?
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == parentContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
if (value.EqualsIgnoreCase("file")) {
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_FILE) {
rv = PR_TRUE;
}
}
}
}
}
}
return rv;
}

View File

@ -793,9 +793,8 @@ nsTextInputSelectionImpl::CompleteMove(PRBool aForward, PRBool aExtend)
if (offset > 0)
{
nsIContent *child = parentDIV->GetChildAt(offset - 1);
nsCOMPtr<nsIAtom> tagName;
child->GetTag(getter_AddRefs(tagName));
if (tagName == nsHTMLAtoms::br)
if (child->Tag() == nsHTMLAtoms::br)
{
--offset;
hint = HINTRIGHT; // for Bug 106855
@ -1329,16 +1328,7 @@ PRBool nsTextControlFrame::IsSingleLineTextControl() const
PRBool nsTextControlFrame::IsTextArea() const
{
if (!mContent)
return PR_FALSE;
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(getter_AddRefs(tag));
if (nsHTMLAtoms::textarea == tag)
return PR_TRUE;
return PR_FALSE;
return mContent && mContent->Tag() == nsHTMLAtoms::textarea;
}
// XXX: wouldn't it be nice to get this from the style context!
@ -2297,9 +2287,7 @@ nsTextControlFrame::SelectAllContents()
// br under the root node!
nsIContent *child = rootContent->GetChildAt(numChildren - 1);
if (child) {
nsCOMPtr<nsIAtom> tagName;
child->GetTag(getter_AddRefs(tagName));
if (tagName == nsHTMLAtoms::br)
if (child->Tag() == nsHTMLAtoms::br)
--numChildren;
}
}

View File

@ -121,7 +121,6 @@
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
static NS_DEFINE_CID(kAttributeContentCID, NS_ATTRIBUTECONTENT_CID);
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
@ -1438,23 +1437,24 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex
// Creates the content and frame and return if successful
nsresult rv = NS_ERROR_FAILURE;
if (nsnull != attrName) {
if (attrName) {
nsIFrame* textFrame = nsnull;
nsCOMPtr<nsIContent> content(do_CreateInstance(kAttributeContentCID));
if (content) {
nsCOMPtr<nsIContent> content;
rv = NS_NewAttributeContent(getter_AddRefs(content));
nsCOMPtr<nsIAttributeContent> attrContent(do_QueryInterface(content));
if (attrContent) {
attrContent->Init(aContent, attrNameSpace, attrName);
}
// Set aContent as the parent content and set the document object. This
// way event handling works
// Set aContent as the parent content and set the document
// object. This way event handling works
content->SetParent(aContent);
content->SetDocument(aDocument, PR_TRUE, PR_TRUE);
// Create a text frame and initialize it
NS_NewTextFrame(shell, &textFrame);
textFrame->Init(aPresContext, content, aParentFrame, aStyleContext, nsnull);
textFrame->Init(aPresContext, content, aParentFrame, aStyleContext,
nsnull);
// Return the text frame
*aFrame = textFrame;
@ -2980,13 +2980,15 @@ nsCSSFrameConstructor::ConstructTableForeignFrame(nsIPresShell* aPres
nsIFrame* parentFrame = nsnull;
aIsPseudoParent = PR_FALSE;
// XXX form code needs to be fixed so that the forms can work without a frame.
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
// XXX form code needs to be fixed so that the forms can work
// without a frame.
nsIAtom *tag = aContent->Tag();
// Do not construct pseudo frames for trees
if (MustGeneratePseudoParent(aPresContext, aParentFrameIn, tag.get(), aContent, aStyleContext)) {
// this frame may have a pseudo parent, use block frame type to trigger foreign
if (MustGeneratePseudoParent(aPresContext, aParentFrameIn, tag, aContent,
aStyleContext)) {
// this frame may have a pseudo parent, use block frame type to
// trigger foreign
GetParentFrame(aPresShell, aPresContext, aTableCreator, *aParentFrameIn,
nsLayoutAtoms::blockFrame, aState, parentFrame, aIsPseudoParent);
if (!aIsPseudoParent && !aState.mPseudoFrames.IsEmpty()) {
@ -5087,9 +5089,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell
#ifdef MOZ_XUL
// Only cut XUL scrollbars off if they're not in a XUL document. This allows
// scrollbars to be styled from XUL (although not from XML or HTML).
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::scrollbar) {
if (content->Tag() == nsXULAtoms::scrollbar) {
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(aDocument));
if (xulDoc)
content->SetBindingParent(aParent);
@ -6165,10 +6165,8 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_TRUE,
childItems, PR_TRUE);
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, newFrame, PR_FALSE, childItems);
// Set the scrolled frame's initial child lists
scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
@ -6228,10 +6226,8 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE,
childItems, PR_TRUE);
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, newFrame, PR_FALSE, childItems);
// Set the frame's initial child list(s)
newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
@ -6577,15 +6573,11 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext,
if (aContent->IsContentOfType(nsIContent::eELEMENT)) {
return aPresContext->ResolveStyleContextFor(aContent, parentStyleContext);
} else {
#ifdef DEBUG
{
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
NS_ASSERTION(tag == nsLayoutAtoms::textTagName,
NS_ASSERTION(aContent->Tag() == nsLayoutAtoms::textTagName,
"shouldn't waste time creating style contexts for "
"comments and processing instructions");
}
#endif
return aPresContext->ResolveStyleContextForNonElement(parentStyleContext);
}
}
@ -7023,8 +7015,7 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresShell* aPresShell,
}
// Get the element's tag
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
nsIAtom *tag = aContent->Tag();
// never create frames for comments on PIs
if (tag == nsLayoutAtoms::commentTagName ||
@ -7104,7 +7095,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe
PRInt32 nameSpaceID;
xblService->ResolveTag(aContent, &nameSpaceID, getter_AddRefs(baseTag));
if (baseTag.get() != aTag || aNameSpaceID != nameSpaceID) {
if (baseTag != aTag || aNameSpaceID != nameSpaceID) {
// Construct the frame using the XBL base tag.
rv = ConstructFrameInternal( aPresShell,
aPresContext,
@ -7612,7 +7603,7 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell,
nodeList->Item(PRUint32(index), getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
if (child.get() == aChild)
if (child == aChild)
break;
}
@ -7694,7 +7685,7 @@ FindNextAnonymousSibling(nsIPresShell* aPresShell,
nodeList->Item(PRUint32(index), getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
if (child.get() == aChild)
if (child == aChild)
break;
}
@ -7935,8 +7926,7 @@ inline PRBool
ShouldIgnoreSelectChild(nsIContent* aContainer)
{
// Ignore options and optgroups inside a select (size > 1)
nsCOMPtr<nsIAtom> containerTag;
aContainer->GetTag(getter_AddRefs(containerTag));
nsIAtom *containerTag = aContainer->Tag();
if (containerTag == nsHTMLAtoms::optgroup ||
containerTag == nsHTMLAtoms::select) {
@ -7947,7 +7937,7 @@ ShouldIgnoreSelectChild(nsIContent* aContainer)
if (!selectContent) {
break;
}
selectContent->GetTag(getter_AddRefs(containerTag));
containerTag = selectContent->Tag();
}
nsCOMPtr<nsISelectElement> selectElement = do_QueryInterface(selectContent);
@ -8097,7 +8087,8 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
if (tag == nsXULAtoms::treechildren ||
tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::treerow ||
(UseXBLForms() && ShouldIgnoreSelectChild(aContainer)))
(namespaceID == kNameSpaceID_XUL && UseXBLForms() &&
ShouldIgnoreSelectChild(aContainer)))
return NS_OK;
}
@ -8656,10 +8647,7 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext,
if (!aContainer)
return PR_FALSE;
nsCOMPtr<nsIAtom> tag;
aChild->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::listitem) {
if (aChild->Tag() == nsXULAtoms::listitem) {
nsListBoxBodyFrame* listBoxBody = nsnull;
if (aChildFrame) {
// There is a frame for the removed content, so its parent frame is the listboxbody
@ -8693,6 +8681,7 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext,
return PR_TRUE;
}
nsCOMPtr<nsIAtom> tag;
PRInt32 namespaceID;
aDocument->GetBindingManager()->ResolveTag(aContainer, &namespaceID,
getter_AddRefs(tag));
@ -8701,7 +8690,8 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext,
if (tag == nsXULAtoms::treechildren ||
tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::treerow ||
(aUseXBLForms && ShouldIgnoreSelectChild(aContainer)))
(namespaceID == kNameSpaceID_XUL && aUseXBLForms &&
ShouldIgnoreSelectChild(aContainer)))
return PR_TRUE;
return PR_FALSE;
@ -10178,7 +10168,9 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
mDocument->GetBindingManager()->ResolveTag(aContent, &namespaceID,
getter_AddRefs(tag));
if (tag && (tag.get() == nsXULAtoms::listitem || tag.get() == nsXULAtoms::listcell))
if (namespaceID == kNameSpaceID_XUL &&
(tag == nsXULAtoms::listitem ||
tag == nsXULAtoms::listcell))
return NS_OK;
}
@ -10312,9 +10304,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell,
aFrame = nsnull;
// Get the alternate text to use
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
GetAlternateTextFor(aContent, tag, altText);
GetAlternateTextFor(aContent, aContent->Tag(), altText);
// Create a text content element for the alternate text
nsCOMPtr<nsIContent> altTextContent(do_CreateInstance(kTextNodeCID,&rv));
@ -10437,12 +10427,12 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
// Get aFrame's content object and the tag name
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> tag;
nsIAtom* tag;
nsIContent* content = aFrame->GetContent();
NS_ASSERTION(content, "null content object");
content->GetNameSpaceID(&nameSpaceID);
content->GetTag(getter_AddRefs(tag));
tag = content->Tag();
// Get the child list name that the frame is contained in
nsCOMPtr<nsIAtom> listName;
@ -10464,8 +10454,8 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
// See whether it's an IMG or an INPUT element (for image buttons)
// or if it is an applet with no displayable children
// XXX need to check nameSpaceID in these spots
if (nsHTMLAtoms::img == tag.get() || nsHTMLAtoms::input == tag.get() ||
(nsHTMLAtoms::applet == tag.get() && !HasDisplayableChildren(aPresContext, aFrame))) {
if (nsHTMLAtoms::img == tag || nsHTMLAtoms::input == tag ||
(nsHTMLAtoms::applet == tag && !HasDisplayableChildren(aPresContext, aFrame))) {
// Try and construct an alternate frame to use when the
// image can't be rendered
nsIFrame* newFrame;
@ -10508,9 +10498,9 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
}
}
} else if ((nsHTMLAtoms::object == tag.get()) ||
(nsHTMLAtoms::embed == tag.get()) ||
(nsHTMLAtoms::applet == tag.get())) {
} else if ((nsHTMLAtoms::object == tag) ||
(nsHTMLAtoms::embed == tag) ||
(nsHTMLAtoms::applet == tag)) {
// It's an OBJECT, EMBED, or APPLET, so we should display the contents
// instead
nsIFrame* absoluteContainingBlock;
@ -10529,10 +10519,10 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
#ifdef NS_DEBUG
// Verify that we calculated the same containing block
if (listName.get() == nsLayoutAtoms::absoluteList) {
if (listName == nsLayoutAtoms::absoluteList) {
NS_ASSERTION(absoluteContainingBlock == parentFrame,
"wrong absolute containing block");
} else if (listName.get() == nsLayoutAtoms::floatList) {
} else if (listName == nsLayoutAtoms::floatList) {
NS_ASSERTION(floatContainingBlock == parentFrame,
"wrong float containing block");
}
@ -10610,13 +10600,13 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
// block frame.
SplitToContainingBlock(aPresContext, state, parentFrame, list1, list2, list3, PR_FALSE);
}
} else if (listName.get() == nsLayoutAtoms::absoluteList) {
} else if (listName == nsLayoutAtoms::absoluteList) {
newFrame = state.mAbsoluteItems.childList;
state.mAbsoluteItems.childList = nsnull;
} else if (listName.get() == nsLayoutAtoms::fixedList) {
} else if (listName == nsLayoutAtoms::fixedList) {
newFrame = state.mFixedItems.childList;
state.mFixedItems.childList = nsnull;
} else if (listName.get() == nsLayoutAtoms::floatList) {
} else if (listName == nsLayoutAtoms::floatList) {
newFrame = state.mFloatedItems.childList;
state.mFloatedItems.childList = nsnull;
}
@ -10631,7 +10621,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell,
InsertOutOfFlowFrames(state, aPresContext);
}
} else if (nsHTMLAtoms::input == tag.get()) {
} else if (nsHTMLAtoms::input == tag) {
// XXX image INPUT elements are also image frames, but don't throw away the
// image frame, because the frame class has extra logic that is specific to
// INPUT elements
@ -11216,7 +11206,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
while (parentFrame) {
// Search the child frames for a match
*aFrame = FindFrameWithContent(aPresContext, aFrameManager, parentFrame,
parentContent.get(), aContent, aHint);
parentContent, aContent, aHint);
#ifdef NOISY_FINDFRAME
printf("FindFrameWithContent returned %p\n", *aFrame);
#endif
@ -11233,7 +11223,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
#endif
nsIFrame *verifyTestFrame =
FindFrameWithContent(aPresContext, aFrameManager, parentFrame,
parentContent.get(), aContent, nsnull);
parentContent, aContent, nsnull);
#ifdef NOISY_FINDFRAME
printf("VERIFY returned %p\n", verifyTestFrame);
#endif
@ -11263,9 +11253,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
if (aHint && !*aFrame)
{ // if we had a hint, and we didn't get a frame, see if we should try the slow way
nsCOMPtr<nsIAtom>tag;
aContent->GetTag(getter_AddRefs(tag));
if (nsLayoutAtoms::textTagName == tag.get())
if (aContent->Tag() == nsLayoutAtoms::textTagName)
{
#ifdef NOISY_FINDFRAME
FFWC_slowSearchForText++;
@ -12244,11 +12232,11 @@ nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
// Take the old textFrame out of the inline parents child list
DeletingFrameSubtree(aPresContext, aState.mPresShell,
aState.mFrameManager, textFrame);
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell.get(),
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell,
nsnull, textFrame);
// Insert in the letter frame(s)
parentFrame->InsertFrames(aPresContext, *aState.mPresShell.get(),
parentFrame->InsertFrames(aPresContext, *aState.mPresShell,
nsnull, prevFrame, letterFrames.childList);
}
}
@ -12552,16 +12540,16 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsIPresShell* aPresShell, nsIPresCont
// Take the old textFrame out of the parents child list
DeletingFrameSubtree(aPresContext, aState.mPresShell,
aState.mFrameManager, textFrame);
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell.get(),
parentFrame->RemoveFrame(aPresContext, *aState.mPresShell,
nsnull, textFrame);
// Insert in the letter frame(s)
parentFrame->InsertFrames(aPresContext, *aState.mPresShell.get(),
parentFrame->InsertFrames(aPresContext, *aState.mPresShell,
nsnull, prevFrame, letterFrames.childList);
// Insert in floats too if needed
if (aState.mFloatedItems.childList) {
aBlockFrame->AppendFrames(aPresContext, *aState.mPresShell.get(),
aBlockFrame->AppendFrames(aPresContext, *aState.mPresShell,
nsLayoutAtoms::floatList,
aState.mFloatedItems.childList);
}
@ -12608,13 +12596,11 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext,
return NS_OK;
}
nsCOMPtr<nsIAtom> tag;
aChild->GetTag(getter_AddRefs(tag));
PRInt32 namespaceID;
aChild->GetNameSpaceID(&namespaceID);
rv = ConstructFrameInternal(shell, aPresContext, state, aChild, aParentFrame, tag, namespaceID,
rv = ConstructFrameInternal(shell, aPresContext, state, aChild,
aParentFrame, aChild->Tag(), namespaceID,
styleContext, frameItems, PR_FALSE);
nsIFrame* newFrame = frameItems.childList;
@ -12688,10 +12674,8 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell,
nsresult rv = ProcessChildren(aPresShell, aPresContext, aState, aContent,
aNewFrame, PR_TRUE, childItems, PR_TRUE);
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, aNewFrame, PR_FALSE, childItems);
// Set the frame's initial child list
aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
@ -12762,10 +12746,8 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell,
aNewFrame, PR_TRUE, childItems, &kidsAllInline);
if (kidsAllInline) {
// Set the inline frame's initial child list
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(getter_AddRefs(tag));
CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame,
PR_FALSE, childItems);
CreateAnonymousFrames(aPresShell, aPresContext, aContent->Tag(), aState,
aContent, aNewFrame, PR_FALSE, childItems);
aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);

View File

@ -194,7 +194,7 @@ protected:
static InlineBackgroundData gInlineBGData;
static void GetPath(nsFloatPoint aPoints[],nsPoint aPolyPath[],PRInt32 *aCurIndex,ePathTypes aPathType,PRInt32 &aC1Index,float aFrac=0);
static nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame);
static void GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame);
// FillRect or InvertRect depending on the renderingaInvert parameter
static void FillOrInvertRect(nsIRenderingContext& aRC,nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aInvert);
@ -1555,15 +1555,14 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,
nsIContent *pContent;
if ((pContent = doc->GetRootContent())) {
// make sure that this is the HTML element
nsCOMPtr<nsIAtom> tag;
pContent->GetTag(getter_AddRefs(tag));
nsIAtom *tag = pContent->Tag();
NS_ASSERTION(tag, "Tag could not be retrieved from root content element");
if (tag) {
if (tag == nsHTMLAtoms::html ||
tag == nsHTMLAtoms::body) {
// use this guy's color
nsIFrame *pFrame = nsnull;
if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) && pFrame) {
if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) &&
pFrame) {
nsStyleContext *pContext = pFrame->GetStyleContext();
if (pContext) {
const nsStyleBackground* color = pContext->GetStyleBackground();
@ -1580,7 +1579,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,
printf( "Root Content is not HTML or BODY: cannot get bgColor of HTML or BODY\n");
}
#endif
}// if tag
}// if content
NS_RELEASE(doc);
}// if doc
@ -1599,23 +1597,25 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,
// The check is a bit expensive, however until the canvas frame is somehow cached on the
// body frame, or the root element, we need to walk the frames up until we find the canvas
//
nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame, nsIFrame **aBGFrame)
void
GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFrame,
nsIFrame **aBGFrame)
{
NS_ASSERTION(aFrame && aBGFrame, "illegal null parameter");
if (!aFrame || !aBGFrame) {
NS_ERROR("illegal null parameter");
nsresult rv = NS_OK;
return;
}
if (aFrame && aBGFrame) {
*aBGFrame = aFrame; // default to the frame passed in
nsIContent* pContent = aFrame->GetContent();
if (pContent) {
// make sure that this is the HTML or BODY element
nsCOMPtr<nsIAtom> tag;
pContent->GetTag(getter_AddRefs(tag));
if (tag) {
if (tag.get() == nsHTMLAtoms::html ||
tag.get() == nsHTMLAtoms::body) {
nsIAtom *tag = pContent->Tag();
if (tag == nsHTMLAtoms::html ||
tag == nsHTMLAtoms::body) {
// the frame is the body frame, so we provide the canvas frame
nsIFrame *pCanvasFrame = aFrame->GetParent();
while (pCanvasFrame) {
@ -1626,12 +1626,7 @@ nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFra
pCanvasFrame = pCanvasFrame->GetParent();
}
}// if tag == html or body
}// if tag
}
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
// helper macro to determine if the borderstyle 'a' is a MOZ-BG-XXX style
@ -2744,9 +2739,7 @@ FindElementBackground(nsIPresContext* aPresContext,
if (!parentFrame)
return PR_TRUE; // no parent to look at
nsCOMPtr<nsIAtom> tag;
content->GetTag(getter_AddRefs(tag));
if (tag != nsHTMLAtoms::body)
if (content->Tag() != nsHTMLAtoms::body)
return PR_TRUE; // not frame for <BODY> element
// We should only look at the <html> background if we're in an HTML document

Some files were not shown because too many files have changed in this diff Show More