Fixing bug 215981. DeCOMtaminating nsIContent and nsIDocument some, and also some minor changes to other related interfaces. r=caillon@aillon.org, sr=peterv@propagandism.org.
git-svn-id: svn://10.0.0.236/trunk@147354 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e350065f77
commit
ef67a47aab
@ -93,8 +93,7 @@ nsresult nsAccessibleText::GetSelections(nsISelectionController **aSelCon, nsISe
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mTextNode));
|
||||
@ -644,8 +643,7 @@ NS_IMETHODIMP nsAccessibleText::GetCharacterExtents(PRInt32 aOffset,
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
@ -975,8 +973,7 @@ nsITextControlFrame* nsAccessibleEditableText::GetTextFrame()
|
||||
if (!doc) // that could be a composer
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(shell, nsnull);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mTextNode));
|
||||
|
||||
@ -148,7 +148,7 @@ nsHTMLTableAccessibleWrap::SetSummary(const nsAString &aSummary)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetColumns(PRInt32 *aColumns)
|
||||
{
|
||||
nsITableLayout *tableLayout = nsnull;
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -197,7 +197,7 @@ nsHTMLTableAccessibleWrap::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetRows(PRInt32 *aRows)
|
||||
{
|
||||
nsITableLayout *tableLayout = nsnull;
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -454,7 +454,7 @@ NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsITableLayout *tableLayout = nsnull;
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -498,6 +498,8 @@ nsHTMLTableAccessibleWrap::GetTableNode(nsIDOMNode **_retval)
|
||||
nsresult
|
||||
nsHTMLTableAccessibleWrap::GetTableLayout(nsITableLayout **aLayoutObject)
|
||||
{
|
||||
*aLayoutObject = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tableNode;
|
||||
@ -507,15 +509,12 @@ nsHTMLTableAccessibleWrap::GetTableLayout(nsITableLayout **aLayoutObject)
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(tableNode));
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = content->GetDocument()->GetShellAt(0, getter_AddRefs(presShell));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsIPresShell *presShell = content->GetDocument()->GetShellAt(0);
|
||||
|
||||
nsCOMPtr<nsISupports> layoutObject;
|
||||
rv = presShell->GetLayoutObjectFor(content, getter_AddRefs(layoutObject));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aLayoutObject = nsnull;
|
||||
return CallQueryInterface(layoutObject, aLayoutObject);
|
||||
}
|
||||
|
||||
@ -528,7 +527,7 @@ nsHTMLTableAccessibleWrap::GetCellAt(PRInt32 aRowIndex,
|
||||
rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
PRBool isSelected;
|
||||
|
||||
nsITableLayout *tableLayout = nsnull;
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
@ -276,7 +276,16 @@ NS_IMETHODIMP
|
||||
nsAccessNode::GetNumChildren(PRInt32 *aNumChildren)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return content? content->ChildCount(*aNumChildren) : NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!content) {
|
||||
*aNumChildren = 0;
|
||||
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aNumChildren = content->GetChildCount();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -394,11 +403,11 @@ nsAccessNode::GetNextSiblingNode(nsIAccessNode **aAccessNode)
|
||||
NS_IMETHODIMP
|
||||
nsAccessNode::GetChildNodeAt(PRInt32 aChildNum, nsIAccessNode **aAccessNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child, content(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
|
||||
|
||||
content->ChildAt(aChildNum, getter_AddRefs(child));
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(child));
|
||||
nsCOMPtr<nsIDOMNode> domNode =
|
||||
do_QueryInterface(content->GetChildAt(aChildNum));
|
||||
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
return MakeAccessNode(domNode, aAccessNode);
|
||||
|
||||
@ -234,10 +234,8 @@ nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIW
|
||||
#endif
|
||||
|
||||
// do_GetWR only works into a |nsCOMPtr| :-(
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
weakShell = do_GetWeakReference(tempShell);
|
||||
nsCOMPtr<nsIWeakReference> weakShell =
|
||||
do_GetWeakReference(document->GetShellAt(0));
|
||||
NS_IF_ADDREF(*aShell = weakShell);
|
||||
|
||||
return NS_OK;
|
||||
@ -253,8 +251,7 @@ nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **a
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// ---- Get the pres shell ----
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -304,9 +301,9 @@ nsAccessibilityService::CreateRootAccessible(nsIPresShell *aShell,
|
||||
nsCOMPtr<nsIDocument> parentDoc;
|
||||
aDocument->GetParentDocument(getter_AddRefs(parentDoc));
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell(aShell);
|
||||
nsIPresShell *presShell(aShell);
|
||||
if (!presShell) {
|
||||
aDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
presShell = aDocument->GetShellAt(0);
|
||||
}
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
|
||||
|
||||
@ -1516,8 +1513,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
||||
if (!doc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
return GetAccessibleInShell(aNode, presShell, aAccessible);
|
||||
}
|
||||
|
||||
|
||||
@ -1120,19 +1120,15 @@ nsresult nsAccessible::AppendFlatStringFromSubtreeRecurse(nsIContent *aContent,
|
||||
// Depth first search for all text nodes that are decendants of content node.
|
||||
// Append all the text into one flat string
|
||||
|
||||
PRInt32 numChildren = 0;
|
||||
PRUint32 numChildren = aContent->GetChildCount();
|
||||
|
||||
aContent->ChildCount(numChildren);
|
||||
if (numChildren == 0) {
|
||||
AppendFlatStringFromContentNode(aContent, aFlatString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> contentWalker;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < numChildren; index++) {
|
||||
aContent->ChildAt(index, getter_AddRefs(contentWalker));
|
||||
AppendFlatStringFromSubtree(contentWalker, aFlatString);
|
||||
for (PRUint32 index = 0; index < numChildren; index++) {
|
||||
AppendFlatStringFromSubtree(aContent->GetChildAt(index), aFlatString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1162,10 +1158,10 @@ NS_IMETHODIMP nsAccessible::AppendLabelText(nsIDOMNode *aLabelNode, nsAString& _
|
||||
/**
|
||||
* Called for HTML work only
|
||||
*/
|
||||
NS_IMETHODIMP nsAccessible::AppendLabelFor(nsIContent *aLookNode, const nsAString *aId, nsAString *aLabel)
|
||||
NS_IMETHODIMP nsAccessible::AppendLabelFor(nsIContent *aLookNode,
|
||||
const nsAString *aId,
|
||||
nsAString *aLabel)
|
||||
{
|
||||
PRInt32 numChildren = 0;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement(do_QueryInterface(aLookNode));
|
||||
if (labelElement) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aLookNode));
|
||||
@ -1180,11 +1176,10 @@ NS_IMETHODIMP nsAccessible::AppendLabelFor(nsIContent *aLookNode, const nsAStrin
|
||||
return rv;
|
||||
}
|
||||
|
||||
aLookNode->ChildCount(numChildren);
|
||||
nsCOMPtr<nsIContent> contentWalker;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < numChildren; index++) {
|
||||
aLookNode->ChildAt(index, getter_AddRefs(contentWalker));
|
||||
PRUint32 numChildren = aLookNode->GetChildCount();
|
||||
|
||||
for (PRUint32 index = 0; index < numChildren; index++) {
|
||||
nsIContent *contentWalker = aLookNode->GetChildAt(index);
|
||||
if (contentWalker)
|
||||
AppendLabelFor(contentWalker, aId, aLabel);
|
||||
}
|
||||
@ -1485,8 +1480,12 @@ nsresult nsAccessible::GetParentBlockNode(nsIPresShell *aPresShell, nsIDOMNode *
|
||||
nsIFrame *firstTextFrame = nsnull;
|
||||
FindTextFrame(index, presContext, childFrame, &firstTextFrame, frame);
|
||||
if (firstTextFrame) {
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(firstTextFrame->GetContent()));
|
||||
NS_IF_ADDREF(*aBlockNode = domNode);
|
||||
nsIContent *content = firstTextFrame->GetContent();
|
||||
|
||||
if (content) {
|
||||
CallQueryInterface(content, aBlockNode);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -419,8 +419,7 @@ void nsDocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
nsCOMPtr<nsIDocument> parentDoc;
|
||||
|
||||
while (document) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
document->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = document->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return;
|
||||
}
|
||||
@ -792,7 +791,7 @@ void nsDocAccessible::GetEventShell(nsIDOMNode *aNode, nsIPresShell **aEventShel
|
||||
{
|
||||
// XXX aaronl - this is not ideal.
|
||||
// We could avoid this whole section and the fallible
|
||||
// doc->GetShellAt(0, ...) by putting the event handler
|
||||
// doc->GetShellAt(0) by putting the event handler
|
||||
// on nsDocAccessible instead.
|
||||
// The disadvantage would be that we would be seeing some events
|
||||
// for inner documents that we don't care about.
|
||||
@ -800,8 +799,10 @@ void nsDocAccessible::GetEventShell(nsIDOMNode *aNode, nsIPresShell **aEventShel
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDocument));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument));
|
||||
if (doc)
|
||||
doc->GetShellAt(0, aEventShell);
|
||||
if (doc) {
|
||||
*aEventShell = doc->GetShellAt(0);
|
||||
NS_IF_ADDREF(*aEventShell);
|
||||
}
|
||||
}
|
||||
|
||||
void nsDocAccessible::GetEventDocAccessible(nsIDOMNode *aNode,
|
||||
|
||||
@ -114,8 +114,7 @@ NS_IMETHODIMP nsOuterDocAccessible::Init()
|
||||
nsCOMPtr<nsIDOMNode> innerNode(do_QueryInterface(innerDoc));
|
||||
NS_ENSURE_TRUE(innerNode, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresShell> innerPresShell;
|
||||
innerDoc->GetShellAt(0, getter_AddRefs(innerPresShell));
|
||||
nsIPresShell *innerPresShell = innerDoc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(innerPresShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessible> innerAccessible;
|
||||
|
||||
@ -270,7 +270,7 @@ void nsRootAccessible::GetEventShell(nsIDOMNode *aNode, nsIPresShell **aEventShe
|
||||
{
|
||||
// XXX aaronl - this is not ideal.
|
||||
// We could avoid this whole section and the fallible
|
||||
// doc->GetShellAt(0, ...) by putting the event handler
|
||||
// doc->GetShellAt(0) by putting the event handler
|
||||
// on nsDocAccessible instead.
|
||||
// The disadvantage would be that we would be seeing some events
|
||||
// for inner documents that we don't care about.
|
||||
@ -280,8 +280,10 @@ void nsRootAccessible::GetEventShell(nsIDOMNode *aNode, nsIPresShell **aEventShe
|
||||
if (!doc) { // This is necessary when the node is the document node
|
||||
doc = do_QueryInterface(aNode);
|
||||
}
|
||||
if (doc)
|
||||
doc->GetShellAt(0, aEventShell);
|
||||
if (doc) {
|
||||
*aEventShell = doc->GetShellAt(0);
|
||||
NS_IF_ADDREF(*aEventShell);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------- nsIDOMEventListener Methods (3) ------------------------
|
||||
|
||||
@ -731,9 +731,9 @@ nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIDOMNode *aListNod
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aListNode));
|
||||
nsCOMPtr<nsIDocument> document = content->GetDocument();
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
if (document)
|
||||
document->GetShellAt(0,getter_AddRefs(shell));
|
||||
nsIPresShell *shell = nsnull;
|
||||
if (document)
|
||||
shell = document->GetShellAt(0);
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
@ -186,16 +186,16 @@ STDMETHODIMP nsAccessNodeWrap::get_attributes(
|
||||
if (!content)
|
||||
return E_FAIL;
|
||||
|
||||
PRInt32 numAttribs;
|
||||
content->GetAttrCount(numAttribs);
|
||||
PRUint32 numAttribs = content->GetAttrCount();
|
||||
|
||||
if (numAttribs > aMaxAttribs)
|
||||
numAttribs = aMaxAttribs;
|
||||
*aNumAttribs = NS_STATIC_CAST(unsigned short, numAttribs);
|
||||
|
||||
PRInt32 index, nameSpaceID;
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> nameAtom, prefixAtom;
|
||||
|
||||
for (index = 0; index < numAttribs; index++) {
|
||||
for (PRUint32 index = 0; index < numAttribs; index++) {
|
||||
aNameSpaceIDs[index] = 0; aAttribValues[index] = aAttribNames[index] = nsnull;
|
||||
nsAutoString attributeValue;
|
||||
const char *pszAttributeName;
|
||||
@ -486,9 +486,8 @@ nsAccessNodeWrap::get_childAt(unsigned aChildIndex,
|
||||
if (!content)
|
||||
return E_FAIL; // Node already shut down
|
||||
|
||||
nsCOMPtr<nsIContent> childContent;
|
||||
content->ChildAt(aChildIndex, getter_AddRefs(childContent));
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(childContent));
|
||||
nsCOMPtr<nsIDOMNode> node =
|
||||
do_QueryInterface(content->GetChildAt(aChildIndex));
|
||||
|
||||
if (!node)
|
||||
return E_FAIL; // No such child
|
||||
|
||||
@ -129,8 +129,7 @@ STDMETHODIMP nsDocAccessibleWrap::get_accChild(
|
||||
nsCOMPtr<nsIDocument> parentDoc;
|
||||
mDocument->GetParentDocument(getter_AddRefs(parentDoc));
|
||||
if (parentDoc) {
|
||||
nsCOMPtr<nsIPresShell> parentShell;
|
||||
parentDoc->GetShellAt(0, getter_AddRefs(parentShell));
|
||||
nsIPresShell *parentShell = parentDoc->GetShellAt(0);
|
||||
nsCOMPtr<nsIWeakReference> weakParentShell(do_GetWeakReference(parentShell));
|
||||
if (weakParentShell) {
|
||||
nsCOMPtr<nsIAccessibleDocument> parentDocAccessible;
|
||||
|
||||
@ -129,33 +129,33 @@ public:
|
||||
* Get the NodeInfo for this element
|
||||
* @param aResult the tag [OUT]
|
||||
*/
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const = 0;
|
||||
NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const = 0;
|
||||
|
||||
/**
|
||||
* Tell whether this element can contain children
|
||||
* @param aResult whether this element can contain children [OUT]
|
||||
*/
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const = 0;
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of children
|
||||
* @param aResult the number of children [OUT]
|
||||
*/
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const = 0;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const = 0;
|
||||
|
||||
/**
|
||||
* Get a child by index
|
||||
* @param aIndex the index of the child to get, or null if index out of bounds
|
||||
* @param aResult the child [OUT]
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const = 0;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Get the index of a child within this content
|
||||
* @param aPossibleChild the child to get the index
|
||||
* @param aIndex the index of the child, or -1 if not a child [OUT]
|
||||
*/
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const = 0;
|
||||
|
||||
/**
|
||||
* Insert a content node at a particular index.
|
||||
@ -167,7 +167,7 @@ public:
|
||||
* occurred
|
||||
* @param aDeepSetDocument whether to set document on all children of aKid
|
||||
*/
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument) = 0;
|
||||
|
||||
/**
|
||||
@ -179,7 +179,7 @@ public:
|
||||
* occurred
|
||||
* @param aDeepSetDocument whether to set document on all children of aKid
|
||||
*/
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument) = 0;
|
||||
|
||||
/**
|
||||
@ -200,7 +200,7 @@ public:
|
||||
* @param aNotify whether to notify the document that the replace has
|
||||
* occurred
|
||||
*/
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) = 0;
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Normalizes an attribute string into an atom that represents the
|
||||
@ -229,8 +229,7 @@ public:
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
const nsAString& aValue, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Set attribute values. All attribute values are assumed to have a
|
||||
@ -245,8 +244,7 @@ public:
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAString& aValue,
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo, const nsAString& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
@ -314,7 +312,7 @@ public:
|
||||
* @param aPrefix the attribute prefix [OUT]
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const = 0;
|
||||
@ -324,7 +322,7 @@ public:
|
||||
*
|
||||
* @param aCountResult the number of attributes [OUT]
|
||||
*/
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aCountResult) const = 0;
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const = 0;
|
||||
|
||||
/**
|
||||
* Inform content of range ownership changes. This allows content
|
||||
@ -402,7 +400,7 @@ public:
|
||||
* These methods are DEPRECATED, DON'T USE THEM!!!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) = 0;
|
||||
NS_IMETHOD GetContentID(PRUint32 *aId) = 0;
|
||||
/**
|
||||
* Set the unique content ID for this content.
|
||||
* @param aID the ID to set
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
// are explicitly avoiding an FlushPendingNotifications. The
|
||||
// flush guarantees that the list will be up to date.
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength, PRBool aDoFlush) = 0;
|
||||
NS_IMETHOD_(PRUint32) GetLength(PRBool aDoFlush) = 0;
|
||||
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush) = 0;
|
||||
@ -73,8 +73,7 @@ public:
|
||||
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush) = 0;
|
||||
|
||||
NS_IMETHOD IndexOf(nsIContent *aContent, PRInt32& aIndex,
|
||||
PRBool aDoFlush) = 0;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent *aContent, PRBool aDoFlush) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIContentList_h___ */
|
||||
|
||||
@ -229,9 +229,9 @@ public:
|
||||
nsIViewManager* aViewManager,
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult) = 0;
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell) = 0;
|
||||
virtual PRInt32 GetNumberOfShells() = 0;
|
||||
NS_IMETHOD GetShellAt(PRInt32 aIndex, nsIPresShell** aShell) = 0;
|
||||
NS_IMETHOD_(PRBool) DeleteShell(nsIPresShell* aShell) = 0;
|
||||
NS_IMETHOD_(PRUint32) GetNumberOfShells() const = 0;
|
||||
NS_IMETHOD_(nsIPresShell *) GetShellAt(PRUint32 aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Return the parent document of this document. Will return null
|
||||
@ -272,9 +272,9 @@ public:
|
||||
* Get the direct children of the document - content in
|
||||
* the prolog, the root content and content in the epilog.
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const = 0;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount) = 0;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const = 0;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const = 0;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const = 0;
|
||||
|
||||
/**
|
||||
* Accessors to the collection of stylesheets owned by this document.
|
||||
|
||||
@ -307,7 +307,10 @@ nsContentAreaDragDrop::DragOver(nsIDOMEvent* inEvent)
|
||||
break;
|
||||
nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
|
||||
if (override) {
|
||||
nsresult hookResult = override->AllowDrop(inEvent, session, &dropAllowed);
|
||||
#ifdef DEBUG
|
||||
nsresult hookResult =
|
||||
#endif
|
||||
override->AllowDrop(inEvent, session, &dropAllowed);
|
||||
NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in AllowDrop");
|
||||
if (!dropAllowed)
|
||||
break;
|
||||
@ -450,7 +453,10 @@ nsContentAreaDragDrop::DragDrop(nsIDOMEvent* inMouseEvent)
|
||||
break;
|
||||
nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
|
||||
if (override) {
|
||||
nsresult hookResult = override->OnPasteOrDrop(inMouseEvent, trans, &actionCanceled);
|
||||
#ifdef DEBUG
|
||||
nsresult hookResult =
|
||||
#endif
|
||||
override->OnPasteOrDrop(inMouseEvent, trans, &actionCanceled);
|
||||
NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in OnPasteOrDrop");
|
||||
if (!actionCanceled)
|
||||
return NS_OK;
|
||||
@ -602,7 +608,10 @@ nsContentAreaDragDrop::DragGesture(nsIDOMEvent* inMouseEvent)
|
||||
break;
|
||||
nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
|
||||
if (override) {
|
||||
nsresult hookResult = override->AllowStartDrag(inMouseEvent, &allow);
|
||||
#ifdef DEBUG
|
||||
nsresult hookResult =
|
||||
#endif
|
||||
override->AllowStartDrag(inMouseEvent, &allow);
|
||||
NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in AllowStartDrag");
|
||||
if (!allow)
|
||||
return NS_OK;
|
||||
@ -633,7 +642,10 @@ nsContentAreaDragDrop::DragGesture(nsIDOMEvent* inMouseEvent)
|
||||
nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
|
||||
if (override)
|
||||
{
|
||||
nsresult hookResult = override->OnCopyOrDrag(inMouseEvent, trans, &doContinueDrag);
|
||||
#ifdef DEBUG
|
||||
nsresult hookResult =
|
||||
#endif
|
||||
override->OnCopyOrDrag(inMouseEvent, trans, &doContinueDrag);
|
||||
NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in OnCopyOrDrag");
|
||||
if (!doContinueDrag)
|
||||
return NS_OK;
|
||||
@ -1423,13 +1435,14 @@ nsresult nsTransferableFactory::GetDraggableSelectionData(nsISelection* inSelect
|
||||
nsCOMPtr<nsIContent> selStartContent = do_QueryInterface(selectionStart);
|
||||
if (selStartContent)
|
||||
{
|
||||
PRInt32 childOffset = (anchorOffset < focusOffset) ? anchorOffset : focusOffset;
|
||||
nsCOMPtr<nsIContent> childContent;
|
||||
selStartContent->ChildAt(childOffset, getter_AddRefs(childContent));
|
||||
PRInt32 childOffset =
|
||||
(anchorOffset < focusOffset) ? anchorOffset : focusOffset;
|
||||
nsIContent *childContent =
|
||||
selStartContent->GetChildAt(childOffset);
|
||||
// if we find an image, we'll fall into the node-dragging code,
|
||||
// rather the the selection-dragging code
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> selectedImage;
|
||||
selectedImage = do_QueryInterface(childContent);
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> selectedImage =
|
||||
do_QueryInterface(childContent);
|
||||
if (selectedImage)
|
||||
{
|
||||
CallQueryInterface(selectedImage, outImageOrLinkNode); // addrefs
|
||||
|
||||
@ -111,12 +111,10 @@ GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ContentHasChildren: returns true if the content has children
|
||||
//
|
||||
static PRBool
|
||||
static inline PRBool
|
||||
ContentHasChildren(nsIContent *aContent)
|
||||
{
|
||||
PRInt32 numChildren = 0;
|
||||
aContent->ChildCount(numChildren);
|
||||
return numChildren != 0;
|
||||
return aContent->GetChildCount() > 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -139,10 +137,7 @@ ContentToParentOffset(nsIContent *aContent, nsIDOMNode **aParent, PRInt32 *aOffs
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
nsresult rv = parent->IndexOf(aContent, *aOffset);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
*aOffset = parent->IndexOf(aContent);
|
||||
|
||||
CallQueryInterface(parent, aParent);
|
||||
}
|
||||
@ -227,8 +222,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsIContent> GetDeepFirstChild(nsCOMPtr<nsIContent> aRoot, nsVoidArray *aIndexes);
|
||||
nsCOMPtr<nsIContent> GetDeepLastChild(nsCOMPtr<nsIContent> aRoot, nsVoidArray *aIndexes);
|
||||
nsIContent *GetDeepFirstChild(nsIContent *aRoot, nsVoidArray *aIndexes);
|
||||
nsIContent *GetDeepLastChild(nsIContent *aRoot, nsVoidArray *aIndexes);
|
||||
|
||||
nsresult GetNextSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<nsIContent> *aSibling, nsVoidArray *aIndexes);
|
||||
nsresult GetPrevSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<nsIContent> *aSibling, nsVoidArray *aIndexes);
|
||||
@ -379,7 +374,7 @@ nsresult nsContentIterator::Init(nsIContent* aRoot)
|
||||
if (!aRoot)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
mIsDone = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> root( do_QueryInterface(aRoot) );
|
||||
nsCOMPtr<nsIContent> root(aRoot);
|
||||
mIndexes.Clear();
|
||||
|
||||
if (mPre)
|
||||
@ -477,7 +472,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
|
||||
if (!cData && ContentHasChildren(startCon))
|
||||
startCon->ChildAt(startIndx, getter_AddRefs(cChild));
|
||||
cChild = startCon->GetChildAt(startIndx);
|
||||
|
||||
if (!cChild) // no children, must be a text node
|
||||
{
|
||||
@ -551,7 +546,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
|
||||
{
|
||||
PRInt32 indx = endIndx;
|
||||
|
||||
endCon->ChildAt(--indx, getter_AddRefs(cChild));
|
||||
cChild = endCon->GetChildAt(--indx);
|
||||
|
||||
if (!cChild) // No child at offset!
|
||||
{
|
||||
@ -602,7 +597,6 @@ nsresult nsContentIterator::RebuildIndexStack()
|
||||
// thats far better than too few.
|
||||
nsIContent* parent;
|
||||
nsIContent* current;
|
||||
PRInt32 indx;
|
||||
|
||||
mIndexes.Clear();
|
||||
current = mCurNode;
|
||||
@ -614,10 +608,10 @@ nsresult nsContentIterator::RebuildIndexStack()
|
||||
{
|
||||
parent = current->GetParent();
|
||||
|
||||
if (!parent || NS_FAILED(parent->IndexOf(current, indx)))
|
||||
if (!parent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mIndexes.InsertElementAt(NS_INT32_TO_PTR(indx),0);
|
||||
mIndexes.InsertElementAt(NS_INT32_TO_PTR(parent->IndexOf(current)), 0);
|
||||
|
||||
current = parent;
|
||||
}
|
||||
@ -635,65 +629,58 @@ void nsContentIterator::MakeEmpty()
|
||||
mIndexes.Clear();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> nsContentIterator::GetDeepFirstChild(nsCOMPtr<nsIContent> aRoot, nsVoidArray *aIndexes)
|
||||
nsIContent *
|
||||
nsContentIterator::GetDeepFirstChild(nsIContent *aRoot, nsVoidArray *aIndexes)
|
||||
{
|
||||
nsCOMPtr<nsIContent> deepFirstChild;
|
||||
|
||||
if (aRoot)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cN = aRoot;
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
cN->ChildAt(0, getter_AddRefs(cChild));
|
||||
while ( cChild )
|
||||
{
|
||||
if (aIndexes)
|
||||
{
|
||||
// Add this node to the stack of indexes
|
||||
aIndexes->AppendElement(NS_INT32_TO_PTR(0));
|
||||
}
|
||||
cN = cChild;
|
||||
cN->ChildAt(0, getter_AddRefs(cChild));
|
||||
}
|
||||
deepFirstChild = cN;
|
||||
if (!aRoot) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return deepFirstChild;
|
||||
|
||||
nsIContent *cN = aRoot;
|
||||
nsIContent *cChild = cN->GetChildAt(0);
|
||||
|
||||
while (cChild)
|
||||
{
|
||||
if (aIndexes)
|
||||
{
|
||||
// Add this node to the stack of indexes
|
||||
aIndexes->AppendElement(NS_INT32_TO_PTR(0));
|
||||
}
|
||||
cN = cChild;
|
||||
cChild = cN->GetChildAt(0);
|
||||
}
|
||||
|
||||
return cN;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> nsContentIterator::GetDeepLastChild(nsCOMPtr<nsIContent> aRoot, nsVoidArray *aIndexes)
|
||||
nsIContent *
|
||||
nsContentIterator::GetDeepLastChild(nsIContent *aRoot, nsVoidArray *aIndexes)
|
||||
{
|
||||
nsCOMPtr<nsIContent> deepFirstChild;
|
||||
|
||||
if (aRoot)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cN = aRoot;
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
PRInt32 numChildren;
|
||||
|
||||
cN->ChildCount(numChildren);
|
||||
|
||||
while ( numChildren )
|
||||
{
|
||||
cN->ChildAt(--numChildren, getter_AddRefs(cChild));
|
||||
if (cChild)
|
||||
{
|
||||
if (aIndexes)
|
||||
{
|
||||
// Add this node to the stack of indexes
|
||||
aIndexes->AppendElement(NS_INT32_TO_PTR(numChildren));
|
||||
}
|
||||
cChild->ChildCount(numChildren);
|
||||
cN = cChild;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
deepFirstChild = cN;
|
||||
if (!aRoot) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return deepFirstChild;
|
||||
|
||||
nsIContent *deepLastChild = aRoot;
|
||||
|
||||
nsIContent *cN = aRoot;
|
||||
PRInt32 numChildren = cN->GetChildCount();
|
||||
|
||||
while (numChildren)
|
||||
{
|
||||
nsIContent *cChild = cN->GetChildAt(--numChildren);
|
||||
|
||||
if (aIndexes)
|
||||
{
|
||||
// Add this node to the stack of indexes
|
||||
aIndexes->AppendElement(NS_INT32_TO_PTR(numChildren));
|
||||
}
|
||||
numChildren = cChild->GetChildCount();
|
||||
cN = cChild;
|
||||
|
||||
deepLastChild = cN;
|
||||
}
|
||||
|
||||
return deepLastChild;
|
||||
}
|
||||
|
||||
// Get the next sibling, or parents next sibling, or grandpa's next sibling...
|
||||
@ -725,16 +712,15 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr<nsIContent> aNode,
|
||||
// reverify that the index of the current node hasn't changed.
|
||||
// not super cheap, but a lot cheaper than IndexOf(), and still O(1).
|
||||
// ignore result this time - the index may now be out of range.
|
||||
(void) parent->ChildAt(indx, getter_AddRefs(sib)); // sib defaults to nsnull
|
||||
sib = parent->GetChildAt(indx);
|
||||
if (sib != aNode)
|
||||
{
|
||||
// someone changed our index - find the new index the painful way
|
||||
if (NS_FAILED(parent->IndexOf(aNode,indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
indx = parent->IndexOf(aNode);
|
||||
}
|
||||
|
||||
// indx is now canonically correct
|
||||
if (NS_SUCCEEDED(parent->ChildAt(++indx, getter_AddRefs(sib))) && sib)
|
||||
if ((sib = parent->GetChildAt(++indx)))
|
||||
{
|
||||
*aSibling = sib;
|
||||
// update index cache
|
||||
@ -793,17 +779,15 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode,
|
||||
|
||||
// reverify that the index of the current node hasn't changed
|
||||
// ignore result this time - the index may now be out of range.
|
||||
(void) parent->ChildAt(indx, getter_AddRefs(sib)); // sib defaults to nsnull
|
||||
sib = parent->GetChildAt(indx);
|
||||
if (sib != aNode)
|
||||
{
|
||||
// someone changed our index - find the new index the painful way
|
||||
if (NS_FAILED(parent->IndexOf(aNode,indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
indx = parent->IndexOf(aNode);
|
||||
}
|
||||
|
||||
// indx is now canonically correct
|
||||
if (indx > 0 &&
|
||||
NS_SUCCEEDED(parent->ChildAt(--indx, getter_AddRefs(sib))) && sib)
|
||||
if (indx > 0 && (sib = parent->GetChildAt(--indx)))
|
||||
{
|
||||
*aSibling = sib;
|
||||
// update index cache
|
||||
@ -831,7 +815,9 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsContentIterator::NextNode(nsCOMPtr<nsIContent> *ioNextNode, nsVoidArray *aIndexes)
|
||||
nsresult
|
||||
nsContentIterator::NextNode(nsCOMPtr<nsIContent> *ioNextNode,
|
||||
nsVoidArray *aIndexes)
|
||||
{
|
||||
if (!ioNextNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -840,19 +826,11 @@ nsresult nsContentIterator::NextNode(nsCOMPtr<nsIContent> *ioNextNode, nsVoidArr
|
||||
|
||||
if (mPre) // if we are a Pre-order iterator, use pre-order
|
||||
{
|
||||
nsCOMPtr<nsIContent> cFirstChild;
|
||||
PRInt32 numChildren;
|
||||
|
||||
cN->ChildCount(numChildren);
|
||||
|
||||
// if it has children then next node is first child
|
||||
if (numChildren)
|
||||
if (ContentHasChildren(cN))
|
||||
{
|
||||
if (NS_FAILED(cN->ChildAt(0, getter_AddRefs(cFirstChild))))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!cFirstChild)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsIContent *cFirstChild = cN->GetChildAt(0);
|
||||
|
||||
// update cache
|
||||
if (aIndexes)
|
||||
{
|
||||
@ -889,16 +867,16 @@ nsresult nsContentIterator::NextNode(nsCOMPtr<nsIContent> *ioNextNode, nsVoidArr
|
||||
// not super cheap, but a lot cheaper than IndexOf(), and still O(1).
|
||||
// ignore result this time - the index may now be out of range.
|
||||
if (indx >= 0)
|
||||
(void) parent->ChildAt(indx, getter_AddRefs(cSibling));
|
||||
cSibling = parent->GetChildAt(indx);
|
||||
if (cSibling != cN)
|
||||
{
|
||||
// someone changed our index - find the new index the painful way
|
||||
if (NS_FAILED(parent->IndexOf(cN,indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
indx = parent->IndexOf(cN);
|
||||
}
|
||||
|
||||
// indx is now canonically correct
|
||||
if (NS_SUCCEEDED(parent->ChildAt(++indx, getter_AddRefs(cSibling))) && cSibling)
|
||||
cSibling = parent->GetChildAt(++indx);
|
||||
if (cSibling)
|
||||
{
|
||||
// update cache
|
||||
if (aIndexes)
|
||||
@ -957,16 +935,16 @@ nsresult nsContentIterator::PrevNode(nsCOMPtr<nsIContent> *ioNextNode, nsVoidArr
|
||||
// not super cheap, but a lot cheaper than IndexOf(), and still O(1).
|
||||
// ignore result this time - the index may now be out of range.
|
||||
if (indx >= 0)
|
||||
(void) parent->ChildAt(indx, getter_AddRefs(cSibling));
|
||||
cSibling = parent->GetChildAt(indx);
|
||||
|
||||
if (cSibling != cN)
|
||||
{
|
||||
// someone changed our index - find the new index the painful way
|
||||
if (NS_FAILED(parent->IndexOf(cN,indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
indx = parent->IndexOf(cN);
|
||||
}
|
||||
|
||||
// indx is now canonically correct
|
||||
if (indx && NS_SUCCEEDED(parent->ChildAt(--indx, getter_AddRefs(cSibling))) && cSibling)
|
||||
if (indx && (cSibling = parent->GetChildAt(--indx)))
|
||||
{
|
||||
// update cache
|
||||
if (aIndexes)
|
||||
@ -994,15 +972,13 @@ nsresult nsContentIterator::PrevNode(nsCOMPtr<nsIContent> *ioNextNode, nsVoidArr
|
||||
else // post-order
|
||||
{
|
||||
nsCOMPtr<nsIContent> cLastChild;
|
||||
PRInt32 numChildren;
|
||||
|
||||
cN->ChildCount(numChildren);
|
||||
PRInt32 numChildren = cN->GetChildCount();
|
||||
|
||||
// if it has children then prev node is last child
|
||||
if (numChildren)
|
||||
{
|
||||
if (NS_FAILED(cN->ChildAt(--numChildren, getter_AddRefs(cLastChild))))
|
||||
return NS_ERROR_FAILURE;
|
||||
cLastChild = cN->GetChildAt(--numChildren);
|
||||
|
||||
if (!cLastChild)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -1194,15 +1170,12 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
|
||||
// Ok. We have the array of old parents. Look for a match.
|
||||
while (newCurNode)
|
||||
{
|
||||
PRInt32 indx;
|
||||
|
||||
parent = newCurNode->GetParent();
|
||||
|
||||
if (!parent) // this node has no parent, and thus no index
|
||||
break;
|
||||
|
||||
if (NS_FAILED(parent->IndexOf(newCurNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
PRInt32 indx = parent->IndexOf(newCurNode);
|
||||
|
||||
// insert at the head!
|
||||
newIndexes.InsertElementAt(NS_INT32_TO_PTR(indx),0);
|
||||
@ -1377,7 +1350,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
// short circuit when start node == end node
|
||||
if (startParent == endParent)
|
||||
{
|
||||
cStartP->ChildAt(0, getter_AddRefs(cChild));
|
||||
cChild = cStartP->GetChildAt(0);
|
||||
|
||||
if (!cChild) // no children, must be a text node or empty container
|
||||
{
|
||||
@ -1580,15 +1553,16 @@ nsresult nsContentSubtreeIterator::Next()
|
||||
{
|
||||
// as long as we are finding ancestors of the endpoint of the range,
|
||||
// dive down into their children
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
nextNode->ChildAt(0, getter_AddRefs(cChild));
|
||||
if (!cChild) return NS_ERROR_NULL_POINTER;
|
||||
nsIContent *cChild = nextNode->GetChildAt(0);
|
||||
if (!cChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// should be impossible to get a null pointer. If we went all the
|
||||
// down the child chain to the bottom without finding an interior node,
|
||||
// then the previous node should have been the last, which was
|
||||
// was tested at top of routine.
|
||||
nextNode = cChild;
|
||||
i = mEndNodes.IndexOf((void*)nextNode);
|
||||
i = mEndNodes.IndexOf(nextNode.get());
|
||||
}
|
||||
|
||||
mCurNode = do_QueryInterface(nextNode);
|
||||
|
||||
@ -121,12 +121,10 @@ nsBaseContentList::RemoveElement(nsIContent *aContent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::IndexOf(nsIContent *aContent, PRInt32& aIndex)
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsBaseContentList::IndexOf(nsIContent *aContent, PRBool aDoFlush)
|
||||
{
|
||||
aIndex = mElements.IndexOf(aContent);
|
||||
|
||||
return NS_OK;
|
||||
return mElements.IndexOf(aContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -420,14 +418,13 @@ nsContentList::GetParentObject(nsISupports** aParentObject)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::GetLength(PRUint32* aLength, PRBool aDoFlush)
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsContentList::GetLength(PRBool aDoFlush)
|
||||
{
|
||||
CheckDocumentExistence();
|
||||
BringSelfUpToDate(aDoFlush);
|
||||
|
||||
*aLength = mElements.Count();
|
||||
return NS_OK;
|
||||
return mElements.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -487,20 +484,21 @@ nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn, PRBool aD
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::IndexOf(nsIContent *aContent, PRInt32& aIndex, PRBool aDoFlush)
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsContentList::IndexOf(nsIContent *aContent, PRBool aDoFlush)
|
||||
{
|
||||
CheckDocumentExistence();
|
||||
BringSelfUpToDate(aDoFlush);
|
||||
|
||||
aIndex = mElements.IndexOf(aContent);
|
||||
return NS_OK;
|
||||
return mElements.IndexOf(aContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
return GetLength(aLength, PR_TRUE);
|
||||
*aLength = GetLength(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -560,8 +558,7 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
if (mState == LIST_DIRTY)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 count;
|
||||
aContainer->ChildCount(count);
|
||||
PRInt32 count = aContainer->GetChildCount();
|
||||
|
||||
/*
|
||||
* We want to handle the case of ContentAppended by sometimes
|
||||
@ -586,11 +583,10 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
*/
|
||||
nsCOMPtr<nsIDOM3Node> ourLastDOM3Node(do_QueryInterface(ourLastContent));
|
||||
if (ourLastDOM3Node) {
|
||||
nsCOMPtr<nsIContent> firstAppendedContent;
|
||||
aContainer->ChildAt(aNewIndexInContainer,
|
||||
getter_AddRefs(firstAppendedContent));
|
||||
nsCOMPtr<nsIDOMNode> newNode(do_QueryInterface(firstAppendedContent));
|
||||
nsCOMPtr<nsIDOMNode> newNode =
|
||||
do_QueryInterface(aContainer->GetChildAt(aNewIndexInContainer));
|
||||
NS_ASSERTION(newNode, "Content being inserted is not a node.... why?");
|
||||
|
||||
PRUint16 comparisonFlags;
|
||||
nsresult rv =
|
||||
ourLastDOM3Node->CompareDocumentPosition(newNode, &comparisonFlags);
|
||||
@ -606,10 +602,8 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
if (!appendToList) {
|
||||
// The new stuff is somewhere in the middle of our list; check
|
||||
// whether we need to invalidate
|
||||
nsCOMPtr<nsIContent> content;
|
||||
for (i = aNewIndexInContainer; i <= count-1; ++i) {
|
||||
aContainer->ChildAt(i, getter_AddRefs(content));
|
||||
if (MatchSelf(content)) {
|
||||
if (MatchSelf(aContainer->GetChildAt(i))) {
|
||||
// Uh-oh. We're gonna have to add elements into the middle
|
||||
// of our list. That's not worth the effort.
|
||||
mState = LIST_DIRTY;
|
||||
@ -633,11 +627,9 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
* We're up to date. That means someone's actively using us; we
|
||||
* may as well grab this content....
|
||||
*/
|
||||
nsCOMPtr<nsIContent> content;
|
||||
for (i = aNewIndexInContainer; i <= count-1; ++i) {
|
||||
aContainer->ChildAt(i, getter_AddRefs(content));
|
||||
PRUint32 limit = PRUint32(-1);
|
||||
PopulateWith(content, PR_TRUE, limit);
|
||||
PopulateWith(aContainer->GetChildAt(i), PR_TRUE, limit);
|
||||
}
|
||||
}
|
||||
|
||||
@ -721,9 +713,7 @@ nsContentList::Match(nsIContent *aContent)
|
||||
return PR_FALSE;
|
||||
|
||||
if (mMatchAtom) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
aContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
if (!ni)
|
||||
return PR_FALSE;
|
||||
|
||||
@ -772,14 +762,11 @@ nsContentList::MatchSelf(nsIContent *aContent)
|
||||
|
||||
if (Match(aContent))
|
||||
return PR_TRUE;
|
||||
|
||||
PRInt32 i, count = -1;
|
||||
|
||||
aContent->ChildCount(count);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRUint32 i, count = aContent->GetChildCount();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
if (MatchSelf(child)) {
|
||||
if (MatchSelf(aContent->GetChildAt(i))) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
@ -800,12 +787,10 @@ nsContentList::PopulateWith(nsIContent *aContent, PRBool aIncludeRoot,
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
aContent->ChildCount(count);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRUint32 i, count = aContent->GetChildCount();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
PopulateWith(child, PR_TRUE, aElementsToAppend);
|
||||
PopulateWith(aContent->GetChildAt(i), PR_TRUE, aElementsToAppend);
|
||||
if (aElementsToAppend == 0)
|
||||
return;
|
||||
}
|
||||
@ -821,17 +806,15 @@ nsContentList::PopulateWithStartingAfter(nsIContent *aStartRoot,
|
||||
#endif
|
||||
PRInt32 i = 0;
|
||||
if (aStartChild) {
|
||||
aStartRoot->IndexOf(aStartChild, i);
|
||||
i = aStartRoot->IndexOf(aStartChild);
|
||||
NS_ASSERTION(i >= 0, "The start child must be a child of the start root!");
|
||||
++i; // move to one past
|
||||
}
|
||||
|
||||
PRInt32 childCount;
|
||||
aStartRoot->ChildCount(childCount);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for ( ; i < childCount; ++i) {
|
||||
aStartRoot->ChildAt(i, getter_AddRefs(child));
|
||||
PopulateWith(child, PR_TRUE, aElementsToAppend);
|
||||
|
||||
PRUint32 childCount = aStartRoot->GetChildCount();
|
||||
for ( ; ((PRUint32)i) < childCount; ++i) {
|
||||
PopulateWith(aStartRoot->GetChildAt(i), PR_TRUE, aElementsToAppend);
|
||||
|
||||
NS_ASSERTION(aElementsToAppend + mElements.Count() == invariant,
|
||||
"Something is awry in PopulateWith!");
|
||||
if (aElementsToAppend == 0)
|
||||
|
||||
@ -67,7 +67,7 @@ public:
|
||||
|
||||
NS_IMETHOD AppendElement(nsIContent *aContent);
|
||||
NS_IMETHOD RemoveElement(nsIContent *aContent);
|
||||
NS_IMETHOD IndexOf(nsIContent *aContent, PRInt32& aIndex);
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent *aContent, PRBool aDoFlush);
|
||||
NS_IMETHOD Reset();
|
||||
|
||||
static void Shutdown();
|
||||
@ -175,13 +175,12 @@ public:
|
||||
|
||||
/// nsIContentList
|
||||
NS_IMETHOD GetParentObject(nsISupports** aParentObject);
|
||||
NS_IMETHOD GetLength(PRUint32* aLength, PRBool aDoFlush);
|
||||
NS_IMETHOD_(PRUint32) GetLength(PRBool aDoFlush);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush);
|
||||
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush);
|
||||
NS_IMETHOD IndexOf(nsIContent *aContent, PRInt32& aIndex,
|
||||
PRBool aDoFlush);
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent *aContent, PRBool aDoFlush);
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_DECL_NSIDOCUMENTOBSERVER
|
||||
|
||||
@ -450,7 +450,7 @@ nsContentUtils::GetDocumentAndPrincipal(nsIDOMNode* aNode,
|
||||
// manager
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
if (content) {
|
||||
content->GetNodeInfo(getter_AddRefs(ni));
|
||||
ni = content->GetNodeInfo();
|
||||
}
|
||||
else {
|
||||
attr->GetNodeInfo(getter_AddRefs(ni));
|
||||
@ -539,9 +539,8 @@ nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode,
|
||||
|
||||
nsCOMPtr<nsIContent> cont = do_QueryInterface(aTrustedNode);
|
||||
NS_ENSURE_TRUE(cont, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
cont->GetNodeInfo(getter_AddRefs(ni));
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni = cont->GetNodeInfo();
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_UNEXPECTED);
|
||||
|
||||
ni->GetDocumentPrincipal(getter_AddRefs(trustedPrincipal));
|
||||
@ -678,12 +677,11 @@ nsContentUtils::InProlog(nsIDOMNode *aNode)
|
||||
|
||||
// Check that there are no elements before aNode to make sure we are not
|
||||
// in the epilog
|
||||
PRInt32 pos;
|
||||
doc->IndexOf(cont, pos);
|
||||
PRInt32 pos = doc->IndexOf(cont);
|
||||
|
||||
while (pos > 0) {
|
||||
--pos;
|
||||
nsCOMPtr<nsIContent> sibl;
|
||||
doc->ChildAt(pos, getter_AddRefs(sibl));
|
||||
nsIContent *sibl = doc->GetChildAt(pos);
|
||||
if (sibl->IsContentOfType(nsIContent::eELEMENT)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
@ -732,13 +730,10 @@ nsContentUtils::doReparentContentWrapper(nsIContent *aChild,
|
||||
rv = old_wrapper->GetJSObject(&old);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRInt32 count = 0, i;
|
||||
|
||||
aChild->ChildCount(count);
|
||||
PRUint32 i, count = aChild->GetChildCount();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
aChild->ChildAt(i, getter_AddRefs(child));
|
||||
nsIContent *child = aChild->GetChildAt(i);
|
||||
NS_ENSURE_TRUE(child, NS_ERROR_UNEXPECTED);
|
||||
|
||||
rv = doReparentContentWrapper(child, aNewDocument, aOldDocument, cx, old);
|
||||
@ -790,9 +785,7 @@ nsContentUtils::ReparentContentWrapper(nsIContent *aContent,
|
||||
nsIDocument* old_doc = aOldDocument;
|
||||
|
||||
if (!old_doc) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
||||
aContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsCOMPtr<nsINodeInfo> ni = aContent->GetNodeInfo();
|
||||
|
||||
if (ni) {
|
||||
old_doc = ni->GetDocument();
|
||||
@ -1018,7 +1011,7 @@ nsContentUtils::GetAncestorsAndOffsets(nsIDOMNode* aNode,
|
||||
nsIContent* child = content;
|
||||
nsIContent* parent = child->GetParent();
|
||||
while (parent) {
|
||||
parent->IndexOf(child, offset);
|
||||
offset = parent->IndexOf(child);
|
||||
aAncestorNodes->AppendElement(parent);
|
||||
aAncestorOffsets->AppendElement(NS_INT32_TO_PTR(offset));
|
||||
child = parent;
|
||||
@ -1458,7 +1451,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
||||
|
||||
// Append the index of the form in the document
|
||||
nsCOMPtr<nsIContent> formContent(do_QueryInterface(formElement));
|
||||
htmlForms->IndexOf(formContent, index, PR_FALSE);
|
||||
index = htmlForms->IndexOf(formContent, PR_FALSE);
|
||||
if (index <= -1) {
|
||||
//
|
||||
// XXX HACK this uses some state that was dumped into the document
|
||||
@ -1503,7 +1496,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
||||
// causes a signficant pageload performance hit. See bug
|
||||
// 166636. Doing this wrong means you will see the assertion
|
||||
// below being hit.
|
||||
htmlFormControls->IndexOf(aContent, index, PR_FALSE);
|
||||
index = htmlFormControls->IndexOf(aContent, PR_FALSE);
|
||||
NS_ASSERTION(index > -1,
|
||||
"nsFrameManager::GenerateStateKey didn't find content "
|
||||
"by type! See bug 139568");
|
||||
@ -1591,11 +1584,7 @@ nsContentUtils::BelongsInForm(nsIDOMHTMLFormElement *aForm,
|
||||
content = content->GetParent();
|
||||
}
|
||||
|
||||
PRInt32 count = 0;
|
||||
|
||||
form->ChildCount(count);
|
||||
|
||||
if (count > 0) {
|
||||
if (form->GetChildCount() > 0) {
|
||||
// The form is a container but aContent wasn't inside the form,
|
||||
// return false
|
||||
|
||||
|
||||
@ -144,8 +144,7 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context) );
|
||||
@ -313,7 +312,10 @@ nsresult nsCopySupport::DoHooks(nsIDocument *aDoc, nsITransferable *aTrans,
|
||||
override = do_QueryInterface(isupp);
|
||||
if (override)
|
||||
{
|
||||
nsresult hookResult = override->OnCopyOrDrag(nsnull, aTrans, aDoPutOnClipboard);
|
||||
#ifdef DEBUG
|
||||
nsresult hookResult =
|
||||
#endif
|
||||
override->OnCopyOrDrag(nsnull, aTrans, aDoPutOnClipboard);
|
||||
NS_ASSERTION(NS_SUCCEEDED(hookResult), "OnCopyOrDrag hook failed");
|
||||
if (!*aDoPutOnClipboard)
|
||||
break;
|
||||
|
||||
@ -622,8 +622,7 @@ nsDOMAttribute::IsSameNode(nsIDOMNode* aOther,
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(nodeOwner));
|
||||
// Check to see if we're in HTML.
|
||||
if (content->IsContentOfType(nsIContent::eHTML)) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
content->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsINodeInfo *ni = content->GetNodeInfo();
|
||||
if (ni) {
|
||||
// If there is no namespace, we're in HTML (as opposed to XHTML)
|
||||
// and we'll need to compare node names case insensitively.
|
||||
|
||||
@ -234,8 +234,7 @@ nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
nsAutoString value, name;
|
||||
mContent->GetAttr(nameSpaceID, nameAtom, value);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsCOMPtr<nsINodeInfo> ni(mContent->GetNodeInfo());
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
@ -262,16 +261,13 @@ nsDOMAttributeMap::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
|
||||
PRInt32 n;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull != mContent) {
|
||||
rv = mContent->GetAttrCount(n);
|
||||
*aLength = PRUint32(n);
|
||||
if (mContent) {
|
||||
*aLength = mContent->GetAttrCount();
|
||||
} else {
|
||||
*aLength = 0;
|
||||
}
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -288,8 +284,7 @@ nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI,
|
||||
PRInt32 nameSpaceID = kNameSpaceID_None;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsCOMPtr<nsINodeInfo> ni(mContent->GetNodeInfo());
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
@ -358,8 +353,7 @@ nsDOMAttributeMap::SetNamedItemNS(nsIDOMNode* aArg, nsIDOMNode** aReturn)
|
||||
attribute->GetName(name);
|
||||
attribute->GetNamespaceURI(nsURI);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsCOMPtr<nsINodeInfo> ni(mContent->GetNodeInfo());
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
@ -416,8 +410,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
|
||||
nsCOMPtr<nsIDOMNode> attribute;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsCOMPtr<nsINodeInfo> ni(mContent->GetNodeInfo());
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
|
||||
@ -412,14 +412,12 @@ nsDocumentChildNodes::~nsDocumentChildNodes()
|
||||
NS_IMETHODIMP
|
||||
nsDocumentChildNodes::GetLength(PRUint32* aLength)
|
||||
{
|
||||
PRInt32 count = 0;
|
||||
|
||||
if (mDocument) {
|
||||
mDocument->GetChildCount(count);
|
||||
*aLength = mDocument->GetChildCount();
|
||||
} else {
|
||||
*aLength = 0;
|
||||
}
|
||||
|
||||
*aLength = (PRUint32)count;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -429,8 +427,8 @@ nsDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
*aReturn = nsnull;
|
||||
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIContent> content;
|
||||
mDocument->ChildAt(aIndex, getter_AddRefs(content));
|
||||
nsIContent *content = mDocument->GetChildAt(aIndex);
|
||||
|
||||
if (content) {
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
@ -1194,19 +1192,16 @@ nsDocument::DeleteShell(nsIPresShell* aShell)
|
||||
return mPresShells.RemoveElement(aShell);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsDocument::GetNumberOfShells()
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsDocument::GetNumberOfShells() const
|
||||
{
|
||||
return mPresShells.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetShellAt(PRInt32 aIndex, nsIPresShell** aShell)
|
||||
NS_IMETHODIMP_(nsIPresShell *)
|
||||
nsDocument::GetShellAt(PRUint32 aIndex) const
|
||||
{
|
||||
*aShell = (nsIPresShell*) mPresShells.SafeElementAt(aIndex);
|
||||
NS_IF_ADDREF(*aShell);
|
||||
|
||||
return NS_OK;
|
||||
return (nsIPresShell*)mPresShells.SafeElementAt(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1406,30 +1401,26 @@ nsDocument::SetRootContent(nsIContent* aRoot)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::ChildAt(PRInt32 aIndex, nsIContent** aResult) const
|
||||
NS_IMETHODIMP_(nsIContent *)
|
||||
nsDocument::GetChildAt(PRUint32 aIndex) const
|
||||
{
|
||||
NS_PRECONDITION(aIndex >= 0, "Negative indices are bad");
|
||||
if (aIndex < 0 || aIndex >= mChildren.Count()) {
|
||||
*aResult = nsnull;
|
||||
} else {
|
||||
NS_IF_ADDREF(*aResult = mChildren[aIndex]);
|
||||
if (aIndex >= (PRUint32)mChildren.Count()) {
|
||||
return nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
return mChildren[aIndex];
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsDocument::IndexOf(nsIContent* aPossibleChild) const
|
||||
{
|
||||
aIndex = mChildren.IndexOf(aPossibleChild);
|
||||
return NS_OK;
|
||||
return mChildren.IndexOf(aPossibleChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetChildCount(PRInt32& aCount)
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsDocument::GetChildCount() const
|
||||
{
|
||||
aCount = mChildren.Count();
|
||||
return NS_OK;
|
||||
return mChildren.Count();
|
||||
}
|
||||
|
||||
PRInt32
|
||||
@ -1975,9 +1966,7 @@ nsDocument::EndLoad()
|
||||
if (innerEvent) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
ancestor_doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
|
||||
nsIPresShell *shell = ancestor_doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
@ -2659,12 +2648,10 @@ GetElementByAttribute(nsIContent* aContent, nsIAtom* aAttrName,
|
||||
return CallQueryInterface(aContent, aResult);
|
||||
}
|
||||
|
||||
PRInt32 childCount;
|
||||
aContent->ChildCount(childCount);
|
||||
PRUint32 childCount = aContent->GetChildCount();
|
||||
|
||||
for (PRInt32 i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIContent> current;
|
||||
aContent->ChildAt(i, getter_AddRefs(current));
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent *current = aContent->GetChildAt(i);
|
||||
|
||||
GetElementByAttribute(current, aAttrName, aAttrValue, aUniversalMatch,
|
||||
aResult);
|
||||
@ -2877,8 +2864,7 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -3882,8 +3868,7 @@ nsDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
||||
if (count == 0)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -3955,9 +3940,7 @@ nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
|
||||
|
||||
// Obtain a presentation context
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
|
||||
if (shell) {
|
||||
|
||||
@ -366,9 +366,9 @@ public:
|
||||
nsIViewManager* aViewManager,
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell);
|
||||
virtual PRInt32 GetNumberOfShells();
|
||||
NS_IMETHOD GetShellAt(PRInt32 aIndex, nsIPresShell** aShell);
|
||||
NS_IMETHOD_(PRBool) DeleteShell(nsIPresShell* aShell);
|
||||
NS_IMETHOD_(PRUint32) GetNumberOfShells() const;
|
||||
NS_IMETHOD_(nsIPresShell *) GetShellAt(PRUint32 aIndex) const;
|
||||
|
||||
/**
|
||||
* Return the parent document of this document. Will return null
|
||||
@ -392,9 +392,9 @@ public:
|
||||
* Get the direct children of the document - content in
|
||||
* the prolog, the root content and content in the epilog.
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount);
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const;
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
|
||||
@ -494,14 +494,13 @@ nsDocumentEncoder::FlushText(nsAString& aString, PRBool aForce)
|
||||
// there are problems with it so we don't use it now, maybe later...
|
||||
static nsresult ChildAt(nsIDOMNode* aNode, PRInt32 aIndex, nsIDOMNode*& aChild)
|
||||
{
|
||||
nsCOMPtr<nsIContent> node(do_QueryInterface(aNode));
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
|
||||
aChild = nsnull;
|
||||
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
node->ChildAt(aIndex, getter_AddRefs(child));
|
||||
nsIContent *child = content->GetChildAt(aIndex);
|
||||
|
||||
if (child)
|
||||
return CallQueryInterface(child, &aChild);
|
||||
@ -514,14 +513,10 @@ static PRInt32 IndexOf(nsIDOMNode* aParent, nsIDOMNode* aChild)
|
||||
nsCOMPtr<nsIContent> parent(do_QueryInterface(aParent));
|
||||
nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
|
||||
|
||||
if (!parent || !child)
|
||||
if (!parent)
|
||||
return -1;
|
||||
|
||||
PRInt32 indx = 0;
|
||||
|
||||
parent->IndexOf(child, indx);
|
||||
|
||||
return indx;
|
||||
return parent->IndexOf(child);
|
||||
}
|
||||
|
||||
static inline PRInt32 GetIndex(nsVoidArray& aIndexArray)
|
||||
@ -704,8 +699,8 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// do some calculations that will tell us which children of this node are in the range.
|
||||
nsCOMPtr<nsIContent> child;
|
||||
// do some calculations that will tell us which children of this
|
||||
// node are in the range.
|
||||
nsCOMPtr<nsIDOMNode> childAsNode;
|
||||
PRInt32 startOffset = 0, endOffset = -1;
|
||||
if (startNode == content && mStartRootIndex >= aDepth)
|
||||
@ -713,9 +708,9 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
|
||||
if (endNode == content && mEndRootIndex >= aDepth)
|
||||
endOffset = NS_PTR_TO_INT32(mEndOffsets[mEndRootIndex - aDepth]) ;
|
||||
// generated content will cause offset values of -1 to be returned.
|
||||
PRInt32 j, childCount=0;
|
||||
rv = content->ChildCount(childCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRInt32 j;
|
||||
PRUint32 childCount = content->GetChildCount();
|
||||
|
||||
if (startOffset == -1) startOffset = 0;
|
||||
if (endOffset == -1) endOffset = childCount;
|
||||
else
|
||||
@ -736,13 +731,13 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
|
||||
// serialize the children of this node that are in the range
|
||||
for (j=startOffset; j<endOffset; j++)
|
||||
{
|
||||
rv = content->ChildAt(j, getter_AddRefs(child));
|
||||
childAsNode = do_QueryInterface(child);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
childAsNode = do_QueryInterface(content->GetChildAt(j));
|
||||
|
||||
if ((j==startOffset) || (j==endOffset-1))
|
||||
rv = SerializeRangeNodes(aRange, childAsNode, aString, aDepth+1);
|
||||
else
|
||||
rv = SerializeToStringRecursive(childAsNode, aString);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -1604,13 +1599,10 @@ nsHTMLCopyEncoder::GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
|
||||
return resultNode;
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
NS_PRECONDITION(content, "null content in nsHTMLCopyEncoder::GetChildAt");
|
||||
|
||||
if (NS_FAILED(content->ChildAt(aOffset, getter_AddRefs(cChild))))
|
||||
return resultNode;
|
||||
|
||||
resultNode = do_QueryInterface(cChild);
|
||||
|
||||
resultNode = do_QueryInterface(content->GetChildAt(aOffset));
|
||||
|
||||
return resultNode;
|
||||
}
|
||||
|
||||
@ -1635,7 +1627,9 @@ nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCopyEncoder::GetNodeLocation(nsIDOMNode *inChild, nsCOMPtr<nsIDOMNode> *outParent, PRInt32 *outOffset)
|
||||
nsHTMLCopyEncoder::GetNodeLocation(nsIDOMNode *inChild,
|
||||
nsCOMPtr<nsIDOMNode> *outParent,
|
||||
PRInt32 *outOffset)
|
||||
{
|
||||
NS_ASSERTION((inChild && outParent && outOffset), "bad args");
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
@ -1646,8 +1640,10 @@ nsHTMLCopyEncoder::GetNodeLocation(nsIDOMNode *inChild, nsCOMPtr<nsIDOMNode> *ou
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(*outParent);
|
||||
nsCOMPtr<nsIContent> cChild = do_QueryInterface(inChild);
|
||||
if (!cChild || !content) return NS_ERROR_NULL_POINTER;
|
||||
result = content->IndexOf(cChild, *outOffset);
|
||||
if (!cChild || !content)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*outOffset = content->IndexOf(cChild);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -146,7 +146,7 @@ public:
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const
|
||||
@ -242,16 +242,10 @@ NS_IMPL_RELEASE(nsDocumentFragment)
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::DisconnectChildren()
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRInt32 i, count;
|
||||
|
||||
ChildCount(count);
|
||||
PRUint32 i, count = GetChildCount();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ChildAt(i, getter_AddRefs(child));
|
||||
NS_ASSERTION(child, "Bad content container");
|
||||
|
||||
child->SetParent(nsnull);
|
||||
GetChildAt(i)->SetParent(nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -260,25 +254,18 @@ nsDocumentFragment::DisconnectChildren()
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::ReconnectChildren()
|
||||
{
|
||||
nsCOMPtr<nsIContent> child, parent;
|
||||
PRInt32 i, count = 0;
|
||||
|
||||
ChildCount(count);
|
||||
PRUint32 i, count = GetChildCount();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ChildAt(i, getter_AddRefs(child));
|
||||
NS_ASSERTION(child, "Bad content container");
|
||||
|
||||
parent = child->GetParent();
|
||||
nsIContent *child = GetChildAt(i);
|
||||
nsIContent *parent = child->GetParent();
|
||||
|
||||
if (parent) {
|
||||
PRInt32 indx = -1;
|
||||
|
||||
// This is potentially a O(n**2) operation, but it should only
|
||||
// happen in error cases (such as out of memory or something
|
||||
// similar) so we don't care for now.
|
||||
|
||||
parent->IndexOf(child, indx);
|
||||
PRInt32 indx = parent->IndexOf(child);
|
||||
|
||||
if (indx >= 0) {
|
||||
parent->RemoveChildAt(indx, PR_TRUE);
|
||||
@ -294,11 +281,9 @@ nsDocumentFragment::ReconnectChildren()
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::DropChildReferences()
|
||||
{
|
||||
PRInt32 count;
|
||||
PRUint32 count = GetChildCount();
|
||||
|
||||
ChildCount(count);
|
||||
|
||||
for (PRInt32 index = 0; index < count; ++index) {
|
||||
for (PRUint32 index = 0; index < count; ++index) {
|
||||
nsIContent* kid = NS_STATIC_CAST(nsIContent*, mChildren.ElementAt(index));
|
||||
NS_RELEASE(kid);
|
||||
}
|
||||
|
||||
@ -1693,7 +1693,7 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
||||
// Note this is also defined in nsPrintEngine
|
||||
// They can't share it because nsPrintEngine may not be available
|
||||
// when printing isn't turned on
|
||||
static nsIPresShell*
|
||||
static nsIPresShell *
|
||||
GetPresShellFor(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
@ -1702,10 +1702,7 @@ GetPresShellFor(nsIDocShell* aDocShell)
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc) return nsnull;
|
||||
|
||||
nsIPresShell* shell = nsnull;
|
||||
doc->GetShellAt(0, &shell);
|
||||
|
||||
return shell;
|
||||
return doc->GetShellAt(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -1725,15 +1722,17 @@ DocumentViewerImpl::GetPresShellAndRootContent(nsIWebShell * aWebShell,
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebShell));
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell(getter_AddRefs(GetPresShellFor(docShell)));
|
||||
if (!presShell) return;
|
||||
nsIPresShell *presShell = GetPresShellFor(docShell);
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc) return;
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
doc->GetRootContent(aContent); // this addrefs
|
||||
*aPresShell = presShell.get();
|
||||
*aPresShell = presShell;
|
||||
NS_ADDREF(*aPresShell);
|
||||
}
|
||||
|
||||
@ -1742,14 +1741,14 @@ nsresult
|
||||
DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent,
|
||||
const nsIID& aIID)
|
||||
{
|
||||
PRInt32 numChildren;
|
||||
aParentContent->ChildCount(numChildren);
|
||||
PRUint32 numChildren = aParentContent->GetChildCount();
|
||||
|
||||
// do a breadth search across all siblings
|
||||
PRInt32 inx;
|
||||
PRUint32 inx;
|
||||
for (inx = 0; inx < numChildren; ++inx) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
if (NS_SUCCEEDED(aParentContent->ChildAt(inx, getter_AddRefs(child))) && child) {
|
||||
nsIContent *child = aParentContent->GetChildAt(inx);
|
||||
|
||||
if (child) {
|
||||
nsCOMPtr<nsISupports> temp;
|
||||
if (NS_SUCCEEDED(child->QueryInterface(aIID, (void**)getter_AddRefs(temp)))) {
|
||||
return NS_OK;
|
||||
|
||||
@ -384,8 +384,7 @@ nsFrameLoader::GetPresContext(nsIPresContext **aPresContext)
|
||||
nsCOMPtr<nsIDocument> doc = mOwnerContent->GetDocument();
|
||||
|
||||
while (doc) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
|
||||
if (presShell) {
|
||||
presShell->GetPresContext(aPresContext);
|
||||
@ -519,7 +518,7 @@ nsFrameLoader::EnsureDocShell()
|
||||
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
|
||||
parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
|
||||
|
||||
if(parentTreeOwner) {
|
||||
if (parentTreeOwner) {
|
||||
PRBool is_primary = parentType == nsIDocShellTreeItem::typeChrome &&
|
||||
value == NS_LITERAL_STRING("content-primary");
|
||||
|
||||
|
||||
@ -299,7 +299,6 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> dN;
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
|
||||
nsCOMPtr<nsIContent> startCon;
|
||||
nsCOMPtr<nsIDOMNode> startDOM;
|
||||
@ -334,12 +333,13 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
aRange->GetEndOffset(&endIndx);
|
||||
|
||||
|
||||
// find first node in range
|
||||
nsIContent *cChild = startCon->GetChildAt(0);
|
||||
|
||||
// short circuit when start node == end node
|
||||
if (startDOM == endDOM)
|
||||
{
|
||||
startCon->ChildAt(0, getter_AddRefs(cChild));
|
||||
|
||||
if (!cChild) // no children, must be a text node or empty container
|
||||
{
|
||||
mFirst = startCon;
|
||||
@ -357,16 +357,13 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
}
|
||||
|
||||
// find first node in range
|
||||
startCon->ChildAt(0, getter_AddRefs(cChild));
|
||||
|
||||
if (!cChild) // no children, must be a text node
|
||||
{
|
||||
mFirst = startCon;
|
||||
}
|
||||
else
|
||||
{
|
||||
startCon->ChildAt(startIndx, getter_AddRefs(cChild));
|
||||
cChild = startCon->GetChildAt(startIndx);
|
||||
if (!cChild) // offset after last child, parent is first node
|
||||
{
|
||||
mFirst = startCon;
|
||||
@ -394,7 +391,7 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
|
||||
// find last node in range
|
||||
endCon->ChildAt(0, getter_AddRefs(cChild));
|
||||
cChild = endCon->GetChildAt(0);
|
||||
|
||||
if (!cChild) // no children, must be a text node
|
||||
{
|
||||
@ -406,11 +403,11 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
else
|
||||
{
|
||||
endCon->ChildAt(--endIndx, getter_AddRefs(cChild));
|
||||
cChild = endCon->GetChildAt(--endIndx);
|
||||
if (!cChild) // offset after last child, last child is last node
|
||||
{
|
||||
endCon->ChildCount(endIndx);
|
||||
endCon->ChildAt(--endIndx, getter_AddRefs(cChild));
|
||||
endIndx = (PRInt32)endCon->GetChildCount();
|
||||
cChild = endCon->GetChildAt(--endIndx);
|
||||
if (!cChild)
|
||||
{
|
||||
NS_NOTREACHED("nsGeneratedContentIterator::nsGeneratedContentIterator");
|
||||
@ -449,7 +446,6 @@ nsCOMPtr<nsIContent> nsGeneratedContentIterator::GetDeepFirstChild(nsCOMPtr<nsIC
|
||||
if (aRoot)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cN = aRoot;
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
|
||||
#if DO_BEFORE
|
||||
//CHECK FOR BEFORESTUFF
|
||||
@ -463,8 +459,9 @@ nsCOMPtr<nsIContent> nsGeneratedContentIterator::GetDeepFirstChild(nsCOMPtr<nsIC
|
||||
return cN;
|
||||
}
|
||||
#endif
|
||||
cN->ChildAt(0, getter_AddRefs(cChild));
|
||||
while ( cChild )
|
||||
|
||||
nsIContent *cChild;
|
||||
while ((cChild = cN->GetChildAt(0)))
|
||||
{
|
||||
cN = cChild;
|
||||
|
||||
@ -479,9 +476,8 @@ nsCOMPtr<nsIContent> nsGeneratedContentIterator::GetDeepFirstChild(nsCOMPtr<nsIC
|
||||
return cN;
|
||||
}
|
||||
#endif
|
||||
|
||||
cN->ChildAt(0, getter_AddRefs(cChild));
|
||||
}
|
||||
|
||||
deepFirstChild = cN;
|
||||
}
|
||||
|
||||
@ -496,7 +492,6 @@ nsCOMPtr<nsIContent> nsGeneratedContentIterator::GetDeepLastChild(nsCOMPtr<nsICo
|
||||
{
|
||||
nsCOMPtr<nsIContent> cN = aRoot;
|
||||
nsCOMPtr<nsIContent> cChild;
|
||||
PRInt32 numChildren;
|
||||
|
||||
#if DO_AFTER
|
||||
//CHECK FOR AFTER STUFF
|
||||
@ -511,11 +506,11 @@ nsCOMPtr<nsIContent> nsGeneratedContentIterator::GetDeepLastChild(nsCOMPtr<nsICo
|
||||
}
|
||||
#endif
|
||||
|
||||
cN->ChildCount(numChildren);
|
||||
PRUint32 numChildren = cN->GetChildCount();
|
||||
|
||||
while ( numChildren )
|
||||
{
|
||||
cN->ChildAt(--numChildren, getter_AddRefs(cChild));
|
||||
cChild = cN->GetChildAt(--numChildren);
|
||||
if (cChild)
|
||||
{
|
||||
#if DO_AFTER
|
||||
@ -529,7 +524,7 @@ nsCOMPtr<nsIContent> nsGeneratedContentIterator::GetDeepLastChild(nsCOMPtr<nsICo
|
||||
return cChild;
|
||||
}
|
||||
#endif
|
||||
cChild->ChildCount(numChildren);
|
||||
numChildren = cChild->GetChildCount();
|
||||
cN = cChild;
|
||||
}
|
||||
else
|
||||
@ -550,19 +545,17 @@ nsresult nsGeneratedContentIterator::GetNextSibling(nsCOMPtr<nsIContent> aNode,
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aSibling)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContent> sib;
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
PRInt32 indx;
|
||||
|
||||
parent = aNode->GetParent();
|
||||
|
||||
nsIContent *parent = aNode->GetParent();
|
||||
if (!parent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(parent->IndexOf(aNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
PRInt32 indx = parent->IndexOf(aNode);
|
||||
|
||||
if (NS_SUCCEEDED(parent->ChildAt(++indx, getter_AddRefs(sib))) && sib)
|
||||
nsIContent *sib = parent->GetChildAt(++indx);
|
||||
|
||||
if (sib)
|
||||
{
|
||||
*aSibling = sib;
|
||||
}
|
||||
@ -604,16 +597,14 @@ nsresult nsGeneratedContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode,
|
||||
|
||||
nsCOMPtr<nsIContent> sib;
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
PRInt32 indx;
|
||||
|
||||
parent = aNode->GetParent();
|
||||
if (!parent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(parent->IndexOf(aNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
PRInt32 indx = parent->IndexOf(aNode);
|
||||
|
||||
if (indx && NS_SUCCEEDED(parent->ChildAt(--indx, getter_AddRefs(sib))) && sib)
|
||||
if (indx && (sib = parent->GetChildAt(--indx)))
|
||||
{
|
||||
*aSibling = sib;
|
||||
}
|
||||
@ -661,30 +652,32 @@ nsresult nsGeneratedContentIterator::NextNode(nsCOMPtr<nsIContent> *ioNextNode)
|
||||
//*ioNextNode = parent; leave it the same
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIContent>cN;
|
||||
(*ioNextNode)->ChildAt(0, getter_AddRefs(cN));
|
||||
nsIContent *cN = (*ioNextNode)->GetChildAt(0);
|
||||
if (cN)
|
||||
{
|
||||
*ioNextNode=GetDeepFirstChild(cN);
|
||||
*ioNextNode = GetDeepFirstChild(cN);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIContent> cN = *ioNextNode;
|
||||
nsCOMPtr<nsIContent> cSibling;
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
PRInt32 indx;
|
||||
|
||||
// get next sibling if there is one
|
||||
parent = cN->GetParent();
|
||||
if (!parent || NS_FAILED(parent->IndexOf(cN, indx)))
|
||||
if (!parent)
|
||||
{
|
||||
// a little noise to catch some iterator usage bugs.
|
||||
NS_NOTREACHED("nsGeneratedContentIterator::NextNode() : no parent found");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_SUCCEEDED(parent->ChildAt(++indx, getter_AddRefs(cSibling))) && cSibling)
|
||||
|
||||
PRInt32 indx = parent->IndexOf(cN);
|
||||
|
||||
nsIContent *cSibling = parent->GetChildAt(++indx);
|
||||
if (cSibling)
|
||||
{
|
||||
// next node is siblings "deep left" child
|
||||
*ioNextNode = GetDeepFirstChild(cSibling);
|
||||
@ -717,25 +710,26 @@ nsresult nsGeneratedContentIterator::NextNode(nsCOMPtr<nsIContent> *ioNextNode)
|
||||
|
||||
|
||||
//THIS NEEDS TO USE A GENERATED SUBTREEITER HERE
|
||||
nsresult nsGeneratedContentIterator::PrevNode(nsCOMPtr<nsIContent> *ioNextNode)
|
||||
nsresult
|
||||
nsGeneratedContentIterator::PrevNode(nsCOMPtr<nsIContent> *ioNextNode)
|
||||
{
|
||||
if (!ioNextNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContent> cN = *ioNextNode;
|
||||
nsCOMPtr<nsIContent> cLastChild;
|
||||
PRInt32 numChildren;
|
||||
|
||||
cN->ChildCount(numChildren);
|
||||
|
||||
|
||||
nsIContent *cN = *ioNextNode;
|
||||
|
||||
PRUint32 numChildren = cN->GetChildCount();
|
||||
|
||||
// if it has children then prev node is last child
|
||||
if (numChildren)
|
||||
if (numChildren > 0)
|
||||
{
|
||||
if (NS_FAILED(cN->ChildAt(--numChildren, getter_AddRefs(cLastChild))))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsIContent *cLastChild = cN->GetChildAt(--numChildren);
|
||||
|
||||
if (!cLastChild)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*ioNextNode = cLastChild;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -973,7 +967,7 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
// short circuit when start node == end node
|
||||
if (startParent == endParent)
|
||||
{
|
||||
cStartP->ChildAt(0, getter_AddRefs(cChild));
|
||||
cChild = cStartP->GetChildAt(0);
|
||||
|
||||
if (!cChild) // no children, must be a text node or empty container
|
||||
{
|
||||
@ -1172,13 +1166,16 @@ nsresult nsGeneratedSubtreeIterator::Next()
|
||||
if (mGenIter->IsDone())
|
||||
{
|
||||
mGenIter = 0;
|
||||
if (mIterType == nsIPresShell::After ||
|
||||
NS_FAILED(mCurNode->ChildAt(0,
|
||||
getter_AddRefs(nextNode))))
|
||||
|
||||
if (mIterType == nsIPresShell::After)
|
||||
{
|
||||
if (NS_FAILED(GetNextSibling(mCurNode, address_of(nextNode))))
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextNode = mCurNode->GetChildAt(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
return mGenIter->Next();
|
||||
|
||||
@ -146,24 +146,22 @@ nsGenericDOMDataNode::GetParentNode(nsIDOMNode** aParentNode)
|
||||
nsresult
|
||||
nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aPrevSibling)
|
||||
{
|
||||
nsCOMPtr<nsIContent> sibling;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIContent *parent_weak = GetParentWeak();
|
||||
nsIContent *sibling = nsnull;
|
||||
|
||||
if (parent_weak) {
|
||||
PRInt32 pos;
|
||||
parent_weak->IndexOf(this, pos);
|
||||
if (pos > 0 ) {
|
||||
parent_weak->ChildAt(--pos, getter_AddRefs(sibling));
|
||||
PRInt32 pos = parent_weak->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = parent_weak->GetChildAt(pos - 1);
|
||||
}
|
||||
} else if (mDocument) {
|
||||
// Nodes that are just below the document (their parent is the
|
||||
// document) need to go to the document to find their next sibling.
|
||||
PRInt32 pos;
|
||||
mDocument->IndexOf(this, pos);
|
||||
if (pos > 0 ) {
|
||||
mDocument->ChildAt(--pos, getter_AddRefs(sibling));
|
||||
PRInt32 pos = mDocument->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = mDocument->GetChildAt(pos - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,25 +178,23 @@ nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aPrevSibling)
|
||||
nsresult
|
||||
nsGenericDOMDataNode::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
nsCOMPtr<nsIContent> sibling;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIContent *parent_weak = GetParentWeak();
|
||||
nsIContent *sibling = nsnull;
|
||||
|
||||
if (parent_weak) {
|
||||
PRInt32 pos;
|
||||
parent_weak->IndexOf(this, pos);
|
||||
PRInt32 pos = parent_weak->IndexOf(this);
|
||||
if (pos > -1 ) {
|
||||
parent_weak->ChildAt(++pos, getter_AddRefs(sibling));
|
||||
sibling = parent_weak->GetChildAt(pos + 1);
|
||||
}
|
||||
}
|
||||
else if (mDocument) {
|
||||
// Nodes that are just below the document (their parent is the
|
||||
// document) need to go to the document to find their next sibling.
|
||||
PRInt32 pos;
|
||||
mDocument->IndexOf(this, pos);
|
||||
PRInt32 pos = mDocument->IndexOf(this);
|
||||
if (pos > -1 ) {
|
||||
mDocument->ChildAt(++pos, getter_AddRefs(sibling));
|
||||
sibling = mDocument->GetChildAt(pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -742,7 +738,7 @@ nsGenericDOMDataNode::HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::GetAttrNameAt(PRInt32 aIndex, PRInt32* aNameSpaceID,
|
||||
nsGenericDOMDataNode::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName, nsIAtom** aPrefix) const
|
||||
{
|
||||
*aNameSpaceID = kNameSpaceID_None;
|
||||
@ -752,11 +748,10 @@ nsGenericDOMDataNode::GetAttrNameAt(PRInt32 aIndex, PRInt32* aNameSpaceID,
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::GetAttrCount(PRInt32& aResult) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsGenericDOMDataNode::GetAttrCount() const
|
||||
{
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -857,51 +852,45 @@ nsGenericDOMDataNode::SetContentID(PRUint32 aID)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::GetNodeInfo(nsINodeInfo** aResult) const
|
||||
NS_IMETHODIMP_(nsINodeInfo *)
|
||||
nsGenericDOMDataNode::GetNodeInfo() const
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsGenericDOMDataNode::CanContainChildren() const
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsGenericDOMDataNode::GetChildCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIContent *)
|
||||
nsGenericDOMDataNode::GetChildAt(PRUint32 aIndex) const
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsGenericDOMDataNode::IndexOf(nsIContent* aPossibleChild) const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::CanContainChildren(PRBool& aResult) const
|
||||
{
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::ChildCount(PRInt32& aResult) const
|
||||
{
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::ChildAt(PRInt32 aIndex, nsIContent** aResult) const
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::IndexOf(nsIContent* aPossibleChild,
|
||||
PRInt32& aResult) const
|
||||
{
|
||||
aResult = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsGenericDOMDataNode::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
return NS_OK;
|
||||
@ -915,7 +904,7 @@ nsGenericDOMDataNode::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsGenericDOMDataNode::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1124,14 +1113,11 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
|
||||
nsIContent* parentNode = GetParentWeak();
|
||||
|
||||
if (parentNode) {
|
||||
PRInt32 index;
|
||||
PRInt32 index = parentNode->IndexOf(this);
|
||||
|
||||
rv = parentNode->IndexOf(this, index);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(newNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(newNode));
|
||||
|
||||
rv = parentNode->InsertChildAt(content, index+1, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
parentNode->InsertChildAt(content, index+1, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
|
||||
return CallQueryInterface(newNode, aReturn);
|
||||
@ -1355,7 +1341,9 @@ nsGenericDOMDataNode::AppendTextTo(nsAString& aResult)
|
||||
if (mText.Is2b()) {
|
||||
aResult.Append(mText.Get2b(), mText.GetLength());
|
||||
} else {
|
||||
|
||||
// XXX we would like to have a AppendASCIItoUCS2 here
|
||||
|
||||
aResult.Append(NS_ConvertASCIItoUCS2(mText.Get1b(),
|
||||
mText.GetLength()).get(),
|
||||
mText.GetLength());
|
||||
|
||||
@ -190,9 +190,9 @@ public:
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsIAtom** aPrefix, nsAString& aResult) const;
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const;
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex, PRInt32* aNameSpaceID,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName, nsIAtom** aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
|
||||
@ -216,18 +216,18 @@ public:
|
||||
NS_IMETHOD GetBaseURL(nsIURI** aURI) const;
|
||||
NS_IMETHOD DoneCreatingElement();
|
||||
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const;
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const;
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
// nsITextContent
|
||||
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -372,41 +372,7 @@ public:
|
||||
NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous);
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32* aNameSpaceID) const;
|
||||
NS_IMETHOD GetTag(nsIAtom** aResult) const;
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const;
|
||||
// NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
// NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
// NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
// NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
// NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
// NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
// NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
// nsINodeInfo** aNodeInfo);
|
||||
// NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// const nsAString& aValue,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
// const nsAString& aValue,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// nsAString& aResult) const;
|
||||
// NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// nsIAtom** aPrefix,
|
||||
// nsAString& aResult) const;
|
||||
// NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
// PRInt32& aNameSpaceID,
|
||||
// nsIAtom** aName,
|
||||
// nsIAtom** aPrefix) const;
|
||||
// NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
#ifdef DEBUG
|
||||
// NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
// NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
#endif
|
||||
NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const;
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange* aRange);
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange* aRange);
|
||||
NS_IMETHOD GetRangeList(nsVoidArray** aResult) const;
|
||||
@ -800,26 +766,26 @@ public:
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
#endif
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
#ifdef DEBUG
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
@ -563,12 +563,12 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
nsAString& aStr)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 index, count;
|
||||
PRUint32 index, count;
|
||||
nsAutoString nameStr, valueStr;
|
||||
PRInt32 namespaceID;
|
||||
nsCOMPtr<nsIAtom> attrName, attrPrefix;
|
||||
|
||||
aContent->GetAttrCount(count);
|
||||
count = aContent->GetAttrCount();
|
||||
|
||||
NS_NAMED_LITERAL_STRING(_mozStr, "_moz");
|
||||
|
||||
|
||||
@ -470,8 +470,7 @@ nsImageLoadingContent::ImageURIChanged(const nsACString& aNewURI)
|
||||
// and it's not of the right type, reframe it.
|
||||
PRInt32 numShells = doc->GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < numShells; ++i) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(i, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(i);
|
||||
if (shell) {
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(thisContent, &frame);
|
||||
@ -556,8 +555,7 @@ nsImageLoadingContent::GetOurDocument()
|
||||
|
||||
if (!doc) { // nodeinfo time
|
||||
// XXXbz GetOwnerDocument
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
thisContent->GetNodeInfo(getter_AddRefs(nodeInfo));
|
||||
nsINodeInfo *nodeInfo = thisContent->GetNodeInfo();
|
||||
if (nodeInfo) {
|
||||
doc = nodeInfo->GetDocument();
|
||||
}
|
||||
@ -687,8 +685,7 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
document->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
document->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = document->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
|
||||
@ -45,9 +45,10 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsNodeInfoManager* nsNodeInfoManager::gAnonymousNodeInfoManager = nsnull;
|
||||
PRUint32 nsNodeInfoManager::gNodeManagerCount = 0;
|
||||
nsNodeInfoManager* nsNodeInfoManager::gAnonymousNodeInfoManager;
|
||||
PRUint32 nsNodeInfoManager::gNodeManagerCount;
|
||||
|
||||
|
||||
nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult)
|
||||
@ -286,24 +287,30 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
|
||||
{
|
||||
NS_ENSURE_ARG(!aQualifiedName.IsEmpty());
|
||||
|
||||
nsAutoString name(aQualifiedName);
|
||||
nsAutoString prefix;
|
||||
PRInt32 nsoffset = name.FindChar(':');
|
||||
if (-1 != nsoffset) {
|
||||
name.Left(prefix, nsoffset);
|
||||
name.Cut(0, nsoffset+1);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(name);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsAString::const_iterator start, end;
|
||||
aQualifiedName.BeginReading(start);
|
||||
aQualifiedName.EndReading(end);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefixAtom;
|
||||
|
||||
if (!prefix.IsEmpty()) {
|
||||
prefixAtom = do_GetAtom(prefix);
|
||||
nsAString::const_iterator iter(start);
|
||||
|
||||
if (FindCharInReadable(':', iter, end)) {
|
||||
prefixAtom = do_GetAtom(Substring(start, iter));
|
||||
NS_ENSURE_TRUE(prefixAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
start = ++iter; // step over the ':'
|
||||
|
||||
if (iter == end) {
|
||||
// No data after the ':'.
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(Substring(start, end));
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRInt32 nsid = kNameSpaceID_None;
|
||||
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
@ -395,7 +402,10 @@ nsNodeInfoManager::RemoveNodeInfo(nsNodeInfo *aNodeInfo)
|
||||
NS_WARN_IF_FALSE(aNodeInfo, "Trying to remove null nodeinfo from manager!");
|
||||
|
||||
if (aNodeInfo) {
|
||||
PRBool ret = PL_HashTableRemove(mNodeInfoHash, &aNodeInfo->mInner);
|
||||
#ifdef DEBUG
|
||||
PRBool ret =
|
||||
#endif
|
||||
PL_HashTableRemove(mNodeInfoHash, &aNodeInfo->mInner);
|
||||
|
||||
NS_WARN_IF_FALSE(ret, "Can't find nsINodeInfo to remove!!!");
|
||||
}
|
||||
|
||||
@ -1973,8 +1973,7 @@ nsPrintEngine::MapContentForPO(nsPrintObject* aRootObject,
|
||||
nsCOMPtr<nsISupports> container;
|
||||
subDoc->GetContainer(getter_AddRefs(container));
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
subDoc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = subDoc->GetShellAt(0);
|
||||
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(container));
|
||||
|
||||
@ -2015,11 +2014,9 @@ nsPrintEngine::MapContentForPO(nsPrintObject* aRootObject,
|
||||
}
|
||||
|
||||
// walk children content
|
||||
PRInt32 count;
|
||||
aContent->ChildCount(count);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
PRUint32 count = aContent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
MapContentForPO(aRootObject, aPresShell, child);
|
||||
}
|
||||
}
|
||||
@ -2428,7 +2425,7 @@ nsPrintEngine::SetupToPrintContent(nsIDeviceContext* aDContext,
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
{
|
||||
float calcRatio;
|
||||
float calcRatio = 0.0f;
|
||||
if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
|
||||
nsPrintObject* smallestPO = FindSmallestSTF();
|
||||
NS_ASSERTION(smallestPO, "There must always be an XMost PO!");
|
||||
@ -3906,19 +3903,19 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Note this is also defined in DocumentViewerImpl
|
||||
nsIPresShell*
|
||||
nsPrintEngine::GetPresShellFor(nsIDocShell* aDocShell)
|
||||
// static
|
||||
nsIPresShell *
|
||||
GetPresShellFor(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
if (!domDoc) return nsnull;
|
||||
if (!domDoc)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc) return nsnull;
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
nsIPresShell* shell = nsnull;
|
||||
doc->GetShellAt(0, &shell);
|
||||
|
||||
return shell;
|
||||
return doc->GetShellAt(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -4780,7 +4777,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
|
||||
if (nsnull != aDocShell) {
|
||||
fprintf(out, "docshell=%p \n", aDocShell);
|
||||
nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell);
|
||||
if (nsnull != shell) {
|
||||
if (shell) {
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
nsIView* root;
|
||||
@ -4789,7 +4786,6 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
|
||||
root->List(out);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
else {
|
||||
fputs("null pres shell\n", out);
|
||||
|
||||
@ -281,9 +281,8 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> theDOMNode( do_QueryInterface(aNode) );
|
||||
PRInt32 indx;
|
||||
theDOMNode->GetParentNode(getter_AddRefs(*outParent));
|
||||
|
||||
|
||||
if (!(*outParent)) // special case for root node
|
||||
{
|
||||
// can't make a parent/offset pair to represent start or
|
||||
@ -293,8 +292,8 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
|
||||
nsCOMPtr<nsIContent> cN(do_QueryInterface(*outParent));
|
||||
if (!cN)
|
||||
return PR_FALSE;
|
||||
cN->ChildCount(indx);
|
||||
if (!indx)
|
||||
PRUint32 indx = cN->GetChildCount();
|
||||
if (!indx)
|
||||
return PR_FALSE;
|
||||
*outStartOffset = 0;
|
||||
*outEndOffset = indx;
|
||||
@ -654,24 +653,24 @@ PRInt32 nsRange::GetNodeLength(nsIDOMNode *aNode)
|
||||
{
|
||||
if (!aNode)
|
||||
return 0;
|
||||
|
||||
|
||||
PRUint16 nodeType;
|
||||
PRUint32 len = -1;
|
||||
|
||||
PRInt32 len = -1;
|
||||
|
||||
aNode->GetNodeType(&nodeType);
|
||||
if( (nodeType == nsIDOMNode::CDATA_SECTION_NODE) ||
|
||||
(nodeType == nsIDOMNode::TEXT_NODE) )
|
||||
{
|
||||
nsCOMPtr<nsIDOMText> textText = do_QueryInterface(aNode);
|
||||
if (textText)
|
||||
textText->GetLength(&len);
|
||||
textText->GetLength((PRUint32 *)&len);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIDOMNodeList> childList;
|
||||
nsresult res = aNode->GetChildNodes(getter_AddRefs(childList));
|
||||
if (NS_SUCCEEDED(res) && childList)
|
||||
childList->GetLength(&len);
|
||||
childList->GetLength((PRUint32 *)&len);
|
||||
}
|
||||
|
||||
return len;
|
||||
@ -849,31 +848,19 @@ PRBool nsRange::IsIncreasing(nsIDOMNode* aStartN, PRInt32 aStartOffset,
|
||||
|
||||
PRInt32 nsRange::IndexOf(nsIDOMNode* aChildNode)
|
||||
{
|
||||
if (!aChildNode)
|
||||
// convert node to nsIContent, so that we can find the child index
|
||||
|
||||
nsCOMPtr<nsIContent> contentChild = do_QueryInterface(aChildNode);
|
||||
if (!contentChild)
|
||||
return 0;
|
||||
|
||||
// get the parent node
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
nsresult res = aChildNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
if (NS_FAILED(res))
|
||||
return 0;
|
||||
|
||||
// convert node and parent to nsIContent, so that we can find the child index
|
||||
nsCOMPtr<nsIContent> contentParent = do_QueryInterface(parentNode, &res);
|
||||
if (NS_FAILED(res))
|
||||
nsIContent *parent = contentChild->GetParent();
|
||||
|
||||
if (!parent)
|
||||
return 0;
|
||||
|
||||
nsCOMPtr<nsIContent> contentChild = do_QueryInterface(aChildNode, &res);
|
||||
if (NS_FAILED(res))
|
||||
return 0;
|
||||
|
||||
// finally we get the index
|
||||
PRInt32 theIndex = 0;
|
||||
res = contentParent->IndexOf(contentChild,theIndex);
|
||||
if (NS_FAILED(res))
|
||||
return 0;
|
||||
|
||||
return theIndex;
|
||||
return parent->IndexOf(contentChild);
|
||||
}
|
||||
|
||||
nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent* aSourceNode)
|
||||
@ -1177,9 +1164,7 @@ nsresult nsRange::SelectNode(nsIDOMNode* aN)
|
||||
parent = aN;//parent is now equal to the node you passed in
|
||||
// which is the root. start is zero, end is the number of children
|
||||
start = 0;
|
||||
res = content->ChildCount(end);
|
||||
if (NS_FAILED(res))
|
||||
return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR;
|
||||
end = content->GetChildCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -205,9 +205,8 @@ nsScriptLoader::InNonScriptingContainer(nsIDOMHTMLScriptElement* aScriptElement)
|
||||
if (!content) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
content->GetNodeInfo(getter_AddRefs(nodeInfo));
|
||||
|
||||
nsINodeInfo *nodeInfo = content->GetNodeInfo();
|
||||
NS_ASSERTION(nodeInfo, "element without node info");
|
||||
|
||||
if (nodeInfo) {
|
||||
|
||||
@ -1102,8 +1102,6 @@ nsSelection::GetRootForContentSubtree(nsIContent *aContent, nsIContent **aParent
|
||||
// as a child of it's parent. In this case, the anonymous content would
|
||||
// be considered the root of the subtree.
|
||||
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (!aContent || !aParent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -1118,23 +1116,14 @@ nsSelection::GetRootForContentSubtree(nsIContent *aContent, nsIContent **aParent
|
||||
if (!parent)
|
||||
break;
|
||||
|
||||
PRInt32 childIndex = 0;
|
||||
PRInt32 childCount = 0;
|
||||
|
||||
result = parent->ChildCount(childCount);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
PRUint32 childCount = parent->GetChildCount();
|
||||
|
||||
if (childCount < 1)
|
||||
break;
|
||||
|
||||
result = parent->IndexOf(child, childIndex);
|
||||
PRInt32 childIndex = parent->IndexOf(child);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (childIndex < 0 || childIndex >= childCount)
|
||||
if (childIndex < 0 || ((PRUint32)childIndex) >= childCount)
|
||||
break;
|
||||
|
||||
child = parent;
|
||||
@ -1142,7 +1131,7 @@ nsSelection::GetRootForContentSubtree(nsIContent *aContent, nsIContent **aParent
|
||||
|
||||
NS_IF_ADDREF(*aParent = child);
|
||||
|
||||
return result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1363,20 +1352,20 @@ ParentOffset(nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset)
|
||||
{
|
||||
if (!aNode || !aParent || !aChildOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode, &result);
|
||||
if (NS_SUCCEEDED(result) && content)
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (content)
|
||||
{
|
||||
nsIContent* parent = content->GetParent();
|
||||
if (parent)
|
||||
{
|
||||
result = parent->IndexOf(content, *aChildOffset);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = CallQueryInterface(parent, aParent);
|
||||
}
|
||||
*aChildOffset = parent->IndexOf(content);
|
||||
|
||||
return CallQueryInterface(parent, aParent);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMNode *
|
||||
@ -1777,15 +1766,19 @@ nsTypedSelection::GetInterlinePosition(PRBool *aHintRight)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsDirection ReverseDirection(nsDirection aDirection)
|
||||
#ifdef VISUALSELECTION
|
||||
|
||||
static nsDirection
|
||||
ReverseDirection(nsDirection aDirection)
|
||||
{
|
||||
return (eDirNext == aDirection) ? eDirPrevious : eDirNext;
|
||||
}
|
||||
|
||||
nsresult FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
|
||||
static nsresult
|
||||
FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
|
||||
{
|
||||
nsIFrame *blockFrame = aFrame;
|
||||
nsIFrame *thisBlock;
|
||||
nsIFrame *thisBlock = nsnull;
|
||||
nsCOMPtr<nsILineIteratorNavigator> it;
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
while (NS_FAILED(result) && blockFrame)
|
||||
@ -1802,7 +1795,6 @@ nsresult FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
|
||||
return it->FindLineContaining(thisBlock, aLine);
|
||||
}
|
||||
|
||||
#ifdef VISUALSELECTION
|
||||
NS_IMETHODIMP
|
||||
nsSelection::VisualSequence(nsIPresContext *aPresContext,
|
||||
nsIFrame* aSelectFrame,
|
||||
@ -2235,7 +2227,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
|
||||
*/
|
||||
|
||||
nsIFrame *blockFrame = currentFrame;
|
||||
nsIFrame *thisBlock;
|
||||
nsIFrame *thisBlock = nsnull;
|
||||
PRInt32 thisLine;
|
||||
nsCOMPtr<nsILineIteratorNavigator> it;
|
||||
result = NS_ERROR_FAILURE;
|
||||
@ -2953,17 +2945,11 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin
|
||||
|
||||
*aReturnOffset = aOffset;
|
||||
|
||||
nsresult result;
|
||||
PRBool canContainChildren = PR_FALSE;
|
||||
|
||||
result = aNode->CanContainChildren(canContainChildren);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContent> theNode = aNode;
|
||||
|
||||
if (canContainChildren)
|
||||
if (aNode->CanContainChildren())
|
||||
{
|
||||
PRInt32 childIndex = 0;
|
||||
PRInt32 numChildren = 0;
|
||||
@ -2977,10 +2963,7 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin
|
||||
}
|
||||
else // HINTRIGHT
|
||||
{
|
||||
result = theNode->ChildCount(numChildren);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
numChildren = theNode->GetChildCount();
|
||||
|
||||
if (aOffset >= numChildren)
|
||||
{
|
||||
@ -2993,12 +2976,7 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin
|
||||
childIndex = aOffset;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> childNode;
|
||||
|
||||
result = theNode->ChildAt(childIndex, getter_AddRefs(childNode));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
nsCOMPtr<nsIContent> childNode = theNode->GetChildAt(childIndex);
|
||||
|
||||
if (!childNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -3012,21 +2990,13 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin
|
||||
// Now that we have the child node, check if it too
|
||||
// can contain children. If so, call this method again!
|
||||
|
||||
result = theNode->CanContainChildren(canContainChildren);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (canContainChildren)
|
||||
if (theNode->CanContainChildren())
|
||||
{
|
||||
PRInt32 newOffset = 0;
|
||||
|
||||
if (aOffset > childIndex)
|
||||
{
|
||||
result = theNode->ChildCount(numChildren);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
numChildren = theNode->GetChildCount();
|
||||
|
||||
newOffset = numChildren;
|
||||
}
|
||||
@ -3253,8 +3223,7 @@ NS_IMETHODIMP nsSelection::SelectAll()
|
||||
if (!rootContent)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PRInt32 numChildren;
|
||||
rootContent->ChildCount(numChildren);
|
||||
PRInt32 numChildren = rootContent->GetChildCount();
|
||||
PostReason(nsISelectionListener::NO_REASON);
|
||||
return TakeFocus(mLimiter, 0, numChildren, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
@ -3378,21 +3347,19 @@ nsSelection::HandleTableSelection(nsIContent *aParentContent, PRInt32 aContentOf
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(aParentContent);
|
||||
if (!parentNode) return NS_ERROR_FAILURE;
|
||||
if (!parentNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> childContent;
|
||||
nsresult result =
|
||||
aParentContent->ChildAt(aContentOffset,
|
||||
getter_AddRefs(childContent));
|
||||
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!childContent) return NS_ERROR_FAILURE;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsIContent *childContent = aParentContent->GetChildAt(aContentOffset);
|
||||
nsCOMPtr<nsIDOMNode> childNode = do_QueryInterface(childContent);
|
||||
if (!childNode) return NS_ERROR_FAILURE;
|
||||
if (!childNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// When doing table selection, always set the direction to next
|
||||
// so we can be sure that anchorNode's offset always points to the selected cell
|
||||
// When doing table selection, always set the direction to next so
|
||||
// we can be sure that anchorNode's offset always points to the
|
||||
// selected cell
|
||||
PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL);
|
||||
mDomSelections[index]->SetDirection(eDirNext);
|
||||
|
||||
@ -3648,9 +3615,7 @@ printf("HandleTableSelection: Unselecting mUnselectCellOnMouseUp; rangeCount=%d\
|
||||
range->GetStartOffset(&offset);
|
||||
// Be sure previous selection is a table cell
|
||||
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
result = parentContent->ChildAt(offset, getter_AddRefs(child));
|
||||
if (NS_FAILED(result)) return result;
|
||||
nsCOMPtr<nsIContent> child = parentContent->GetChildAt(offset);
|
||||
if (child && IsCell(child))
|
||||
previousCellParent = parent;
|
||||
|
||||
@ -3932,18 +3897,20 @@ nsSelection::GetFirstCellNodeInRange(nsIDOMRange *aRange, nsIDOMNode **aCellNode
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startParent;
|
||||
nsresult result = aRange->GetStartContainer(getter_AddRefs(startParent));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!startParent) return NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
if (!startParent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 offset;
|
||||
result = aRange->GetStartOffset(&offset);
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(startParent);
|
||||
nsCOMPtr<nsIContent> childContent;
|
||||
result = parentContent->ChildAt(offset, getter_AddRefs(childContent));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!childContent) return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIContent> childContent = parentContent->GetChildAt(offset);
|
||||
if (!childContent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
// Don't return node if not a cell
|
||||
if (!IsCell(childContent)) return NS_OK;
|
||||
|
||||
@ -4108,20 +4075,22 @@ nsSelection::GetParentTable(nsIContent *aCell, nsIContent **aTable)
|
||||
nsresult
|
||||
nsSelection::SelectCellElement(nsIDOMElement *aCellElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> cellNode = do_QueryInterface(aCellElement);
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsresult result = cellNode->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!parent) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIContent> cellContent = do_QueryInterface(aCellElement);
|
||||
|
||||
if (!cellContent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIContent *parent = cellContent->GetParent();
|
||||
nsCOMPtr<nsIDOMNode> parentNode(do_QueryInterface(parent));
|
||||
if (!parentNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get child offset
|
||||
PRInt32 offset;
|
||||
result = parentContent->IndexOf(cellContent, offset);
|
||||
if (NS_FAILED(result)) return result;
|
||||
return CreateAndAddRange(parent, offset);
|
||||
PRInt32 offset = parent->IndexOf(cellContent);
|
||||
|
||||
return CreateAndAddRange(parentNode, offset);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -4150,24 +4119,28 @@ nsTypedSelection::getTableCellLocationFromRange(nsIDOMRange *aRange, PRInt32 *aS
|
||||
// us that this really is a table cell
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
result = aRange->GetStartContainer(getter_AddRefs(startNode));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(startNode));
|
||||
if (!content) return NS_ERROR_FAILURE;
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
PRInt32 startOffset;
|
||||
result = aRange->GetStartOffset(&startOffset);
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
result = content->ChildAt(startOffset, getter_AddRefs(child));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!child) return NS_ERROR_FAILURE;
|
||||
nsIContent *child = content->GetChildAt(startOffset);
|
||||
if (!child)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
//Note: This is a non-ref-counted pointer to the frame
|
||||
nsITableCellLayout *cellLayout = mFrameSelection->GetCellLayout(child);
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!cellLayout) return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
if (!cellLayout)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return cellLayout->GetCellIndexes(*aRow, *aCol);
|
||||
}
|
||||
|
||||
@ -4270,12 +4243,9 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(startNode);
|
||||
if (!content) return NS_ERROR_FAILURE;
|
||||
|
||||
//if we simply cannot have children, return NS_OK as a non-failing, non-completing case for table selection
|
||||
PRBool canContainChildren = PR_FALSE;
|
||||
result = content->CanContainChildren(canContainChildren);
|
||||
if (NS_FAILED(result))
|
||||
return result;//simply asking should NOT fail
|
||||
if (!canContainChildren)
|
||||
// if we simply cannot have children, return NS_OK as a non-failing,
|
||||
// non-completing case for table selection
|
||||
if (!content->CanContainChildren())
|
||||
return NS_OK; //got to be a text node, definately not a table row/cell
|
||||
|
||||
PRInt32 startOffset;
|
||||
@ -4299,13 +4269,11 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele
|
||||
}
|
||||
else //check to see if we are selecting a table or row (column and all cells not done yet)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
result = content->ChildAt(startOffset, getter_AddRefs(child));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!child) return NS_ERROR_FAILURE;
|
||||
nsIContent *child = content->GetChildAt(startOffset);
|
||||
if (!child)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
child->GetTag(getter_AddRefs(atom));
|
||||
if (!atom) return NS_ERROR_FAILURE;
|
||||
|
||||
if (atom == nsHTMLAtoms::table)
|
||||
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE;
|
||||
@ -4357,9 +4325,8 @@ nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsCOMPtr<nsIContent> parentContent = selectAllContent->GetParent();
|
||||
if (parentContent)
|
||||
{
|
||||
PRInt32 startOffset;
|
||||
rv = parentContent->IndexOf(selectAllContent, startOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRInt32 startOffset = parentContent->IndexOf(selectAllContent);
|
||||
|
||||
if (startOffset < 0)
|
||||
{
|
||||
// hrmm, this is probably anonymous content. Let's go up another level
|
||||
@ -4367,9 +4334,7 @@ nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsCOMPtr<nsIContent> superParent = parentContent->GetParent();
|
||||
if (superParent)
|
||||
{
|
||||
PRInt32 superStartOffset;
|
||||
rv = superParent->IndexOf(parentContent, superStartOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRInt32 superStartOffset = superParent->IndexOf(parentContent);
|
||||
if (superStartOffset < 0)
|
||||
return NS_ERROR_FAILURE; // give up
|
||||
|
||||
@ -4922,24 +4887,18 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf
|
||||
if (!content)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRBool canContainChildren = PR_FALSE;
|
||||
|
||||
result = content->CanContainChildren(canContainChildren);
|
||||
|
||||
if (NS_SUCCEEDED(result) && canContainChildren)
|
||||
if (content->CanContainChildren())
|
||||
{
|
||||
if (aIsEndNode)
|
||||
aOffset--;
|
||||
|
||||
if (aOffset >= 0)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
result = content->ChildAt(aOffset, getter_AddRefs(child));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
nsIContent *child = content->GetChildAt(aOffset);
|
||||
if (!child) //out of bounds?
|
||||
return NS_ERROR_FAILURE;
|
||||
content = child;//releases the focusnode
|
||||
|
||||
content = child; // releases the focusnode
|
||||
}
|
||||
}
|
||||
result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content,aReturnFrame);
|
||||
@ -5133,9 +5092,8 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange
|
||||
content = do_QueryInterface(FetchStartParent(aRange), &result);
|
||||
if (NS_FAILED(result) || !content)
|
||||
return result;
|
||||
PRBool canContainChildren = PR_FALSE;
|
||||
result = content->CanContainChildren(canContainChildren);
|
||||
if (NS_SUCCEEDED(result) && !canContainChildren)
|
||||
|
||||
if (!content->CanContainChildren())
|
||||
{
|
||||
result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame);
|
||||
if (NS_SUCCEEDED(result) && frame)
|
||||
@ -5157,9 +5115,8 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange
|
||||
content = do_QueryInterface(FetchEndParent(aRange), &result);
|
||||
if (NS_FAILED(result) || !content)
|
||||
return result;
|
||||
canContainChildren = PR_FALSE;
|
||||
result = content->CanContainChildren(canContainChildren);
|
||||
if (NS_SUCCEEDED(result) && !canContainChildren)
|
||||
|
||||
if (!content->CanContainChildren())
|
||||
{
|
||||
result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame);
|
||||
if (NS_SUCCEEDED(result) && frame)
|
||||
@ -6798,15 +6755,19 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
}
|
||||
|
||||
static inline nsresult GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset)
|
||||
static nsresult
|
||||
GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset)
|
||||
{
|
||||
NS_ASSERTION((aChild && aParent), "bad args");
|
||||
if (!aChild || !aParent) return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
|
||||
nsCOMPtr<nsIContent> cChild = do_QueryInterface(aChild);
|
||||
if (!cChild || !content) return NS_ERROR_NULL_POINTER;
|
||||
nsresult res = content->IndexOf(cChild, aOffset);
|
||||
return res;
|
||||
|
||||
if (!cChild || !content)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
aOffset = content->IndexOf(cChild);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -271,18 +271,14 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
PRBool doneLoading;
|
||||
nsresult rv = NS_OK;
|
||||
if (isInline) {
|
||||
PRInt32 count;
|
||||
thisContent->ChildCount(count);
|
||||
if (count < 0)
|
||||
return NS_OK;
|
||||
PRUint32 count = thisContent->GetChildCount();
|
||||
|
||||
nsString *content = new nsString();
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRInt32 i;
|
||||
nsCOMPtr<nsIContent> node;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
thisContent->ChildAt(i, getter_AddRefs(node));
|
||||
nsIContent *node = thisContent->GetChildAt(i);
|
||||
nsCOMPtr<nsIDOMText> tc = do_QueryInterface(node);
|
||||
// Ignore nodes that are not DOMText.
|
||||
if (!tc) {
|
||||
|
||||
@ -622,15 +622,13 @@ nsresult nsTreeWalker::IndexOf(nsIDOMNode* aParent,
|
||||
nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
|
||||
|
||||
if (possibleIndex >= 0) {
|
||||
nsCOMPtr<nsIContent> tmp;
|
||||
contParent->ChildAt(possibleIndex, getter_AddRefs(tmp));
|
||||
if (tmp == child) {
|
||||
if (child == contParent->GetChildAt(possibleIndex)) {
|
||||
*_childNum = possibleIndex;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
contParent->IndexOf(child, *_childNum);
|
||||
*_childNum = contParent->IndexOf(child);
|
||||
|
||||
return *_childNum >= 0 ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
@ -640,15 +638,13 @@ nsresult nsTreeWalker::IndexOf(nsIDOMNode* aParent,
|
||||
nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
|
||||
|
||||
if (possibleIndex >= 0) {
|
||||
nsCOMPtr<nsIContent> tmp;
|
||||
docParent->ChildAt(possibleIndex, getter_AddRefs(tmp));
|
||||
if (tmp == child) {
|
||||
if (child == docParent->GetChildAt(possibleIndex)) {
|
||||
*_childNum = possibleIndex;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
docParent->IndexOf(child, *_childNum);
|
||||
*_childNum = docParent->IndexOf(child);
|
||||
|
||||
return *_childNum >= 0 ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
@ -487,12 +487,12 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
|
||||
PRInt32 namespaceID;
|
||||
|
||||
PRInt32 index, count;
|
||||
PRUint32 index, count;
|
||||
nsAutoString nameStr, prefixStr, uriStr, valueStr;
|
||||
nsCOMPtr<nsIAtom> attrName, attrPrefix;
|
||||
|
||||
content->GetAttrCount(count);
|
||||
|
||||
count = content->GetAttrCount();
|
||||
|
||||
// First scan for namespace declarations, pushing each on the stack
|
||||
for (index = 0; index < count; index++) {
|
||||
|
||||
|
||||
@ -1883,8 +1883,7 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
||||
|
||||
if (!document) {
|
||||
// XXXbz GetOwnerDocument
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
targetContent->GetNodeInfo(getter_AddRefs(nodeInfo));
|
||||
nsINodeInfo *nodeInfo = targetContent->GetNodeInfo();
|
||||
if (nodeInfo) {
|
||||
document = nodeInfo->GetDocument();
|
||||
}
|
||||
@ -1896,8 +1895,7 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
||||
}
|
||||
|
||||
// Obtain a presentation shell
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
document->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = document->GetShellAt(0);
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIWidget.h"
|
||||
@ -487,8 +488,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
||||
if (gLastFocusedContent) // could have changed in HandleDOMEvent
|
||||
doc = gLastFocusedContent->GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> oldPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
||||
@ -639,8 +639,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
||||
// in the Ender widget case.
|
||||
nsCOMPtr<nsIDocument> doc = gLastFocusedContent->GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> oldPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
||||
@ -734,8 +733,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
||||
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDoc);
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
document->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = document->GetShellAt(0);
|
||||
NS_ASSERTION(shell, "Focus events should not be getting thru when this is null!");
|
||||
if (shell) {
|
||||
if (focusedElement) {
|
||||
@ -805,8 +803,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
||||
event.flags = 0;
|
||||
|
||||
if (gLastFocusedContent) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
gLastFocusedDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = gLastFocusedDocument->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> oldPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
||||
@ -1532,8 +1529,7 @@ nsEventStateManager::ChangeTextSize(PRInt32 change)
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
if(!doc) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
if(!presShell) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
@ -1778,8 +1774,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> pPresShell;
|
||||
parentDoc->GetShellAt(0, getter_AddRefs(pPresShell));
|
||||
nsIPresShell *pPresShell = parentDoc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(pPresShell, NS_ERROR_FAILURE);
|
||||
|
||||
/* now find the content node in our parent docshell's document that
|
||||
@ -2557,8 +2552,7 @@ nsEventStateManager::MaybeDispatchMouseEventToIframe(
|
||||
docContent->GetTag(getter_AddRefs(tag));
|
||||
if (tag == nsHTMLAtoms::iframe) {
|
||||
// We're an IFRAME. Send an event to our IFRAME tag.
|
||||
nsCOMPtr<nsIPresShell> parentShell;
|
||||
parentDoc->GetShellAt(0, getter_AddRefs(parentShell));
|
||||
nsIPresShell *parentShell = parentDoc->GetShellAt(0);
|
||||
if (parentShell) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
@ -3563,12 +3557,11 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
|
||||
if (NS_SUCCEEDED(nsImageMapUtils::FindImageMap(doc,usemap,getter_AddRefs(imageMap))) && imageMap) {
|
||||
nsCOMPtr<nsIContent> map(do_QueryInterface(imageMap));
|
||||
if (map) {
|
||||
nsCOMPtr<nsIContent> childArea;
|
||||
PRInt32 count, index;
|
||||
map->ChildCount(count);
|
||||
//First see if mCurrentFocus is in this map
|
||||
nsIContent *childArea;
|
||||
PRUint32 index, count = map->GetChildCount();
|
||||
// First see if mCurrentFocus is in this map
|
||||
for (index = 0; index < count; index++) {
|
||||
map->ChildAt(index, getter_AddRefs(childArea));
|
||||
childArea = map->GetChildAt(index);
|
||||
if (childArea == mCurrentFocus) {
|
||||
PRInt32 val = 0;
|
||||
TabIndexFrom(childArea, &val);
|
||||
@ -3587,7 +3580,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
|
||||
PRInt32 start = index < count ? index + increment : (forward ? 0 : count - 1);
|
||||
for (index = start; index < count && index >= 0; index += increment) {
|
||||
//Iterate over the children.
|
||||
map->ChildAt(index, getter_AddRefs(childArea));
|
||||
childArea = map->GetChildAt(index);
|
||||
|
||||
//Got the map area, check its tabindex.
|
||||
PRInt32 val = 0;
|
||||
@ -3703,15 +3696,15 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
|
||||
PRInt32
|
||||
nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||
{
|
||||
PRInt32 count, tabIndex, childTabIndex;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
||||
aParent->ChildCount(count);
|
||||
PRInt32 tabIndex, childTabIndex;
|
||||
nsIContent *child;
|
||||
|
||||
PRUint32 count = aParent->GetChildCount();
|
||||
|
||||
if (forward) {
|
||||
tabIndex = 0;
|
||||
for (PRInt32 index = 0; index < count; index++) {
|
||||
aParent->ChildAt(index, getter_AddRefs(child));
|
||||
for (PRUint32 index = 0; index < count; index++) {
|
||||
child = aParent->GetChildAt(index);
|
||||
childTabIndex = GetNextTabIndex(child, forward);
|
||||
if (childTabIndex > mCurrentTabIndex && childTabIndex != tabIndex) {
|
||||
tabIndex = (tabIndex == 0 || childTabIndex < tabIndex) ? childTabIndex : tabIndex;
|
||||
@ -3727,10 +3720,10 @@ nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||
}
|
||||
else { /* !forward */
|
||||
tabIndex = 1;
|
||||
for (PRInt32 index = 0; index < count; index++) {
|
||||
aParent->ChildAt(index, getter_AddRefs(child));
|
||||
for (PRUint32 index = 0; index < count; index++) {
|
||||
child = aParent->GetChildAt(index);
|
||||
childTabIndex = GetNextTabIndex(child, forward);
|
||||
if ((mCurrentTabIndex==0 && childTabIndex > tabIndex) ||
|
||||
if ((mCurrentTabIndex == 0 && childTabIndex > tabIndex) ||
|
||||
(childTabIndex < mCurrentTabIndex && childTabIndex > tabIndex)) {
|
||||
tabIndex = childTabIndex;
|
||||
}
|
||||
@ -3739,7 +3732,7 @@ nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||
child->GetAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex, tabIndexStr);
|
||||
PRInt32 ec, val = tabIndexStr.ToInteger(&ec);
|
||||
if (NS_SUCCEEDED (ec)) {
|
||||
if ((mCurrentTabIndex==0 && val > tabIndex) ||
|
||||
if ((mCurrentTabIndex == 0 && val > tabIndex) ||
|
||||
(val < mCurrentTabIndex && val > tabIndex) ) {
|
||||
tabIndex = val;
|
||||
}
|
||||
@ -4152,8 +4145,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||
// associated view manager on exit from this function.
|
||||
// See bug 53763.
|
||||
nsCOMPtr<nsIViewManager> kungFuDeathGrip;
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
kungFuDeathGrip = shell->GetViewManager();
|
||||
|
||||
@ -4371,8 +4363,7 @@ nsEventStateManager::GetFocusedFrame(nsIFrame** aFrame)
|
||||
if (!mCurrentFocusFrame && mCurrentFocus) {
|
||||
nsIDocument* doc = mCurrentFocus->GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
shell->GetPrimaryFrameFor(mCurrentFocus, &mCurrentFocusFrame);
|
||||
if (mCurrentFocusFrame)
|
||||
@ -4601,8 +4592,11 @@ nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult)
|
||||
}
|
||||
|
||||
|
||||
nsresult nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, nsIContent **aEndContent,
|
||||
nsIFrame **aStartFrame, PRUint32* aStartOffset)
|
||||
nsresult
|
||||
nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent,
|
||||
nsIContent **aEndContent,
|
||||
nsIFrame **aStartFrame,
|
||||
PRUint32* aStartOffset)
|
||||
{
|
||||
// In order to return the nsIContent and nsIFrame of the caret's position,
|
||||
// we need to get a pres shell, and then get the selection from it
|
||||
@ -4625,7 +4619,7 @@ nsresult nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent
|
||||
nsCOMPtr<nsISelection> domSelection;
|
||||
if (frameSelection)
|
||||
rv = frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(domSelection));
|
||||
getter_AddRefs(domSelection));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
||||
PRBool isCollapsed = PR_FALSE;
|
||||
@ -4637,26 +4631,22 @@ nsresult nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent
|
||||
if (domRange) {
|
||||
domRange->GetStartContainer(getter_AddRefs(startNode));
|
||||
domRange->GetEndContainer(getter_AddRefs(endNode));
|
||||
typedef PRInt32* PRInt32_ptr;
|
||||
domRange->GetStartOffset(PRInt32_ptr(aStartOffset));
|
||||
domRange->GetStartOffset(NS_REINTERPRET_CAST(PRInt32 *, aStartOffset));
|
||||
|
||||
nsCOMPtr<nsIContent> childContent;
|
||||
PRBool canContainChildren;
|
||||
nsIContent *childContent = nsnull;
|
||||
|
||||
startContent = do_QueryInterface(startNode);
|
||||
if (NS_SUCCEEDED(startContent->CanContainChildren(canContainChildren)) &&
|
||||
canContainChildren) {
|
||||
startContent->ChildAt(*aStartOffset, getter_AddRefs(childContent));
|
||||
if (startContent->CanContainChildren()) {
|
||||
childContent = startContent->GetChildAt(*aStartOffset);
|
||||
if (childContent)
|
||||
startContent = childContent;
|
||||
}
|
||||
|
||||
endContent = do_QueryInterface(endNode);
|
||||
if (NS_SUCCEEDED(endContent->CanContainChildren(canContainChildren)) &&
|
||||
canContainChildren) {
|
||||
if (endContent->CanContainChildren()) {
|
||||
PRInt32 endOffset = 0;
|
||||
domRange->GetEndOffset(&endOffset);
|
||||
endContent->ChildAt(endOffset, getter_AddRefs(childContent));
|
||||
childContent = endContent->GetChildAt(endOffset);
|
||||
if (childContent)
|
||||
endContent = childContent;
|
||||
}
|
||||
@ -5123,14 +5113,14 @@ nsEventStateManager::IsFrameSetDoc(nsIDocShell* aDocShell)
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
doc->GetRootContent(getter_AddRefs(rootContent));
|
||||
if (rootContent) {
|
||||
PRInt32 childCount;
|
||||
rootContent->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIContent> childContent;
|
||||
rootContent->ChildAt(i, getter_AddRefs(childContent));
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
childContent->GetTag(getter_AddRefs(childTag));
|
||||
if (childTag == nsHTMLAtoms::frameset) {
|
||||
PRUint32 childCount = rootContent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent *childContent = rootContent->GetChildAt(i);
|
||||
|
||||
nsINodeInfo *ni = childContent->GetNodeInfo();
|
||||
|
||||
if (childContent->IsContentOfType(nsIContent::eHTML) &&
|
||||
ni->Equals(nsHTMLAtoms::frameset)) {
|
||||
isFrameSet = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -55,6 +55,15 @@ GenericElementCollection::~GenericElementCollection()
|
||||
// reference for us.
|
||||
}
|
||||
|
||||
static inline PRBool
|
||||
MatchHTMLTag(nsIContent *aContent, nsIAtom *aTag)
|
||||
{
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
return (ni && ni->Equals(aTag) &&
|
||||
aContent->IsContentOfType(nsIContent::eHTML));
|
||||
}
|
||||
|
||||
// we re-count every call. A better implementation would be to set ourselves
|
||||
// up as an observer of contentAppended, contentInserted, and contentDeleted.
|
||||
NS_IMETHODIMP
|
||||
@ -65,16 +74,13 @@ GenericElementCollection::GetLength(PRUint32* aLength)
|
||||
*aLength = 0;
|
||||
|
||||
if (mParent) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRUint32 childIndex = 0;
|
||||
mParent->ChildAt(childIndex, getter_AddRefs(child));
|
||||
while (child) {
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
child->GetTag(getter_AddRefs(childTag));
|
||||
if (mTag == childTag) {
|
||||
nsIContent *child;
|
||||
|
||||
while ((child = mParent->GetChildAt(childIndex++))) {
|
||||
if (MatchHTMLTag(child, mTag)) {
|
||||
++(*aLength);
|
||||
}
|
||||
mParent->ChildAt(++childIndex, getter_AddRefs(child));
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,15 +95,12 @@ GenericElementCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
*aReturn = nsnull;
|
||||
|
||||
if (mParent) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsIContent *child;
|
||||
PRUint32 childIndex = 0;
|
||||
mParent->ChildAt(childIndex, getter_AddRefs(child));
|
||||
|
||||
PRUint32 theIndex = 0;
|
||||
while (child) {
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
child->GetTag(getter_AddRefs(childTag));
|
||||
if (mTag == childTag) {
|
||||
while ((child = mParent->GetChildAt(childIndex++))) {
|
||||
if (MatchHTMLTag(child, mTag)) {
|
||||
if (aIndex == theIndex) {
|
||||
CallQueryInterface(child, aReturn);
|
||||
NS_ASSERTION(aReturn, "content element must be an nsIDOMNode");
|
||||
@ -106,7 +109,6 @@ GenericElementCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
}
|
||||
++theIndex;
|
||||
}
|
||||
mParent->ChildAt(++childIndex, getter_AddRefs(child));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -102,13 +102,11 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const
|
||||
NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
@ -151,13 +149,13 @@ public:
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const {
|
||||
return PR_FALSE;
|
||||
}
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex, PRInt32* aNameSpaceID, nsIAtom** aName, nsIAtom** aPrefix) const {
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID, nsIAtom** aName, nsIAtom** aPrefix) const {
|
||||
aName = nsnull;
|
||||
aPrefix = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const { aResult = 0; return NS_OK; }
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const { return 0; }
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { return NS_OK; }
|
||||
@ -183,19 +181,19 @@ public:
|
||||
NS_IMETHOD GetRangeList(nsVoidArray** aResult) const;
|
||||
|
||||
// Implementation for nsIContent
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { aResult = PR_FALSE; return NS_OK; }
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const { return PR_FALSE; }
|
||||
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { aResult = 0; return NS_OK; }
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const { aResult = nsnull; return NS_OK; }
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { aResult = -1; return NS_OK; }
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) { return NS_OK; }
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) { return NS_OK; }
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const { return 0; }
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const { return nsnull; }
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const { return -1; }
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) { return NS_OK; }
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) { return NS_OK; }
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) { return NS_OK; }
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn){ return NS_OK; }
|
||||
PRBool aDeepSetDocument) { return NS_OK; }
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn){ return NS_OK; }
|
||||
|
||||
///////////////////
|
||||
// Implementation for nsITextContent
|
||||
|
||||
@ -320,8 +320,7 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mAttributes) {
|
||||
PRInt32 index, count;
|
||||
GetAttrCount(count);
|
||||
PRUint32 index, count = GetAttrCount();
|
||||
nsCOMPtr<nsIAtom> name, prefix;
|
||||
PRInt32 namespace_id;
|
||||
nsAutoString value;
|
||||
@ -359,9 +358,11 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 id;
|
||||
if (mDocument) {
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
nsIDocument *doc = mNodeInfo->GetDocument();
|
||||
|
||||
PRInt32 id = PR_INT32_MAX;
|
||||
if (doc) {
|
||||
doc->GetAndIncrementContentID(&id);
|
||||
}
|
||||
|
||||
aDst->SetContentID(id);
|
||||
@ -528,18 +529,24 @@ nsGenericHTMLElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
||||
}
|
||||
|
||||
|
||||
static inline PRBool
|
||||
IsBodyTag(nsIAtom *aAtom)
|
||||
static PRBool
|
||||
IsBody(nsIContent *aContent)
|
||||
{
|
||||
return aAtom == nsHTMLAtoms::body;
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
return (ni && ni->Equals(nsHTMLAtoms::body) &&
|
||||
aContent->IsContentOfType(nsIContent::eHTML));
|
||||
}
|
||||
|
||||
static inline PRBool
|
||||
IsOffsetParentTag(nsIAtom *aAtom)
|
||||
static PRBool
|
||||
IsOffsetParent(nsIContent *aContent)
|
||||
{
|
||||
return (aAtom == nsHTMLAtoms::td ||
|
||||
aAtom == nsHTMLAtoms::table ||
|
||||
aAtom == nsHTMLAtoms::th);
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
return (ni && (ni->Equals(nsHTMLAtoms::td) ||
|
||||
ni->Equals(nsHTMLAtoms::table) ||
|
||||
ni->Equals(nsHTMLAtoms::th)) &&
|
||||
aContent->IsContentOfType(nsIContent::eHTML));
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -556,8 +563,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
|
||||
}
|
||||
|
||||
// Get Presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
|
||||
if (!presShell) {
|
||||
return NS_OK;
|
||||
@ -599,14 +605,11 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
|
||||
// the tagName passed in or is the document element.
|
||||
nsIFrame* parent = nsnull;
|
||||
PRBool done = PR_FALSE;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
nsIContent* content = frame->GetContent();
|
||||
|
||||
if (content) {
|
||||
content->GetTag(getter_AddRefs(tag));
|
||||
|
||||
if (IsBodyTag(tag) || content == docElement) {
|
||||
if (IsBody(content) || content == docElement) {
|
||||
done = PR_TRUE;
|
||||
|
||||
parent = frame;
|
||||
@ -666,12 +669,10 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
|
||||
break;
|
||||
}
|
||||
|
||||
content->GetTag(getter_AddRefs(tag));
|
||||
|
||||
// If the tag of this frame is a offset parent tag and this
|
||||
// element is *not* positioned, break here. Also break if we
|
||||
// hit the body element.
|
||||
if ((!is_positioned && IsOffsetParentTag(tag)) || IsBodyTag(tag)) {
|
||||
if ((!is_positioned && IsOffsetParent(content)) || IsBody(content)) {
|
||||
*aOffsetParent = content;
|
||||
NS_ADDREF(*aOffsetParent);
|
||||
|
||||
@ -958,8 +959,7 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
|
||||
mDocument->FlushPendingNotifications(PR_TRUE, PR_FALSE);
|
||||
|
||||
// Get the presentation shell
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1256,8 +1256,7 @@ nsGenericHTMLElement::ScrollIntoView(PRBool aTop)
|
||||
}
|
||||
|
||||
// Get the presentation shell
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1312,10 +1311,7 @@ nsresult
|
||||
nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool doNothing = PR_FALSE;
|
||||
if (aDocument == mDocument) {
|
||||
doNothing = PR_TRUE; // short circuit useless work
|
||||
}
|
||||
PRBool doNothing = aDocument == mDocument; // short circuit useless work
|
||||
|
||||
nsresult result = nsGenericElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
@ -1323,15 +1319,12 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!doNothing) {
|
||||
if (mDocument && mAttributes) {
|
||||
ReparseStyleAttribute();
|
||||
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
|
||||
if (sheet) {
|
||||
mAttributes->SetStyleSheet(sheet);
|
||||
// sheet->SetAttributesFor(htmlContent, mAttributes); // sync attributes with sheet
|
||||
NS_RELEASE(sheet);
|
||||
}
|
||||
if (!doNothing && mDocument && mAttributes) {
|
||||
ReparseStyleAttribute();
|
||||
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
|
||||
if (sheet) {
|
||||
mAttributes->SetStyleSheet(sheet);
|
||||
NS_RELEASE(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1344,27 +1337,21 @@ nsGenericHTMLElement::FindForm(nsIDOMHTMLFormElement **aForm)
|
||||
// XXX: Namespaces!!!
|
||||
|
||||
nsIContent* content = this;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
*aForm = nsnull;
|
||||
|
||||
while (content) {
|
||||
if (content->IsContentOfType(nsIContent::eHTML)) {
|
||||
content->GetTag(getter_AddRefs(tag));
|
||||
|
||||
// If the current ancestor is a form, return it as our form
|
||||
if (tag == nsHTMLAtoms::form) {
|
||||
return CallQueryInterface(content, aForm);
|
||||
}
|
||||
// If the current ancestor is a form, return it as our form
|
||||
if (content->IsContentOfType(nsIContent::eHTML) &&
|
||||
content->GetNodeInfo()->Equals(nsHTMLAtoms::form)) {
|
||||
return CallQueryInterface(content, aForm);
|
||||
}
|
||||
|
||||
nsIContent *tmp = content;
|
||||
content = tmp->GetParent();
|
||||
|
||||
if (content) {
|
||||
PRInt32 i;
|
||||
|
||||
content->IndexOf(tmp, i);
|
||||
PRInt32 i = content->IndexOf(tmp);
|
||||
|
||||
if (i < 0) {
|
||||
// This means 'tmp' is anonymous content, form controls in
|
||||
@ -1393,6 +1380,15 @@ nsGenericHTMLElement::FindAndSetForm(nsIFormControl *aFormControl)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
IsArea(nsIContent *aContent)
|
||||
{
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
return (ni && ni->Equals(nsHTMLAtoms::area) &&
|
||||
aContent->IsContentOfType(nsIContent::eHTML));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
@ -1425,21 +1421,15 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext,
|
||||
if (NS_SUCCEEDED(aPresContext->GetEventStateManager(getter_AddRefs(esm))) && esm) {
|
||||
nsCOMPtr<nsIContent> target;
|
||||
esm->GetEventTargetContent(aEvent, getter_AddRefs(target));
|
||||
if (target) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
target->GetTag(getter_AddRefs(tag));
|
||||
if (tag && tag.get() == nsHTMLAtoms::area) {
|
||||
targetIsArea = PR_TRUE;
|
||||
}
|
||||
if (target && IsArea(target)) {
|
||||
targetIsArea = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetIsArea) {
|
||||
//We are over an area. If our element is not one, then return without
|
||||
//running anchor code.
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
GetTag(getter_AddRefs(tag));
|
||||
if (tag && tag.get() != nsHTMLAtoms::area) {
|
||||
if (IsArea(this)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -2235,7 +2225,7 @@ nsGenericHTMLElement::GetHTMLAttribute(nsIAtom* aAttribute,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
nsGenericHTMLElement::GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const
|
||||
@ -2252,14 +2242,21 @@ nsGenericHTMLElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetAttrCount(PRInt32& aCount) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsGenericHTMLElement::GetAttrCount() const
|
||||
{
|
||||
if (nsnull != mAttributes) {
|
||||
return mAttributes->GetAttributeCount(aCount);
|
||||
if (!mAttributes) {
|
||||
return 0;
|
||||
}
|
||||
aCount = 0;
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 count;
|
||||
nsresult rv = mAttributes->GetAttributeCount(count);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2411,8 +2408,8 @@ nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
|
||||
void
|
||||
nsGenericHTMLElement::ListAttributes(FILE* out) const
|
||||
{
|
||||
PRInt32 index, count;
|
||||
GetAttrCount(count);
|
||||
PRUint32 index, count = GetAttrCount();
|
||||
|
||||
for (index = 0; index < count; index++) {
|
||||
// name
|
||||
nsCOMPtr<nsIAtom> attr;
|
||||
@ -2448,28 +2445,21 @@ nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
GetTag(getter_AddRefs(tag));
|
||||
if (tag) {
|
||||
nsAutoString buf;
|
||||
tag->ToString(buf);
|
||||
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
|
||||
}
|
||||
nsAutoString buf;
|
||||
mNodeInfo->GetQualifiedName(buf);
|
||||
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
|
||||
|
||||
fprintf(out, "@%p", (void*)this);
|
||||
|
||||
ListAttributes(out);
|
||||
|
||||
fprintf(out, " refcount=%d<", mRefCnt.get());
|
||||
|
||||
PRBool canHaveKids;
|
||||
CanContainChildren(canHaveKids);
|
||||
if (canHaveKids) {
|
||||
if (CanContainChildren()) {
|
||||
fputs("\n", out);
|
||||
PRInt32 kids;
|
||||
ChildCount(kids);
|
||||
nsCOMPtr<nsIContent> kid;
|
||||
PRInt32 kids = GetChildCount();
|
||||
for (index = 0; index < kids; index++) {
|
||||
ChildAt(index, getter_AddRefs(kid));
|
||||
nsIContent *kid = GetChildAt(index);
|
||||
kid->List(out, aIndent + 1);
|
||||
}
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
@ -2480,34 +2470,27 @@ nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const {
|
||||
nsGenericHTMLElement::DumpContent(FILE* out, PRInt32 aIndent,
|
||||
PRBool aDumpAll) const {
|
||||
NS_PRECONDITION(nsnull != mDocument, "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
nsAutoString buf;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
GetTag(getter_AddRefs(tag));
|
||||
if (tag) {
|
||||
tag->ToString(buf);
|
||||
fputs("<",out);
|
||||
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
|
||||
mNodeInfo->GetQualifiedName(buf);
|
||||
fputs("<",out);
|
||||
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
|
||||
|
||||
if(aDumpAll) ListAttributes(out);
|
||||
if(aDumpAll) ListAttributes(out);
|
||||
|
||||
fputs(">",out);
|
||||
}
|
||||
fputs(">",out);
|
||||
|
||||
PRBool canHaveKids;
|
||||
CanContainChildren(canHaveKids);
|
||||
if (canHaveKids) {
|
||||
if (CanContainChildren()) {
|
||||
if(aIndent) fputs("\n", out);
|
||||
PRInt32 kids;
|
||||
ChildCount(kids);
|
||||
nsCOMPtr<nsIContent> kid;
|
||||
PRInt32 kids = GetChildCount();
|
||||
for (index = 0; index < kids; index++) {
|
||||
ChildAt(index, getter_AddRefs(kid));
|
||||
nsIContent *kid = GetChildAt(index);
|
||||
PRInt32 indent = aIndent ? aIndent + 1 : 0;
|
||||
kid->DumpContent(out, indent, aDumpAll);
|
||||
}
|
||||
@ -2616,16 +2599,15 @@ nsGenericHTMLElement::GetPrimaryFrameFor(nsIContent* aContent,
|
||||
}
|
||||
|
||||
// Get presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = aDocument->GetShellAt(0);
|
||||
|
||||
nsIFrame *frame = nsnull;
|
||||
|
||||
if (presShell) {
|
||||
nsIFrame *frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(aContent, &frame);
|
||||
return frame;
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
return frame;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -2751,8 +2733,7 @@ nsGenericHTMLElement::GetPresContext(nsIHTMLContent* aContent,
|
||||
nsIDocument* doc = aContent->GetDocument();
|
||||
if (doc) {
|
||||
// Get presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
if (presShell) {
|
||||
return presShell->GetPresContext(aPresContext);
|
||||
}
|
||||
@ -3690,45 +3671,33 @@ nsGenericHTMLContainerElement::Compact()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::CanContainChildren(PRBool& aResult) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsGenericHTMLContainerElement::CanContainChildren() const
|
||||
{
|
||||
aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::ChildCount(PRInt32& aCount) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsGenericHTMLContainerElement::GetChildCount() const
|
||||
{
|
||||
aCount = mChildren.Count();
|
||||
return NS_OK;
|
||||
return mChildren.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::ChildAt(PRInt32 aIndex,
|
||||
nsIContent** aResult) const
|
||||
NS_IMETHODIMP_(nsIContent *)
|
||||
nsGenericHTMLContainerElement::GetChildAt(PRUint32 aIndex) const
|
||||
{
|
||||
// I really prefer NOT to do this test on all ChildAt calls - perhaps we
|
||||
// should add FastChildAt().
|
||||
nsIContent *child = (nsIContent *)mChildren.SafeElementAt(aIndex);
|
||||
NS_IF_ADDREF(child);
|
||||
*aResult = child;
|
||||
|
||||
return NS_OK;
|
||||
return (nsIContent *)mChildren.SafeElementAt(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::IndexOf(nsIContent* aPossibleChild,
|
||||
PRInt32& aIndex) const
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsGenericHTMLContainerElement::IndexOf(nsIContent* aPossibleChild) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aPossibleChild, "null ptr");
|
||||
aIndex = mChildren.IndexOf(aPossibleChild);
|
||||
return NS_OK;
|
||||
return mChildren.IndexOf(aPossibleChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid,
|
||||
PRInt32 aIndex,
|
||||
PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
@ -3771,7 +3740,7 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid,
|
||||
PRInt32 aIndex,
|
||||
PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
@ -3859,7 +3828,7 @@ nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsGenericHTMLContainerElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsIDocument* doc = mDocument;
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
@ -3905,27 +3874,27 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLContainerElement::ReplaceContentsWithText(const nsAString& aText,
|
||||
PRBool aNotify) {
|
||||
PRInt32 children;
|
||||
nsresult rv = ChildCount(children);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRBool aNotify)
|
||||
{
|
||||
PRUint32 count = GetChildCount();
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContent> firstChild;
|
||||
nsCOMPtr<nsIDOMText> textChild;
|
||||
// if we already have a DOMText child, reuse it.
|
||||
if (children > 0) {
|
||||
rv = ChildAt(0, getter_AddRefs(firstChild));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
textChild = do_QueryInterface(firstChild);
|
||||
}
|
||||
|
||||
PRInt32 i;
|
||||
PRInt32 lastChild = textChild ? 1 : 0;
|
||||
for (i = children - 1; i >= lastChild; --i) {
|
||||
RemoveChildAt(i, aNotify);
|
||||
|
||||
if (count > 0) {
|
||||
// if we already have a DOMText child, reuse it.
|
||||
textChild = do_QueryInterface(GetChildAt(0));
|
||||
|
||||
PRUint32 lastChild = textChild ? 1 : 0;
|
||||
PRUint32 i = count - 1;
|
||||
while (i-- > lastChild) {
|
||||
RemoveChildAt(i, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
if (!textChild) {
|
||||
if (textChild) {
|
||||
rv = textChild->SetData(aText);
|
||||
} else {
|
||||
nsCOMPtr<nsITextContent> text;
|
||||
rv = NS_NewTextNode(getter_AddRefs(text));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -3933,8 +3902,6 @@ nsGenericHTMLContainerElement::ReplaceContentsWithText(const nsAString& aText,
|
||||
rv = text->SetText(aText, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = InsertChildAt(text, 0, aNotify, PR_FALSE);
|
||||
} else {
|
||||
rv = textChild->SetData(aText);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -3944,18 +3911,14 @@ nsresult
|
||||
nsGenericHTMLContainerElement::GetContentsAsText(nsAString& aText)
|
||||
{
|
||||
aText.Truncate();
|
||||
PRInt32 children;
|
||||
nsresult rv = ChildCount(children);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRInt32 children = GetChildCount();
|
||||
|
||||
nsCOMPtr<nsIDOMText> tc;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsAutoString textData;
|
||||
|
||||
PRInt32 i;
|
||||
for (i = 0; i < children; ++i) {
|
||||
ChildAt(i, getter_AddRefs(child));
|
||||
tc = do_QueryInterface(child);
|
||||
tc = do_QueryInterface(GetChildAt(i));
|
||||
if (tc) {
|
||||
if (aText.IsEmpty()) {
|
||||
tc->GetData(aText);
|
||||
|
||||
@ -192,11 +192,11 @@ public:
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
@ -820,27 +820,23 @@ public:
|
||||
NS_IMETHOD Compact() {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const {
|
||||
return PR_FALSE;
|
||||
}
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const {
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const {
|
||||
return 0;
|
||||
}
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const {
|
||||
aResult = nsnull;
|
||||
return NS_OK;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const {
|
||||
return nsnull;
|
||||
}
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
|
||||
aResult = -1;
|
||||
return NS_OK;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const {
|
||||
return -1;
|
||||
}
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -848,7 +844,7 @@ public:
|
||||
PRBool aDeepSetDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
@ -895,17 +891,17 @@ public:
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
NS_IMETHOD Compact();
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
/** The list of children */
|
||||
nsSmallVoidArray mChildren;
|
||||
|
||||
@ -155,9 +155,7 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||
if (!aData || (aData->mSID != eStyleStruct_Margin) || !aData->mMarginData || !mPart)
|
||||
return NS_OK; // We only care about margins.
|
||||
|
||||
nsHTMLValue value;
|
||||
PRInt32 attrCount;
|
||||
mPart->GetAttrCount(attrCount);
|
||||
nsHTMLValue value;
|
||||
|
||||
PRInt32 bodyMarginWidth = -1;
|
||||
PRInt32 bodyMarginHeight = -1;
|
||||
@ -172,7 +170,7 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||
aData->mPresContext->GetCompatibilityMode(&mode);
|
||||
|
||||
|
||||
if (attrCount > 0) {
|
||||
if (mPart->GetAttrCount() > 0) {
|
||||
// if marginwidth/marginheight are set, reflect them as 'margin'
|
||||
mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
||||
|
||||
@ -289,31 +289,29 @@ nsHTMLButtonElement::Click()
|
||||
nsCOMPtr<nsIDocument> doc = mDocument;
|
||||
|
||||
if (mDocument) {
|
||||
PRInt32 numShells = doc->GetNumberOfShells();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
for (PRInt32 count=0; count < numShells; count++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(count, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
if (context) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_MOUSE_EVENT;
|
||||
event.message = NS_MOUSE_LEFT_CLICK;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
HandleDOMEvent(context, &event, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
if (context) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_MOUSE_EVENT;
|
||||
event.message = NS_MOUSE_LEFT_CLICK;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
HandleDOMEvent(context, &event, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mHandlingClick = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -1047,8 +1047,7 @@ nsHTMLFormElement::CompareNodes(nsIDOMNode* a, nsIDOMNode* b, PRInt32* retval)
|
||||
if (!parentA || !contentA) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
rv = parentA->IndexOf(contentA, indexA);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
indexA = parentA->IndexOf(contentA);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentBNode;
|
||||
@ -1067,8 +1066,7 @@ nsHTMLFormElement::CompareNodes(nsIDOMNode* a, nsIDOMNode* b, PRInt32* retval)
|
||||
if (!parentB || !bContent) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
rv = parentB->IndexOf(bContent, indexB);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
indexB = parentB->IndexOf(bContent);
|
||||
}
|
||||
|
||||
*retval = ComparePoints(parentANode, indexA, parentBNode, indexB);
|
||||
|
||||
@ -318,9 +318,7 @@ nsHTMLImageElement::GetXY(PRInt32* aX, PRInt32* aY)
|
||||
}
|
||||
|
||||
// Get Presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1233,41 +1233,39 @@ nsHTMLInputElement::Click()
|
||||
|
||||
// see what type of input we are. Only click button, checkbox, radio,
|
||||
// reset, submit, & image
|
||||
if (mType == NS_FORM_INPUT_BUTTON || mType == NS_FORM_INPUT_CHECKBOX ||
|
||||
mType == NS_FORM_INPUT_RADIO || mType == NS_FORM_INPUT_RESET ||
|
||||
mType == NS_FORM_INPUT_SUBMIT) {
|
||||
if (mDocument &&
|
||||
(mType == NS_FORM_INPUT_BUTTON ||
|
||||
mType == NS_FORM_INPUT_CHECKBOX ||
|
||||
mType == NS_FORM_INPUT_RADIO ||
|
||||
mType == NS_FORM_INPUT_RESET ||
|
||||
mType == NS_FORM_INPUT_SUBMIT)) {
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mDocument; // Strong in case the event kills it
|
||||
if (doc) {
|
||||
PRInt32 numShells = doc->GetNumberOfShells();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
for (PRInt32 i=0; i<numShells; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(i, getter_AddRefs(shell));
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
|
||||
if (shell) {
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
|
||||
if (context) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_MOUSE_EVENT;
|
||||
event.message = NS_MOUSE_LEFT_CLICK;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
|
||||
SET_BOOLBIT(mBitField, BF_HANDLING_CLICK, PR_TRUE);
|
||||
if (shell) {
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
|
||||
rv = HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT,
|
||||
&status);
|
||||
if (context) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_MOUSE_EVENT;
|
||||
event.message = NS_MOUSE_LEFT_CLICK;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
|
||||
SET_BOOLBIT(mBitField, BF_HANDLING_CLICK, PR_FALSE);
|
||||
}
|
||||
}
|
||||
SET_BOOLBIT(mBitField, BF_HANDLING_CLICK, PR_TRUE);
|
||||
|
||||
rv = HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT,
|
||||
&status);
|
||||
|
||||
SET_BOOLBIT(mBitField, BF_HANDLING_CLICK, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,23 +511,19 @@ nsHTMLLabelElement::GetForContent()
|
||||
already_AddRefed<nsIContent>
|
||||
nsHTMLLabelElement::GetFirstFormControl(nsIContent *current)
|
||||
{
|
||||
PRInt32 numNodes;
|
||||
nsresult rv = current->ChildCount(numNodes);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (PRInt32 i = 0; i < numNodes; i++) {
|
||||
nsIContent *child;
|
||||
current->ChildAt(i, &child);
|
||||
if (child) {
|
||||
if (child->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
return child;
|
||||
}
|
||||
else {
|
||||
nsIContent* content = GetFirstFormControl(child).get();
|
||||
NS_RELEASE(child);
|
||||
if (content) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
PRUint32 numNodes = current->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < numNodes; i++) {
|
||||
nsIContent *child = current->GetChildAt(i);
|
||||
if (child) {
|
||||
if (child->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
NS_ADDREF(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
nsIContent* content = GetFirstFormControl(child).get();
|
||||
if (content) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,13 +75,13 @@ public:
|
||||
NS_DECL_NSIDOMHTMLOPTGROUPELEMENT
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent, PRUint32 aFlags,
|
||||
@ -233,9 +233,7 @@ nsHTMLOptGroupElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
PRInt32 count;
|
||||
ChildCount(count);
|
||||
sel->WillAddOptions(aKid, this, count);
|
||||
sel->WillAddOptions(aKid, this, GetChildCount());
|
||||
}
|
||||
|
||||
// Actually perform the append
|
||||
@ -245,7 +243,7 @@ nsHTMLOptGroupElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
@ -261,7 +259,7 @@ nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLOptGroupElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
@ -278,7 +276,7 @@ nsHTMLOptGroupElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsHTMLOptGroupElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
|
||||
@ -117,13 +117,13 @@ public:
|
||||
NS_IMETHOD SetSelectedInternal(PRBool aValue, PRBool aNotify);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -509,33 +509,22 @@ nsHTMLOptionElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetText(nsAString& aText)
|
||||
{
|
||||
PRInt32 numNodes, i;
|
||||
PRUint32 i, numNodes = GetChildCount();
|
||||
|
||||
aText.Truncate();
|
||||
|
||||
nsresult rv = ChildCount(numNodes);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString text;
|
||||
for (i = 0; i < numNodes; i++) {
|
||||
nsCOMPtr<nsIContent> node;
|
||||
nsCOMPtr<nsIDOMText> domText(do_QueryInterface(GetChildAt(i)));
|
||||
|
||||
ChildAt(i, getter_AddRefs(node));
|
||||
|
||||
if (node) {
|
||||
nsCOMPtr<nsIDOMText> domText(do_QueryInterface(node));
|
||||
|
||||
if (domText) {
|
||||
rv = domText->GetData(text);
|
||||
if (NS_FAILED(rv)) {
|
||||
aText.Truncate();
|
||||
return rv;
|
||||
}
|
||||
|
||||
aText.Append(text);
|
||||
if (domText) {
|
||||
nsresult rv = domText->GetData(text);
|
||||
if (NS_FAILED(rv)) {
|
||||
aText.Truncate();
|
||||
return rv;
|
||||
}
|
||||
|
||||
aText.Append(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,21 +539,12 @@ nsHTMLOptionElement::GetText(nsAString& aText)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::SetText(const nsAString& aText)
|
||||
{
|
||||
PRInt32 numNodes, i;
|
||||
PRUint32 i, numNodes = GetChildCount();
|
||||
PRBool usedExistingTextNode = PR_FALSE; // Do we need to create a text node?
|
||||
|
||||
nsresult rv = ChildCount(numNodes);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
for (i = 0; i < numNodes; i++) {
|
||||
nsCOMPtr<nsIContent> node;
|
||||
|
||||
ChildAt(i, getter_AddRefs(node));
|
||||
|
||||
nsCOMPtr<nsIDOMText> domText(do_QueryInterface(node));
|
||||
nsCOMPtr<nsIDOMText> domText(do_QueryInterface(GetChildAt(i)));
|
||||
|
||||
if (domText) {
|
||||
rv = domText->SetData(aText);
|
||||
@ -617,7 +597,7 @@ nsHTMLOptionElement::NotifyTextChanged()
|
||||
// is changing
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLOptionElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::InsertChildAt(aKid, aIndex,
|
||||
@ -628,7 +608,7 @@ nsHTMLOptionElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLOptionElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::ReplaceChildAt(aKid, aIndex,
|
||||
@ -649,7 +629,7 @@ nsHTMLOptionElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDee
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsHTMLOptionElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::RemoveChildAt(aIndex,
|
||||
aNotify);
|
||||
|
||||
@ -349,7 +349,7 @@ public:
|
||||
const nsAString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers);
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
@ -476,7 +476,7 @@ nsHTMLScriptElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLScriptElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLScriptElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::InsertChildAt(aKid, aIndex,
|
||||
|
||||
@ -225,13 +225,13 @@ public:
|
||||
NS_DECL_NSIDOMNSXBLFORMCONTROL
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
@ -543,9 +543,7 @@ NS_IMETHODIMP
|
||||
nsHTMLSelectElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
PRInt32 count = 0;
|
||||
ChildCount(count);
|
||||
WillAddOptions(aKid, this, count);
|
||||
WillAddOptions(aKid, this, GetChildCount());
|
||||
|
||||
// Actually perform the append
|
||||
return nsGenericHTMLContainerFormElement::AppendChildTo(aKid,
|
||||
@ -554,7 +552,7 @@ nsHTMLSelectElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLSelectElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
WillAddOptions(aKid, this, aIndex);
|
||||
@ -566,7 +564,7 @@ nsHTMLSelectElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLSelectElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
WillRemoveOptions(this, aIndex);
|
||||
@ -579,7 +577,7 @@ nsHTMLSelectElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsHTMLSelectElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
WillRemoveOptions(this, aIndex);
|
||||
|
||||
@ -676,12 +674,10 @@ nsHTMLSelectElement::PrintOptions(nsIContent* aOptions, PRInt32 tabs)
|
||||
// doesn't *hurt* to search under other stuff and it's more
|
||||
// efficient in the normal only-optgroup-and-option case
|
||||
// (one less QueryInterface).
|
||||
PRInt32 numChildren;
|
||||
aOptions->ChildCount(numChildren);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (PRInt32 i=0;i<numChildren;i++) {
|
||||
aOptions->ChildAt(i,*getter_AddRefs(child));
|
||||
PrintOptions(child, tabs+1);
|
||||
PRUint32 numChildren = aOptions->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
PrintOptions(aOptions->GetChildAt(i), tabs + 1);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -704,7 +700,7 @@ nsHTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
|
||||
if (selectFrame) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
GetPresContext(this, getter_AddRefs(presContext));
|
||||
for (int i=aListIndex;i<aListIndex+numRemoved;i++) {
|
||||
for (int i = aListIndex; i < aListIndex + numRemoved; ++i) {
|
||||
selectFrame->RemoveOption(presContext, i);
|
||||
}
|
||||
}
|
||||
@ -730,6 +726,14 @@ nsHTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool IsOptGroup(nsIContent *aContent)
|
||||
{
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
return (ni && ni->Equals(nsHTMLAtoms::optgroup) &&
|
||||
aContent->IsContentOfType(nsIContent::eHTML));
|
||||
}
|
||||
|
||||
// If the document is such that recursing over these options gets us
|
||||
// deeper than four levels, there is something terribly wrong with the
|
||||
// world.
|
||||
@ -757,9 +761,7 @@ nsHTMLSelectElement::InsertOptionsIntoListRecurse(nsIContent* aOptions,
|
||||
mNonOptionChildren++;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aOptions->GetTag(getter_AddRefs(tag));
|
||||
if (tag == nsHTMLAtoms::optgroup) {
|
||||
if (IsOptGroup(aOptions)) {
|
||||
mOptGroupCount++;
|
||||
DispatchDOMEvent(NS_LITERAL_STRING("selectHasGroups"));
|
||||
}
|
||||
@ -771,12 +773,11 @@ nsHTMLSelectElement::InsertOptionsIntoListRecurse(nsIContent* aOptions,
|
||||
// doesn't *hurt* to search under other stuff and it's more
|
||||
// efficient in the normal only-optgroup-and-option case
|
||||
// (one less QueryInterface).
|
||||
PRInt32 numChildren;
|
||||
aOptions->ChildCount(numChildren);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (PRInt32 i = 0; i < numChildren; ++i) {
|
||||
aOptions->ChildAt(i, getter_AddRefs(child));
|
||||
nsresult rv = InsertOptionsIntoListRecurse(child, aInsertIndex, aDepth+1);
|
||||
PRUint32 numChildren = aOptions->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
nsresult rv = InsertOptionsIntoListRecurse(aOptions->GetChildAt(i),
|
||||
aInsertIndex, aDepth+1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -810,9 +811,7 @@ nsHTMLSelectElement::RemoveOptionsFromListRecurse(nsIContent* aOptions,
|
||||
}
|
||||
|
||||
if (mOptGroupCount) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aOptions->GetTag(getter_AddRefs(tag));
|
||||
if (tag == nsHTMLAtoms::optgroup) {
|
||||
if (IsOptGroup(aOptions)) {
|
||||
mOptGroupCount--;
|
||||
DispatchDOMEvent(NS_LITERAL_STRING("selectHasNoGroups"));
|
||||
}
|
||||
@ -825,12 +824,11 @@ nsHTMLSelectElement::RemoveOptionsFromListRecurse(nsIContent* aOptions,
|
||||
// doesn't *hurt* to search under other stuff and it's more
|
||||
// efficient in the normal only-optgroup-and-option case
|
||||
// (one less QueryInterface).
|
||||
PRInt32 numChildren;
|
||||
aOptions->ChildCount(numChildren);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (PRInt32 i = 0; i < numChildren; ++i) {
|
||||
aOptions->ChildAt(i, getter_AddRefs(child));
|
||||
nsresult rv = RemoveOptionsFromListRecurse(child, aRemoveIndex,
|
||||
PRUint32 numChildren = aOptions->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
nsresult rv = RemoveOptionsFromListRecurse(aOptions->GetChildAt(i),
|
||||
aRemoveIndex,
|
||||
aNumRemoved,
|
||||
aDepth + 1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -862,8 +860,8 @@ nsHTMLSelectElement::WillAddOptions(nsIContent* aOptions,
|
||||
} else {
|
||||
// If there are artifacts, we have to get the index of the option the
|
||||
// hard way
|
||||
PRInt32 children;
|
||||
aParent->ChildCount(children);
|
||||
PRInt32 children = aParent->GetChildCount();
|
||||
|
||||
if (aContentIndex >= children) {
|
||||
// If the content insert is after the end of the parent, then we want to get
|
||||
// the next index *after* the parent and insert there.
|
||||
@ -872,8 +870,7 @@ nsHTMLSelectElement::WillAddOptions(nsIContent* aOptions,
|
||||
// If the content insert is somewhere in the middle of the container, then
|
||||
// we want to get the option currently at the index and insert in front of
|
||||
// that.
|
||||
nsCOMPtr<nsIContent> currentKid;
|
||||
aParent->ChildAt(aContentIndex, getter_AddRefs(currentKid));
|
||||
nsIContent *currentKid = aParent->GetChildAt(aContentIndex);
|
||||
NS_ASSERTION(currentKid, "Child not found!");
|
||||
if (currentKid) {
|
||||
ind = GetOptionIndexAt(currentKid);
|
||||
@ -898,8 +895,7 @@ nsHTMLSelectElement::WillRemoveOptions(nsIContent* aParent,
|
||||
}
|
||||
|
||||
// Get the index where the options will be removed
|
||||
nsCOMPtr<nsIContent> currentKid;
|
||||
aParent->ChildAt(aContentIndex, getter_AddRefs(currentKid));
|
||||
nsIContent *currentKid = aParent->GetChildAt(aContentIndex);
|
||||
if (currentKid) {
|
||||
PRInt32 ind;
|
||||
if (!mNonOptionChildren) {
|
||||
@ -967,10 +963,8 @@ nsHTMLSelectElement::GetOptionIndexAfter(nsIContent* aOptions)
|
||||
nsCOMPtr<nsIContent> parent = aOptions->GetParent();
|
||||
|
||||
if (parent) {
|
||||
PRInt32 index;
|
||||
PRInt32 count;
|
||||
parent->IndexOf(aOptions, index);
|
||||
parent->ChildCount(count);
|
||||
PRInt32 index = parent->IndexOf(aOptions);
|
||||
PRInt32 count = parent->GetChildCount();
|
||||
|
||||
retval = GetFirstChildOptionIndex(parent, index+1, count);
|
||||
|
||||
@ -994,9 +988,7 @@ nsHTMLSelectElement::GetFirstOptionIndex(nsIContent* aOptions)
|
||||
return listIndex;
|
||||
}
|
||||
|
||||
PRInt32 numChildren;
|
||||
aOptions->ChildCount(numChildren);
|
||||
listIndex = GetFirstChildOptionIndex(aOptions, 0, numChildren);
|
||||
listIndex = GetFirstChildOptionIndex(aOptions, 0, aOptions->GetChildCount());
|
||||
|
||||
return listIndex;
|
||||
}
|
||||
@ -1007,10 +999,9 @@ nsHTMLSelectElement::GetFirstChildOptionIndex(nsIContent* aOptions,
|
||||
PRInt32 aEndIndex)
|
||||
{
|
||||
PRInt32 retval = -1;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
||||
for (PRInt32 i = aStartIndex; i < aEndIndex; ++i) {
|
||||
aOptions->ChildAt(i, getter_AddRefs(child));
|
||||
retval = GetFirstOptionIndex(child);
|
||||
retval = GetFirstOptionIndex(aOptions->GetChildAt(i));
|
||||
if (retval != -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -145,9 +145,8 @@ nsHTMLSpanElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
nsresult
|
||||
nsHTMLSpanElement::GetInnerHTML(nsAString& aInnerHTML)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
GetTag(getter_AddRefs(tag));
|
||||
if (tag == nsHTMLAtoms::xmp || tag == nsHTMLAtoms::plaintext) {
|
||||
if (mNodeInfo->Equals(nsHTMLAtoms::xmp) ||
|
||||
mNodeInfo->Equals(nsHTMLAtoms::plaintext)) {
|
||||
return GetContentsAsText(aInnerHTML);
|
||||
}
|
||||
|
||||
@ -157,9 +156,8 @@ nsHTMLSpanElement::GetInnerHTML(nsAString& aInnerHTML)
|
||||
nsresult
|
||||
nsHTMLSpanElement::SetInnerHTML(const nsAString& aInnerHTML)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
GetTag(getter_AddRefs(tag));
|
||||
if (tag == nsHTMLAtoms::xmp || tag == nsHTMLAtoms::plaintext) {
|
||||
if (mNodeInfo->Equals(nsHTMLAtoms::xmp) ||
|
||||
mNodeInfo->Equals(nsHTMLAtoms::plaintext)) {
|
||||
return ReplaceContentsWithText(aInnerHTML, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,8 @@ public:
|
||||
// nsIDOMHTMLStyleElement
|
||||
NS_DECL_NSIDOMHTMLSTYLEELEMENT
|
||||
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, PRBool aDeepSetDocument)
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::InsertChildAt(aKid, aIndex, aNotify, aDeepSetDocument);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -85,7 +86,8 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, PRBool aDeepSetDocument)
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::ReplaceChildAt(aKid, aIndex, aNotify, aDeepSetDocument);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -94,7 +96,8 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument)
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::AppendChildTo(aKid, aNotify, aDeepSetDocument);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -103,7 +106,7 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLContainerElement::RemoveChildAt(aIndex, aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -123,7 +126,7 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
NS_IMETHOD SetAttr(PRUint32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, PRBool aNotify) {
|
||||
nsresult rv = nsGenericHTMLContainerElement::SetAttr(aNameSpaceID, aName,
|
||||
aValue, aNotify);
|
||||
|
||||
@ -210,9 +210,8 @@ nsHTMLTableCellElement::GetTable()
|
||||
if (mParent) { // mParent should be a row
|
||||
nsIContent* section = mParent->GetParent();
|
||||
if (section) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
section->GetTag(getter_AddRefs(tag));
|
||||
if (tag == nsHTMLAtoms::table) {
|
||||
if (section->IsContentOfType(eHTML) &&
|
||||
section->GetNodeInfo()->Equals(nsHTMLAtoms::table)) {
|
||||
// XHTML, without a row group
|
||||
result = section;
|
||||
} else {
|
||||
|
||||
@ -93,6 +93,8 @@ public:
|
||||
NS_IMETHOD_(PRBool) HasAttributeDependentStyle(const nsIAtom* aAttribute) const;
|
||||
|
||||
protected:
|
||||
already_AddRefed<nsIDOMHTMLTableSectionElement> GetSection(nsIAtom *aTag);
|
||||
|
||||
GenericElementCollection *mTBodies;
|
||||
TableRowsCollection *mRows;
|
||||
};
|
||||
@ -451,32 +453,33 @@ nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue)
|
||||
return rv;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMHTMLTableSectionElement>
|
||||
nsHTMLTableElement::GetSection(nsIAtom *aTag)
|
||||
{
|
||||
PRUint32 childCount = GetChildCount();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent *child = GetChildAt(i);
|
||||
|
||||
section = do_QueryInterface(child);
|
||||
|
||||
if (section && child->GetNodeInfo()->Equals(aTag)) {
|
||||
nsIDOMHTMLTableSectionElement *result = section;
|
||||
NS_ADDREF(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
while (child) {
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section(do_QueryInterface(child));
|
||||
|
||||
if (section) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(section);
|
||||
|
||||
content->GetTag(getter_AddRefs(tag));
|
||||
if (tag.get() == nsHTMLAtoms::thead) {
|
||||
*aValue = section;
|
||||
NS_ADDREF(*aValue);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nsIDOMNode *temp = child.get();
|
||||
temp->GetNextSibling(getter_AddRefs(child));
|
||||
}
|
||||
*aValue = GetSection(nsHTMLAtoms::thead).get();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -506,30 +509,7 @@ nsHTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
while (child) {
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section(do_QueryInterface(child));
|
||||
|
||||
if (section) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(section);
|
||||
|
||||
content->GetTag(getter_AddRefs(tag));
|
||||
|
||||
if (tag.get() == nsHTMLAtoms::tfoot) {
|
||||
*aValue = section;
|
||||
NS_ADDREF(*aValue);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nsIDOMNode *temp = child.get();
|
||||
temp->GetNextSibling(getter_AddRefs(child));
|
||||
}
|
||||
*aValue = GetSection(nsHTMLAtoms::tfoot).get();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -82,6 +82,15 @@ nsTableCellCollection::~nsTableCellCollection()
|
||||
{
|
||||
}
|
||||
|
||||
static PRBool
|
||||
IsCell(nsIContent *aContent)
|
||||
{
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
return (ni && (ni->Equals(nsHTMLAtoms::td) || ni->Equals(nsHTMLAtoms::th)) &&
|
||||
aContent->IsContentOfType(nsIContent::eHTML));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableCellCollection::GetLength(PRUint32* aLength)
|
||||
{
|
||||
@ -94,22 +103,13 @@ nsTableCellCollection::GetLength(PRUint32* aLength)
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (mParent) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsIContent *child;
|
||||
PRUint32 childIndex = 0;
|
||||
|
||||
mParent->ChildAt(childIndex, getter_AddRefs(child));
|
||||
|
||||
while (child) {
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
child->GetTag(getter_AddRefs(childTag));
|
||||
|
||||
if ((nsHTMLAtoms::td == childTag.get()) ||
|
||||
(nsHTMLAtoms::th == childTag.get())) {
|
||||
while ((child = mParent->GetChildAt(childIndex++))) {
|
||||
if (IsCell(child)) {
|
||||
(*aLength)++;
|
||||
}
|
||||
|
||||
childIndex++;
|
||||
mParent->ChildAt(childIndex, getter_AddRefs(child));
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,29 +125,20 @@ nsTableCellCollection::Item(PRUint32 aIndex,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mParent) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsIContent *child;
|
||||
PRUint32 childIndex = 0;
|
||||
|
||||
mParent->ChildAt(childIndex, getter_AddRefs(child));
|
||||
|
||||
while (child) {
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
|
||||
child->GetTag(getter_AddRefs(childTag));
|
||||
|
||||
if ((nsHTMLAtoms::td == childTag.get()) ||
|
||||
(nsHTMLAtoms::th == childTag.get())) {
|
||||
while ((child = mParent->GetChildAt(childIndex++))) {
|
||||
if (IsCell(child)) {
|
||||
if (aIndex == theIndex) {
|
||||
CallQueryInterface(child, aReturn);
|
||||
NS_ASSERTION(aReturn, "content element must be an nsIDOMNode");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
theIndex++;
|
||||
}
|
||||
|
||||
childIndex++;
|
||||
mParent->ChildAt(childIndex, getter_AddRefs(child));
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,8 +197,7 @@ void DebugList(nsIDOMHTMLTableElement* aTable) {
|
||||
if (root) {
|
||||
root->List();
|
||||
}
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsIFrame* rootFrame;
|
||||
shell->GetRootFrame(rootFrame);
|
||||
|
||||
@ -118,13 +118,13 @@ public:
|
||||
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsHTMLValue& aResult);
|
||||
@ -537,7 +537,7 @@ nsHTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLTextAreaElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -550,7 +550,7 @@ nsHTMLTextAreaElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsHTMLTextAreaElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -576,7 +576,7 @@ nsHTMLTextAreaElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsHTMLTextAreaElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsGenericHTMLContainerFormElement::RemoveChildAt(aIndex, aNotify);
|
||||
|
||||
@ -491,7 +491,7 @@ public:
|
||||
|
||||
void UpdateAllContexts();
|
||||
void NotifyAppend(nsIContent* aContent,
|
||||
PRInt32 aStartIndex);
|
||||
PRUint32 aStartIndex);
|
||||
void NotifyInsert(nsIContent* aContent,
|
||||
nsIContent* aChildContent,
|
||||
PRInt32 aIndexInContainer);
|
||||
@ -780,7 +780,7 @@ public:
|
||||
}
|
||||
|
||||
nsresult Begin(nsHTMLTag aNodeType, nsIHTMLContent* aRoot,
|
||||
PRInt32 aNumFlushed, PRInt32 aInsertionPoint);
|
||||
PRUint32 aNumFlushed, PRInt32 aInsertionPoint);
|
||||
nsresult OpenContainer(const nsIParserNode& aNode);
|
||||
nsresult CloseContainer(const nsHTMLTag aTag);
|
||||
nsresult AddLeaf(const nsIParserNode& aNode);
|
||||
@ -816,7 +816,7 @@ public:
|
||||
nsHTMLTag mType;
|
||||
nsIHTMLContent* mContent;
|
||||
PRUint32 mFlags;
|
||||
PRInt32 mNumFlushed;
|
||||
PRUint32 mNumFlushed;
|
||||
PRInt32 mInsertionPoint;
|
||||
};
|
||||
|
||||
@ -1214,7 +1214,7 @@ SinkContext::~SinkContext()
|
||||
nsresult
|
||||
SinkContext::Begin(nsHTMLTag aNodeType,
|
||||
nsIHTMLContent* aRoot,
|
||||
PRInt32 aNumFlushed,
|
||||
PRUint32 aNumFlushed,
|
||||
PRInt32 aInsertionPoint)
|
||||
{
|
||||
if (mStackSize < 1) {
|
||||
@ -1273,14 +1273,11 @@ SinkContext::GetCurrentContainer()
|
||||
void
|
||||
SinkContext::DidAddContent(nsIContent* aContent, PRBool aDidNotify)
|
||||
{
|
||||
PRInt32 childCount;
|
||||
|
||||
// If there was a notification done for this content, update the
|
||||
// parent's notification count.
|
||||
if (aDidNotify && (0 < mStackPos)) {
|
||||
nsIContent* parent = mStack[mStackPos - 1].mContent;
|
||||
parent->ChildCount(childCount);
|
||||
mStack[mStackPos - 1].mNumFlushed = childCount;
|
||||
mStack[mStackPos - 1].mNumFlushed = parent->GetChildCount();
|
||||
}
|
||||
|
||||
if ((mStackPos == 2) && (mSink->mBody == mStack[1].mContent)) {
|
||||
@ -1311,8 +1308,7 @@ SinkContext::DidAddContent(nsIContent* aContent, PRBool aDidNotify)
|
||||
|
||||
mSink->NotifyInsert(parent, aContent,
|
||||
mStack[mStackPos - 1].mInsertionPoint - 1);
|
||||
parent->ChildCount(childCount);
|
||||
mStack[mStackPos - 1].mNumFlushed = childCount;
|
||||
mStack[mStackPos - 1].mNumFlushed = parent->GetChildCount();
|
||||
} else if (!aDidNotify && mSink->IsTimeToNotify()) {
|
||||
SINK_TRACE(SINK_TRACE_REFLOW,
|
||||
("SinkContext::DidAddContent: Notification as a result of the "
|
||||
@ -1490,13 +1486,10 @@ SinkContext::CloseContainer(const nsHTMLTag aTag)
|
||||
// we go up the tree, and we're at the level where the next
|
||||
// notification needs to be done, do the notification.
|
||||
if (mNotifyLevel >= mStackPos) {
|
||||
PRInt32 childCount;
|
||||
|
||||
// Check to see if new content has been added after our last
|
||||
// notification
|
||||
content->ChildCount(childCount);
|
||||
|
||||
if (mStack[mStackPos].mNumFlushed < childCount) {
|
||||
if (mStack[mStackPos].mNumFlushed < content->GetChildCount()) {
|
||||
#ifdef NS_DEBUG
|
||||
// Tracing code
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
@ -1877,7 +1870,7 @@ SinkContext::FlushTags(PRBool aNotify)
|
||||
// Don't release last text node in case we need to add to it again
|
||||
FlushText();
|
||||
|
||||
PRInt32 childCount;
|
||||
PRUint32 childCount;
|
||||
nsIHTMLContent* content;
|
||||
|
||||
// Start from the top of the stack (growing upwards) and append
|
||||
@ -1910,7 +1903,7 @@ SinkContext::FlushTags(PRBool aNotify)
|
||||
PRBool flushed = PR_FALSE;
|
||||
while (stackPos < mStackPos) {
|
||||
content = mStack[stackPos].mContent;
|
||||
content->ChildCount(childCount);
|
||||
childCount = content->GetChildCount();
|
||||
|
||||
if (!flushed && (mStack[stackPos].mNumFlushed < childCount)) {
|
||||
#ifdef NS_DEBUG
|
||||
@ -1950,7 +1943,6 @@ SinkContext::FlushTags(PRBool aNotify)
|
||||
void
|
||||
SinkContext::UpdateChildCounts()
|
||||
{
|
||||
PRInt32 childCount;
|
||||
nsIHTMLContent* content;
|
||||
|
||||
// Start from the top of the stack (growing upwards) and see if any
|
||||
@ -1961,8 +1953,7 @@ SinkContext::UpdateChildCounts()
|
||||
while (stackPos > 0) {
|
||||
if (mStack[stackPos].mFlags & APPENDED) {
|
||||
content = mStack[stackPos].mContent;
|
||||
content->ChildCount(childCount);
|
||||
mStack[stackPos].mNumFlushed = childCount;
|
||||
mStack[stackPos].mNumFlushed = content->GetChildCount();
|
||||
}
|
||||
|
||||
stackPos--;
|
||||
@ -2121,7 +2112,7 @@ HTMLContentSink::~HTMLContentSink()
|
||||
|
||||
PRInt32 numContexts = mContextStack.Count();
|
||||
|
||||
if (mCurrentContext == mHeadContext) {
|
||||
if (mCurrentContext == mHeadContext && numContexts > 0) {
|
||||
// Pop off the second html context if it's not done earlier
|
||||
mContextStack.RemoveElementAt(--numContexts);
|
||||
}
|
||||
@ -2740,8 +2731,7 @@ HTMLContentSink::BeginContext(PRInt32 aPosition)
|
||||
// has a child on the stack, the insertion point is
|
||||
// before the last child.
|
||||
if (aPosition < (mCurrentContext->mStackPos - 1)) {
|
||||
content->ChildCount(insertionPoint);
|
||||
insertionPoint--;
|
||||
insertionPoint = content->GetChildCount() - 1;
|
||||
}
|
||||
|
||||
sc->Begin(nodeType,
|
||||
@ -2972,15 +2962,13 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
|
||||
|
||||
PRBool didInitialReflow = PR_FALSE;
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
PRUint32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
shell->GetDidInitialReflow(&didInitialReflow);
|
||||
if (didInitialReflow) {
|
||||
break;
|
||||
}
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
shell->GetDidInitialReflow(&didInitialReflow);
|
||||
if (didInitialReflow) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3758,8 +3746,7 @@ HTMLContentSink::DidProcessAToken(void)
|
||||
// switches to low frequency interrupt mode.
|
||||
|
||||
// Get the current user event time
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
|
||||
if (!shell) {
|
||||
// If there's no pres shell in the document, return early since
|
||||
@ -3913,10 +3900,9 @@ HTMLContentSink::StartLayout()
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
PRUint32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
if (shell) {
|
||||
// Make sure we don't call InitialReflow() for a shell that has
|
||||
@ -3986,19 +3972,17 @@ HTMLContentSink::StartLayout()
|
||||
// scroll bars.
|
||||
ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
nsIView* rootView = nsnull;
|
||||
vm->GetRootView(rootView);
|
||||
if (rootView) {
|
||||
nsCOMPtr<nsIScrollableView> sview(do_QueryInterface(rootView));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
if (sview) {
|
||||
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
|
||||
}
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
nsIView* rootView = nsnull;
|
||||
vm->GetRootView(rootView);
|
||||
if (rootView) {
|
||||
nsCOMPtr<nsIScrollableView> sview(do_QueryInterface(rootView));
|
||||
|
||||
if (sview) {
|
||||
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4090,42 +4074,40 @@ HTMLContentSink::ScrollToRef(PRBool aReallyScroll)
|
||||
nsAutoString ref;
|
||||
CopyUTF8toUTF16(unescapedRef, ref);
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
PRUint32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
// Scroll to the anchor
|
||||
if (aReallyScroll) {
|
||||
shell->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
// Check an empty string which might be caused by the UTF-8 conversion
|
||||
if (!ref.IsEmpty()) {
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
// Scroll to the anchor
|
||||
if (aReallyScroll) {
|
||||
shell->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
|
||||
// If UTF-8 URL failed then try to assume the string as a
|
||||
// document's charset.
|
||||
// Check an empty string which might be caused by the UTF-8 conversion
|
||||
if (!ref.IsEmpty()) {
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCAutoString docCharset;
|
||||
rv = mDocument->GetDocumentCharacterSet(docCharset);
|
||||
// If UTF-8 URL failed then try to assume the string as a
|
||||
// document's charset.
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CharsetConvRef(docCharset, unescapedRef, ref);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCAutoString docCharset;
|
||||
rv = mDocument->GetDocumentCharacterSet(docCharset);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mScrolledToRefAlready = PR_TRUE;
|
||||
rv = CharsetConvRef(docCharset, unescapedRef, ref);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mScrolledToRefAlready = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4987,8 +4969,7 @@ HTMLContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
|
||||
// Disable theming for the presshell if the value is no.
|
||||
nsAutoString value(aValue);
|
||||
if (value.EqualsIgnoreCase("no")) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
if (shell)
|
||||
shell->DisableThemeSupport();
|
||||
}
|
||||
@ -5024,7 +5005,7 @@ HTMLContentSink::ForceReflow()
|
||||
#endif
|
||||
|
||||
void
|
||||
HTMLContentSink::NotifyAppend(nsIContent* aContainer, PRInt32 aStartIndex)
|
||||
HTMLContentSink::NotifyAppend(nsIContent* aContainer, PRUint32 aStartIndex)
|
||||
{
|
||||
mInNotification++;
|
||||
|
||||
@ -5434,9 +5415,9 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
||||
parent->AppendChildTo(element, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
||||
// To prevent script evaluation, in a frameset document, we
|
||||
// suspended the script loader. Now that the script content
|
||||
// has been handled let's resume the script loader.
|
||||
// To prevent script evaluation in a frameset document, we suspended
|
||||
// the script loader. Now that the script content has been handled,
|
||||
// let's resume the script loader.
|
||||
if (loader) {
|
||||
loader->SetEnabled(PR_TRUE);
|
||||
}
|
||||
|
||||
@ -1154,7 +1154,7 @@ nsHTMLDocument::GetImageMap(const nsAString& aMapName,
|
||||
nsAutoString name;
|
||||
PRUint32 i, n = mImageMaps.Count();
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
nsCOMPtr<nsIDOMHTMLMapElement> map = mImageMaps[i];
|
||||
NS_ASSERTION(map, "Null map in map list!");
|
||||
|
||||
@ -1368,15 +1368,10 @@ nsHTMLDocument::ContentAppended(nsIContent* aContainer,
|
||||
|
||||
// Register new content. That is the content numbered from
|
||||
// aNewIndexInContainer and upwards.
|
||||
PRInt32 count=0;
|
||||
aContainer->ChildCount(count);
|
||||
PRUint32 count = aContainer->GetChildCount();
|
||||
|
||||
PRInt32 i;
|
||||
nsCOMPtr<nsIContent> newChild;
|
||||
for (i = aNewIndexInContainer; i < count; ++i) {
|
||||
aContainer->ChildAt(i, getter_AddRefs(newChild));
|
||||
if (newChild)
|
||||
RegisterNamedItems(newChild);
|
||||
for (PRUint32 i = aNewIndexInContainer; i < count; ++i) {
|
||||
RegisterNamedItems(aContainer->GetChildAt(i));
|
||||
}
|
||||
|
||||
return nsDocument::ContentAppended(aContainer, aNewIndexInContainer);
|
||||
@ -2168,8 +2163,7 @@ GetHTMLDocumentNamespace(nsIContent *aContent)
|
||||
PRBool
|
||||
nsHTMLDocument::MatchLinks(nsIContent *aContent, nsString* aData)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
aContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
if (ni) {
|
||||
PRInt32 namespaceID = GetHTMLDocumentNamespace(aContent);
|
||||
@ -2202,8 +2196,7 @@ nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks)
|
||||
PRBool
|
||||
nsHTMLDocument::MatchAnchors(nsIContent *aContent, nsString* aData)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
aContent->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsINodeInfo *ni = aContent->GetNodeInfo();
|
||||
|
||||
if (ni) {
|
||||
PRInt32 namespaceID = GetHTMLDocumentNamespace(aContent);
|
||||
@ -2422,20 +2415,17 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
||||
nsCOMPtr<nsIContent> root(mRootContent);
|
||||
|
||||
if (root) {
|
||||
PRInt32 count;
|
||||
root->ChildCount(count);
|
||||
PRUint32 count = root->GetChildCount();
|
||||
|
||||
// Remove all the children from the root.
|
||||
while (--count >= 0) {
|
||||
while (count-- > 0) {
|
||||
root->RemoveChildAt(count, PR_TRUE);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
mRootContent->GetAttrCount(count);
|
||||
count = mRootContent->GetAttrCount();
|
||||
|
||||
// Remove all attributes from the root element
|
||||
while (--count >= 0) {
|
||||
while (count-- > 0) {
|
||||
nsCOMPtr<nsIAtom> name, prefix;
|
||||
PRInt32 nsid;
|
||||
|
||||
@ -2560,12 +2550,12 @@ nsHTMLDocument::Close()
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mParser && mIsWriting) {
|
||||
mWriteLevel++;
|
||||
++mWriteLevel;
|
||||
rv = mParser->Parse(NS_LITERAL_STRING("</HTML>"),
|
||||
NS_GENERATE_PARSER_KEY(),
|
||||
NS_LITERAL_CSTRING("text/html"), PR_FALSE,
|
||||
PR_TRUE);
|
||||
mWriteLevel--;
|
||||
--mWriteLevel;
|
||||
mIsWriting = 0;
|
||||
mParser = nsnull;
|
||||
|
||||
@ -2616,7 +2606,7 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
||||
mWriteLevel++;
|
||||
++mWriteLevel;
|
||||
|
||||
static NS_NAMED_LITERAL_STRING(new_line, "\n");
|
||||
static NS_NAMED_LITERAL_STRING(empty, "");
|
||||
@ -2634,7 +2624,7 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
|
||||
NS_LITERAL_CSTRING("text/html"), PR_FALSE,
|
||||
(!mIsWriting || (mWriteLevel > 1)));
|
||||
|
||||
mWriteLevel--;
|
||||
--mWriteLevel;
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -2733,7 +2723,7 @@ nsHTMLDocument::ScriptWriteCommon(PRBool aNewlineTerminate)
|
||||
if (argc > 1) {
|
||||
nsAutoString string_buffer;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
for (i = 0; i < argc; ++i) {
|
||||
JSString *str = JS_ValueToString(cx, argv[i]);
|
||||
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
@ -2875,14 +2865,14 @@ nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::AddedForm()
|
||||
{
|
||||
mNumForms++;
|
||||
++mNumForms;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::RemovedForm()
|
||||
{
|
||||
mNumForms--;
|
||||
--mNumForms;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2981,11 +2971,9 @@ nsHTMLDocument::GetWidth(PRInt32* aWidth)
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
*aWidth = 0;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
// We make the assumption that the first presentation shell
|
||||
// is the one for which we need information.
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3003,11 +2991,9 @@ nsHTMLDocument::GetHeight(PRInt32* aHeight)
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
*aHeight = 0;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
// We make the assumption that the first presentation shell
|
||||
// is the one for which we need information.
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3450,11 +3436,7 @@ nsHTMLDocument::UpdateNameTableEntry(const nsAString& aName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 i;
|
||||
|
||||
list->IndexOf(aContent, i);
|
||||
|
||||
if (i < 0) {
|
||||
if (list->IndexOf(aContent, PR_FALSE) < 0) {
|
||||
list->AppendElement(aContent);
|
||||
}
|
||||
|
||||
@ -3572,16 +3554,10 @@ nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent)
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
PRUint32 i, count = aContent->GetChildCount();
|
||||
|
||||
aContent->ChildCount(count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
|
||||
UnregisterNamedItems(child);
|
||||
for (i = 0; i < count; ++i) {
|
||||
UnregisterNamedItems(aContent->GetChildAt(i));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -3616,16 +3592,10 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent)
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
PRUint32 i, count = aContent->GetChildCount();
|
||||
|
||||
aContent->ChildCount(count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
|
||||
RegisterNamedItems(child);
|
||||
for (i = 0; i < count; ++i) {
|
||||
RegisterNamedItems(aContent->GetChildAt(i));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -3661,16 +3631,10 @@ FindNamedItems(const nsAString& aName, nsIContent *aContent,
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
PRUint32 i, count = aContent->GetChildCount();
|
||||
|
||||
aContent->ChildCount(count);
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
|
||||
FindNamedItems(aName, child, aEntry, aIsXHTML);
|
||||
for (i = 0; i < count; ++i) {
|
||||
FindNamedItems(aName, aContent->GetChildAt(i), aEntry, aIsXHTML);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3821,24 +3785,18 @@ nsHTMLDocument::GetBodyContent()
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 i, child_count;
|
||||
root->ChildCount(child_count);
|
||||
PRUint32 i, child_count = root->GetChildCount();
|
||||
|
||||
for (i = 0; i < child_count; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
||||
root->ChildAt(i, getter_AddRefs(child));
|
||||
for (i = 0; i < child_count; ++i) {
|
||||
nsIContent *child = root->GetChildAt(i);
|
||||
NS_ENSURE_TRUE(child, NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (child->IsContentOfType(nsIContent::eHTML)) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
child->GetNodeInfo(getter_AddRefs(ni));
|
||||
if (child->IsContentOfType(nsIContent::eHTML) &&
|
||||
child->GetNodeInfo()->Equals(nsHTMLAtoms::body,
|
||||
mDefaultNamespaceID)) {
|
||||
mBodyContent = do_QueryInterface(child);
|
||||
|
||||
if (ni->Equals(nsHTMLAtoms::body, mDefaultNamespaceID)) {
|
||||
mBodyContent = do_QueryInterface(child);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -525,8 +525,7 @@ nsImageDocument::CreateSyntheticDocument()
|
||||
nsresult
|
||||
nsImageDocument::CheckOverflowing()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -275,26 +275,24 @@ nsMediaDocument::StartLayout()
|
||||
scrollableContainer->ResetScrollbarPreferences();
|
||||
}
|
||||
|
||||
PRInt32 numberOfShells = GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < numberOfShells; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(i, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
// Make shell an observer for next time.
|
||||
shell->BeginObservingDocument();
|
||||
PRUint32 numberOfShells = GetNumberOfShells();
|
||||
for (PRUint32 i = 0; i < numberOfShells; i++) {
|
||||
nsIPresShell *shell = GetShellAt(i);
|
||||
|
||||
// Initial-reflow this time.
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsRect visibleArea;
|
||||
context->GetVisibleArea(visibleArea);
|
||||
shell->InitialReflow(visibleArea.width, visibleArea.height);
|
||||
// Make shell an observer for next time.
|
||||
shell->BeginObservingDocument();
|
||||
|
||||
// Now trigger a refresh.
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
}
|
||||
// Initial-reflow this time.
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsRect visibleArea;
|
||||
context->GetVisibleArea(visibleArea);
|
||||
shell->InitialReflow(visibleArea.width, visibleArea.height);
|
||||
|
||||
// Now trigger a refresh.
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -224,29 +224,29 @@ nsPluginDocument::Print()
|
||||
{
|
||||
NS_ENSURE_TRUE(mPluginContent, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mPluginContent, &frame);
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mPluginContent, &frame);
|
||||
|
||||
nsIObjectFrame* objectFrame = nsnull;
|
||||
CallQueryInterface(frame,&objectFrame);
|
||||
nsIObjectFrame* objectFrame = nsnull;
|
||||
CallQueryInterface(frame, &objectFrame);
|
||||
|
||||
if (objectFrame) {
|
||||
nsCOMPtr<nsIPluginInstance> pi;
|
||||
objectFrame->GetPluginInstance(*getter_AddRefs(pi));
|
||||
if (pi) {
|
||||
if (objectFrame) {
|
||||
nsCOMPtr<nsIPluginInstance> pi;
|
||||
objectFrame->GetPluginInstance(*getter_AddRefs(pi));
|
||||
|
||||
nsPluginPrint npprint;
|
||||
npprint.mode = nsPluginMode_Full;
|
||||
npprint.print.fullPrint.pluginPrinted = PR_FALSE;
|
||||
npprint.print.fullPrint.printOne = PR_FALSE;
|
||||
npprint.print.fullPrint.platformPrint = nsnull;
|
||||
if (pi) {
|
||||
nsPluginPrint npprint;
|
||||
npprint.mode = nsPluginMode_Full;
|
||||
npprint.print.fullPrint.pluginPrinted = PR_FALSE;
|
||||
npprint.print.fullPrint.printOne = PR_FALSE;
|
||||
npprint.print.fullPrint.platformPrint = nsnull;
|
||||
|
||||
pi->Print(&npprint);
|
||||
}
|
||||
pi->Print(&npprint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3219,9 +3219,7 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// see if there are attributes for the content
|
||||
PRInt32 attrCount = 0;
|
||||
aContent->GetAttrCount(attrCount);
|
||||
mHasAttributes = attrCount > 0;
|
||||
mHasAttributes = aContent->GetAttrCount() > 0;
|
||||
|
||||
// check for HTMLContent and Link status
|
||||
if (aContent->IsContentOfType(nsIContent::eHTML))
|
||||
@ -3283,9 +3281,7 @@ const nsString* RuleProcessorData::GetLang(void)
|
||||
return nsnull;
|
||||
for (nsIContent* content = mContent; content;
|
||||
content = content->GetParent()) {
|
||||
PRInt32 attrCount = 0;
|
||||
content->GetAttrCount(attrCount);
|
||||
if (attrCount > 0) {
|
||||
if (content->GetAttrCount() > 0) {
|
||||
// xml:lang has precedence over lang on HTML elements (see
|
||||
// XHTML1 section C.7).
|
||||
nsAutoString value;
|
||||
@ -3532,14 +3528,14 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
while (result && (nsnull != pseudoClass)) {
|
||||
if ((nsCSSPseudoClasses::firstChild == pseudoClass->mAtom) ||
|
||||
(nsCSSPseudoClasses::firstNode == pseudoClass->mAtom) ) {
|
||||
nsCOMPtr<nsIContent> firstChild;
|
||||
nsCOMPtr<nsIContent> parent = data.mParentContent;
|
||||
nsIContent *firstChild = nsnull;
|
||||
nsIContent *parent = data.mParentContent;
|
||||
if (parent) {
|
||||
PRBool acceptNonWhitespace =
|
||||
nsCSSPseudoClasses::firstNode == pseudoClass->mAtom;
|
||||
PRInt32 index = -1;
|
||||
do {
|
||||
parent->ChildAt(++index, getter_AddRefs(firstChild));
|
||||
firstChild = parent->GetChildAt(++index);
|
||||
// stop at first non-comment and non-whitespace node (and
|
||||
// non-text node for firstChild)
|
||||
} while (firstChild &&
|
||||
@ -3549,15 +3545,14 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
}
|
||||
else if ((nsCSSPseudoClasses::lastChild == pseudoClass->mAtom) ||
|
||||
(nsCSSPseudoClasses::lastNode == pseudoClass->mAtom)) {
|
||||
nsCOMPtr<nsIContent> lastChild;
|
||||
nsCOMPtr<nsIContent> parent = data.mParentContent;
|
||||
nsIContent *lastChild = nsnull;
|
||||
nsIContent *parent = data.mParentContent;
|
||||
if (parent) {
|
||||
PRBool acceptNonWhitespace =
|
||||
nsCSSPseudoClasses::lastNode == pseudoClass->mAtom;
|
||||
PRInt32 index;
|
||||
parent->ChildCount(index);
|
||||
PRUint32 index = parent->GetChildCount();
|
||||
do {
|
||||
parent->ChildAt(--index, getter_AddRefs(lastChild));
|
||||
lastChild = parent->GetChildAt(--index);
|
||||
// stop at first non-comment and non-whitespace node (and
|
||||
// non-text node for lastChild)
|
||||
} while (lastChild &&
|
||||
@ -3566,11 +3561,11 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
result = localTrue == (data.mContent == lastChild);
|
||||
}
|
||||
else if (nsCSSPseudoClasses::empty == pseudoClass->mAtom) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsCOMPtr<nsIContent> element = data.mContent;
|
||||
nsIContent *child = nsnull;
|
||||
nsIContent *element = data.mContent;
|
||||
PRInt32 index = -1;
|
||||
do {
|
||||
element->ChildAt(++index, getter_AddRefs(child));
|
||||
child = element->GetChildAt(++index);
|
||||
// stop at first non-comment and non-whitespace node
|
||||
} while (child && !IsSignificantChild(child, PR_TRUE));
|
||||
result = localTrue == (child == nsnull);
|
||||
@ -3737,13 +3732,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
// have a chance at matching, of course, are ones that the element
|
||||
// actually has attributes in), short-circuiting if we ever match.
|
||||
// Then deal with the localFalse/localTrue stuff.
|
||||
PRInt32 attrCount;
|
||||
data.mContent->GetAttrCount(attrCount);
|
||||
PRUint32 attrCount = data.mContent->GetAttrCount();
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
PRBool attrSelectorMatched = PR_FALSE;
|
||||
for (PRInt32 i = 0; i < attrCount; ++i) {
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
#ifdef DEBUG
|
||||
nsresult attrState =
|
||||
#endif
|
||||
@ -3883,11 +3877,10 @@ static PRBool SelectorMatchesTree(RuleProcessorData &data,
|
||||
newdata = curdata->mPreviousSiblingData;
|
||||
if (!newdata) {
|
||||
nsIContent* parent = lastContent->GetParent();
|
||||
PRInt32 index;
|
||||
if (parent) {
|
||||
parent->IndexOf(lastContent, index);
|
||||
PRInt32 index = parent->IndexOf(lastContent);
|
||||
while (0 <= --index) { // skip text & comment nodes
|
||||
parent->ChildAt(index, &content);
|
||||
content = parent->GetChildAt(index);
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
content->GetTag(getter_AddRefs(tag));
|
||||
if ((tag != nsLayoutAtoms::textTagName) &&
|
||||
@ -3898,8 +3891,9 @@ static PRBool SelectorMatchesTree(RuleProcessorData &data,
|
||||
curdata->mPreviousSiblingData = newdata;
|
||||
break;
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
|
||||
content = nsnull;
|
||||
}
|
||||
} else {
|
||||
content = newdata->mContent;
|
||||
|
||||
@ -82,7 +82,10 @@ nsDOMCSSAttributeDeclaration::DeclarationChanged()
|
||||
{
|
||||
NS_ASSERTION(mContent, "Must have content node to set the decl!");
|
||||
nsHTMLValue val;
|
||||
nsresult rv = mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
|
||||
NS_ASSERTION(rv == NS_CONTENT_ATTR_HAS_VALUE &&
|
||||
eHTMLUnit_ISupports == val.GetUnit(),
|
||||
"content must have rule");
|
||||
@ -160,12 +163,9 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
*aBaseURI = nsnull;
|
||||
*aCSSLoader = nsnull;
|
||||
*aCSSParser = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult result = mContent->GetNodeInfo(getter_AddRefs(nodeInfo));
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsINodeInfo *nodeInfo = mContent->GetNodeInfo();
|
||||
|
||||
// XXXbz GetOwnerDocument
|
||||
nsIDocument* doc = nodeInfo->GetDocument();
|
||||
|
||||
@ -177,13 +177,15 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
}
|
||||
NS_ASSERTION(!doc || *aCSSLoader, "Document with no CSS loader!");
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (*aCSSLoader) {
|
||||
result = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
|
||||
rv = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
|
||||
} else {
|
||||
result = NS_NewCSSParser(aCSSParser);
|
||||
rv = NS_NewCSSParser(aCSSParser);
|
||||
}
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// If we are not HTML, we need to be case-sensitive. Otherwise, Look up our
|
||||
|
||||
@ -90,30 +90,30 @@ nsInspectorCSSUtils::IsRuleNodeRoot(nsRuleNode *aNode, PRBool *aIsRoot)
|
||||
NS_IMETHODIMP
|
||||
nsInspectorCSSUtils::AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect)
|
||||
{
|
||||
const nsStyleMargin* margins = aFrame->GetStyleMargin();
|
||||
|
||||
// adjust coordinates for margins
|
||||
nsStyleCoord coord;
|
||||
if (margins->mMargin.GetTopUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetTop(coord);
|
||||
aRect.y -= coord.GetCoordValue();
|
||||
aRect.height += coord.GetCoordValue();
|
||||
}
|
||||
if (margins->mMargin.GetLeftUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetLeft(coord);
|
||||
aRect.x -= coord.GetCoordValue();
|
||||
aRect.width += coord.GetCoordValue();
|
||||
}
|
||||
if (margins->mMargin.GetRightUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetRight(coord);
|
||||
aRect.width += coord.GetCoordValue();
|
||||
}
|
||||
if (margins->mMargin.GetBottomUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetBottom(coord);
|
||||
aRect.height += coord.GetCoordValue();
|
||||
}
|
||||
const nsStyleMargin* margins = aFrame->GetStyleMargin();
|
||||
|
||||
return NS_OK;
|
||||
// adjust coordinates for margins
|
||||
nsStyleCoord coord;
|
||||
if (margins->mMargin.GetTopUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetTop(coord);
|
||||
aRect.y -= coord.GetCoordValue();
|
||||
aRect.height += coord.GetCoordValue();
|
||||
}
|
||||
if (margins->mMargin.GetLeftUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetLeft(coord);
|
||||
aRect.x -= coord.GetCoordValue();
|
||||
aRect.width += coord.GetCoordValue();
|
||||
}
|
||||
if (margins->mMargin.GetRightUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetRight(coord);
|
||||
aRect.width += coord.GetCoordValue();
|
||||
}
|
||||
if (margins->mMargin.GetBottomUnit() == eStyleUnit_Coord) {
|
||||
margins->mMargin.GetBottom(coord);
|
||||
aRect.height += coord.GetCoordValue();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsStyleContext*
|
||||
@ -176,11 +176,11 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent,
|
||||
nsIDocument* doc = aContent->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsRefPtr<nsStyleContext> sContext = GetStyleContextForContent(aContent, presShell);
|
||||
nsRefPtr<nsStyleContext> sContext =
|
||||
GetStyleContextForContent(aContent, presShell);
|
||||
*aRuleNode = sContext->GetRuleNode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -790,11 +790,8 @@ nsSVGAttributes::NormalizeAttrString(const nsAString& aStr,
|
||||
NS_ASSERTION(mContent,"no owner content");
|
||||
if (!mContent) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> contentNodeInfo;
|
||||
mContent->GetNodeInfo(getter_AddRefs(contentNodeInfo));
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
contentNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr));
|
||||
mContent->GetNodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
return nimgr->GetNodeInfo(aStr, nsnull, kNameSpaceID_None, aNodeInfo);
|
||||
@ -833,11 +830,8 @@ nsSVGAttributes::AddMappedSVGValue(nsIAtom* name, nsISupports* value)
|
||||
NS_ASSERTION(mContent,"no owner content");
|
||||
if (!mContent) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> contentNodeInfo;
|
||||
mContent->GetNodeInfo(getter_AddRefs(contentNodeInfo));
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
contentNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr));
|
||||
mContent->GetNodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
||||
@ -127,40 +127,32 @@ nsSVGElement::Init()
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::CanContainChildren(PRBool& aResult) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSVGElement::CanContainChildren() const
|
||||
{
|
||||
aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsSVGElement::GetChildCount() const
|
||||
{
|
||||
return mChildren.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIContent *)
|
||||
nsSVGElement::GetChildAt(PRUint32 aIndex) const
|
||||
{
|
||||
return (nsIContent *)mChildren.SafeElementAt(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsSVGElement::IndexOf(nsIContent* aPossibleChild) const
|
||||
{
|
||||
return mChildren.IndexOf(aPossibleChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ChildCount(PRInt32& aResult) const
|
||||
{
|
||||
aResult = mChildren.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ChildAt(PRInt32 aIndex, nsIContent** aResult) const
|
||||
{
|
||||
nsIContent *child = (nsIContent *)mChildren.SafeElementAt(aIndex);
|
||||
|
||||
*aResult = child;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aPossibleChild, "null ptr");
|
||||
aResult = mChildren.IndexOf(aPossibleChild);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsSVGElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
@ -203,7 +195,7 @@ nsSVGElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
nsSVGElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
@ -277,7 +269,7 @@ nsSVGElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsSVGElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsIDocument* doc = mDocument;
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
@ -387,7 +379,7 @@ nsSVGElement::HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
nsSVGElement::GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const
|
||||
@ -395,11 +387,10 @@ nsSVGElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
return mAttributes->GetAttrNameAt(aIndex, aNameSpaceID, aName, aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttrCount(PRInt32& aResult) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsSVGElement::GetAttrCount() const
|
||||
{
|
||||
aResult = mAttributes->Count();
|
||||
return NS_OK;
|
||||
return mAttributes->Count();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -653,12 +644,8 @@ nsSVGElement::HasAttributes(PRBool* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
PRInt32 attrCount = 0;
|
||||
|
||||
GetAttrCount(attrCount);
|
||||
|
||||
*aReturn = (attrCount > 0);
|
||||
|
||||
*aReturn = GetAttrCount() > 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -71,28 +71,19 @@ public:
|
||||
|
||||
// nsIContent interface methods
|
||||
|
||||
// NS_IMETHOD GetDocument(nsIDocument** aResult) const;
|
||||
// NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
// PRBool aCompileEventHandlers);
|
||||
// NS_IMETHOD GetParent(nsIContent** aResult) const;
|
||||
// NS_IMETHOD SetParent(nsIContent* aParent);
|
||||
// NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpaceID) const;
|
||||
// NS_IMETHOD GetTag(nsIAtom** aResult) const;
|
||||
// NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const;
|
||||
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
@ -109,11 +100,11 @@ public:
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
|
||||
@ -373,9 +373,8 @@ nsSVGSVGElement::GetPixelUnitToMillimeterX(float *aPixelUnitToMillimeterX)
|
||||
*aPixelUnitToMillimeterX = 0.28f; // 90dpi
|
||||
|
||||
if (!mDocument) return NS_OK;
|
||||
// Get Presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0,getter_AddRefs(presShell));
|
||||
// Get Presentation shell 0
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!presShell) return NS_OK;
|
||||
|
||||
// Get the Presentation Context from the Shell
|
||||
@ -407,8 +406,7 @@ nsSVGSVGElement::GetScreenPixelToMillimeterX(float *aScreenPixelToMillimeterX)
|
||||
|
||||
if (!mDocument) return NS_OK;
|
||||
// Get Presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!presShell) return NS_OK;
|
||||
|
||||
// Get the Presentation Context from the Shell
|
||||
@ -482,8 +480,7 @@ nsSVGSVGElement::SuspendRedraw(PRUint32 max_wait_milliseconds, PRUint32 *_retval
|
||||
return NS_OK;
|
||||
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "need presShell to suspend redraw");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
@ -535,8 +532,7 @@ nsSVGSVGElement::UnsuspendRedrawAll()
|
||||
mRedrawSuspendCount = 0;
|
||||
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "need presShell to unsuspend redraw");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
@ -563,8 +559,7 @@ nsSVGSVGElement::ForceRedraw()
|
||||
{
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "need presShell to unsuspend redraw");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
@ -961,8 +956,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
|
||||
|
||||
if (!mDocument) return;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
NS_ERROR("couldn't get presshell");
|
||||
return;
|
||||
|
||||
@ -585,10 +585,11 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum
|
||||
SetContentListFor(aContent, nsnull);
|
||||
SetAnonymousNodesFor(aContent, nsnull);
|
||||
|
||||
for (PRInt32 i = aOldDocument->GetNumberOfShells() - 1; i >= 0; --i) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aOldDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
NS_ASSERTION(shell != nsnull, "Zoiks! nsIPresShell::ShellAt() broke");
|
||||
PRUint32 count = aOldDocument->GetNumberOfShells();
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIPresShell *shell = aOldDocument->GetShellAt(i);
|
||||
NS_ASSERTION(shell != nsnull, "Zoiks! nsIDocument::GetShellAt() broke");
|
||||
|
||||
// See if the element has nsIAnonymousContentCreator-created
|
||||
// anonymous content...
|
||||
@ -878,15 +879,15 @@ nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, const nsAString& aU
|
||||
// ...and recreate it's frames. We need to do this since the frames may have
|
||||
// been removed and style may have changed due to the removal of the
|
||||
// anonymous children.
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
|
||||
return presShell->RecreateFramesFor(aContent);;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, const nsAString& aURL,
|
||||
nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc,
|
||||
const nsAString& aURL,
|
||||
nsIDocument** aResult)
|
||||
{
|
||||
NS_ConvertUCS2toUTF8 url(aURL);
|
||||
@ -1412,11 +1413,10 @@ nsBindingManager::ContentAppended(nsIDocument* aDocument,
|
||||
// It's anonymous.
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 childCount;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContainer->ChildCount(childCount);
|
||||
aContainer->ChildAt(aNewIndexInContainer, getter_AddRefs(child));
|
||||
|
||||
PRInt32 childCount = aContainer->GetChildCount();
|
||||
|
||||
nsIContent *child = aContainer->GetChildAt(aNewIndexInContainer);
|
||||
|
||||
nsCOMPtr<nsIContent> ins;
|
||||
GetNestedInsertionPoint(aContainer, child, getter_AddRefs(ins));
|
||||
|
||||
@ -1439,7 +1439,7 @@ nsBindingManager::ContentAppended(nsIDocument* aDocument,
|
||||
// We're real. Jam all the kids in.
|
||||
// XXX Check the filters to find the correct points.
|
||||
for (PRInt32 j = aNewIndexInContainer; j < childCount; j++) {
|
||||
aContainer->ChildAt(j, getter_AddRefs(child));
|
||||
child = aContainer->GetChildAt(j);
|
||||
point->AddChild(child);
|
||||
SetInsertionParent(child, ins);
|
||||
}
|
||||
|
||||
@ -216,11 +216,9 @@ nsXBLBinding::InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElem
|
||||
|
||||
// (2) The children's parent back pointer should not be to this synthetic root
|
||||
// but should instead point to the enclosing parent element.
|
||||
PRInt32 childCount;
|
||||
aAnonParent->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aAnonParent->ChildAt(i, getter_AddRefs(child));
|
||||
PRUint32 childCount = aAnonParent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = aAnonParent->GetChildAt(i);
|
||||
child->SetParent(aElement);
|
||||
child->SetBindingParent(mBoundElement);
|
||||
|
||||
@ -462,11 +460,9 @@ PRBool PR_CALLBACK RealizeDefaultContent(nsHashKey* aKey, void* aData, void* aCl
|
||||
|
||||
// Now make sure the kids of the clone are added to the insertion point as
|
||||
// children.
|
||||
PRInt32 cloneKidCount;
|
||||
clonedContent->ChildCount(cloneKidCount);
|
||||
for (PRInt32 k = 0; k < cloneKidCount; k++) {
|
||||
nsCOMPtr<nsIContent> cloneChild;
|
||||
clonedContent->ChildAt(k, getter_AddRefs(cloneChild));
|
||||
PRUint32 cloneKidCount = clonedContent->GetChildCount();
|
||||
for (PRUint32 k = 0; k < cloneKidCount; k++) {
|
||||
nsIContent *cloneChild = clonedContent->GetChildAt(k);
|
||||
bm->SetInsertionParent(cloneChild, insParent);
|
||||
currPoint->AddChild(cloneChild);
|
||||
}
|
||||
@ -509,8 +505,7 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
|
||||
// Find out if we're really building kids or if we're just
|
||||
// using the attribute-setting shorthand hack.
|
||||
PRInt32 contentCount;
|
||||
content->ChildCount(contentCount);
|
||||
PRUint32 contentCount = content->GetChildCount();
|
||||
|
||||
// Plan to build the content by default.
|
||||
PRBool hasContent = (contentCount > 0);
|
||||
@ -682,14 +677,13 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
// Always check the content element for potential attributes.
|
||||
// This shorthand hack always happens, even when we didn't
|
||||
// build anonymous content.
|
||||
PRInt32 length;
|
||||
content->GetAttrCount(length);
|
||||
PRUint32 length = content->GetAttrCount();
|
||||
|
||||
PRInt32 namespaceID;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
for (PRInt32 i = 0; i < length; ++i) {
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
content->GetAttrNameAt(i, &namespaceID, getter_AddRefs(name),
|
||||
getter_AddRefs(prefix));
|
||||
|
||||
@ -1237,11 +1231,10 @@ nsXBLBinding::GetImmediateChild(nsIAtom* aTag, nsIContent** aResult)
|
||||
nsCOMPtr<nsIContent> binding = mPrototypeBinding->GetBindingElement();
|
||||
|
||||
*aResult = nsnull;
|
||||
PRInt32 childCount;
|
||||
binding->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
binding->ChildAt(i, getter_AddRefs(child));
|
||||
PRUint32 childCount = binding->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = binding->GetChildAt(i);
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
child->GetTag(getter_AddRefs(tag));
|
||||
if (aTag == tag) {
|
||||
@ -1250,8 +1243,6 @@ nsXBLBinding::GetImmediateChild(nsIAtom* aTag, nsIContent** aResult)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -1333,14 +1324,11 @@ nsXBLBinding::GetTextData(nsIContent *aParent, nsString& aResult)
|
||||
{
|
||||
aResult.Truncate(0);
|
||||
|
||||
nsCOMPtr<nsIContent> textChild;
|
||||
PRInt32 textCount;
|
||||
aParent->ChildCount(textCount);
|
||||
PRUint32 textCount = aParent->GetChildCount();
|
||||
nsAutoString answer;
|
||||
for (PRInt32 j = 0; j < textCount; j++) {
|
||||
for (PRUint32 j = 0; j < textCount; j++) {
|
||||
// Get the child.
|
||||
aParent->ChildAt(j, getter_AddRefs(textChild));
|
||||
nsCOMPtr<nsIDOMText> text(do_QueryInterface(textChild));
|
||||
nsCOMPtr<nsIDOMText> text(do_QueryInterface(aParent->GetChildAt(j)));
|
||||
if (text) {
|
||||
nsAutoString data;
|
||||
text->GetData(data);
|
||||
|
||||
@ -178,3 +178,23 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewXBLProtoImpl(nsXBLPrototypeBinding* aBinding,
|
||||
const PRUnichar* aClassName,
|
||||
nsXBLProtoImpl** aResult)
|
||||
{
|
||||
nsXBLProtoImpl* impl = new nsXBLProtoImpl();
|
||||
if (!impl)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (aClassName)
|
||||
impl->mClassName.AssignWithConversion(aClassName);
|
||||
else
|
||||
aBinding->GetBindingURI(impl->mClassName);
|
||||
aBinding->SetImplementation(impl);
|
||||
*aResult = impl;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -87,20 +87,9 @@ public:
|
||||
nsXBLPrototypeHandler* mDestructor; // Our class destructor.
|
||||
};
|
||||
|
||||
static nsresult
|
||||
nsresult
|
||||
NS_NewXBLProtoImpl(nsXBLPrototypeBinding* aBinding,
|
||||
const PRUnichar* aClassName,
|
||||
nsXBLProtoImpl** aResult) {
|
||||
nsXBLProtoImpl* impl = new nsXBLProtoImpl();
|
||||
if (!impl)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (aClassName)
|
||||
impl->mClassName.AssignWithConversion(aClassName);
|
||||
else
|
||||
aBinding->GetBindingURI(impl->mClassName);
|
||||
aBinding->SetImplementation(impl);
|
||||
*aResult = impl;
|
||||
return NS_OK;
|
||||
}
|
||||
nsXBLProtoImpl** aResult);
|
||||
|
||||
#endif // nsXBLProtoImpl_h__
|
||||
|
||||
@ -505,11 +505,10 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
|
||||
realElement->GetTag(getter_AddRefs(tag));
|
||||
if (dstAttr == nsXBLAtoms::xbltext || (tag == nsHTMLAtoms::html) && (dstAttr == nsHTMLAtoms::value)) {
|
||||
// Flush out all our kids.
|
||||
PRInt32 childCount;
|
||||
realElement->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++)
|
||||
PRUint32 childCount = realElement->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; i++)
|
||||
realElement->RemoveChildAt(0, aNotify);
|
||||
|
||||
|
||||
if (!aRemoveFlag) {
|
||||
// Construct a new text node and insert it.
|
||||
nsAutoString value;
|
||||
@ -725,17 +724,15 @@ nsXBLPrototypeBinding::ImplementsInterface(REFNSIID aIID)
|
||||
already_AddRefed<nsIContent>
|
||||
nsXBLPrototypeBinding::GetImmediateChild(nsIAtom* aTag)
|
||||
{
|
||||
PRInt32 childCount;
|
||||
mBinding->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
mBinding->ChildAt(i, getter_AddRefs(child));
|
||||
PRUint32 childCount = mBinding->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = mBinding->GetChildAt(i);
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
child->GetTag(getter_AddRefs(tag));
|
||||
if (aTag == tag) {
|
||||
nsIContent* result = child;
|
||||
NS_ADDREF(result);
|
||||
return result;
|
||||
NS_ADDREF(child);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,12 +826,11 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
defContent = currPoint->GetDefaultContent();
|
||||
if (defContent) {
|
||||
// Find out the index of the template element within the <children> elt.
|
||||
PRInt32 index;
|
||||
childPoint->IndexOf(aTemplChild, index);
|
||||
PRInt32 index = childPoint->IndexOf(aTemplChild);
|
||||
|
||||
// Now we just have to find the corresponding elt underneath the cloned
|
||||
// default content.
|
||||
defContent->ChildAt(index, &result); // addrefs
|
||||
result = defContent->GetChildAt(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -842,11 +838,12 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
}
|
||||
else if (copyParent)
|
||||
{
|
||||
PRInt32 index;
|
||||
templParent->IndexOf(aTemplChild, index);
|
||||
copyParent->ChildAt(index, &result); // Addref happens here.
|
||||
PRInt32 index = templParent->IndexOf(aTemplChild);
|
||||
result = copyParent->GetChildAt(index);
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1053,12 +1050,9 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement)
|
||||
}
|
||||
|
||||
// Recur into our children.
|
||||
PRInt32 childCount;
|
||||
aElement->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aElement->ChildAt(i, getter_AddRefs(child));
|
||||
ConstructAttributeTable(child);
|
||||
PRUint32 childCount = aElement->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
ConstructAttributeTable(aElement->GetChildAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1136,8 +1130,7 @@ nsXBLPrototypeBinding::ConstructInsertionTable(nsIContent* aContent)
|
||||
// if we dynamically obtain our index each time, then the removals of previous
|
||||
// siblings will cause the index to adjust (and we won't have to take that into
|
||||
// account explicitly).
|
||||
PRInt32 index;
|
||||
parent->IndexOf(child, index);
|
||||
PRInt32 index = parent->IndexOf(child);
|
||||
xblIns->SetInsertionIndex((PRUint32)index);
|
||||
|
||||
// Now remove the <children> element from the template. This ensures that the
|
||||
@ -1148,8 +1141,7 @@ nsXBLPrototypeBinding::ConstructInsertionTable(nsIContent* aContent)
|
||||
// See if the insertion point contains default content. Default content must
|
||||
// be cached in our insertion point entry, since it will need to be cloned
|
||||
// in situations where no content ends up being placed at the insertion point.
|
||||
PRInt32 defaultCount;
|
||||
child->ChildCount(defaultCount);
|
||||
PRUint32 defaultCount = child->GetChildCount();
|
||||
if (defaultCount > 0) {
|
||||
// Annotate the insertion point with our default content.
|
||||
xblIns->SetDefaultContent(child);
|
||||
@ -1239,11 +1231,11 @@ void
|
||||
nsXBLPrototypeBinding::GetNestedChildren(nsIAtom* aTag, nsIContent* aContent,
|
||||
nsISupportsArray** aList)
|
||||
{
|
||||
PRInt32 childCount;
|
||||
aContent->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
PRUint32 childCount = aContent->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
child->GetTag(getter_AddRefs(tag));
|
||||
if (aTag == tag) {
|
||||
|
||||
@ -273,7 +273,7 @@ nsXBLResourceLoader::NotifyBoundElements()
|
||||
nsCOMPtr<nsIContent> parent = content->GetParent();
|
||||
PRInt32 index = 0;
|
||||
if (parent)
|
||||
parent->IndexOf(content, index);
|
||||
index = parent->IndexOf(content);
|
||||
|
||||
// If |content| is (in addition to having binding |mBinding|)
|
||||
// also a descendant of another element with binding |mBinding|,
|
||||
@ -284,8 +284,7 @@ nsXBLResourceLoader::NotifyBoundElements()
|
||||
// has a primary frame and whether it's in the undisplayed map
|
||||
// before sending a ContentInserted notification, or bad things
|
||||
// will happen.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsIFrame* childFrame;
|
||||
shell->GetPrimaryFrameFor(content, &childFrame);
|
||||
|
||||
@ -153,7 +153,7 @@ public:
|
||||
nsCOMPtr<nsIContent> parent = mBoundElement->GetParent();
|
||||
PRInt32 index = 0;
|
||||
if (parent)
|
||||
parent->IndexOf(mBoundElement, index);
|
||||
index = parent->IndexOf(mBoundElement);
|
||||
|
||||
// If |mBoundElement| is (in addition to having binding |mBinding|)
|
||||
// also a descendant of another element with binding |mBinding|,
|
||||
@ -164,8 +164,7 @@ public:
|
||||
// has a primary frame and whether it's in the undisplayed map
|
||||
// before sending a ContentInserted notification, or bad things
|
||||
// will happen.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsIFrame* childFrame;
|
||||
shell->GetPrimaryFrameFor(mBoundElement, &childFrame);
|
||||
|
||||
@ -75,15 +75,13 @@ static void
|
||||
BuildHandlerChain(nsIContent* aContent, nsXBLPrototypeHandler** aResult)
|
||||
{
|
||||
nsXBLPrototypeHandler *firstHandler = nsnull, *currHandler = nsnull;
|
||||
|
||||
PRInt32 handlerCount;
|
||||
aContent->ChildCount(handlerCount);
|
||||
for (PRInt32 j = 0; j < handlerCount; j++) {
|
||||
nsCOMPtr<nsIContent> handler;
|
||||
aContent->ChildAt(j, getter_AddRefs(handler));
|
||||
|
||||
|
||||
PRUint32 handlerCount = aContent->GetChildCount();
|
||||
for (PRUint32 j = 0; j < handlerCount; j++) {
|
||||
nsIContent *handler = aContent->GetChildAt(j);
|
||||
|
||||
nsXBLPrototypeHandler* newHandler = new nsXBLPrototypeHandler(handler);
|
||||
|
||||
|
||||
if (newHandler) {
|
||||
if (currHandler)
|
||||
currHandler->SetNextHandler(newHandler);
|
||||
|
||||
@ -528,93 +528,6 @@ nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// XXX Yuck! Reaching into the generic content object isn't good.
|
||||
nsDOMSlots *slots = GetDOMSlots();
|
||||
|
||||
if (!slots) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!slots->mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
nsAutoString tag;
|
||||
mNodeInfo->GetQualifiedName(tag);
|
||||
|
||||
res = factory->NewScriptXMLElement(tag, aContext,
|
||||
NS_STATIC_CAST(nsIContent *, this),
|
||||
mParent, (void**)&slots->mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
|
||||
if (mDocument && slots->mScriptObject) {
|
||||
aContext->AddNamedReference((void *)&slots->mScriptObject,
|
||||
slots->mScriptObject,
|
||||
"nsXMLElement::mScriptObject");
|
||||
|
||||
// See if we have a frame.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIFrame* frame;
|
||||
shell->GetPrimaryFrameFor(this, &frame);
|
||||
if (!frame) {
|
||||
// We must ensure that the XBL Binding is installed before we hand
|
||||
// back this object.
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(this, getter_AddRefs(binding));
|
||||
if (!binding) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> global;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(global));
|
||||
nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(global));
|
||||
if (viewCSS) {
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
nsAutoString empty;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
viewCSS->GetComputedStyle(elt, empty, getter_AddRefs(cssDecl));
|
||||
if (cssDecl) {
|
||||
nsAutoString behavior;
|
||||
behavior.Assign(NS_LITERAL_STRING("-moz-binding"));
|
||||
|
||||
nsAutoString value;
|
||||
cssDecl->GetPropertyValue(behavior, value);
|
||||
if (!value.IsEmpty()) {
|
||||
// We have a binding that must be installed.
|
||||
nsresult rv;
|
||||
PRBool dummy;
|
||||
nsCOMPtr<nsIXBLService> xblService =
|
||||
do_GetService("@mozilla.org/xbl;1", &rv);
|
||||
xblService->LoadBindings(this, value, PR_FALSE,
|
||||
getter_AddRefs(binding), &dummy);
|
||||
if (binding) {
|
||||
binding->ExecuteAttachedHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aScriptObject = slots->mScriptObject;
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nsIStyledContent implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -330,35 +330,33 @@ nsXMLContentSink::ScrollToRef(PRBool aReallyScroll)
|
||||
// http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
|
||||
NS_ConvertUTF8toUCS2 ref(unescapedRef);
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
PRUint32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
// Scroll to the anchor
|
||||
if (aReallyScroll) {
|
||||
shell->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
// Check an empty string which might be caused by the UTF-8 conversion
|
||||
if (!ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
// Scroll to the anchor
|
||||
if (aReallyScroll) {
|
||||
shell->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
|
||||
// If UTF-8 URL failed then try to assume the string as a
|
||||
// document's charset.
|
||||
// Check an empty string which might be caused by the UTF-8 conversion
|
||||
if (!ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCAutoString docCharset;
|
||||
rv = mDocument->GetDocumentCharacterSet(docCharset);
|
||||
// If UTF-8 URL failed then try to assume the string as a
|
||||
// document's charset.
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CharsetConvRef(docCharset, unescapedRef, ref);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCAutoString docCharset;
|
||||
rv = mDocument->GetDocumentCharacterSet(docCharset);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CharsetConvRef(docCharset, unescapedRef, ref);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1122,8 +1120,7 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
|
||||
// Disable theming for the presshell if the value is no.
|
||||
nsAutoString value(aValue);
|
||||
if (value.EqualsIgnoreCase("no")) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
if (shell)
|
||||
shell->DisableThemeSupport();
|
||||
}
|
||||
@ -1326,26 +1323,24 @@ nsXMLContentSink::StartLayout()
|
||||
scrollableContainer->ResetScrollbarPreferences();
|
||||
}
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
PRUint32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (nsnull != shell) {
|
||||
// Make shell an observer for next time
|
||||
shell->BeginObservingDocument();
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
// Resize-reflow this time
|
||||
nsCOMPtr<nsIPresContext> cx;
|
||||
shell->GetPresContext(getter_AddRefs(cx));
|
||||
nsRect r;
|
||||
cx->GetVisibleArea(r);
|
||||
shell->InitialReflow(r.width, r.height);
|
||||
// Make shell an observer for next time
|
||||
shell->BeginObservingDocument();
|
||||
|
||||
// Now trigger a refresh
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
RefreshIfEnabled(vm);
|
||||
}
|
||||
// Resize-reflow this time
|
||||
nsCOMPtr<nsIPresContext> cx;
|
||||
shell->GetPresContext(getter_AddRefs(cx));
|
||||
nsRect r;
|
||||
cx->GetVisibleArea(r);
|
||||
shell->InitialReflow(r.width, r.height);
|
||||
|
||||
// Now trigger a refresh
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
RefreshIfEnabled(vm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1357,7 +1352,7 @@ nsXMLContentSink::StartLayout()
|
||||
// finding the 'ref' part of the URI, we'll haveto revert to
|
||||
// string routines for finding the data past '#'
|
||||
|
||||
nsresult rv = mDocumentURL->GetSpec(ref);
|
||||
mDocumentURL->GetSpec(ref);
|
||||
|
||||
nsReadingIterator<char> start, end;
|
||||
|
||||
@ -1390,19 +1385,17 @@ nsXMLContentSink::StartLayout()
|
||||
// scroll bars.
|
||||
ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
nsIView* rootView = nsnull;
|
||||
vm->GetRootView(rootView);
|
||||
if (rootView) {
|
||||
nsIScrollableView* sview = nsnull;
|
||||
CallQueryInterface(rootView, &sview);
|
||||
if (sview) {
|
||||
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
|
||||
}
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
nsIViewManager* vm = shell->GetViewManager();
|
||||
if (vm) {
|
||||
nsIView* rootView = nsnull;
|
||||
vm->GetRootView(rootView);
|
||||
if (rootView) {
|
||||
nsIScrollableView* sview = nsnull;
|
||||
CallQueryInterface(rootView, &sview);
|
||||
if (sview) {
|
||||
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1065,13 +1065,10 @@ MatchElementId(nsIContent *aContent, const nsACString& aUTF8Id, const nsAString&
|
||||
}
|
||||
|
||||
nsIContent *result = nsnull;
|
||||
PRInt32 i, count;
|
||||
PRUint32 i, count = aContent->GetChildCount();
|
||||
|
||||
aContent->ChildCount(count);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (i = 0; i < count && result == nsnull; i++) {
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
result = MatchElementId(child, aUTF8Id, aId);
|
||||
result = MatchElementId(aContent->GetChildAt(i), aUTF8Id, aId);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@ -66,7 +66,7 @@ public:
|
||||
* Peek at a XUL element's child count without forcing children to be
|
||||
* instantiated.
|
||||
*/
|
||||
NS_IMETHOD PeekChildCount(PRInt32& aCount) const = 0;
|
||||
NS_IMETHOD_(PRUint32) PeekChildCount() const = 0;
|
||||
|
||||
/**
|
||||
* These flags are used to maintain bookkeeping information for partially-
|
||||
|
||||
@ -173,7 +173,7 @@ public:
|
||||
|
||||
// Implementation methods
|
||||
// VoidArray Helpers
|
||||
PRInt32 Count() { return mAttributes.Count(); };
|
||||
PRUint32 Count() { return mAttributes.Count(); };
|
||||
nsXULAttribute* ElementAt(PRInt32 i) { return (nsXULAttribute*)mAttributes.ElementAt(i); };
|
||||
void AppendElement(nsXULAttribute* aElement) { mAttributes.AppendElement((void*)aElement); };
|
||||
void RemoveElementAt(PRInt32 aIndex) { mAttributes.RemoveElementAt(aIndex); };
|
||||
|
||||
@ -505,7 +505,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
|
||||
// Check each attribute on the prototype to see if we need to do
|
||||
// any additional processing and hookup that would otherwise be
|
||||
// done 'automagically' by SetAttribute().
|
||||
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i)
|
||||
for (PRUint32 i = 0; i < aPrototype->mNumAttributes; ++i)
|
||||
element->AddListenerFor(aPrototype->mAttributes[i].mNodeInfo, PR_TRUE);
|
||||
}
|
||||
|
||||
@ -716,17 +716,10 @@ nsXULElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
NS_ENSURE_TRUE(children, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(children);
|
||||
|
||||
PRInt32 count;
|
||||
rv = ChildCount(count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get child count");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 count = GetChildCount();
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = ChildAt(i, getter_AddRefs(child));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get child");
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *child = GetChildAt(i);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(child);
|
||||
if (!domNode) {
|
||||
@ -749,14 +742,10 @@ nsXULElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = ChildAt(0, getter_AddRefs(child));
|
||||
nsIContent *child = GetChildAt(0);
|
||||
|
||||
if (child) {
|
||||
rv = CallQueryInterface(child, aFirstChild);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node");
|
||||
return rv;
|
||||
return CallQueryInterface(child, aFirstChild);
|
||||
}
|
||||
|
||||
*aFirstChild = nsnull;
|
||||
@ -767,22 +756,12 @@ nsXULElement::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 count;
|
||||
rv = ChildCount(count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get child count");
|
||||
PRUint32 count = GetChildCount();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (count != 0)) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = ChildAt(count - 1, getter_AddRefs(child));
|
||||
if (count > 0) {
|
||||
nsIContent *child = GetChildAt(count - 1);
|
||||
|
||||
NS_ASSERTION(child, "no child");
|
||||
|
||||
if (child) {
|
||||
rv = CallQueryInterface(child, aLastChild);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node");
|
||||
return rv;
|
||||
}
|
||||
return CallQueryInterface(child, aLastChild);
|
||||
}
|
||||
|
||||
*aLastChild = nsnull;
|
||||
@ -794,11 +773,9 @@ NS_IMETHODIMP
|
||||
nsXULElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
if (nsnull != mParent) {
|
||||
PRInt32 pos;
|
||||
mParent->IndexOf(NS_STATIC_CAST(nsIStyledContent*, this), pos);
|
||||
PRInt32 pos = mParent->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
nsCOMPtr<nsIContent> prev;
|
||||
mParent->ChildAt(--pos, getter_AddRefs(prev));
|
||||
nsIContent *prev = mParent->GetChildAt(--pos);
|
||||
if (prev) {
|
||||
nsresult rv = CallQueryInterface(prev, aPreviousSibling);
|
||||
NS_ASSERTION(*aPreviousSibling, "not a DOM node");
|
||||
@ -818,15 +795,13 @@ NS_IMETHODIMP
|
||||
nsXULElement::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
if (nsnull != mParent) {
|
||||
PRInt32 pos;
|
||||
mParent->IndexOf(NS_STATIC_CAST(nsIStyledContent*, this), pos);
|
||||
PRInt32 pos = mParent->IndexOf(this);
|
||||
if (pos > -1) {
|
||||
nsCOMPtr<nsIContent> next;
|
||||
mParent->ChildAt(++pos, getter_AddRefs(next));
|
||||
nsIContent *next = mParent->GetChildAt(++pos);
|
||||
if (next) {
|
||||
nsresult res = CallQueryInterface(next, aNextSibling);
|
||||
nsresult rv = CallQueryInterface(next, aNextSibling);
|
||||
NS_ASSERTION(*aNextSibling, "not a DOM Node");
|
||||
return res;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -960,10 +935,7 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsCOMPtr<nsIContent> oldparent = newcontent->GetParent();
|
||||
|
||||
if (oldparent) {
|
||||
PRInt32 oldindex;
|
||||
rv = oldparent->IndexOf(newcontent, oldindex);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aNewChild in old parent");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRInt32 oldindex = oldparent->IndexOf(newcontent);
|
||||
|
||||
NS_ASSERTION(oldindex >= 0, "old parent didn't think aNewChild was a child");
|
||||
|
||||
@ -980,10 +952,7 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
if (! refcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(refcontent, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aRefChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRInt32 pos = IndexOf(refcontent);
|
||||
|
||||
if (pos >= 0) {
|
||||
// Some frames assume that the document will have been set,
|
||||
@ -1032,11 +1001,9 @@ nsXULElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
NS_ASSERTION(oldelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (oldelement) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(oldelement, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
PRInt32 pos = IndexOf(oldelement);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
if (pos >= 0) {
|
||||
nsCOMPtr<nsIContent> newelement = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newelement != nsnull, "not an nsIContent");
|
||||
|
||||
@ -1068,11 +1035,9 @@ nsXULElement::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
NS_ASSERTION(element != nsnull, "not an nsIContent");
|
||||
|
||||
if (element) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(element, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
PRInt32 pos = IndexOf(element);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
if (pos >= 0) {
|
||||
rv = RemoveChildAt(pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove old child");
|
||||
}
|
||||
@ -1094,12 +1059,8 @@ nsXULElement::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 count;
|
||||
if (NS_FAILED(rv = ChildCount(count))) {
|
||||
NS_ERROR("unable to count kids");
|
||||
return rv;
|
||||
}
|
||||
PRUint32 count = GetChildCount();
|
||||
|
||||
*aReturn = (count > 0);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1229,13 +1190,10 @@ nsXULElement::GetTagName(nsAString& aTagName)
|
||||
return NodeInfo()->GetQualifiedName(aTagName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetNodeInfo(nsINodeInfo** aResult) const
|
||||
NS_IMETHODIMP_(nsINodeInfo *)
|
||||
nsXULElement::GetNodeInfo() const
|
||||
{
|
||||
*aResult = NodeInfo();
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
return NodeInfo();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1565,11 +1523,10 @@ nsXULElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
|
||||
//----------------------------------------------------------------------
|
||||
// nsIXULContent interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::PeekChildCount(PRInt32& aCount) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsXULElement::PeekChildCount() const
|
||||
{
|
||||
aCount = mChildren.Count();
|
||||
return NS_OK;
|
||||
return mChildren.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1695,7 +1652,7 @@ nsXULElement::GetCompiledEventHandler(nsIAtom *aName, void** aHandler)
|
||||
XUL_PROTOTYPE_ATTRIBUTE_METER(gNumCacheTests);
|
||||
*aHandler = nsnull;
|
||||
if (mPrototype) {
|
||||
for (PRInt32 i = 0; i < mPrototype->mNumAttributes; ++i) {
|
||||
for (PRUint32 i = 0; i < mPrototype->mNumAttributes; ++i) {
|
||||
nsXULPrototypeAttribute* attr = &(mPrototype->mAttributes[i]);
|
||||
|
||||
if (attr->mNodeInfo->Equals(aName, kNameSpaceID_None)) {
|
||||
@ -1749,7 +1706,7 @@ nsXULElement::CompileEventHandler(nsIScriptContext* aContext,
|
||||
|
||||
if (mPrototype) {
|
||||
// Remember the compiled event handler
|
||||
for (PRInt32 i = 0; i < mPrototype->mNumAttributes; ++i) {
|
||||
for (PRUint32 i = 0; i < mPrototype->mNumAttributes; ++i) {
|
||||
nsXULPrototypeAttribute* attr = &(mPrototype->mAttributes[i]);
|
||||
|
||||
if (attr->mNodeInfo->Equals(aName, kNameSpaceID_None)) {
|
||||
@ -1940,57 +1897,46 @@ nsXULElement::SetNativeAnonymous(PRBool aAnonymous)
|
||||
// XXX Need to make this actually do something - bug 165110
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::CanContainChildren(PRBool& aResult) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsXULElement::CanContainChildren() const
|
||||
{
|
||||
// XXX Hmm -- not sure if this is unilaterally true...
|
||||
aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::ChildCount(PRInt32& aResult) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsXULElement::GetChildCount() const
|
||||
{
|
||||
if (NS_FAILED(EnsureContentsGenerated())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return PeekChildCount();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIContent *)
|
||||
nsXULElement::GetChildAt(PRUint32 aIndex) const
|
||||
{
|
||||
if (NS_FAILED(EnsureContentsGenerated())) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return NS_STATIC_CAST(nsIContent*, mChildren.SafeElementAt(aIndex));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsXULElement::IndexOf(nsIContent* aPossibleChild) const
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated())) {
|
||||
aResult = 0;
|
||||
return rv;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return PeekChildCount(aResult);
|
||||
return mChildren.IndexOf(aPossibleChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::ChildAt(PRInt32 aIndex, nsIContent** aResult) const
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated())) {
|
||||
*aResult = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIContent* content = NS_STATIC_CAST(nsIContent*, mChildren.SafeElementAt(aIndex));
|
||||
*aResult = content;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated())) {
|
||||
aResult = -1;
|
||||
return rv;
|
||||
}
|
||||
|
||||
aResult = mChildren.IndexOf(aPossibleChild);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -2036,7 +1982,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
nsXULElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -2118,7 +2064,7 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDoc
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated()))
|
||||
@ -2318,8 +2264,7 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
|
||||
// If someone changes the accesskey, unregister the old one
|
||||
//
|
||||
if (mDocument && !aOldValue.IsEmpty()) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
|
||||
if (shell) {
|
||||
PRBool validElement = PR_TRUE;
|
||||
@ -2774,7 +2719,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
nsXULElement::GetAttrNameAt(PRUint32 aIndex,
|
||||
PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName,
|
||||
nsIAtom** aPrefix) const
|
||||
@ -2848,15 +2793,16 @@ nsXULElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetAttrCount(PRInt32& aResult) const
|
||||
NS_IMETHODIMP_(PRUint32)
|
||||
nsXULElement::GetAttrCount() const
|
||||
{
|
||||
aResult = 0;
|
||||
PRBool haveLocalAttributes;
|
||||
|
||||
PRUint32 count = 0;
|
||||
|
||||
if (Attributes()) {
|
||||
aResult = Attributes()->Count();
|
||||
haveLocalAttributes = aResult > 0;
|
||||
count = Attributes()->Count();
|
||||
haveLocalAttributes = count > 0;
|
||||
} else {
|
||||
haveLocalAttributes = PR_FALSE;
|
||||
}
|
||||
@ -2866,10 +2812,10 @@ nsXULElement::GetAttrCount(PRInt32& aResult) const
|
||||
#endif
|
||||
|
||||
if (mPrototype) {
|
||||
for (int i = 0; i < mPrototype->mNumAttributes; i++) {
|
||||
for (PRUint32 i = 0; i < mPrototype->mNumAttributes; i++) {
|
||||
if (!haveLocalAttributes ||
|
||||
!FindLocalAttribute(mPrototype->mAttributes[i].mNodeInfo)) {
|
||||
aResult++;
|
||||
++count;
|
||||
} else {
|
||||
#ifdef DEBUG_ATTRIBUTE_STATS
|
||||
if (haveLocalAttributes)
|
||||
@ -2893,7 +2839,7 @@ nsXULElement::GetAttrCount(PRInt32& aResult) const
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@ -2909,7 +2855,7 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument != nsnull, "bad content");
|
||||
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
|
||||
rdf_Indent(out, aIndent);
|
||||
fputs("<XUL", out);
|
||||
@ -2922,8 +2868,7 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
||||
|
||||
fprintf(out, "@%p", (void *)this);
|
||||
|
||||
PRInt32 nattrs;
|
||||
GetAttrCount(nattrs);
|
||||
PRUint32 nattrs = GetAttrCount();
|
||||
|
||||
for (i = 0; i < nattrs; ++i) {
|
||||
nsCOMPtr<nsIAtom> attr;
|
||||
@ -2953,17 +2898,13 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
||||
fputs(NS_LossyConvertUCS2toASCII(v).get(), out);
|
||||
}
|
||||
|
||||
PRInt32 nchildren;
|
||||
ChildCount(nchildren);
|
||||
PRUint32 nchildren = GetChildCount();
|
||||
|
||||
if (nchildren) {
|
||||
fputs("\n", out);
|
||||
|
||||
for (i = 0; i < nchildren; ++i) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
ChildAt(i, getter_AddRefs(child));
|
||||
|
||||
child->List(out, aIndent + 1);
|
||||
GetChildAt(i)->List(out, aIndent + 1);
|
||||
}
|
||||
|
||||
rdf_Indent(out, aIndent);
|
||||
@ -4152,19 +4093,17 @@ nsXULElement::Focus()
|
||||
return NS_OK;
|
||||
|
||||
// Obtain a presentation context and then call SetFocus.
|
||||
PRInt32 count = mDocument->GetNumberOfShells();
|
||||
if (count == 0)
|
||||
if (mDocument->GetNumberOfShells() == 0)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
|
||||
// Retrieve the context
|
||||
nsCOMPtr<nsIPresContext> aPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(aPresContext));
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
// Set focus
|
||||
return SetFocus(aPresContext);
|
||||
return SetFocus(presContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -4175,19 +4114,17 @@ nsXULElement::Blur()
|
||||
return NS_OK;
|
||||
|
||||
// Obtain a presentation context and then call SetFocus.
|
||||
PRInt32 count = mDocument->GetNumberOfShells();
|
||||
if (count == 0)
|
||||
if (mDocument->GetNumberOfShells() == 0)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
|
||||
// Retrieve the context
|
||||
nsCOMPtr<nsIPresContext> aPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(aPresContext));
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
// Set focus
|
||||
return RemoveFocus(aPresContext);
|
||||
return RemoveFocus(presContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -4200,12 +4137,11 @@ nsXULElement::Click()
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mDocument; // Strong just in case
|
||||
if (doc) {
|
||||
PRInt32 numShells = doc->GetNumberOfShells();
|
||||
nsCOMPtr<nsIPresShell> shell; // Strong
|
||||
PRUint32 numShells = doc->GetNumberOfShells();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
|
||||
for (PRInt32 i=0; i<numShells; i++) {
|
||||
doc->GetShellAt(i, getter_AddRefs(shell));
|
||||
for (PRUint32 i = 0; i < numShells; ++i) {
|
||||
nsIPresShell *shell = doc->GetShellAt(i);
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
|
||||
nsMouseEvent eventDown;
|
||||
@ -4246,12 +4182,11 @@ nsXULElement::DoCommand()
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = mDocument; // strong just in case
|
||||
if (doc) {
|
||||
PRInt32 numShells = doc->GetNumberOfShells();
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
PRUint32 numShells = doc->GetNumberOfShells();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
|
||||
for (PRInt32 i=0; i<numShells; i++) {
|
||||
doc->GetShellAt(i, getter_AddRefs(shell));
|
||||
for (PRUint32 i = 0; i < numShells; ++i) {
|
||||
nsIPresShell *shell = doc->GetShellAt(i);
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
@ -4302,12 +4237,9 @@ nsXULElement::SetBindingParent(nsIContent* aParent)
|
||||
{
|
||||
mBindingParent = aParent; // [Weak] no addref
|
||||
if (mBindingParent) {
|
||||
PRInt32 count;
|
||||
ChildCount(count);
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
ChildAt(i, getter_AddRefs(child));
|
||||
child->SetBindingParent(aParent);
|
||||
PRUint32 count = GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
GetChildAt(i)->SetBindingParent(aParent);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@ -4456,7 +4388,7 @@ nsXULPrototypeAttribute *
|
||||
nsXULElement::FindPrototypeAttribute(nsINodeInfo *info) const
|
||||
{
|
||||
if (mPrototype) {
|
||||
for (PRInt32 i = 0; i < mPrototype->mNumAttributes; i++) {
|
||||
for (PRUint32 i = 0; i < mPrototype->mNumAttributes; i++) {
|
||||
nsXULPrototypeAttribute *protoattr = &(mPrototype->mAttributes[i]);
|
||||
if (protoattr->mNodeInfo->Equals(info))
|
||||
return protoattr;
|
||||
@ -4470,7 +4402,7 @@ nsXULElement::FindPrototypeAttribute(PRInt32 ns, nsIAtom *name) const
|
||||
{
|
||||
if (!mPrototype)
|
||||
return nsnull;
|
||||
for (PRInt32 i = 0; i < mPrototype->mNumAttributes; i++) {
|
||||
for (PRUint32 i = 0; i < mPrototype->mNumAttributes; i++) {
|
||||
nsXULPrototypeAttribute *protoattr = &(mPrototype->mAttributes[i]);
|
||||
if (protoattr->mNodeInfo->Equals(name, ns))
|
||||
return protoattr;
|
||||
@ -4498,7 +4430,7 @@ nsresult nsXULElement::MakeHeavyweight()
|
||||
|
||||
if (proto->mNumAttributes > 0) {
|
||||
nsXULAttributes *attrs = mSlots->GetAttributes();
|
||||
for (PRInt32 i = 0; i < proto->mNumAttributes; ++i) {
|
||||
for (PRUint32 i = 0; i < proto->mNumAttributes; ++i) {
|
||||
nsXULPrototypeAttribute* protoattr = &(proto->mAttributes[i]);
|
||||
|
||||
// We might have a local value for this attribute, in which case
|
||||
@ -4531,31 +4463,27 @@ nsresult nsXULElement::MakeHeavyweight()
|
||||
nsresult
|
||||
nsXULElement::HideWindowChrome(PRBool aShouldHide)
|
||||
{
|
||||
PRInt32 shellCount = mDocument->GetNumberOfShells();
|
||||
if (shellCount > 0) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = mDocument->GetShellAt(0);
|
||||
|
||||
if (shell) {
|
||||
nsIContent* content = NS_STATIC_CAST(nsIContent*, this);
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
nsIContent* content = NS_STATIC_CAST(nsIContent*, this);
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
if (frame && presContext) {
|
||||
nsIView* view = frame->GetClosestView();
|
||||
if (frame && presContext) {
|
||||
nsIView* view = frame->GetClosestView();
|
||||
|
||||
if (view) {
|
||||
// XXXldb Um, not all views have widgets...
|
||||
view->GetWidget()->HideWindowChrome(aShouldHide);
|
||||
if (view) {
|
||||
// XXXldb Um, not all views have widgets...
|
||||
view->GetWidget()->HideWindowChrome(aShouldHide);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -4615,7 +4543,7 @@ nsXULPrototypeElement::Serialize(nsIObjectOutputStream* aStream,
|
||||
rv |= aStream->Write32(mNumAttributes);
|
||||
|
||||
nsAutoString attributeValue;
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mNumAttributes; ++i) {
|
||||
index = aNodeInfos->IndexOf(mAttributes[i].mNodeInfo);
|
||||
NS_ASSERTION(index >= 0, "unknown nsINodeInfo index");
|
||||
@ -4681,8 +4609,8 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
|
||||
// Read Attributes
|
||||
rv |= aStream->Read32(&number);
|
||||
mNumAttributes = PRInt32(number);
|
||||
|
||||
PRInt32 i;
|
||||
|
||||
PRUint32 i;
|
||||
if (mNumAttributes > 0) {
|
||||
mAttributes = new nsXULPrototypeAttribute[mNumAttributes];
|
||||
if (! mAttributes)
|
||||
@ -4796,7 +4724,7 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
|
||||
nsresult
|
||||
nsXULPrototypeElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsAString& aValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mNumAttributes; ++i) {
|
||||
for (PRUint32 i = 0; i < mNumAttributes; ++i) {
|
||||
if (mAttributes[i].mNodeInfo->Equals(aName, aNameSpaceID)) {
|
||||
mAttributes[i].mValue.GetValue( aValue );
|
||||
return aValue.IsEmpty() ? NS_CONTENT_ATTR_NO_VALUE : NS_CONTENT_ATTR_HAS_VALUE;
|
||||
|
||||
@ -263,12 +263,12 @@ public:
|
||||
nsIURI* aDocumentURI,
|
||||
nsISupportsArray* aNodeInfos);
|
||||
|
||||
PRInt32 mNumChildren;
|
||||
PRUint32 mNumChildren;
|
||||
nsXULPrototypeNode** mChildren; // [OWNER]
|
||||
|
||||
nsCOMPtr<nsINodeInfo> mNodeInfo; // [OWNER]
|
||||
|
||||
PRInt32 mNumAttributes;
|
||||
PRUint32 mNumAttributes;
|
||||
nsXULPrototypeAttribute* mAttributes; // [OWNER]
|
||||
|
||||
nsCOMPtr<nsIStyleRule> mInlineStyleRule; // [OWNER]
|
||||
@ -412,20 +412,20 @@ public:
|
||||
NS_IMETHOD SetParent(nsIContent* aParent);
|
||||
NS_IMETHOD_(PRBool) IsNativeAnonymous() const;
|
||||
NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous);
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent** aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
NS_IMETHOD_(PRBool) CanContainChildren() const;
|
||||
NS_IMETHOD_(PRUint32) GetChildCount() const;
|
||||
NS_IMETHOD_(nsIContent *) GetChildAt(PRUint32 aIndex) const;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(nsIContent* aPossibleChild) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32* aNameSpeceID) const;
|
||||
NS_IMETHOD GetTag(nsIAtom** aResult) const;
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo** aResult) const;
|
||||
NS_IMETHOD_(nsINodeInfo *) GetNodeInfo() const;
|
||||
NS_IMETHOD NormalizeAttrString(const nsAString& aStr, nsINodeInfo** aNodeInfo);
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD SetAttr(nsINodeInfo *aNodeInfo, const nsAString& aValue, PRBool aNotify);
|
||||
@ -433,9 +433,9 @@ public:
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom** aPrefix, nsAString& aResult) const;
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex, PRInt32* aNameSpaceID,
|
||||
NS_IMETHOD GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
|
||||
nsIAtom** aName, nsIAtom** aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD_(PRUint32) GetAttrCount() const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const { return NS_OK; }
|
||||
@ -478,7 +478,7 @@ public:
|
||||
NS_IMETHOD_(PRBool) HasAttributeDependentStyle(const nsIAtom* aAttribute) const;
|
||||
|
||||
// nsIXULContent
|
||||
NS_IMETHOD PeekChildCount(PRInt32& aCount) const;
|
||||
NS_IMETHOD_(PRUint32) PeekChildCount() const;
|
||||
NS_IMETHOD SetLazyState(LazyState aFlags);
|
||||
NS_IMETHOD ClearLazyState(LazyState aFlags);
|
||||
NS_IMETHOD GetLazyState(LazyState aFlag, PRBool& aValue);
|
||||
|
||||
@ -302,12 +302,13 @@ XULPopupListenerImpl::FireFocusOnTargetContent(nsIDOMNode* aTargetNode)
|
||||
rv = aTargetNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if(NS_SUCCEEDED(rv) && domDoc)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
nsCOMPtr<nsIDocument> tempdoc = do_QueryInterface(domDoc);
|
||||
tempdoc->GetShellAt(0, getter_AddRefs(shell)); // Get nsIDOMElement for targetNode
|
||||
|
||||
// Get nsIDOMElement for targetNode
|
||||
nsIPresShell *shell = tempdoc->GetShellAt(0);
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
|
||||
@ -402,11 +403,9 @@ static void
|
||||
GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
PRInt32 childCount;
|
||||
aContent->ChildCount(childCount);
|
||||
PRInt32 childCount = aContent->GetChildCount();
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
child->GetTag(getter_AddRefs(tag));
|
||||
if (aTag == tag.get()) {
|
||||
|
||||
@ -366,13 +366,10 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||
aeventnameC.get()));
|
||||
#endif
|
||||
|
||||
PRInt32 count = document->GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
document->GetShellAt(i, getter_AddRefs(shell));
|
||||
if (! shell)
|
||||
continue;
|
||||
|
||||
PRUint32 count = document->GetNumberOfShells();
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIPresShell *shell = document->GetShellAt(i);
|
||||
|
||||
// Retrieve the context in which our DOM event will fire.
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
rv = shell->GetPresContext(getter_AddRefs(context));
|
||||
|
||||
@ -1071,14 +1071,14 @@ XULContentSinkImpl::ReportError(const PRUnichar* aErrorText,
|
||||
|
||||
const PRUnichar* atts[] = {name.get(), value.get(), nsnull};;
|
||||
|
||||
rv = HandleStartElement(NS_LITERAL_STRING("parsererror").get(), atts, 1, -1, -1);
|
||||
rv = HandleStartElement(NS_LITERAL_STRING("parsererror").get(), atts, 1, 0, 0);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = HandleCharacterData(aErrorText, nsCRT::strlen(aErrorText));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
const PRUnichar* noAtts[] = {0, 0};
|
||||
rv = HandleStartElement(NS_LITERAL_STRING("sourcetext").get(), noAtts, 0, -1, -1);
|
||||
rv = HandleStartElement(NS_LITERAL_STRING("sourcetext").get(), noAtts, 0, 0, 0);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = HandleCharacterData(aSourceText, nsCRT::strlen(aSourceText));
|
||||
@ -1407,8 +1407,8 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
||||
// Use the SRC attribute value to load the URL
|
||||
rv = NS_NewURI(getter_AddRefs(script->mSrcURI), src, nsnull, mDocumentURL);
|
||||
|
||||
// Check if this document is allowed to load a script from this source
|
||||
// NOTE: if we ever allow scripts added via the DOM to run, we need to
|
||||
// Check if this document is allowed to load a script from this source
|
||||
// NOTE: if we ever allow scripts added via the DOM to run, we need to
|
||||
// add a CheckLoadURI call for that as well.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!mSecMan)
|
||||
|
||||
@ -163,7 +163,10 @@ nsXULControllers::InsertControllerAt(PRUint32 aIndex, nsIController *controller)
|
||||
{
|
||||
nsXULControllerData* controllerData = new nsXULControllerData(++mCurControllerID, controller);
|
||||
if (!controllerData) return NS_ERROR_OUT_OF_MEMORY;
|
||||
PRBool inserted = mControllers.InsertElementAt((void *)controllerData, aIndex);
|
||||
#ifdef DEBUG
|
||||
PRBool inserted =
|
||||
#endif
|
||||
mControllers.InsertElementAt((void *)controllerData, aIndex);
|
||||
NS_ASSERTION(inserted, "Insertion of controller failed");
|
||||
return NS_OK;
|
||||
}
|
||||
@ -176,10 +179,13 @@ nsXULControllers::RemoveControllerAt(PRUint32 aIndex, nsIController **_retval)
|
||||
|
||||
nsXULControllerData* controllerData = NS_STATIC_CAST(nsXULControllerData*, mControllers.SafeElementAt(aIndex));
|
||||
if (!controllerData) return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool removed = mControllers.RemoveElementAt(aIndex);
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool removed =
|
||||
#endif
|
||||
mControllers.RemoveElementAt(aIndex);
|
||||
NS_ASSERTION(removed, "Removal of controller failed");
|
||||
|
||||
|
||||
controllerData->GetController(_retval);
|
||||
delete controllerData;
|
||||
|
||||
@ -205,7 +211,11 @@ nsXULControllers::AppendController(nsIController *controller)
|
||||
// This assigns controller IDs starting at 1 so we can use 0 to test if an ID was obtained
|
||||
nsXULControllerData* controllerData = new nsXULControllerData(++mCurControllerID, controller);
|
||||
if (!controllerData) return NS_ERROR_OUT_OF_MEMORY;
|
||||
PRBool appended = mControllers.AppendElement((void *)controllerData);
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool appended =
|
||||
#endif
|
||||
mControllers.AppendElement((void *)controllerData);
|
||||
NS_ASSERTION(appended, "Appending controller failed");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -843,9 +843,8 @@ nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
|
||||
nsCOMPtr<nsIContent> listener = do_QueryInterface(aListener);
|
||||
|
||||
if (aAttr.Equals(NS_LITERAL_STRING("*"))) {
|
||||
PRInt32 count;
|
||||
broadcaster->GetAttrCount(count);
|
||||
while (--count >= 0) {
|
||||
PRUint32 count = broadcaster->GetAttrCount();
|
||||
while (count-- > 0) {
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
@ -1030,19 +1029,16 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
|
||||
// execute the handler.
|
||||
|
||||
nsCOMPtr<nsIContent> listener = do_QueryInterface(aListener);
|
||||
PRInt32 count;
|
||||
listener->ChildCount(count);
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
PRUint32 count = listener->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
// Look for an <observes> element beneath the listener. This
|
||||
// ought to have an |element| attribute that refers to
|
||||
// aBroadcaster, and an |attribute| element that tells us what
|
||||
// attriubtes we're listening for.
|
||||
nsCOMPtr<nsIContent> child;
|
||||
listener->ChildAt(i, getter_AddRefs(child));
|
||||
nsIContent *child = listener->GetChildAt(i);
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
child->GetTag(getter_AddRefs(tag));
|
||||
if (tag != nsXULAtoms::observes)
|
||||
nsINodeInfo *ni = child->GetNodeInfo();
|
||||
if (!ni || !ni->Equals(nsXULAtoms::observes, kNameSpaceID_XUL))
|
||||
continue;
|
||||
|
||||
// Is this the element that was listening to us?
|
||||
@ -1180,19 +1176,12 @@ nsXULDocument::ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
// First update our element map
|
||||
nsresult rv;
|
||||
PRUint32 count = aContainer->GetChildCount();
|
||||
|
||||
PRInt32 count;
|
||||
rv = aContainer->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
for (PRInt32 i = aNewIndexInContainer; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = aContainer->ChildAt(i, getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = AddSubtreeToDocument(child);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
for (PRUint32 i = aNewIndexInContainer; i < count; ++i) {
|
||||
nsresult rv = AddSubtreeToDocument(aContainer->GetChildAt(i));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return nsXMLDocument::ContentAppended(aContainer, aNewIndexInContainer);
|
||||
@ -1203,9 +1192,9 @@ nsXULDocument::ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = AddSubtreeToDocument(aChild);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsresult rv = AddSubtreeToDocument(aChild);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsXMLDocument::ContentInserted(aContainer, aChild,
|
||||
aIndexInContainer);
|
||||
@ -1219,10 +1208,12 @@ nsXULDocument::ContentReplaced(nsIContent* aContainer,
|
||||
{
|
||||
nsresult rv;
|
||||
rv = RemoveSubtreeFromDocument(aOldChild);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = AddSubtreeToDocument(aNewChild);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsXMLDocument::ContentReplaced(aContainer, aOldChild, aNewChild,
|
||||
aIndexInContainer);
|
||||
@ -1235,7 +1226,8 @@ nsXULDocument::ContentRemoved(nsIContent* aContainer,
|
||||
{
|
||||
nsresult rv;
|
||||
rv = RemoveSubtreeFromDocument(aChild);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsXMLDocument::ContentRemoved(aContainer, aChild,
|
||||
aIndexInContainer);
|
||||
@ -1725,21 +1717,20 @@ nsXULDocument::GetWidth(PRInt32* aWidth)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult result = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// We make the assumption that the first presentation shell
|
||||
// is the one for which we need information.
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (shell) {
|
||||
PRInt32 width, height;
|
||||
|
||||
result = GetPixelDimensions(shell, &width, &height);
|
||||
rv = GetPixelDimensions(shell, &width, &height);
|
||||
*aWidth = width;
|
||||
} else
|
||||
*aWidth = 0;
|
||||
|
||||
return result;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1747,21 +1738,20 @@ nsXULDocument::GetHeight(PRInt32* aHeight)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult result = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// We make the assumption that the first presentation shell
|
||||
// is the one for which we need information.
|
||||
GetShellAt(0, getter_AddRefs(shell));
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (shell) {
|
||||
PRInt32 width, height;
|
||||
|
||||
result = GetPixelDimensions(shell, &width, &height);
|
||||
rv = GetPixelDimensions(shell, &width, &height);
|
||||
*aHeight = height;
|
||||
} else
|
||||
*aHeight = 0;
|
||||
|
||||
return result;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1941,18 +1931,15 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aElement)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Recurse to children
|
||||
PRInt32 count = 0;
|
||||
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
|
||||
rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = aElement->ChildAt(count, getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 count =
|
||||
xulcontent ? xulcontent->PeekChildCount() : aElement->GetChildCount();
|
||||
|
||||
rv = AddSubtreeToDocument(child);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
while (count-- > 0) {
|
||||
rv = AddSubtreeToDocument(aElement->GetChildAt(count));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Do post-order addition magic
|
||||
@ -1967,18 +1954,15 @@ nsXULDocument::RemoveSubtreeFromDocument(nsIContent* aElement)
|
||||
nsresult rv;
|
||||
|
||||
// 1. Remove any children from the document.
|
||||
PRInt32 count;
|
||||
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
|
||||
rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = aElement->ChildAt(count, getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 count =
|
||||
xulcontent ? xulcontent->PeekChildCount() : aElement->GetChildCount();
|
||||
|
||||
rv = RemoveSubtreeFromDocument(child);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
while (count-- > 0) {
|
||||
rv = RemoveSubtreeFromDocument(aElement->GetChildAt(count));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// 2. Remove the element from the resource-to-element map
|
||||
@ -2224,12 +2208,9 @@ nsXULDocument::StartLayout(void)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 count = GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
GetShellAt(i, getter_AddRefs(shell));
|
||||
if (nsnull == shell)
|
||||
continue;
|
||||
PRUint32 count = GetNumberOfShells();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIPresShell *shell = GetShellAt(i);
|
||||
|
||||
// Resize-reflow this time
|
||||
nsCOMPtr<nsIPresContext> cx;
|
||||
@ -2883,7 +2864,7 @@ nsXULDocument::ResumeWalk()
|
||||
rv = mContextStack.Peek(&proto, getter_AddRefs(element), &indx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (indx >= proto->mNumChildren) {
|
||||
if (indx >= (PRInt32)proto->mNumChildren) {
|
||||
// We've processed all of the prototype's children. If
|
||||
// we're in the master prototype, do post-order
|
||||
// document-level hookup. (An overlay will get its
|
||||
@ -3557,7 +3538,7 @@ nsXULDocument::AddAttributes(nsXULPrototypeElement* aPrototype,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
|
||||
for (PRUint32 i = 0; i < aPrototype->mNumAttributes; ++i) {
|
||||
nsXULPrototypeAttribute* protoattr = &(aPrototype->mAttributes[i]);
|
||||
nsAutoString valueStr;
|
||||
protoattr->mValue.GetValue( valueStr );
|
||||
@ -3821,9 +3802,7 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
|
||||
|
||||
// Merge attributes from the overlay content node to that of the
|
||||
// actual document.
|
||||
PRInt32 attrCount, i;
|
||||
rv = aOverlayNode->GetAttrCount(attrCount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 i, attrCount = aOverlayNode->GetAttrCount();
|
||||
|
||||
for (i = 0; i < attrCount; ++i) {
|
||||
PRInt32 nameSpaceID;
|
||||
@ -3855,8 +3834,7 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
aTargetNode->GetNodeInfo(getter_AddRefs(ni));
|
||||
nsCOMPtr<nsINodeInfo> ni = aTargetNode->GetNodeInfo();
|
||||
|
||||
if (ni) {
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
@ -3878,14 +3856,14 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
|
||||
// to merge inside that subtree. If not, we just append the tree to
|
||||
// the parent like any other.
|
||||
|
||||
PRInt32 childCount;
|
||||
rv = aOverlayNode->ChildCount(childCount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 childCount = aOverlayNode->GetChildCount();
|
||||
|
||||
// This must be a strong reference since it will be the only
|
||||
// reference to a content object during part of this loop.
|
||||
nsCOMPtr<nsIContent> currContent;
|
||||
|
||||
for (i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIContent> currContent;
|
||||
rv = aOverlayNode->ChildAt(0, getter_AddRefs(currContent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
currContent = aOverlayNode->GetChildAt(0);
|
||||
|
||||
nsAutoString id;
|
||||
rv = currContent->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id);
|
||||
@ -4247,8 +4225,7 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild)
|
||||
if (!content)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRInt32 pos;
|
||||
aParent->IndexOf(content, pos);
|
||||
PRInt32 pos = aParent->IndexOf(content);
|
||||
|
||||
if (pos != -1) {
|
||||
pos = isInsertAfter ? pos + 1 : pos;
|
||||
@ -4292,16 +4269,9 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild)
|
||||
nsresult
|
||||
nsXULDocument::RemoveElement(nsIContent* aParent, nsIContent* aChild)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 nodeOffset = aParent->IndexOf(aChild);
|
||||
|
||||
PRInt32 nodeOffset;
|
||||
rv = aParent->IndexOf(aChild, nodeOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aParent->RemoveChildAt(nodeOffset, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
return aParent->RemoveChildAt(nodeOffset, PR_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -79,24 +79,21 @@ nsContentSupportMap::Remove(nsIContent* aElement)
|
||||
|
||||
PL_DHashTableOperate(&mMap, aElement, PL_DHASH_REMOVE);
|
||||
|
||||
PRInt32 count;
|
||||
PRUint32 count;
|
||||
|
||||
// If possible, use the special nsIXULContent interface to "peek"
|
||||
// at the child count without accidentally creating children as a
|
||||
// side effect, since we're about to rip 'em outta the map anyway.
|
||||
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
|
||||
if (xulcontent) {
|
||||
xulcontent->PeekChildCount(count);
|
||||
count = xulcontent->PeekChildCount();
|
||||
}
|
||||
else {
|
||||
aElement->ChildCount(count);
|
||||
count = aElement->GetChildCount();
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aElement->ChildAt(i, getter_AddRefs(child));
|
||||
|
||||
Remove(child);
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
Remove(aElement->GetChildAt(i));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@ -74,7 +74,8 @@ public:
|
||||
if (entry) {
|
||||
entry->mContent = aContent;
|
||||
entry->mTemplate = aTemplate;
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Remove(nsIContent* aContent) {
|
||||
@ -83,7 +84,7 @@ public:
|
||||
|
||||
PL_DHashTableOperate(&mTable, aContent, PL_DHASH_REMOVE);
|
||||
|
||||
PRInt32 count;
|
||||
PRUint32 count;
|
||||
|
||||
// If possible, use the special nsIXULContent interface to
|
||||
// "peek" at the child count without accidentally creating
|
||||
@ -91,18 +92,16 @@ public:
|
||||
// outta the map anyway.
|
||||
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aContent);
|
||||
if (xulcontent) {
|
||||
xulcontent->PeekChildCount(count);
|
||||
count = xulcontent->PeekChildCount();
|
||||
}
|
||||
else {
|
||||
aContent->ChildCount(count);
|
||||
count = aContent->GetChildCount();
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, getter_AddRefs(child));
|
||||
|
||||
Remove(child);
|
||||
} }
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
Remove(aContent->GetChildAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
@ -113,7 +112,8 @@ public:
|
||||
if (PL_DHASH_ENTRY_IS_BUSY(&entry->mHdr))
|
||||
NS_IF_ADDREF(*aResult = entry->mTemplate);
|
||||
else
|
||||
*aResult = nsnull; }
|
||||
*aResult = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
Clear() { Finish(); Init(); }
|
||||
|
||||
@ -464,18 +464,13 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
|
||||
// Iterate through all of the template children, constructing
|
||||
// "real" content model nodes for each "template" child.
|
||||
PRInt32 count;
|
||||
rv = aTemplateNode->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 count = aTemplateNode->GetChildCount();
|
||||
|
||||
for (PRInt32 kid = 0; kid < count; kid++) {
|
||||
nsCOMPtr<nsIContent> tmplKid;
|
||||
rv = aTemplateNode->ChildAt(kid, getter_AddRefs(tmplKid));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
for (PRUint32 kid = 0; kid < count; kid++) {
|
||||
nsIContent *tmplKid = aTemplateNode->GetChildAt(kid);
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
rv = tmplKid->GetNameSpaceID(&nameSpaceID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
tmplKid->GetNameSpaceID(&nameSpaceID);
|
||||
|
||||
// Check whether this element is the "resource" element. The
|
||||
// "resource" element is the element that is cookie-cutter
|
||||
@ -597,12 +592,11 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
*aContainer = aRealNode;
|
||||
NS_ADDREF(*aContainer);
|
||||
|
||||
PRInt32 indx;
|
||||
aRealNode->ChildCount(indx);
|
||||
PRUint32 indx = aRealNode->GetChildCount();
|
||||
|
||||
// Since EnsureElementHasGenericChild() added us, make
|
||||
// sure to subtract one for our real index.
|
||||
*aNewIndexInContainer = indx - 1;
|
||||
// Since EnsureElementHasGenericChild() added us, make
|
||||
// sure to subtract one for our real index.
|
||||
*aNewIndexInContainer = indx - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,8 +709,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
*aContainer = aRealNode;
|
||||
NS_ADDREF(*aContainer);
|
||||
|
||||
PRInt32 indx;
|
||||
aRealNode->ChildCount(indx);
|
||||
PRUint32 indx = aRealNode->GetChildCount();
|
||||
|
||||
// Since we haven't inserted any content yet, our new
|
||||
// index in the container will be the current count of
|
||||
@ -731,11 +724,9 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
|
||||
// Copy all attributes from the template to the new
|
||||
// element.
|
||||
PRInt32 numAttribs;
|
||||
rv = tmplKid->GetAttrCount(numAttribs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 numAttribs = tmplKid->GetAttrCount();
|
||||
|
||||
for (PRInt32 attr = 0; attr < numAttribs; attr++) {
|
||||
for (PRUint32 attr = 0; attr < numAttribs; attr++) {
|
||||
PRInt32 attribNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attribName, prefix;
|
||||
|
||||
@ -774,8 +765,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
|
||||
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(realKid);
|
||||
if (xulcontent) {
|
||||
PRInt32 count2;
|
||||
tmplKid->ChildCount(count2);
|
||||
PRUint32 count2 = tmplKid->GetChildCount();
|
||||
|
||||
if (count2 == 0 && !isResourceElement) {
|
||||
// If we're at a leaf node, then we'll eagerly
|
||||
@ -921,50 +911,42 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode,
|
||||
// check all attributes on the template node; if they reference a resource,
|
||||
// update the equivalent attribute on the content node
|
||||
|
||||
PRInt32 numAttribs;
|
||||
rv = aTemplateNode->GetAttrCount(numAttribs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 numAttribs = aTemplateNode->GetAttrCount();
|
||||
|
||||
// XXXwaterson. Ugh, we just checked the failure code, above. Why
|
||||
// do it again? This method needs a scrub-down, and could stand
|
||||
// to have some of this bogo-error checking removed.
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
for (PRInt32 aLoop=0; aLoop<numAttribs; aLoop++) {
|
||||
PRInt32 attribNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attribName, prefix;
|
||||
rv = aTemplateNode->GetAttrNameAt(aLoop,
|
||||
&attribNameSpaceID,
|
||||
getter_AddRefs(attribName),
|
||||
getter_AddRefs(prefix));
|
||||
if (NS_FAILED(rv)) break;
|
||||
for (PRUint32 loop = 0; loop < numAttribs; ++loop) {
|
||||
PRInt32 attribNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attribName, prefix;
|
||||
rv = aTemplateNode->GetAttrNameAt(loop, &attribNameSpaceID,
|
||||
getter_AddRefs(attribName),
|
||||
getter_AddRefs(prefix));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
// See if it's one of the attributes that we unilaterally
|
||||
// ignore. If so, on to the next one...
|
||||
if (IsIgnoreableAttribute(attribNameSpaceID, attribName))
|
||||
continue;
|
||||
// See if it's one of the attributes that we unilaterally
|
||||
// ignore. If so, on to the next one...
|
||||
if (IsIgnoreableAttribute(attribNameSpaceID, attribName))
|
||||
continue;
|
||||
|
||||
nsAutoString attribValue;
|
||||
rv = aTemplateNode->GetAttr(attribNameSpaceID,
|
||||
attribName,
|
||||
attribValue);
|
||||
nsAutoString attribValue;
|
||||
rv = aTemplateNode->GetAttr(attribNameSpaceID,
|
||||
attribName,
|
||||
attribValue);
|
||||
|
||||
if (! IsAttrImpactedByVars(aMatch, attribValue, aModifiedVars))
|
||||
continue;
|
||||
if (! IsAttrImpactedByVars(aMatch, attribValue, aModifiedVars))
|
||||
continue;
|
||||
|
||||
nsAutoString newvalue;
|
||||
SubstituteText(aMatch, attribValue, newvalue);
|
||||
nsAutoString newvalue;
|
||||
SubstituteText(aMatch, attribValue, newvalue);
|
||||
|
||||
if (!newvalue.IsEmpty()) {
|
||||
aRealElement->SetAttr(attribNameSpaceID,
|
||||
attribName,
|
||||
newvalue,
|
||||
PR_TRUE);
|
||||
}
|
||||
else {
|
||||
aRealElement->UnsetAttr(attribNameSpaceID,
|
||||
attribName,
|
||||
PR_TRUE);
|
||||
}
|
||||
if (!newvalue.IsEmpty()) {
|
||||
aRealElement->SetAttr(attribNameSpaceID,
|
||||
attribName,
|
||||
newvalue,
|
||||
PR_TRUE);
|
||||
}
|
||||
else {
|
||||
aRealElement->UnsetAttr(attribNameSpaceID,
|
||||
attribName,
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -982,21 +964,15 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode,
|
||||
}
|
||||
|
||||
if (contentsGenerated) {
|
||||
PRInt32 count;
|
||||
rv = aTemplateNode->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 count = aTemplateNode->GetChildCount();
|
||||
|
||||
for (PRInt32 loop=0; loop<count; loop++) {
|
||||
nsCOMPtr<nsIContent> tmplKid;
|
||||
rv = aTemplateNode->ChildAt(loop, getter_AddRefs(tmplKid));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
for (PRUint32 loop = 0; loop < count; ++loop) {
|
||||
nsIContent *tmplKid = aTemplateNode->GetChildAt(loop);
|
||||
|
||||
if (! tmplKid)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIContent> realKid;
|
||||
rv = aRealElement->ChildAt(loop, getter_AddRefs(realKid));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsIContent *realKid = aRealElement->GetChildAt(loop);
|
||||
|
||||
if (! realKid)
|
||||
break;
|
||||
@ -1092,9 +1068,7 @@ nsXULContentBuilder::RemoveMember(nsIContent* aContainerElement,
|
||||
|
||||
nsCOMPtr<nsIContent> parent = child->GetParent();
|
||||
|
||||
PRInt32 pos;
|
||||
rv = parent->IndexOf(child, pos);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRInt32 pos = parent->IndexOf(child);
|
||||
|
||||
NS_ASSERTION(pos >= 0, "parent doesn't think this child has an index");
|
||||
if (pos < 0) continue;
|
||||
@ -1206,7 +1180,7 @@ nsXULContentBuilder::CreateContainerContents(nsIContent* aElement,
|
||||
// "containment" arcs out of the element's resource.
|
||||
nsresult rv;
|
||||
|
||||
// Compile the rules now, if they haven't been already.
|
||||
// Compile the rules now, if they haven't been already.
|
||||
if (! mRulesCompiled) {
|
||||
rv = CompileRules();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -1437,15 +1411,10 @@ nsXULContentBuilder::RemoveGeneratedContent(nsIContent* aElement)
|
||||
nsIContent* element = NS_STATIC_CAST(nsIContent*, ungenerated[last]);
|
||||
ungenerated.RemoveElementAt(last);
|
||||
|
||||
PRInt32 i = 0;
|
||||
element->ChildCount(i);
|
||||
PRUint32 i = element->GetChildCount();
|
||||
|
||||
while (--i >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
element->ChildAt(i, getter_AddRefs(child));
|
||||
NS_ASSERTION(child != nsnull, "huh? no child?");
|
||||
if (! child)
|
||||
continue;
|
||||
while (i-- > 0) {
|
||||
nsIContent *child = element->GetChildAt(i);
|
||||
|
||||
// Optimize for the <template> element, because we *know*
|
||||
// it won't have any generated content: there's no reason
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user