From 29e64a354f37ee5f742809e9766ab90367ac5755 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Sat, 29 Aug 1998 20:20:38 +0000 Subject: [PATCH] XPCOM'ized nsIContent and nsIHTMLContent git-svn-id: svn://10.0.0.236/trunk@8824 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsIContent.h | 130 +++--- mozilla/content/base/public/nsIStyleRule.h | 2 +- mozilla/content/base/src/nsContentList.cpp | 24 +- mozilla/content/base/src/nsDocument.cpp | 79 ++-- .../events/src/nsEventStateManager.cpp | 12 +- .../html/content/public/nsIHTMLContent.h | 74 ++-- .../html/document/src/nsHTMLContentSink.cpp | 6 +- .../html/document/src/nsHTMLDocument.cpp | 117 ++++-- .../html/document/src/nsImageDocument.cpp | 4 +- .../html/document/src/nsMarkupDocument.cpp | 15 +- .../content/html/style/src/nsCSSStyleRule.cpp | 7 +- .../html/style/src/nsCSSStyleSheet.cpp | 20 +- .../html/style/src/nsHTMLAttributes.cpp | 164 +++++--- .../html/style/src/nsHTMLCSSStyleSheet.cpp | 2 +- .../html/style/src/nsHTMLStyleSheet.cpp | 17 +- .../content/html/style/src/nsICSSStyleRule.h | 5 - .../html/style/src/nsIHTMLAttributes.h | 37 +- mozilla/layout/base/public/nsIContent.h | 130 +++--- mozilla/layout/base/public/nsIStyleRule.h | 2 +- mozilla/layout/base/src/nsContentList.cpp | 24 +- mozilla/layout/base/src/nsDocument.cpp | 79 ++-- mozilla/layout/base/src/nsFrame.cpp | 15 +- mozilla/layout/base/src/nsPresShell.cpp | 5 +- .../layout/base/tests/TestContainerFrame.cpp | 116 ++++-- mozilla/layout/css/layout/src/TODO | 53 +-- .../layout/css/layout/src/nsCSSBlockFrame.cpp | 22 +- .../css/layout/src/nsCSSInlineFrame.cpp | 8 +- .../layout/events/src/nsEventStateManager.cpp | 12 +- .../layout/generic/nsHTMLContainerFrame.cpp | 9 +- mozilla/layout/generic/nsObjectFrame.cpp | 10 +- mozilla/layout/generic/nsPageFrame.cpp | 7 +- mozilla/layout/generic/nsPlaceholderFrame.cpp | 7 +- .../layout/html/base/src/nsAbsoluteFrame.cpp | 4 +- mozilla/layout/html/base/src/nsBRPart.cpp | 43 +- mozilla/layout/html/base/src/nsBodyPart.cpp | 25 +- .../layout/html/base/src/nsDOMAttributes.cpp | 11 +- .../layout/html/base/src/nsDOMNodeList.cpp | 6 +- mozilla/layout/html/base/src/nsHRPart.cpp | 3 +- mozilla/layout/html/base/src/nsHTMLBase.cpp | 3 +- mozilla/layout/html/base/src/nsHTMLBullet.cpp | 29 +- .../layout/html/base/src/nsHTMLContainer.cpp | 171 ++++---- .../layout/html/base/src/nsHTMLContainer.h | 36 +- .../html/base/src/nsHTMLContainerFrame.cpp | 9 +- .../layout/html/base/src/nsHTMLContent.cpp | 192 +++++---- mozilla/layout/html/base/src/nsHTMLContent.h | 108 +++-- mozilla/layout/html/base/src/nsHTMLImage.cpp | 106 ++--- .../layout/html/base/src/nsHTMLTagContent.cpp | 249 +++++++----- .../layout/html/base/src/nsHTMLTagContent.h | 87 ++-- mozilla/layout/html/base/src/nsIHTMLContent.h | 74 ++-- .../layout/html/base/src/nsObjectFrame.cpp | 10 +- mozilla/layout/html/base/src/nsPageFrame.cpp | 7 +- .../html/base/src/nsPlaceholderFrame.cpp | 7 +- mozilla/layout/html/base/src/nsRootPart.cpp | 15 +- .../layout/html/base/src/nsScrollFrame.cpp | 12 +- mozilla/layout/html/base/src/nsSpacerPart.cpp | 59 +-- .../layout/html/base/src/nsTextContent.cpp | 55 ++- mozilla/layout/html/base/src/nsWBRPart.cpp | 8 +- .../layout/html/content/src/nsHTMLAnchor.cpp | 49 +-- .../layout/html/content/src/nsHTMLComment.cpp | 18 +- .../html/content/src/nsHTMLGenericContent.cpp | 359 +++++++++------- .../html/content/src/nsHTMLGenericContent.h | 384 +++++++++--------- mozilla/layout/html/content/src/nsHTMLHR.cpp | 33 +- .../layout/html/content/src/nsHTMLHead.cpp | 10 +- .../layout/html/content/src/nsHTMLLayer.cpp | 59 +-- .../layout/html/content/src/nsHTMLMeta.cpp | 10 +- .../layout/html/content/src/nsHTMLTitle.cpp | 127 +++--- .../html/content/src/nsObjectContent.cpp | 26 +- .../layout/html/content/src/nsObjectContent.h | 24 +- .../html/document/src/nsHTMLContentSink.cpp | 6 +- .../html/document/src/nsHTMLDocument.cpp | 117 ++++-- .../layout/html/document/src/nsHTMLFrame.cpp | 47 ++- .../html/document/src/nsHTMLFrameset.cpp | 45 +- .../layout/html/document/src/nsHTMLFrameset.h | 17 +- .../html/document/src/nsImageDocument.cpp | 4 +- .../html/document/src/nsMarkupDocument.cpp | 15 +- .../layout/html/forms/public/nsIFormControl.h | 2 + .../layout/html/forms/public/nsIFormManager.h | 24 +- mozilla/layout/html/forms/src/nsForm.cpp | 61 +-- mozilla/layout/html/forms/src/nsHTMLForms.h | 2 +- mozilla/layout/html/forms/src/nsInput.cpp | 84 ++-- mozilla/layout/html/forms/src/nsInput.h | 26 +- .../layout/html/forms/src/nsInputButton.cpp | 36 +- .../layout/html/forms/src/nsInputCheckbox.cpp | 24 +- .../layout/html/forms/src/nsInputCheckbox.h | 21 +- mozilla/layout/html/forms/src/nsInputFile.cpp | 8 +- mozilla/layout/html/forms/src/nsInputFile.h | 11 +- .../layout/html/forms/src/nsInputFrame.cpp | 12 +- .../layout/html/forms/src/nsInputRadio.cpp | 20 +- mozilla/layout/html/forms/src/nsInputRadio.h | 19 +- mozilla/layout/html/forms/src/nsInputText.cpp | 15 +- mozilla/layout/html/forms/src/nsInputText.h | 15 +- mozilla/layout/html/forms/src/nsSelect.cpp | 141 +++---- .../layout/html/style/src/nsCSSStyleRule.cpp | 7 +- .../layout/html/style/src/nsCSSStyleSheet.cpp | 20 +- .../html/style/src/nsHTMLAttributes.cpp | 164 +++++--- .../html/style/src/nsHTMLCSSStyleSheet.cpp | 2 +- .../html/style/src/nsHTMLStyleSheet.cpp | 17 +- .../layout/html/style/src/nsICSSStyleRule.h | 5 - .../layout/html/style/src/nsIHTMLAttributes.h | 37 +- .../layout/html/table/src/nsTableCaption.cpp | 17 +- .../layout/html/table/src/nsTableCaption.h | 15 +- mozilla/layout/html/table/src/nsTableCell.cpp | 51 ++- mozilla/layout/html/table/src/nsTableCell.h | 23 +- mozilla/layout/html/table/src/nsTableCol.cpp | 24 +- mozilla/layout/html/table/src/nsTableCol.h | 15 +- .../layout/html/table/src/nsTableColGroup.cpp | 55 ++- .../layout/html/table/src/nsTableColGroup.h | 19 +- .../html/table/src/nsTableColGroupFrame.cpp | 3 +- .../layout/html/table/src/nsTableContent.cpp | 29 +- .../layout/html/table/src/nsTableContent.h | 4 +- .../layout/html/table/src/nsTableFrame.cpp | 29 +- .../html/table/src/nsTableOuterFrame.cpp | 3 +- mozilla/layout/html/table/src/nsTablePart.cpp | 94 +++-- mozilla/layout/html/table/src/nsTablePart.h | 15 +- mozilla/layout/html/table/src/nsTableRow.cpp | 45 +- mozilla/layout/html/table/src/nsTableRow.h | 23 +- .../layout/html/table/src/nsTableRowFrame.cpp | 3 +- .../layout/html/table/src/nsTableRowGroup.cpp | 42 +- .../layout/html/table/src/nsTableRowGroup.h | 20 +- .../html/table/src/nsTableRowGroupFrame.cpp | 16 +- mozilla/layout/html/tests/TestAttributes.cpp | 34 +- mozilla/layout/style/nsCSSStyleRule.cpp | 7 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 20 +- mozilla/layout/style/nsHTMLCSSStyleSheet.cpp | 2 +- mozilla/layout/style/nsHTMLStyleSheet.cpp | 17 +- mozilla/layout/style/nsICSSStyleRule.h | 5 - mozilla/layout/style/nsIStyleRule.h | 2 +- .../layout/tables/nsTableColGroupFrame.cpp | 3 +- mozilla/layout/tables/nsTableFrame.cpp | 29 +- mozilla/layout/tables/nsTableOuterFrame.cpp | 3 +- mozilla/layout/tables/nsTableRowFrame.cpp | 3 +- .../layout/tables/nsTableRowGroupFrame.cpp | 16 +- 132 files changed, 3019 insertions(+), 2333 deletions(-) diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index 5c580e94b32..13ae43232cf 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -1,19 +1,20 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/NPL/ * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. */ #ifndef nsIContent_h___ #define nsIContent_h___ @@ -22,6 +23,8 @@ #include "nslayout.h" #include "nsISupports.h" #include "nsGUIEvent.h" + +// Forward declarations class nsIAtom; class nsIContentDelegate; class nsIDocument; @@ -34,56 +37,42 @@ class nsXIFConverter; class nsIDOMEvent; class nsIContent; - // IID for the nsIContent interface #define NS_ICONTENT_IID \ { 0x78030220, 0x9447, 0x11d1, \ {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } -/** - * Content attribute states - */ -enum nsContentAttr { - // Attribute does not exist on the piece of content - eContentAttr_NotThere, - - // Attribute exists, but has no value, e.g. "BORDER" in - eContentAttr_NoValue, - - // Attribute exists and has a value. However, value may be the - // empty string. e.g.
or
- eContentAttr_HasValue -}; - // A node of content in a documents content model. This interface // is supported by all content objects. -class nsIContent : public nsISupports -{ +class nsIContent : public nsISupports { public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0; - virtual void SetDocument(nsIDocument* aDocument) = 0; - virtual nsIContent* GetParent() const = 0; - virtual void SetParent(nsIContent* aParent) = 0; + NS_IMETHOD SetDocument(nsIDocument* aDocument) = 0; - virtual PRBool CanContainChildren() const = 0; - virtual PRInt32 ChildCount() const = 0; - virtual nsIContent* ChildAt(PRInt32 aIndex) const = 0; - virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const = 0; + NS_IMETHOD GetParent(nsIContent*& aResult) const = 0; - NS_IMETHOD InsertChildAt(nsIContent* aKid, - PRInt32 aIndex, + NS_IMETHOD SetParent(nsIContent* aParent) = 0; + + NS_IMETHOD GetTag(nsIAtom*& aResult) const = 0; + + NS_IMETHOD CanContainChildren(PRBool& aResult) const = 0; + + NS_IMETHOD ChildCount(PRInt32& aResult) const = 0; + + NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0; + + NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0; + + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) = 0; - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, - PRInt32 aIndex, + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) = 0; - NS_IMETHOD AppendChildTo(nsIContent* aKid, - PRBool aNotify) = 0; + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) = 0; - NS_IMETHOD RemoveChildAt(PRInt32 aIndex, - PRBool aNotify) = 0; + NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) = 0; /** * Test and see if this piece of content is synthetic. Synthetic content @@ -92,8 +81,6 @@ public: */ NS_IMETHOD IsSynthetic(PRBool& aResult) = 0; - virtual nsIAtom* GetTag() const = 0; - /** * Set attribute values. All attribute values are assumed to have a * canonical String representation that can be used for these @@ -101,9 +88,16 @@ public: * of the canonical form into the underlying content specific * form. * - * aValue may legitimately be the empty string. + * @param aName the name of the attribute + + * @param aValue may legitimately be the empty string. + * + * @param aUpdateMask specifies how whether or not the document should be + * notified of the attribute change. */ - virtual void SetAttribute(const nsString& aName, const nsString& aValue) = 0; + NS_IMETHOD SetAttribute(const nsString& aName, + const nsString& aValue, + PRBool aNotify) = 0; /** * Get the current value of the attribute. This returns a form that is @@ -112,21 +106,27 @@ public: * */ - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const = 0; + * + */ + NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0; + // XXX deprecated virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + /** + * List the content (and anything it contains) out to the given + * file stream. Use aIndent as the base indent during formatting. + * Returns NS_OK unless a file error occurs. + */ + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; /** * Translate the content object into the (XIF) XML Interchange Format @@ -136,12 +136,10 @@ public: * BeginConvertToXIF -- opens a container and writes out the attributes * ConvertContentToXIF -- typically does nothing unless there is text content * FinishConvertToXIF -- closes a container - - - */ - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const = 0; - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const = 0; - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const = 0; + */ + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const = 0; + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const = 0; + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const = 0; /** * Add this object's size information to the sizeof handler and @@ -149,6 +147,9 @@ public: */ NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const = 0; + /** + * Handle a DOM event for this piece of content. + */ NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, @@ -156,4 +157,13 @@ public: nsEventStatus& aEventStatus) = 0; }; +// nsresult codes for GetAttribute +#define NS_CONTENT_ATTR_HAS_VALUE NS_OK + +#define NS_CONTENT_ATTR_NO_VALUE \ + NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,0) + +#define NS_CONTENT_ATTR_NOT_THERE \ + NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,1) + #endif /* nsIContent_h___ */ diff --git a/mozilla/content/base/public/nsIStyleRule.h b/mozilla/content/base/public/nsIStyleRule.h index e79eff7dae8..d54cf4d4723 100644 --- a/mozilla/content/base/public/nsIStyleRule.h +++ b/mozilla/content/base/public/nsIStyleRule.h @@ -37,7 +37,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; #endif /* nsIStyleRule_h___ */ diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index 67d37cde98e..e118ff67128 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -115,7 +115,8 @@ NS_IMETHODIMP nsContentList::Match(nsIContent *aContent, PRBool *aMatch) { if (nsnull != mMatchTag) { - nsIAtom *name = aContent->GetTag(); + nsIAtom *name = nsnull; + aContent->GetTag(name); if ((nsnull !=name) && mMatchTag->EqualsIgnoreCase(name)) { *aMatch = PR_TRUE; @@ -196,9 +197,9 @@ nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn) if (nsnull != content) { nsAutoString name; // XXX Should it be an EqualsIgnoreCase? - if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) && + if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name))) || - ((content->GetAttribute("ID", name) == eContentAttr_HasValue) && + ((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name)))) { return content->QueryInterface(kIDOMNodeIID, (void **)aReturn); } @@ -241,9 +242,10 @@ PRBool nsContentList::MatchSelf(nsIContent *aContent) return PR_TRUE; } - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); if (MatchSelf(child)) { NS_RELEASE(child); return PR_TRUE; @@ -264,9 +266,10 @@ void nsContentList::PopulateSelf(nsIContent *aContent) Add(aContent); } - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); PopulateSelf(child); NS_RELEASE(child); } @@ -276,8 +279,11 @@ NS_IMETHODIMP nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer) { - if (aContainer->ChildCount() > 0) { - nsIContent *content = aContainer->ChildAt(aContainer->ChildCount()-1); + PRInt32 count; + aContainer->ChildCount(count); + if (count > 0) { + nsIContent *content; + aContainer->ChildAt(count-1, content); if (MatchSelf(content)) { Reset(); nsIContent *root = aDocument->GetRootContent(); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index bee4ff98c12..984fbec0776 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -1113,13 +1113,16 @@ nsISelection * nsDocument::GetSelection() { } -void TraverseBlockContent(nsIContent * aContent, nsString & aStr) +static void TraverseBlockContent(nsIContent * aContent, nsString & aStr) { nsIContent * parent = aContent; - PRInt32 i; - for (i=0;iChildCount();i++) { - nsIContent * child = parent->ChildAt(i); - nsIAtom * atom = child->GetTag(); + PRInt32 i, n; + parent->ChildCount(n); + for (i=0;iChildAt(i, child); + nsIAtom * atom; + child->GetTag(atom); if (atom == nsnull) { static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); nsIDOMText* textContent; @@ -1148,13 +1151,16 @@ void nsDocument::SelectAll() { nsIContent * body = nsnull; nsString bodyStr("BODY"); - PRInt32 i; - for (i=0;iChildCount();i++) { - nsIContent * child = mRootContent->ChildAt(i); + PRInt32 i, n; + mRootContent->ChildCount(n); + for (i=0;iChildAt(i, child); PRBool isSynthetic; child->IsSynthetic(isSynthetic); if (!isSynthetic) { - nsIAtom * atom = child->GetTag(); + nsIAtom * atom; + child->GetTag(atom); if (bodyStr.EqualsIgnoreCase(atom)) { body = child; break; @@ -1170,20 +1176,21 @@ void nsDocument::SelectAll() { start = body; // Find Very first Piece of Content - while (start->ChildCount() > 0) { + start->ChildCount(n); + while (n > 0) { nsIContent * child = start; - start = child->ChildAt(0); + child->ChildAt(0, start); NS_RELEASE(child); } end = body; // Last piece of Content - PRInt32 count = end->ChildCount(); - while (count > 0) { + end->ChildCount(n); + while (n > 0) { nsIContent * child = end; - end = child->ChildAt(count-1); + child->ChildAt(n-1, end); NS_RELEASE(child); - count = end->ChildCount(); + end->ChildCount(n); } //NS_RELEASE(start); @@ -1227,7 +1234,8 @@ void nsDocument::TraverseTree(nsString & aText, aText.Append(text); //NS_IF_RELEASE(textContent); } else { - nsIAtom * atom = aContent->GetTag(); + nsIAtom * atom; + aContent->GetTag(atom); if (atom != nsnull) { nsString str; atom->ToString(str); @@ -1251,8 +1259,12 @@ void nsDocument::TraverseTree(nsString & aText, } } - for (PRInt32 i=0;iChildCount();i++) { - TraverseTree(aText, aContent->ChildAt(i), aStart, aEnd, aInRange); + PRInt32 n; + aContent->ChildCount(n); + for (PRInt32 i=0;iChildAt(i, kid); + TraverseTree(aText, kid, aStart, aEnd, aInRange); } if (addReturn) { aText.Append("\n"); @@ -1394,12 +1406,14 @@ nsIContent* nsDocument::FindContent(const nsIContent* aStartNode, const nsIContent* aTest1, const nsIContent* aTest2) const { - PRInt32 count = aStartNode->ChildCount(); + PRInt32 count; + aStartNode->ChildCount(count); PRInt32 index; for(index = 0; index < count;index++) { - nsIContent* child = aStartNode->ChildAt(index); + nsIContent* child; + aStartNode->ChildAt(index, child); nsIContent* content = FindContent(child,aTest1,aTest2); if (content != nsnull) { NS_IF_RELEASE(child); @@ -1485,12 +1499,14 @@ nsIContent* nsDocument::GetPrevContent(const nsIContent *aContent) const if (nsnull != aContent) { - nsIContent* parent = aContent->GetParent(); + nsIContent* parent; + aContent->GetParent(parent); if (parent != nsnull && parent != mRootContent) { - PRInt32 index = parent->IndexOf((nsIContent*)aContent); + PRInt32 index; + parent->IndexOf((nsIContent*)aContent, index); if (index > 0) - result = parent->ChildAt(index-1); + parent->ChildAt(index-1, result); else result = GetPrevContent(parent); } @@ -1506,17 +1522,22 @@ nsIContent* nsDocument::GetNextContent(const nsIContent *aContent) const if (nsnull != aContent) { // Look at next sibling - nsIContent* parent = aContent->GetParent(); + nsIContent* parent; + aContent->GetParent(parent); if (parent != nsnull && parent != mRootContent) { - PRInt32 index = parent->IndexOf((nsIContent*)aContent); - PRInt32 count = parent->ChildCount(); + PRInt32 index; + parent->IndexOf((nsIContent*)aContent, index); + PRInt32 count; + parent->ChildCount(count); if (index+1 < count) { - result = parent->ChildAt(index+1); + parent->ChildAt(index+1, result); // Get first child down the tree - while (result->ChildCount() > 0) { + PRInt32 n; + result->ChildCount(n); + while (n > 0) { nsIContent * old = result; - result = old->ChildAt(0); + old->ChildAt(0, result); NS_RELEASE(old); } } else { diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index e35b8c62eb6..97d85ab0d36 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -102,8 +102,10 @@ NS_METHOD nsEventStateManager::SetActiveLink(nsIContent *aLink) if (nsnull != mActiveLink) { if (NS_OK == mActiveLink->GetDocument(mDocument)) { nsIContent *mKid; - for (int i = 0; i < mActiveLink->ChildCount(); i++) { - mKid = mActiveLink->ChildAt(i); + PRInt32 numKids; + mActiveLink->ChildCount(numKids); + for (int i = 0; i < numKids; i++) { + mActiveLink->ChildAt(i, mKid); mDocument->ContentChanged(mKid, nsnull); NS_RELEASE(mKid); } @@ -119,8 +121,10 @@ NS_METHOD nsEventStateManager::SetActiveLink(nsIContent *aLink) if (nsnull != mActiveLink) { if (NS_OK == mActiveLink->GetDocument(mDocument)) { nsIContent *mKid; - for (int i = 0; i < mActiveLink->ChildCount(); i++) { - mKid = mActiveLink->ChildAt(i); + PRInt32 numKids; + mActiveLink->ChildCount(numKids); + for (int i = 0; i < numKids; i++) { + mActiveLink->ChildAt(i, mKid); mDocument->ContentChanged(mKid, nsnull); NS_RELEASE(mKid); } diff --git a/mozilla/content/html/content/public/nsIHTMLContent.h b/mozilla/content/html/content/public/nsIHTMLContent.h index 9198c695e20..794569b51cb 100644 --- a/mozilla/content/html/content/public/nsIHTMLContent.h +++ b/mozilla/content/html/content/public/nsIHTMLContent.h @@ -40,41 +40,47 @@ public: * If this html content is a container, then compact asks it to minimize * it's storage usage. */ - virtual void Compact() = 0; + NS_IMETHOD Compact() = 0; - virtual void SetAttribute(const nsString& aName, const nsString& aValue) = 0; - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue) = 0; - virtual void SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue=nsHTMLValue::kNull) = 0; + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify) = 0; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) = 0; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRBool aNotify) = 0; - virtual void UnsetAttribute(nsIAtom* aAttribute) = 0; + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) = 0; - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const = 0; - virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const = 0; - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const = 0; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const = 0; - virtual PRInt32 GetAttributeCount(void) const = 0; + NS_IMETHOD GetAttribute(const nsString& aName, + nsString& aResult) const = 0; + NS_IMETHOD GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const = 0; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const = 0; + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCountResult) const = 0; + NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0; - virtual void SetID(nsIAtom* aID) = 0; - virtual nsIAtom* GetID(void) const = 0; - virtual void SetClass(nsIAtom* aClass) = 0; // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const = 0; // XXX this will have to change for CSS2 + NS_IMETHOD SetID(nsIAtom* aID) = 0; + NS_IMETHOD GetID(nsIAtom*& aResult) const = 0; + // XXX this will have to change for CSS2 + NS_IMETHOD SetClass(nsIAtom* aClass) = 0; + // XXX this will have to change for CSS2 + NS_IMETHOD GetClass(nsIAtom*& aResult) const = 0; - virtual nsIStyleRule* GetStyleRule(void) = 0; + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult) = 0; - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) = 0; + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) = 0; - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const = 0; + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const = 0; - virtual nsContentAttr StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) = 0; + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) = 0; /** * Translate this piece of content to html. Note that this only @@ -84,20 +90,18 @@ public: */ // XXX add in output character set information so that we know how // to encode non 7 bit characters - virtual void ToHTMLString(nsString& aResult) const = 0; - - - virtual void ToHTML(FILE* out) const = 0; + NS_IMETHOD ToHTMLString(nsString& aResult) const = 0; + NS_IMETHOD ToHTML(FILE* out) const = 0; /** * Used by the html content's delegate to create a frame * for the content. */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) = 0; + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) = 0; }; #endif /* nsIHTMLContent_h___ */ diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 78f3103463c..818f60dbc7b 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -320,7 +320,7 @@ AddAttributes(const nsIParserNode& aNode, GetAttributeValueAt(aNode, i, v); // Add attribute to content - content->SetAttribute(k, v); + content->SetAttribute(k, v, PR_FALSE); } return NS_OK; } @@ -1651,11 +1651,11 @@ HTMLContentSink::AddBaseTagInfo(nsIHTMLContent* aContent) { if (mBaseHREF.Length() > 0) { nsHTMLValue value(mBaseHREF); - aContent->SetAttribute(nsHTMLAtoms::_baseHref, value); + aContent->SetAttribute(nsHTMLAtoms::_baseHref, value, PR_FALSE); } if (mBaseTarget.Length() > 0) { nsHTMLValue value(mBaseTarget); - aContent->SetAttribute(nsHTMLAtoms::_baseTarget, value); + aContent->SetAttribute(nsHTMLAtoms::_baseTarget, value, PR_FALSE); } } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 0f0146d298b..4eccd1e9963 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -539,14 +539,15 @@ nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets) PRBool nsHTMLDocument::MatchLinks(nsIContent *aContent) { - nsIAtom *name = aContent->GetTag(); + nsIAtom *name; + aContent->GetTag(name); static nsAutoString area("AREA"), anchor("A"); nsAutoString attr; PRBool result = PR_FALSE; if ((nsnull != name) && (area.EqualsIgnoreCase(name) || anchor.EqualsIgnoreCase(name)) && - (eContentAttr_HasValue == aContent->GetAttribute("HREF", attr))) { + (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute("HREF", attr))) { result = PR_TRUE; } @@ -625,14 +626,15 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) PRBool nsHTMLDocument::MatchAnchors(nsIContent *aContent) { - nsIAtom *name = aContent->GetTag(); + nsIAtom *name; + aContent->GetTag(name); static nsAutoString anchor("A"); nsAutoString attr; PRBool result = PR_FALSE; if ((nsnull != name) && anchor.EqualsIgnoreCase(name) && - (eContentAttr_HasValue == aContent->GetAttribute("NAME", attr))) { + (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute("NAME", attr))) { result = PR_TRUE; } @@ -764,19 +766,20 @@ nsHTMLDocument::MatchName(nsIContent *aContent, const nsString& aName) nsAutoString value; nsIContent *result = nsnull; - if ((eContentAttr_HasValue == aContent->GetAttribute(id, value)) && + if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(id, value)) && aName.Equals(value)) { return aContent; } - else if ((eContentAttr_HasValue == aContent->GetAttribute(name, value)) && + else if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(name, value)) && aName.Equals(value)) { return aContent; } PRInt32 i, count; - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count && result == nsnull; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); result = MatchName(child, aName); NS_RELEASE(child); } @@ -939,7 +942,8 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent, PRBool aInForm) { static nsAutoString name("NAME"); nsAutoString value; - nsIAtom *tag = aContent->GetTag(); + nsIAtom *tag; + aContent->GetTag(tag); PRBool inForm; // Only the content types reflected in Level 0 with a NAME @@ -949,7 +953,7 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent, PRBool aInForm) if ((tag == nsHTMLAtoms::img) || (tag == nsHTMLAtoms::form) || (!aInForm && ((tag == nsHTMLAtoms::applet) || (tag == nsHTMLAtoms::embed)))) { - if (eContentAttr_HasValue == aContent->GetAttribute(name, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(name, value)) { char *nameStr = value.ToNewCString(); PL_HashTableAdd(mNamedItems, nameStr, aContent); } @@ -959,9 +963,10 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent, PRBool aInForm) NS_IF_RELEASE(tag); PRInt32 i, count; - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); RegisterNamedItems(child, inForm); NS_RELEASE(child); } @@ -984,7 +989,7 @@ nsHTMLDocument::NamedItem(const nsString& aName, nsIDOMElement** aReturn) nsIFormManager *form = (nsIFormManager *)mTempForms.ElementAt(i); if (NS_OK == form->QueryInterface(kIContentIID, (void **)&content)) { nsAutoString value; - if (eContentAttr_HasValue == content->GetAttribute(name, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(name, value)) { char *nameStr = value.ToNewCString(); PL_HashTableAdd(mNamedItems, nameStr, content); } @@ -1253,7 +1258,8 @@ PRBool nsHTMLDocument::SearchBlock(BlockText & aBlockText, PRBool nsHTMLDocument::ContentIsBlock(nsIContent * aContent) { PRBool isBlock = PR_FALSE; - nsIAtom * atom = aContent->GetTag(); + nsIAtom * atom; + aContent->GetTag(atom); if (atom != nsnull) { nsString str; atom->ToString(str); @@ -1280,7 +1286,8 @@ nsIContent * nsHTMLDocument::FindBlockParent(nsIContent * aContent, NS_RELEASE(mChildStack[i]); } mStackInx = 0; - nsIContent * parent = aContent->GetParent(); + nsIContent * parent; + aContent->GetParent(parent); nsIContent * child; if (parent == nsnull) { @@ -1298,18 +1305,21 @@ nsIContent * nsHTMLDocument::FindBlockParent(nsIContent * aContent, child = aContent; PRBool done = PR_FALSE; while (!done) { - PRInt32 inx = parent->IndexOf(child) + (mSearchDirection == kForward?1:-1); - if (inx < 0 || inx >= parent->ChildCount()) { + PRInt32 inx, numKids; + parent->IndexOf(child, inx); + inx += (mSearchDirection == kForward?1:-1); + parent->ChildCount(numKids); + if (inx < 0 || inx >= numKids) { NS_RELEASE(child); child = parent; - parent = child->GetParent(); + child->GetParent(parent); if (parent == nsnull) { NS_RELEASE(child); return nsnull; } } else { NS_RELEASE(child); - child = parent->ChildAt(inx); + parent->ChildAt(inx, child); done = PR_TRUE; } } @@ -1334,7 +1344,7 @@ nsIContent * nsHTMLDocument::FindBlockParent(nsIContent * aContent, nsIContent * oldChild = child; child = parent; - parent = child->GetParent(); + child->GetParent(parent); NS_RELEASE(oldChild); } while (parent != nsnull); @@ -1382,13 +1392,17 @@ PRBool nsHTMLDocument::BuildBlockFromContent(nsIContent * aContent, PRBool nsHTMLDocument::BuildBlockTraversing(nsIContent * aParent, BlockText & aBlockText) { - nsIAtom * atom = aParent->GetTag(); + nsIAtom * atom; + aParent->GetTag(atom); if (atom != nsnull) { - if (aParent->ChildCount() > 0) { + PRInt32 numKids; + aParent->ChildCount(numKids); + if (numKids > 0) { PRInt32 i; if (mSearchDirection == kForward) { - for (i=0;iChildCount();i++) { - nsIContent * child = aParent->ChildAt(i); + for (i=0;iChildAt(i, child); if (BuildBlockFromContent(child, aBlockText)) { NS_IF_RELEASE(child); return PR_TRUE; @@ -1396,8 +1410,9 @@ PRBool nsHTMLDocument::BuildBlockTraversing(nsIContent * aParent, NS_RELEASE(child); } } else { // Backward - for (i=aParent->ChildCount()-1;i>=0;i--) { - nsIContent * child = aParent->ChildAt(i); + for (i=numKids-1;i>=0;i--) { + nsIContent * child; + aParent->ChildAt(i, child); if (BuildBlockFromContent(child, aBlockText)) { NS_IF_RELEASE(child); return PR_TRUE; @@ -1432,13 +1447,17 @@ PRBool nsHTMLDocument::BuildBlockFromStack(nsIContent * aParent, nsIContent * stackParent = mParentStack[aStackInx]; nsIContent * stackChild = mChildStack[aStackInx]; - PRInt32 inx = aParent->IndexOf(stackChild); + PRInt32 inx; PRInt32 j; + aParent->IndexOf(stackChild, inx); // Forward if (mSearchDirection == kForward) { - for (j=inx;jChildCount();j++) { - nsIContent * child = aParent->ChildAt(j); + PRInt32 numKids; + aParent->ChildCount(numKids); + for (j=inx;jChildAt(j, child); if (child == stackChild && aStackInx < mStackInx) { if (BuildBlockFromStack(child, aBlockText, aStackInx+1)) { NS_IF_RELEASE(child); @@ -1459,7 +1478,8 @@ PRBool nsHTMLDocument::BuildBlockFromStack(nsIContent * aParent, } } else { // Backward for (j=inx;j>=0;j--) { - nsIContent * child = aParent->ChildAt(j); + nsIContent * child; + aParent->ChildAt(j, child); if (child == stackChild && aStackInx < mStackInx) { if (BuildBlockFromStack(child, aBlockText, aStackInx+1)) { NS_IF_RELEASE(child); @@ -1493,12 +1513,16 @@ PRBool nsHTMLDocument::BuildBlock(nsIContent * aParent, { nsIContent * stackParent = mParentStack[0]; nsIContent * stackChild = mChildStack[0]; - PRInt32 inx = stackParent->IndexOf(stackChild); + PRInt32 inx; PRInt32 j; + stackParent->IndexOf(stackChild, inx); if (mSearchDirection == kForward) { - for (j=inx;jChildCount();j++) { - nsIContent * child = stackParent->ChildAt(j); + PRInt32 numKids; + stackParent->ChildCount(numKids); + for (j=inx;jChildAt(j, child); if (child == stackChild && mStackInx > 1) { if (BuildBlockFromStack(child, aBlockText, 1)) { NS_IF_RELEASE(child); @@ -1520,7 +1544,8 @@ PRBool nsHTMLDocument::BuildBlock(nsIContent * aParent, } else { for (j=inx;j>=0;j--) { BlockText blockText; - nsIContent * child = stackParent->ChildAt(j); + nsIContent * child; + stackParent->ChildAt(j, child); if (child == stackChild && mStackInx > 1) { if (BuildBlockFromStack(child, blockText, 1)) { NS_IF_RELEASE(child); @@ -1564,13 +1589,16 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch nsIContent * body = nsnull; nsString bodyStr("BODY"); - PRInt32 i; - for (i=0;iChildCount();i++) { - nsIContent * child = mRootContent->ChildAt(i); + PRInt32 i, n; + mRootContent->ChildCount(n); + for (i=0;iChildAt(i, child); PRBool isSynthetic; child->IsSynthetic(isSynthetic); if (!isSynthetic) { - nsIAtom * atom = child->GetTag(); + nsIAtom * atom; + child->GetTag(atom);/* XXX leak */ if (bodyStr.EqualsIgnoreCase(atom)) { body = child; break; @@ -1587,21 +1615,24 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch start = body; NS_ADDREF(body); // Find Very first Piece of Content - while (start->ChildCount() > 0) { + PRInt32 snc; + start->ChildCount(snc); + while (snc > 0) { nsIContent * child = start; - start = child->ChildAt(0); + child->ChildAt(0, start); NS_RELEASE(child); } end = body; NS_ADDREF(body); // Last piece of Content - PRInt32 count = end->ChildCount(); + PRInt32 count; + end->ChildCount(count); while (count > 0) { nsIContent * child = end; - end = child->ChildAt(count-1); + child->ChildAt(count-1, end); NS_RELEASE(child); - count = end->ChildCount(); + end->ChildCount(count); } nsSelectionRange * range = mSelection->GetRange(); diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index c5a45c72ec7..3edc31b6949 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -230,8 +230,8 @@ nsImageDocument::CreateSyntheticDocument() nsAutoString src; mDocumentURL->ToString(src); nsHTMLValue val(src); - image->SetAttribute(nsHTMLAtoms::src, val); - image->SetAttribute(nsHTMLAtoms::alt, val); + image->SetAttribute(nsHTMLAtoms::src, val, PR_FALSE); + image->SetAttribute(nsHTMLAtoms::alt, val, PR_FALSE); root->AppendChildTo(body, PR_FALSE); center->AppendChildTo(image, PR_FALSE); diff --git a/mozilla/content/html/document/src/nsMarkupDocument.cpp b/mozilla/content/html/document/src/nsMarkupDocument.cpp index 35eaad98766..653a883d7b6 100644 --- a/mozilla/content/html/document/src/nsMarkupDocument.cpp +++ b/mozilla/content/html/document/src/nsMarkupDocument.cpp @@ -222,16 +222,15 @@ void nsMarkupDocument::FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode content->IsSynthetic(isSynthetic); if (PR_FALSE == isSynthetic) { - nsIAtom* tag = content->GetTag(); + nsIAtom* tag; + content->GetTag(tag); if (tag != nsnull) { - if (tag != nsnull) - { - nsString str; - tag->ToString(str); - if (str.EqualsIgnoreCase("Head")) - StyleSheetsToXIF(aConverter); - } + nsString str; + tag->ToString(str); + if (str.EqualsIgnoreCase("Head")) + StyleSheetsToXIF(aConverter); + NS_RELEASE(tag); } } } diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp index 798fe8f243a..43280f8b622 100644 --- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp @@ -169,7 +169,7 @@ public: nsIPresContext* aPresContext); virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; private: // These are not supported and are not implemented! @@ -1053,7 +1053,8 @@ static void ListSelector(FILE* out, const nsCSSSelector* aSelector) } } -void CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const { // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); @@ -1079,6 +1080,8 @@ void CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const fputs("{ null declaration }", out); } fputs("\n", out); + + return NS_OK; } NS_HTML nsresult diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index c17c8d281eb..e40334568fe 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -402,15 +402,18 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, nsCSSSelector* aSelector, nsIContent* aContent) { PRBool result = PR_FALSE; - nsIAtom* contentTag = aContent->GetTag(); + nsIAtom* contentTag; + aContent->GetTag(contentTag); if ((nsnull == aSelector->mTag) || (aSelector->mTag == contentTag)) { if ((nsnull != aSelector->mClass) || (nsnull != aSelector->mID) || (nsnull != aSelector->mPseudoClass)) { nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - nsIAtom* contentClass = htmlContent->GetClass(); - nsIAtom* contentID = htmlContent->GetID(); + nsIAtom* contentClass; + htmlContent->GetClass(contentClass); + nsIAtom* contentID; + htmlContent->GetID(contentID); if ((nsnull == aSelector->mClass) || (aSelector->mClass == contentClass)) { if ((nsnull == aSelector->mID) || (aSelector->mID == contentID)) { if ((contentTag == nsHTMLAtoms::a) && (nsnull != aSelector->mPseudoClass)) { @@ -420,9 +423,9 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) && (nsnull != linkHandler)) { nsAutoString base, href; // XXX base?? - nsContentAttr attrState = htmlContent->GetAttribute("href", href); + nsresult attrState = htmlContent->GetAttribute("href", href); - if (eContentAttr_HasValue == attrState) { + if (NS_CONTENT_ATTR_HAS_VALUE == attrState) { nsIURL* docURL = nsnull; nsIDocument* doc = nsnull; aContent->GetDocument(doc); @@ -563,14 +566,15 @@ PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, BuildHash(); } ContentEnumData data(aPresContext, aContent, aParentFrame, aResults); - nsIAtom* tagAtom = aContent->GetTag(); + nsIAtom* tagAtom; + aContent->GetTag(tagAtom); nsIAtom* idAtom = nsnull; nsIAtom* classAtom = nsnull; nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - idAtom = htmlContent->GetID(); - classAtom = htmlContent->GetClass(); + htmlContent->GetID(idAtom); + htmlContent->GetClass(classAtom); NS_RELEASE(htmlContent); } diff --git a/mozilla/content/html/style/src/nsHTMLAttributes.cpp b/mozilla/content/html/style/src/nsHTMLAttributes.cpp index abdd9f00b7b..849942ed333 100644 --- a/mozilla/content/html/style/src/nsHTMLAttributes.cpp +++ b/mozilla/content/html/style/src/nsHTMLAttributes.cpp @@ -150,32 +150,29 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); + // nsIHTMLAttributes + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRInt32& aCount); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRInt32& aCount); + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRInt32& aCount); + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const; + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const; + NS_IMETHOD Count(PRInt32& aCount) const; + NS_IMETHOD SetID(nsIAtom* aID, PRInt32& aIndex); + NS_IMETHOD GetID(nsIAtom*& aResult) const; + NS_IMETHOD SetClass(nsIAtom* aClass, PRInt32& aIndex); + NS_IMETHOD GetClass(nsIAtom*& aResult) const; + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; + virtual PRBool Equals(const nsIStyleRule* aRule) const; virtual PRUint32 HashValue(void) const; - - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue = nsHTMLValue::kNull); - virtual PRInt32 UnsetAttribute(nsIAtom* aAttribute); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const; - virtual PRInt32 Count(void) const; - - virtual PRInt32 SetID(nsIAtom* aID); - virtual nsIAtom* GetID(void) const; - virtual PRInt32 SetClass(nsIAtom* aClass); // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const; // XXX this will have to change for CSS2 - virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - /** - * Add this object's size information to the sizeof handler. - */ - NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; - private: HTMLAttributesImpl(const HTMLAttributesImpl& aCopy); HTMLAttributesImpl& operator=(const HTMLAttributesImpl& aCopy); @@ -321,19 +318,21 @@ PRUint32 HTMLAttributesImpl::HashValue(void) const return (PRUint32)this; } -PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRInt32& aCount) { if (nsHTMLAtoms::id == aAttribute) { nsIAtom* id = NS_NewAtom(aValue); - PRInt32 result = SetID(id); + nsresult rv = SetID(id, aCount); NS_RELEASE(id); - return result; + return rv; } if (nsHTMLAtoms::kClass == aAttribute) { nsIAtom* classA = NS_NewAtom(aValue); - PRInt32 result = SetClass(classA); + nsresult rv = SetClass(classA, aCount); NS_RELEASE(classA); - return result; + return rv; } HTMLAttribute* last = nsnull; @@ -342,37 +341,45 @@ PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aV while (nsnull != attr) { if (attr->mAttribute == aAttribute) { attr->mValue.SetStringValue(aValue); - return mCount; + aCount = mCount; + return NS_OK; } last = attr; attr = attr->mNext; } attr = new HTMLAttribute(aAttribute, aValue); + if (nsnull == attr) { + return NS_ERROR_OUT_OF_MEMORY; + } if (nsnull == last) { mFirst = attr; } else { last->mNext = attr; } - return ++mCount; + aCount = ++mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue) +NS_IMETHODIMP +HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRInt32& aCount) { if (nsHTMLAtoms::id == aAttribute) { nsAutoString buffer; nsIAtom* id = NS_NewAtom(aValue.GetStringValue(buffer)); - PRInt32 result = SetID(id); + nsresult rv = SetID(id, aCount); NS_RELEASE(id); - return result; + return rv; } if (nsHTMLAtoms::kClass == aAttribute) { nsAutoString buffer; nsIAtom* classA = NS_NewAtom(aValue.GetStringValue(buffer)); - PRInt32 result = SetClass(classA); + nsresult rv = SetClass(classA, aCount); NS_RELEASE(classA); - return result; + return rv; } HTMLAttribute* last = nsnull; @@ -381,29 +388,36 @@ PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& while (nsnull != attr) { if (attr->mAttribute == aAttribute) { attr->mValue = aValue; - return mCount; + aCount = mCount; + return NS_OK; } last = attr; attr = attr->mNext; } attr = new HTMLAttribute(aAttribute, aValue); + if (nsnull == attr) { + return NS_ERROR_OUT_OF_MEMORY; + } if (nsnull == last) { mFirst = attr; } else { last->mNext = attr; } - return ++mCount; + aCount = ++mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::UnsetAttribute(nsIAtom* aAttribute) +NS_IMETHODIMP +HTMLAttributesImpl::UnsetAttribute(nsIAtom* aAttribute, + PRInt32& aCount) { if (nsHTMLAtoms::id == aAttribute) { - return SetID (nsnull); + return SetID (nsnull, aCount); } if (nsHTMLAtoms::kClass == aAttribute) { - return SetClass (nsnull); + return SetClass (nsnull, aCount); } HTMLAttribute* prev = nsnull; @@ -424,34 +438,38 @@ PRInt32 HTMLAttributesImpl::UnsetAttribute(nsIAtom* aAttribute) prev = attr; attr = attr->mNext; } - return mCount; + aCount = mCount; + return NS_OK; } -nsContentAttr HTMLAttributesImpl::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const +NS_IMETHODIMP +HTMLAttributesImpl::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const { aValue.Reset(); if (nsHTMLAtoms::id == aAttribute) { - nsIAtom* id = GetID(); + nsIAtom* id; + GetID(id); if (nsnull != id) { nsAutoString buffer; id->ToString(buffer); aValue.SetStringValue(buffer); NS_RELEASE(id); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } if (nsHTMLAtoms::kClass == aAttribute) { - nsIAtom* classA = GetClass(); + nsIAtom* classA; + GetClass(classA); if (nsnull != classA) { nsAutoString buffer; classA->ToString(buffer); aValue.SetStringValue(buffer); NS_RELEASE(classA); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } HTMLAttribute* attr = mFirst; @@ -459,19 +477,24 @@ nsContentAttr HTMLAttributesImpl::GetAttribute(nsIAtom* aAttribute, while (nsnull != attr) { if (attr->mAttribute == aAttribute) { aValue = attr->mValue; - return ((attr->mValue.GetUnit() == eHTMLUnit_Null) ? eContentAttr_NoValue : eContentAttr_HasValue); + return (attr->mValue.GetUnit() == eHTMLUnit_Null) + ? NS_CONTENT_ATTR_NO_VALUE + : NS_CONTENT_ATTR_HAS_VALUE; } attr = attr->mNext; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -PRInt32 HTMLAttributesImpl::GetAllAttributeNames(nsISupportsArray* aArray) const +NS_IMETHODIMP +HTMLAttributesImpl::GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const { NS_ASSERTION(nsnull != aArray, "null arg"); if (nsnull == aArray) { - return 0; + aCount = 0; + return NS_ERROR_NULL_POINTER; } if (nsnull != mID) { @@ -487,15 +510,19 @@ PRInt32 HTMLAttributesImpl::GetAllAttributeNames(nsISupportsArray* aArray) const aArray->AppendElement(attr->mAttribute); attr = attr->mNext; } - return mCount; + aCount = mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::Count(void) const +NS_IMETHODIMP +HTMLAttributesImpl::Count(PRInt32& aCount) const { - return mCount; + aCount = mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::SetID(nsIAtom* aID) +NS_IMETHODIMP +HTMLAttributesImpl::SetID(nsIAtom* aID, PRInt32& aCount) { if (aID != mID) { if (nsnull != mID) { @@ -508,16 +535,20 @@ PRInt32 HTMLAttributesImpl::SetID(nsIAtom* aID) mCount++; } } - return mCount; + aCount = mCount; + return NS_OK; } -nsIAtom* HTMLAttributesImpl::GetID(void) const +NS_IMETHODIMP +HTMLAttributesImpl::GetID(nsIAtom*& aResult) const { NS_IF_ADDREF(mID); - return mID; + aResult = mID; + return NS_OK; } -PRInt32 HTMLAttributesImpl::SetClass(nsIAtom* aClass) +NS_IMETHODIMP +HTMLAttributesImpl::SetClass(nsIAtom* aClass, PRInt32& aCount) { if (aClass != mClass) { if (nsnull != mClass) { @@ -530,13 +561,16 @@ PRInt32 HTMLAttributesImpl::SetClass(nsIAtom* aClass) mCount++; } } - return mCount; + aCount = mCount; + return NS_OK; } -nsIAtom* HTMLAttributesImpl::GetClass(void) const +NS_IMETHODIMP +HTMLAttributesImpl::GetClass(nsIAtom*& aResult) const { NS_IF_ADDREF(mClass); - return mClass; + aResult = mClass; + return NS_OK; } void HTMLAttributesImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) @@ -558,7 +592,8 @@ HTMLAttributesImpl::SizeOf(nsISizeOfHandler* aHandler) const return NS_OK; } -void HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const { HTMLAttribute* attr = mFirst; nsString buffer; @@ -570,6 +605,7 @@ void HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const fputs("\n", out); attr = attr->mNext; } + return NS_OK; } extern NS_HTML nsresult diff --git a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp index 7b76e770fa5..ec655f2b333 100644 --- a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp @@ -175,7 +175,7 @@ PRInt32 HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, // just get the one and only style rule from the content's STYLE attribute if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { nsHTMLValue value; - if (eContentAttr_HasValue == htmlContent->GetAttribute(nsHTMLAtoms::style, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetAttribute(nsHTMLAtoms::style, value)) { if (eHTMLUnit_ISupports == value.GetUnit()) { nsISupports* rule = value.GetISupportsValue(); if (nsnull != rule) { diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index 45b0719ba65..316a253418d 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -51,7 +51,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; nscolor mColor; }; @@ -86,8 +86,10 @@ void HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPr } } -void HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const { + return NS_OK; } // ----------------------------------------------------------- @@ -295,7 +297,8 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, if (aContent != parentContent) { // if not a pseudo frame... nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - nsIAtom* tag = htmlContent->GetTag(); + nsIAtom* tag; + htmlContent->GetTag(tag); // if we have anchor colors, check if this is an anchor with an href if (tag == nsHTMLAtoms::a) { if ((nsnull != mLinkRule) || (nsnull != mVisitedRule) || (nsnull != mActiveRule)) { @@ -305,9 +308,9 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) && (nsnull != linkHandler)) { nsAutoString base, href; // XXX base?? - nsContentAttr attrState = htmlContent->GetAttribute("href", href); + nsresult attrState = htmlContent->GetAttribute("href", href); - if (eContentAttr_HasValue == attrState) { + if (NS_CONTENT_ATTR_HAS_VALUE == attrState) { nsIURL* docURL = nsnull; nsIDocument* doc = nsnull; aContent->GetDocument(doc); @@ -375,8 +378,8 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, } // end TD/TH tag // just get the one and only style rule from the content - nsIStyleRule* rule = htmlContent->GetStyleRule(); - + nsIStyleRule* rule; + htmlContent->GetStyleRule(rule); if (nsnull != rule) { aResults->AppendElement(rule); NS_RELEASE(rule); diff --git a/mozilla/content/html/style/src/nsICSSStyleRule.h b/mozilla/content/html/style/src/nsICSSStyleRule.h index 153397fe876..2d1fa38ee98 100644 --- a/mozilla/content/html/style/src/nsICSSStyleRule.h +++ b/mozilla/content/html/style/src/nsICSSStyleRule.h @@ -54,9 +54,6 @@ public: class nsICSSStyleRule : public nsIStyleRule { public: - virtual PRBool Equals(const nsIStyleRule* aRule) const = 0; - virtual PRUint32 HashValue(void) const = 0; - virtual nsCSSSelector* FirstSelector(void) = 0; virtual void AddSelector(const nsCSSSelector& aSelector) = 0; virtual void DeleteSelector(nsCSSSelector* aSelector) = 0; @@ -66,8 +63,6 @@ public: virtual PRInt32 GetWeight(void) const = 0; virtual void SetWeight(PRInt32 aWeight) = 0; - - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; extern NS_HTML nsresult diff --git a/mozilla/content/html/style/src/nsIHTMLAttributes.h b/mozilla/content/html/style/src/nsIHTMLAttributes.h index 1c867644735..b2372ebfc5a 100644 --- a/mozilla/content/html/style/src/nsIHTMLAttributes.h +++ b/mozilla/content/html/style/src/nsIHTMLAttributes.h @@ -35,27 +35,38 @@ class nsIHTMLContent; class nsIHTMLAttributes : public nsISupports { public: - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, const nsString& aValue) = 0; - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue = nsHTMLValue::kNull) = 0; - virtual PRInt32 UnsetAttribute(nsIAtom* aAttribute) = 0; - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const = 0; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const = 0; + // XXX why is this part of the interface? + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRInt32& aCount) = 0; - virtual PRInt32 Count(void) const = 0; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRInt32& aCount) = 0; - virtual PRInt32 SetID(nsIAtom* aID) = 0; - virtual nsIAtom* GetID(void) const = 0; - virtual PRInt32 SetClass(nsIAtom* aClass) = 0; // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const = 0; // XXX this will have to change for CSS2 + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRInt32& aCount) = 0; + + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const = 0; + + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const = 0; + + NS_IMETHOD Count(PRInt32& aCount) const = 0; + + NS_IMETHOD SetID(nsIAtom* aID, PRInt32& aIndex) = 0; + + NS_IMETHOD GetID(nsIAtom*& aResult) const = 0; + + NS_IMETHOD SetClass(nsIAtom* aClass, PRInt32& aIndex) = 0; // XXX this will have to change for CSS2 + + NS_IMETHOD GetClass(nsIAtom*& aResult) const = 0; // XXX this will have to change for CSS2 /** * Add this object's size information to the sizeof handler. */ NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; extern NS_HTML nsresult diff --git a/mozilla/layout/base/public/nsIContent.h b/mozilla/layout/base/public/nsIContent.h index 5c580e94b32..13ae43232cf 100644 --- a/mozilla/layout/base/public/nsIContent.h +++ b/mozilla/layout/base/public/nsIContent.h @@ -1,19 +1,20 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/NPL/ * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. */ #ifndef nsIContent_h___ #define nsIContent_h___ @@ -22,6 +23,8 @@ #include "nslayout.h" #include "nsISupports.h" #include "nsGUIEvent.h" + +// Forward declarations class nsIAtom; class nsIContentDelegate; class nsIDocument; @@ -34,56 +37,42 @@ class nsXIFConverter; class nsIDOMEvent; class nsIContent; - // IID for the nsIContent interface #define NS_ICONTENT_IID \ { 0x78030220, 0x9447, 0x11d1, \ {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } -/** - * Content attribute states - */ -enum nsContentAttr { - // Attribute does not exist on the piece of content - eContentAttr_NotThere, - - // Attribute exists, but has no value, e.g. "BORDER" in
- eContentAttr_NoValue, - - // Attribute exists and has a value. However, value may be the - // empty string. e.g.
or
- eContentAttr_HasValue -}; - // A node of content in a documents content model. This interface // is supported by all content objects. -class nsIContent : public nsISupports -{ +class nsIContent : public nsISupports { public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0; - virtual void SetDocument(nsIDocument* aDocument) = 0; - virtual nsIContent* GetParent() const = 0; - virtual void SetParent(nsIContent* aParent) = 0; + NS_IMETHOD SetDocument(nsIDocument* aDocument) = 0; - virtual PRBool CanContainChildren() const = 0; - virtual PRInt32 ChildCount() const = 0; - virtual nsIContent* ChildAt(PRInt32 aIndex) const = 0; - virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const = 0; + NS_IMETHOD GetParent(nsIContent*& aResult) const = 0; - NS_IMETHOD InsertChildAt(nsIContent* aKid, - PRInt32 aIndex, + NS_IMETHOD SetParent(nsIContent* aParent) = 0; + + NS_IMETHOD GetTag(nsIAtom*& aResult) const = 0; + + NS_IMETHOD CanContainChildren(PRBool& aResult) const = 0; + + NS_IMETHOD ChildCount(PRInt32& aResult) const = 0; + + NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0; + + NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0; + + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) = 0; - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, - PRInt32 aIndex, + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) = 0; - NS_IMETHOD AppendChildTo(nsIContent* aKid, - PRBool aNotify) = 0; + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) = 0; - NS_IMETHOD RemoveChildAt(PRInt32 aIndex, - PRBool aNotify) = 0; + NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) = 0; /** * Test and see if this piece of content is synthetic. Synthetic content @@ -92,8 +81,6 @@ public: */ NS_IMETHOD IsSynthetic(PRBool& aResult) = 0; - virtual nsIAtom* GetTag() const = 0; - /** * Set attribute values. All attribute values are assumed to have a * canonical String representation that can be used for these @@ -101,9 +88,16 @@ public: * of the canonical form into the underlying content specific * form. * - * aValue may legitimately be the empty string. + * @param aName the name of the attribute + + * @param aValue may legitimately be the empty string. + * + * @param aUpdateMask specifies how whether or not the document should be + * notified of the attribute change. */ - virtual void SetAttribute(const nsString& aName, const nsString& aValue) = 0; + NS_IMETHOD SetAttribute(const nsString& aName, + const nsString& aValue, + PRBool aNotify) = 0; /** * Get the current value of the attribute. This returns a form that is @@ -112,21 +106,27 @@ public: * */ - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const = 0; + * + */ + NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0; + // XXX deprecated virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + /** + * List the content (and anything it contains) out to the given + * file stream. Use aIndent as the base indent during formatting. + * Returns NS_OK unless a file error occurs. + */ + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; /** * Translate the content object into the (XIF) XML Interchange Format @@ -136,12 +136,10 @@ public: * BeginConvertToXIF -- opens a container and writes out the attributes * ConvertContentToXIF -- typically does nothing unless there is text content * FinishConvertToXIF -- closes a container - - - */ - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const = 0; - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const = 0; - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const = 0; + */ + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const = 0; + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const = 0; + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const = 0; /** * Add this object's size information to the sizeof handler and @@ -149,6 +147,9 @@ public: */ NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const = 0; + /** + * Handle a DOM event for this piece of content. + */ NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, @@ -156,4 +157,13 @@ public: nsEventStatus& aEventStatus) = 0; }; +// nsresult codes for GetAttribute +#define NS_CONTENT_ATTR_HAS_VALUE NS_OK + +#define NS_CONTENT_ATTR_NO_VALUE \ + NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,0) + +#define NS_CONTENT_ATTR_NOT_THERE \ + NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,1) + #endif /* nsIContent_h___ */ diff --git a/mozilla/layout/base/public/nsIStyleRule.h b/mozilla/layout/base/public/nsIStyleRule.h index e79eff7dae8..d54cf4d4723 100644 --- a/mozilla/layout/base/public/nsIStyleRule.h +++ b/mozilla/layout/base/public/nsIStyleRule.h @@ -37,7 +37,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; #endif /* nsIStyleRule_h___ */ diff --git a/mozilla/layout/base/src/nsContentList.cpp b/mozilla/layout/base/src/nsContentList.cpp index 67d37cde98e..e118ff67128 100644 --- a/mozilla/layout/base/src/nsContentList.cpp +++ b/mozilla/layout/base/src/nsContentList.cpp @@ -115,7 +115,8 @@ NS_IMETHODIMP nsContentList::Match(nsIContent *aContent, PRBool *aMatch) { if (nsnull != mMatchTag) { - nsIAtom *name = aContent->GetTag(); + nsIAtom *name = nsnull; + aContent->GetTag(name); if ((nsnull !=name) && mMatchTag->EqualsIgnoreCase(name)) { *aMatch = PR_TRUE; @@ -196,9 +197,9 @@ nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn) if (nsnull != content) { nsAutoString name; // XXX Should it be an EqualsIgnoreCase? - if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) && + if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name))) || - ((content->GetAttribute("ID", name) == eContentAttr_HasValue) && + ((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name)))) { return content->QueryInterface(kIDOMNodeIID, (void **)aReturn); } @@ -241,9 +242,10 @@ PRBool nsContentList::MatchSelf(nsIContent *aContent) return PR_TRUE; } - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); if (MatchSelf(child)) { NS_RELEASE(child); return PR_TRUE; @@ -264,9 +266,10 @@ void nsContentList::PopulateSelf(nsIContent *aContent) Add(aContent); } - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); PopulateSelf(child); NS_RELEASE(child); } @@ -276,8 +279,11 @@ NS_IMETHODIMP nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer) { - if (aContainer->ChildCount() > 0) { - nsIContent *content = aContainer->ChildAt(aContainer->ChildCount()-1); + PRInt32 count; + aContainer->ChildCount(count); + if (count > 0) { + nsIContent *content; + aContainer->ChildAt(count-1, content); if (MatchSelf(content)) { Reset(); nsIContent *root = aDocument->GetRootContent(); diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index bee4ff98c12..984fbec0776 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -1113,13 +1113,16 @@ nsISelection * nsDocument::GetSelection() { } -void TraverseBlockContent(nsIContent * aContent, nsString & aStr) +static void TraverseBlockContent(nsIContent * aContent, nsString & aStr) { nsIContent * parent = aContent; - PRInt32 i; - for (i=0;iChildCount();i++) { - nsIContent * child = parent->ChildAt(i); - nsIAtom * atom = child->GetTag(); + PRInt32 i, n; + parent->ChildCount(n); + for (i=0;iChildAt(i, child); + nsIAtom * atom; + child->GetTag(atom); if (atom == nsnull) { static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); nsIDOMText* textContent; @@ -1148,13 +1151,16 @@ void nsDocument::SelectAll() { nsIContent * body = nsnull; nsString bodyStr("BODY"); - PRInt32 i; - for (i=0;iChildCount();i++) { - nsIContent * child = mRootContent->ChildAt(i); + PRInt32 i, n; + mRootContent->ChildCount(n); + for (i=0;iChildAt(i, child); PRBool isSynthetic; child->IsSynthetic(isSynthetic); if (!isSynthetic) { - nsIAtom * atom = child->GetTag(); + nsIAtom * atom; + child->GetTag(atom); if (bodyStr.EqualsIgnoreCase(atom)) { body = child; break; @@ -1170,20 +1176,21 @@ void nsDocument::SelectAll() { start = body; // Find Very first Piece of Content - while (start->ChildCount() > 0) { + start->ChildCount(n); + while (n > 0) { nsIContent * child = start; - start = child->ChildAt(0); + child->ChildAt(0, start); NS_RELEASE(child); } end = body; // Last piece of Content - PRInt32 count = end->ChildCount(); - while (count > 0) { + end->ChildCount(n); + while (n > 0) { nsIContent * child = end; - end = child->ChildAt(count-1); + child->ChildAt(n-1, end); NS_RELEASE(child); - count = end->ChildCount(); + end->ChildCount(n); } //NS_RELEASE(start); @@ -1227,7 +1234,8 @@ void nsDocument::TraverseTree(nsString & aText, aText.Append(text); //NS_IF_RELEASE(textContent); } else { - nsIAtom * atom = aContent->GetTag(); + nsIAtom * atom; + aContent->GetTag(atom); if (atom != nsnull) { nsString str; atom->ToString(str); @@ -1251,8 +1259,12 @@ void nsDocument::TraverseTree(nsString & aText, } } - for (PRInt32 i=0;iChildCount();i++) { - TraverseTree(aText, aContent->ChildAt(i), aStart, aEnd, aInRange); + PRInt32 n; + aContent->ChildCount(n); + for (PRInt32 i=0;iChildAt(i, kid); + TraverseTree(aText, kid, aStart, aEnd, aInRange); } if (addReturn) { aText.Append("\n"); @@ -1394,12 +1406,14 @@ nsIContent* nsDocument::FindContent(const nsIContent* aStartNode, const nsIContent* aTest1, const nsIContent* aTest2) const { - PRInt32 count = aStartNode->ChildCount(); + PRInt32 count; + aStartNode->ChildCount(count); PRInt32 index; for(index = 0; index < count;index++) { - nsIContent* child = aStartNode->ChildAt(index); + nsIContent* child; + aStartNode->ChildAt(index, child); nsIContent* content = FindContent(child,aTest1,aTest2); if (content != nsnull) { NS_IF_RELEASE(child); @@ -1485,12 +1499,14 @@ nsIContent* nsDocument::GetPrevContent(const nsIContent *aContent) const if (nsnull != aContent) { - nsIContent* parent = aContent->GetParent(); + nsIContent* parent; + aContent->GetParent(parent); if (parent != nsnull && parent != mRootContent) { - PRInt32 index = parent->IndexOf((nsIContent*)aContent); + PRInt32 index; + parent->IndexOf((nsIContent*)aContent, index); if (index > 0) - result = parent->ChildAt(index-1); + parent->ChildAt(index-1, result); else result = GetPrevContent(parent); } @@ -1506,17 +1522,22 @@ nsIContent* nsDocument::GetNextContent(const nsIContent *aContent) const if (nsnull != aContent) { // Look at next sibling - nsIContent* parent = aContent->GetParent(); + nsIContent* parent; + aContent->GetParent(parent); if (parent != nsnull && parent != mRootContent) { - PRInt32 index = parent->IndexOf((nsIContent*)aContent); - PRInt32 count = parent->ChildCount(); + PRInt32 index; + parent->IndexOf((nsIContent*)aContent, index); + PRInt32 count; + parent->ChildCount(count); if (index+1 < count) { - result = parent->ChildAt(index+1); + parent->ChildAt(index+1, result); // Get first child down the tree - while (result->ChildCount() > 0) { + PRInt32 n; + result->ChildCount(n); + while (n > 0) { nsIContent * old = result; - result = old->ChildAt(0); + old->ChildAt(0, result); NS_RELEASE(old); } } else { diff --git a/mozilla/layout/base/src/nsFrame.cpp b/mozilla/layout/base/src/nsFrame.cpp index bc4a5adb58e..4e6c431f02d 100644 --- a/mozilla/layout/base/src/nsFrame.cpp +++ b/mozilla/layout/base/src/nsFrame.cpp @@ -272,9 +272,10 @@ NS_METHOD nsFrame::GetContent(nsIContent*& aContent) const NS_METHOD nsFrame::GetContentIndex(PRInt32& aIndexInParent) const { - nsIContent* parent = mContent->GetParent(); + nsIContent* parent; + mContent->GetParent(parent); if (nsnull != parent) { - aIndexInParent = parent->IndexOf(mContent); + parent->IndexOf(mContent, aIndexInParent); NS_RELEASE(parent); } else { @@ -500,7 +501,9 @@ NS_METHOD nsFrame::Paint(nsIPresContext& aPresContext, // Get Content nsIContent * content; GetContent(content); - if (content->ChildCount() > 0) { + PRInt32 n; + content->ChildCount(n); + if (n > 0) { NS_RELEASE(content); return NS_OK; } @@ -1406,7 +1409,8 @@ NS_METHOD nsFrame::List(FILE* out, PRInt32 aIndent) const // Output the frame's tag NS_METHOD nsFrame::ListTag(FILE* out) const { - nsIAtom* tag = mContent->GetTag(); + nsIAtom* tag; + mContent->GetTag(tag); if (tag != nsnull) { nsAutoString buf; tag->ToString(buf); @@ -1792,7 +1796,8 @@ GetTagName(nsFrame* aFrame, nsIContent* aContent, PRIntn aResultSize, char namebuf[40]; namebuf[0] = 0; if (nsnull != aContent) { - nsIAtom* tag = aContent->GetTag(); + nsIAtom* tag; + aContent->GetTag(tag); if (nsnull != tag) { nsAutoString tmp; tag->ToString(tmp); diff --git a/mozilla/layout/base/src/nsPresShell.cpp b/mozilla/layout/base/src/nsPresShell.cpp index f41245f7e18..eba1aaeea29 100644 --- a/mozilla/layout/base/src/nsPresShell.cpp +++ b/mozilla/layout/base/src/nsPresShell.cpp @@ -620,7 +620,8 @@ ContentTag(nsIContent* aContent, PRIntn aSlot) static char buf0[100], buf1[100], buf2[100]; static char* bufs[] = { buf0, buf1, buf2 }; char* buf = bufs[aSlot]; - nsIAtom* atom = aContent->GetTag(); + nsIAtom* atom; + aContent->GetTag(atom); if (nsnull != atom) { nsAutoString tmp; atom->ToString(tmp); @@ -678,7 +679,7 @@ PresShell::ContentAppended(nsIDocument *aDocument, frame->ContentAppended(this, mPresContext, aContainer); break; } - parentContainer = parentContainer->GetParent(); + parentContainer->GetParent(parentContainer); } ExitReflowLock(); diff --git a/mozilla/layout/base/tests/TestContainerFrame.cpp b/mozilla/layout/base/tests/TestContainerFrame.cpp index 9b03dfa1e32..23fa7da74dd 100644 --- a/mozilla/layout/base/tests/TestContainerFrame.cpp +++ b/mozilla/layout/base/tests/TestContainerFrame.cpp @@ -53,43 +53,85 @@ public: adoc = mDocument; return NS_OK; } - - void SetDocument(nsIDocument* aDocument) {mDocument = aDocument;} - - nsIContent* GetParent() const { return nsnull; } - void SetParent(nsIContent* aParent) {} - - PRBool CanContainChildren() const {return PR_FALSE;} - PRInt32 ChildCount() const {return 0;} - nsIContent* ChildAt(PRInt32 aIndex) const {return nsnull;} - PRInt32 IndexOf(nsIContent* aPossibleChild) const {return -1;} + NS_IMETHOD SetDocument(nsIDocument* aDocument) { + mDocument = aDocument; + return NS_OK; + } + NS_IMETHOD GetParent(nsIContent*& aResult) const { + aResult = nsnull; + return NS_OK; + } + NS_IMETHOD SetParent(nsIContent* aParent) { + return NS_OK; + } + NS_IMETHOD CanContainChildren(PRBool& aResult) const { + aResult = PR_FALSE; + return NS_OK; + } + 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) { return NS_OK; } + PRBool aNotify) { + return NS_OK; + } NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify){ return NS_OK; } - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) {return NS_OK;} - NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {return NS_OK;} - + PRBool aNotify){ + return NS_OK; + } + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { + return NS_OK; + } + NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { + return NS_OK; + } NS_IMETHOD IsSynthetic(PRBool& aResult) { aResult = PR_FALSE; return NS_OK; } - - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const; - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const; - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const; - - - nsIAtom* GetTag() const {return nsnull;} - void SetAttribute(const nsString& aName,const nsString& aValue) {;} - nsContentAttr GetAttribute(const nsString& aName, nsString& aRet) const {return eContentAttr_NotThere;} - - nsIContentDelegate* GetDelegate(nsIPresContext* aCX) {return nsnull;} - - void List(FILE* out = stdout, PRInt32 aIndent = 0) const {;} - NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { return NS_OK; } - NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, nsEventStatus& aEventStatus) - {return NS_OK;} + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { + return NS_OK; + } + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { + return NS_OK; + } + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { + return NS_OK; + } + NS_IMETHOD GetTag(nsIAtom*& aResult) const { + aResult = nsnull; + return NS_OK; + } + NS_IMETHOD SetAttribute(const nsString& aName,const nsString& aValue, + PRBool aNotify) { + return NS_OK; + } + NS_IMETHOD GetAttribute(const nsString& aName, nsString& aRet) const { + return NS_CONTENT_ATTR_NOT_THERE; + } + nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { + return nsnull; + } + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const { + return NS_OK; + } + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { + return NS_OK; + } + NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, PRUint32 aFlags, + nsEventStatus& aEventStatus) { + return NS_OK; + } NS_DECL_ISUPPORTS @@ -101,18 +143,6 @@ SimpleContent::SimpleContent() { } -void SimpleContent::BeginConvertToXIF(nsXIFConverter& aConverter) const -{ -} - -void SimpleContent::FinishConvertToXIF(nsXIFConverter& aConverter) const -{ -} - -void SimpleContent::ConvertContentToXIF(nsXIFConverter& aConverter) const -{ -} - NS_IMPL_ISUPPORTS(SimpleContent, kIContentIID); /////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/layout/css/layout/src/TODO b/mozilla/layout/css/layout/src/TODO index d3f71a075dd..2f918a409e3 100644 --- a/mozilla/layout/css/layout/src/TODO +++ b/mozilla/layout/css/layout/src/TODO @@ -1,8 +1,6 @@ todo for AOL August 1st deadline: --------------------------------- -o pages without titles don't clear the title - o bug17-3.html: when dealing with incremental frame-appended reflow we need to know how the last clean line was ended (e.g. break, clear=all, etc.) otherwise we won't adjust the y coordinate properly. We can save the @@ -31,16 +29,6 @@ o bug2.html o UMR bug because of painting during reflow -o implement base tag support: - o frame, iframe, frameset - o layer - o body background, table background, etc. - -o TEST base tag support: - o script src= - o style src= - -o missing space after ampersand on http://home.netscape.com o fast scroll to #ref for a link targeted at the same document as is currently showing @@ -56,13 +44,13 @@ o Viewer: o fix link-over status o fix floating tables - o current-line floaters need to go in previous line's bcl list; if first line + x current-line floaters need to go in previous line's bcl list; if first line then they go in the block-frame's pending floater list - o ... we need a place to hang current-line floaters!!! + x ... we need a place to hang current-line floaters!!! x http://www.news.com x http://www.usatoday.com/ o http://www.mrshowbiz.com/ - o file:/f:/html/floating-images.html + x file:/f:/html/floating-images.html "tucked between the woofers" isn't o file:/f:/html/floating-tables-inline.html overwrite errors @@ -80,10 +68,6 @@ o fix blocks inside of inlines; need to find the block's inline-layout state and see where the block child is with respect to the left edge of the line. -o iframe on infoseek - -x table tag is closing paragraphs - o mark/insert-at-mark for parser??? o www.cnn.com: crash @@ -91,8 +75,6 @@ o www.cnn.com: crash o performance: o people.netscape.com -o initial black reflow bug - o slide show resize bug o fix assertion on LCIC in nscssblockframe::content-inserted when @@ -100,12 +82,30 @@ o fix assertion on LCIC in nscssblockframe::content-inserted when o docloader needs to disconnect itself as an observer when it's done -o fix limited stack depth in content sink - ---------------------------------------------------------------------- After august 10th ---------------------------------------------------------------------- +o why is nsInlineLayout different from nsInlineReflowState (mott@nc.com) + +BASE TAG SUPPORT: +o revise the way that base tags work (somehow); either make the + content sink aware of all tags that can have url's in them, or better + yet, add in base tag api's to the nsHTMLDocument and make the content + set-attribute methods deal with it; or add in a method to + nsIHTMLContent called SetBaseURL and SetTarget (which is defined to be + ignored except for those tags that care) + + o implement base tag support: + o frame, iframe, frameset + o layer + o Body (background), TABLE, TR, TD (background), etc. + o Image, Anchor; look at html4.0 spec for attributes that are URI's + + o TEST base tag support: + o script src= + o style src= + o NS_FRAME_FIRST_REFLOW needs to go; block code is the only consumer instead keep a list of new frames and when we hit one, trigger the initial reflow @@ -224,3 +224,10 @@ Would be nice someday async dns slow mode css parser keeping comments + +---------------------------------------------------------------------- +DONE +---------------------------------------------------------------------- + +x fix limited stack depth in content sink +x missing space after ampersand on http://home.netscape.com diff --git a/mozilla/layout/css/layout/src/nsCSSBlockFrame.cpp b/mozilla/layout/css/layout/src/nsCSSBlockFrame.cpp index b60461dc403..388477c93f6 100644 --- a/mozilla/layout/css/layout/src/nsCSSBlockFrame.cpp +++ b/mozilla/layout/css/layout/src/nsCSSBlockFrame.cpp @@ -860,11 +860,12 @@ nsCSSBlockReflowState::nsCSSBlockReflowState(nsIPresContext* aPresContext, mNextListOrdinal = -1; nsIContent* blockContent; mBlock->GetContent(blockContent); - nsIAtom* tag = blockContent->GetTag(); + nsIAtom* tag; + blockContent->GetTag(tag); if ((tag == nsHTMLAtoms::ul) || (tag == nsHTMLAtoms::ol) || (tag == nsHTMLAtoms::menu) || (tag == nsHTMLAtoms::dir)) { nsHTMLValue value; - if (eContentAttr_HasValue == + if (NS_CONTENT_ATTR_HAS_VALUE == ((nsIHTMLContent*)blockContent)->GetAttribute(nsHTMLAtoms::start, value)) { if (eHTMLUnit_Integer == value.GetUnit()) { @@ -872,6 +873,7 @@ nsCSSBlockReflowState::nsCSSBlockReflowState(nsIPresContext* aPresContext, } } } + NS_IF_RELEASE(tag); NS_RELEASE(blockContent); } @@ -1034,7 +1036,8 @@ nsCSSBlockFrame::ListTag(FILE* out) const { if ((nsnull != mGeometricParent) && IsPseudoFrame()) { fprintf(out, "*block<"); - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { nsAutoString tmp; atom->ToString(tmp); @@ -1416,7 +1419,8 @@ nsCSSBlockFrame::ProcessInitialReflow(nsIPresContext* aPresContext) // bullet crated. Check to see if the first child of the // container is a synthetic object; if it is, then don't make a // bullet (XXX what a hack!). - nsIContent* firstContent = mContent->ChildAt(0); + nsIContent* firstContent; + mContent->ChildAt(0, firstContent); if (nsnull != firstContent) { PRBool is; firstContent->IsSynthetic(is); @@ -1738,13 +1742,13 @@ nsCSSBlockFrame::CreateNewFrames(nsIPresContext* aPresContext) // Now create frames for all of the new content. nsresult rv; PRInt32 lastContentIndex; - lastContentIndex = mContent->ChildCount(); + mContent->ChildCount(lastContentIndex); NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("enter nsCSSBlockFrame::CreateNewFrames: kidContentIndex=%d lastContentIndex=%d", kidContentIndex, lastContentIndex)); for (; kidContentIndex < lastContentIndex; kidContentIndex++) { nsIContent* kid; - kid = mContent->ChildAt(kidContentIndex); + mContent->ChildAt(kidContentIndex, kid); if (nsnull == kid) { break; } @@ -3055,7 +3059,8 @@ nsCSSBlockFrame::ContentInserted(nsIPresShell* aShell, // Find the frame that precedes this frame nsIFrame* prevSibling = nsnull; if (aIndexInParent > 0) { - nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1); + nsIContent* precedingContent; + aContainer->ChildAt(aIndexInParent - 1, precedingContent); prevSibling = aShell->FindFrameWithContent(precedingContent); NS_ASSERTION(nsnull != prevSibling, "no frame for preceding content"); NS_RELEASE(precedingContent); @@ -3256,7 +3261,8 @@ nsCSSBlockFrame::ContentDeleted(nsIPresShell* aShell, nsIFrame* deadFrame; nsIFrame* prevSibling; if (aIndexInParent > 0) { - nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1); + nsIContent* precedingContent; + aContainer->ChildAt(aIndexInParent - 1, precedingContent); prevSibling = aShell->FindFrameWithContent(precedingContent); NS_RELEASE(precedingContent); diff --git a/mozilla/layout/css/layout/src/nsCSSInlineFrame.cpp b/mozilla/layout/css/layout/src/nsCSSInlineFrame.cpp index e621210ff86..09781e13fa0 100644 --- a/mozilla/layout/css/layout/src/nsCSSInlineFrame.cpp +++ b/mozilla/layout/css/layout/src/nsCSSInlineFrame.cpp @@ -478,13 +478,13 @@ nsCSSInlineFrame::CreateNewFrames(nsIPresContext* aPresContext) nsresult rv; PRInt32 lastContentIndex; - lastContentIndex = mContent->ChildCount(); + mContent->ChildCount(lastContentIndex); NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("enter nsCSSInlineFrame::CreateNewFrames: kidContentIndex=%d lastContentIndex=%d childPrevInFlow=%p", kidContentIndex, lastContentIndex, childPrevInFlow)); while (kidContentIndex < lastContentIndex) { nsIContent* kid; - kid = mContent->ChildAt(kidContentIndex); + mContent->ChildAt(kidContentIndex, kid); if (nsnull == kid) { // Our content container is bad break; @@ -629,7 +629,7 @@ nsCSSInlineFrame::ReflowMapped(nsCSSInlineReflowState& aState, // the child we just reflowed happens to be the last // possible child we can contain. PRInt32 lastContentIndex; - lastContentIndex = mContent->ChildCount(); + mContent->ChildCount(lastContentIndex); NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("nsCSSInlineFrame::ReflowMapped: HERE kidContentIndex=%d lastContentIndex=%d frame=%p c=%c kidRS=%x", kidContentIndex, lastContentIndex, child, mLastContentIsComplete ? 'T' : 'F', aReflowStatus)); @@ -793,7 +793,7 @@ nsCSSInlineFrame::PullUpChildren(nsCSSInlineReflowState& aState, // the child we just reflowed happens to be the last // possible child we can contain. PRInt32 lastContentIndex; - lastContentIndex = mContent->ChildCount(); + mContent->ChildCount(lastContentIndex); if (++kidContentIndex == lastContentIndex) { // We are complete. Yippee. :-) aReflowStatus &= ~NS_FRAME_NOT_COMPLETE; diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index e35b8c62eb6..97d85ab0d36 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -102,8 +102,10 @@ NS_METHOD nsEventStateManager::SetActiveLink(nsIContent *aLink) if (nsnull != mActiveLink) { if (NS_OK == mActiveLink->GetDocument(mDocument)) { nsIContent *mKid; - for (int i = 0; i < mActiveLink->ChildCount(); i++) { - mKid = mActiveLink->ChildAt(i); + PRInt32 numKids; + mActiveLink->ChildCount(numKids); + for (int i = 0; i < numKids; i++) { + mActiveLink->ChildAt(i, mKid); mDocument->ContentChanged(mKid, nsnull); NS_RELEASE(mKid); } @@ -119,8 +121,10 @@ NS_METHOD nsEventStateManager::SetActiveLink(nsIContent *aLink) if (nsnull != mActiveLink) { if (NS_OK == mActiveLink->GetDocument(mDocument)) { nsIContent *mKid; - for (int i = 0; i < mActiveLink->ChildCount(); i++) { - mKid = mActiveLink->ChildAt(i); + PRInt32 numKids; + mActiveLink->ChildCount(numKids); + for (int i = 0; i < numKids; i++) { + mActiveLink->ChildAt(i, mKid); mDocument->ContentChanged(mKid, nsnull); NS_RELEASE(mKid); } diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 504841ec65b..b8731fefbe0 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -114,7 +114,8 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresConte // Get child's cursor, if any nsContainerFrame::GetCursorAndContentAt(aPresContext, aPoint, aFrame, aContent, aCursor); if (aCursor != NS_STYLE_CURSOR_INHERIT) { - nsIAtom* tag = mContent->GetTag(); + nsIAtom* tag; + mContent->GetTag(tag); if (nsHTMLAtoms::a == tag) { // Anchor tags override their child cursors in some cases. if ((NS_STYLE_CURSOR_IBEAM == aCursor) && @@ -171,7 +172,8 @@ nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, // Find the frame that precedes the insertion point nsIFrame* prevSibling = nsnull; if (aIndexInParent > 0) { - nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1); + nsIContent* precedingContent; + aContainer->ChildAt(aIndexInParent - 1, precedingContent); prevSibling = aShell->FindFrameWithContent(precedingContent); NS_RELEASE(precedingContent); @@ -252,7 +254,8 @@ nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell, nsIFrame* deadFrame; nsIFrame* prevSibling; if (aIndexInParent > 0) { - nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1); + nsIContent* precedingContent; + aContainer->ChildAt(aIndexInParent - 1, precedingContent); prevSibling = aShell->FindFrameWithContent(precedingContent); NS_RELEASE(precedingContent); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 328508ef143..1bfae2e788c 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -220,7 +220,8 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, // XXX deal with border and padding the usual way...wrap it up! - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { //don't make a view for an applet since we know we can't support them yet... if (atom != nsHTMLAtoms::applet) { @@ -276,10 +277,10 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, //stream in the object source if there is one... - if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", src)) { SetURL(src); - if (eContentAttr_HasValue == mContent->GetAttribute(NS_HTML_BASE_HREF, base)) + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(NS_HTML_BASE_HREF, base)) SetBaseHREF(base); nsIPresShell *shell = aPresContext.GetShell(); @@ -367,7 +368,8 @@ nsObjectFrame::Paint(nsIPresContext& aPresContext, float p2t = aPresContext.GetPixelsToTwips(); nscoord px3 = NSIntPixelsToTwips(3, p2t); nsAutoString tmp; - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { atom->ToString(tmp); NS_RELEASE(atom); diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 3c2a7814c83..6712b0e02c4 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -35,12 +35,13 @@ void nsPageFrame::CreateFirstChild(nsIPresContext* aPresContext) // Create a frame for the body child PRInt32 i, n; - n = mContent->ChildCount(); + mContent->ChildCount(n); for (i = 0; i < n; i++) { - nsIContent* child = mContent->ChildAt(i); + nsIContent* child; + mContent->ChildAt(i, child); if (nsnull != child) { nsIAtom* tag; - tag = child->GetTag(); + child->GetTag(tag); // XXX added frameset check, is it necessary, what is a page frame anyway if ((nsHTMLAtoms::body == tag) || (nsHTMLAtoms::frameset == tag)) { // Create a frame diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index 654e0c71666..2340a74b125 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -106,7 +106,8 @@ nsPlaceholderFrame::InlineReflow(nsCSSLineLayout& aLineLayout, // content children rather than create a table frame and let it map the // children... PRBool select = PR_FALSE; - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); nsAutoString tmp; if (nsnull != atom) { atom->ToString(tmp); @@ -121,7 +122,9 @@ nsPlaceholderFrame::InlineReflow(nsCSSLineLayout& aLineLayout, } // XXX end hack - if (mContent->CanContainChildren() && !select) { + PRBool canHaveKids; + mContent->CanContainChildren(canHaveKids); + if (canHaveKids && !select) { nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this); // Use our style context for the pseudo-frame diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp index 8847930766e..f701bc6556e 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp +++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp @@ -57,7 +57,9 @@ NS_IMETHODIMP nsAbsoluteFrame::Reflow(nsIPresContext& aPresContext, // Have we created the absolutely positioned item yet? if (nsnull == mFrame) { // If the content object is a container then wrap it in a body pseudo-frame - if (mContent->CanContainChildren()) { + PRBool canHaveKids; + mContent->CanContainChildren(canHaveKids); + if (canHaveKids) { nsBodyFrame::NewFrame(&mFrame, mContent, this); // Use our style context for the pseudo-frame diff --git a/mozilla/layout/html/base/src/nsBRPart.cpp b/mozilla/layout/html/base/src/nsBRPart.cpp index 543b2fa79f5..22ebac009fb 100644 --- a/mozilla/layout/html/base/src/nsBRPart.cpp +++ b/mozilla/layout/html/base/src/nsBRPart.cpp @@ -135,19 +135,20 @@ class BRPart : public nsHTMLTagContent { public: BRPart(nsIAtom* aTag); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; protected: virtual ~BRPart(); - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; }; BRPart::BRPart(nsIAtom* aTag) @@ -159,7 +160,7 @@ BRPart::~BRPart() { } -nsresult +NS_IMETHODIMP BRPart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, @@ -182,20 +183,21 @@ static nsHTMLTagContent::EnumTable kClearTable[] = { { 0 } }; -void -BRPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +BRPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::clear) { nsHTMLValue value; if (ParseEnumValue(aString, kClearTable, value)) { - nsHTMLTagContent::SetAttribute(aAttribute, value); + nsHTMLTagContent::SetAttribute(aAttribute, value, aNotify); } - return; + return NS_OK; } - nsHTMLTagContent::SetAttribute(aAttribute, aString); + return nsHTMLTagContent::SetAttribute(aAttribute, aString, aNotify); } -void +NS_IMETHODIMP BRPart::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -208,9 +210,10 @@ BRPart::MapAttributesInto(nsIStyleContext* aContext, display->mBreakType = value.GetIntValue(); } } + return NS_OK; } -nsContentAttr +NS_IMETHODIMP BRPart::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -219,10 +222,10 @@ BRPart::AttributeToString(nsIAtom* aAttribute, if ((eHTMLUnit_Enumerated == aValue.GetUnit()) && (NS_STYLE_CLEAR_NONE != aValue.GetIntValue())) { EnumValueToString(aValue, kClearTable, aResult); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } //---------------------------------------------------------------------- diff --git a/mozilla/layout/html/base/src/nsBodyPart.cpp b/mozilla/layout/html/base/src/nsBodyPart.cpp index 7d1bcd743da..834d7fce354 100644 --- a/mozilla/layout/html/base/src/nsBodyPart.cpp +++ b/mozilla/layout/html/base/src/nsBodyPart.cpp @@ -42,7 +42,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; BodyPart* mPart; }; @@ -54,12 +54,12 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual nsIStyleRule* GetStyleRule(void); + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult); protected: virtual ~BodyPart(); @@ -103,7 +103,8 @@ void BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont nsHTMLValue value; nsStyleCoord zero(0); PRInt32 count = 0; - PRInt32 attrCount = mPart->GetAttributeCount(); + PRInt32 attrCount; + mPart->GetAttributeCount(attrCount); if (0 < attrCount) { // if marginwidth/marginheigth is set in our attribute zero out left,right/top,bottom padding @@ -154,8 +155,10 @@ void BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont } } -void BodyRule::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +BodyRule::List(FILE* out, PRInt32 aIndent) const { + return NS_OK; } // ----------------------------------------------------------- @@ -204,14 +207,16 @@ BodyPart::CreateFrame(nsIPresContext* aPresContext, return NS_OK; } -nsIStyleRule* BodyPart::GetStyleRule(void) +NS_IMETHODIMP +BodyPart::GetStyleRule(nsIStyleRule*& aResult) { if (nsnull == mStyleRule) { mStyleRule = new BodyRule(this); NS_IF_ADDREF(mStyleRule); } NS_IF_ADDREF(mStyleRule); - return mStyleRule; + aResult = mStyleRule; + return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsDOMAttributes.cpp b/mozilla/layout/html/base/src/nsDOMAttributes.cpp index 2541d875af5..4b01ff6bf19 100644 --- a/mozilla/layout/html/base/src/nsDOMAttributes.cpp +++ b/mozilla/layout/html/base/src/nsDOMAttributes.cpp @@ -322,7 +322,7 @@ nsresult nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode) attribute->GetValue(value); NS_RELEASE(attribute); - mContent.SetAttribute(name, value); + mContent.SetAttribute(name, value, PR_TRUE); return NS_OK; } @@ -346,7 +346,8 @@ nsresult nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsAutoString name, value; nsISupportsArray *attributes = nsnull; if (NS_OK == NS_NewISupportsArray(&attributes)) { - PRInt32 count = mContent.GetAllAttributeNames(attributes); + PRInt32 count; + mContent.GetAllAttributeNames(attributes, count); if (count > 0) { if ((PRInt32)aIndex < count) { nsISupports *att = attributes->ElementAt(aIndex); @@ -354,7 +355,7 @@ nsresult nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsIAtom *atName = nsnull; if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) { atName->ToString(name); - if (eContentAttr_NotThere != mContent.GetAttribute(name, value)) { + if (NS_CONTENT_ATTR_NOT_THERE != mContent.GetAttribute(name, value)) { *aReturn = (nsIDOMNode *)new nsDOMAttribute(name, value); res = NS_OK; } @@ -370,7 +371,9 @@ nsresult nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsresult nsDOMAttributeMap::GetLength(PRUint32 *aLength) { - *aLength = mContent.GetAttributeCount(); + PRInt32 n; + mContent.GetAttributeCount(n); + *aLength = PRUint32(n); return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsDOMNodeList.cpp b/mozilla/layout/html/base/src/nsDOMNodeList.cpp index 6374fec4d5c..9804d5c6d50 100644 --- a/mozilla/layout/html/base/src/nsDOMNodeList.cpp +++ b/mozilla/layout/html/base/src/nsDOMNodeList.cpp @@ -86,7 +86,9 @@ NS_IMETHODIMP nsDOMNodeList::GetLength(PRUint32* aLength) { if (nsnull != mContent) { - *aLength = mContent->ChildCount(); + PRInt32 n; + mContent->ChildCount(n); + *aLength = PRUint32(n); } else { *aLength = 0; @@ -100,7 +102,7 @@ nsDOMNodeList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsIContent *content = nsnull; nsresult res = NS_OK; if (nsnull != mContent) { - content = mContent->ChildAt(aIndex); + mContent->ChildAt(aIndex, content); if (nsnull != content) { res = content->QueryInterface(kIDOMNodeIID, (void**)aReturn); NS_RELEASE(content); diff --git a/mozilla/layout/html/base/src/nsHRPart.cpp b/mozilla/layout/html/base/src/nsHRPart.cpp index bef3f0131b7..682a178c390 100644 --- a/mozilla/layout/html/base/src/nsHRPart.cpp +++ b/mozilla/layout/html/base/src/nsHRPart.cpp @@ -307,7 +307,8 @@ HRuleFrame::GetThickness() // Winner. Get the size attribute to determine how thick the HR // should be. nsHTMLValue value; - if (eContentAttr_HasValue == hc->GetAttribute(nsHTMLAtoms::size, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == + hc->GetAttribute(nsHTMLAtoms::size, value)) { if (value.GetUnit() == eHTMLUnit_Pixel) { PRInt32 pixels = value.GetPixelValue(); switch (pixels) { diff --git a/mozilla/layout/html/base/src/nsHTMLBase.cpp b/mozilla/layout/html/base/src/nsHTMLBase.cpp index 88f54642b5d..927da7befdf 100644 --- a/mozilla/layout/html/base/src/nsHTMLBase.cpp +++ b/mozilla/layout/html/base/src/nsHTMLBase.cpp @@ -133,7 +133,8 @@ nsHTMLBase::CreateFrame(nsIPresContext* aPresContext, { nsIStyleContext* kidSC; // XXX Cheesy hack for text - nsIAtom* tag = aKid->GetTag(); + nsIAtom* tag; + aKid->GetTag(tag); if (nsnull == tag) { kidSC = aPresContext->ResolvePseudoStyleContextFor(nsHTMLAtoms::text, aParentFrame); } else { diff --git a/mozilla/layout/html/base/src/nsHTMLBullet.cpp b/mozilla/layout/html/base/src/nsHTMLBullet.cpp index fbdaa0d1ca3..1f3545bcf58 100644 --- a/mozilla/layout/html/base/src/nsHTMLBullet.cpp +++ b/mozilla/layout/html/base/src/nsHTMLBullet.cpp @@ -55,15 +55,15 @@ public: NS_IMETHOD IsSynthetic(PRBool& aResult); - void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); - void List(FILE* out, PRInt32 aIndent) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); }; class BulletFrame : public nsFrame, private nsIInlineReflow { @@ -119,7 +119,7 @@ Bullet::Bullet() { } -void +NS_IMETHODIMP Bullet::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -127,23 +127,25 @@ Bullet::MapAttributesInto(nsIStyleContext* aContext, nsStyleDisplay* display = (nsStyleDisplay*) aContext->GetMutableStyleData(eStyleStruct_Display); display->mDisplay = NS_STYLE_DISPLAY_INLINE; + return NS_OK; } -NS_METHOD +NS_IMETHODIMP Bullet::IsSynthetic(PRBool& aResult) { aResult = PR_TRUE; return NS_OK; } -void +NS_IMETHODIMP Bullet::List(FILE* out, PRInt32 aIndent) const { for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "Bullet RefCnt=%d<>\n", mRefCnt); + return NS_OK; } -nsresult +NS_IMETHODIMP Bullet::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, @@ -317,7 +319,8 @@ BulletFrame::GetListContainerReflowState(nsIPresContext* aCX, while (nsnull != rs) { nsIContent* content; rs->frame->GetContent(content); - nsIAtom* tag = content->GetTag(); + nsIAtom* tag; + content->GetTag(tag); NS_RELEASE(content); if ((tag == nsHTMLAtoms::ul) || (tag == nsHTMLAtoms::ol) || (tag == nsHTMLAtoms::menu) || (tag == nsHTMLAtoms::dir)) { @@ -347,7 +350,7 @@ BulletFrame::GetListItemOrdinal(nsIPresContext* aCX, nsIContent* parentContent; mContentParent->GetContent(parentContent); nsIHTMLContent* html = (nsIHTMLContent*) parentContent; - if (eContentAttr_HasValue == html->GetAttribute(nsHTMLAtoms::value, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == html->GetAttribute(nsHTMLAtoms::value, value)) { if (eHTMLUnit_Integer == value.GetUnit()) { ordinal = value.GetIntValue(); if (nsnull != aReflowState) { diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.cpp b/mozilla/layout/html/base/src/nsHTMLContainer.cpp index 2aea3605e46..5c331d10c65 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainer.cpp @@ -114,29 +114,37 @@ nsHTMLContainer::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const } } -PRBool nsHTMLContainer::CanContainChildren() const +NS_IMETHODIMP +nsHTMLContainer::CanContainChildren(PRBool& aResult) const { - return PR_TRUE; + aResult = PR_TRUE; + return NS_OK; } -PRInt32 nsHTMLContainer::ChildCount() const +NS_IMETHODIMP +nsHTMLContainer::ChildCount(PRInt32& aCount) const { - return mChildren.Count(); + aCount = mChildren.Count(); + return NS_OK; } -nsIContent* nsHTMLContainer::ChildAt(PRInt32 aIndex) const +NS_IMETHODIMP +nsHTMLContainer::ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { nsIContent *child = (nsIContent*) mChildren.ElementAt(aIndex); if (nsnull != child) { NS_ADDREF(child); } - return child; + aResult = child; + return NS_OK; } -PRInt32 nsHTMLContainer::IndexOf(nsIContent* aPossibleChild) const +NS_IMETHODIMP +nsHTMLContainer::IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const { NS_PRECONDITION(nsnull != aPossibleChild, "null ptr"); - return mChildren.IndexOf(aPossibleChild); + aIndex = mChildren.IndexOf(aPossibleChild); + return NS_OK; } NS_IMETHODIMP @@ -227,12 +235,14 @@ nsHTMLContainer::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) return NS_OK; } -void nsHTMLContainer::Compact() +NS_IMETHODIMP +nsHTMLContainer::Compact() { //XXX I'll turn this on in a bit... mChildren.Compact(); + return NS_OK; } -nsresult +NS_IMETHODIMP nsHTMLContainer::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, @@ -304,8 +314,10 @@ static nsHTMLTagContent::EnumTable kDirTable[] = { { 0 } }; -void nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) +NS_IMETHODIMP +nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, + const nsString& aValue, + PRBool aNotify) { // Special handling code for various html container attributes; note // that if an attribute doesn't require special handling then we @@ -315,36 +327,30 @@ void nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, // Check for attributes common to most html containers if (aAttribute == nsHTMLAtoms::dir) { if (ParseEnumValue(aValue, kDirTable, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } - if (aAttribute == nsHTMLAtoms::lang) { - nsHTMLTagContent::SetAttribute(aAttribute, aValue); - return; + else if (aAttribute == nsHTMLAtoms::lang) { + return nsHTMLTagContent::SetAttribute(aAttribute, aValue, aNotify); } if (mTag == nsHTMLAtoms::p) { if ((aAttribute == nsHTMLAtoms::align) && ParseDivAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (mTag == nsHTMLAtoms::a) { if (aAttribute == nsHTMLAtoms::href) { nsAutoString href(aValue); href.StripWhitespace(); - nsHTMLTagContent::SetAttribute(aAttribute, href); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, href, aNotify); } if (aAttribute == nsHTMLAtoms::suppress) { if (aValue.EqualsIgnoreCase("true")) { nsHTMLValue val; val.SetEmptyValue(); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } // XXX PRE? @@ -359,37 +365,31 @@ void nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, PRUnichar ch = tmp.First(); val.SetIntValue(v, ((ch == '+') || (ch == '-')) ? eHTMLUnit_Integer : eHTMLUnit_Enumerated); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::color) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if ((mTag == nsHTMLAtoms::div) || (mTag == nsHTMLAtoms::multicol)) { if ((mTag == nsHTMLAtoms::div) && (aAttribute == nsHTMLAtoms::align) && ParseDivAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::cols) { ParseValue(aValue, 0, val, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } // Note: These attributes only apply when cols > 1 if (aAttribute == nsHTMLAtoms::gutter) { ParseValue(aValue, 1, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::width) { ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if ((mTag == nsHTMLAtoms::h1) || (mTag == nsHTMLAtoms::h2) || @@ -397,21 +397,18 @@ void nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, (mTag == nsHTMLAtoms::h5) || (mTag == nsHTMLAtoms::h6)) { if ((aAttribute == nsHTMLAtoms::align) && ParseDivAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (mTag == nsHTMLAtoms::pre) { if ((aAttribute == nsHTMLAtoms::wrap) || (aAttribute == nsHTMLAtoms::variable)) { val.SetEmptyValue(); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::cols) { ParseValue(aValue, 0, val, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::tabstop) { PRInt32 ec, tabstop = aValue.ToInteger(&ec); @@ -419,22 +416,19 @@ void nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, tabstop = 8; } val.SetIntValue(tabstop, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (mTag == nsHTMLAtoms::li) { if (aAttribute == nsHTMLAtoms::type) { if (ParseEnumValue(aValue, kListItemTypeTable, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } // Illegal type values are left as is for the dom } if (aAttribute == nsHTMLAtoms::value) { ParseValue(aValue, 1, val, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if ((mTag == nsHTMLAtoms::ul) || (mTag == nsHTMLAtoms::ol) || @@ -443,96 +437,85 @@ void nsHTMLContainer::SetAttribute(nsIAtom* aAttribute, if (!ParseEnumValue(aValue, kListTypeTable, val)) { val.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); } - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::start) { ParseValue(aValue, 1, val, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::compact) { val.SetEmptyValue(); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (mTag == nsHTMLAtoms::dl) { if (aAttribute == nsHTMLAtoms::compact) { val.SetEmptyValue(); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (mTag == nsHTMLAtoms::body) { if (aAttribute == nsHTMLAtoms::background) { nsAutoString href(aValue); href.StripWhitespace(); - nsHTMLTagContent::SetAttribute(aAttribute, href); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, href, aNotify); } if (aAttribute == nsHTMLAtoms::bgcolor) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::text) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::link) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::alink) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::vlink) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::marginwidth) { ParseValue(aValue, 0, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::marginheight) { ParseValue(aValue, 0, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } // Use default attribute catching code - nsHTMLTagContent::SetAttribute(aAttribute, aValue); + return nsHTMLTagContent::SetAttribute(aAttribute, aValue, aNotify); } -nsContentAttr nsHTMLContainer::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +NS_IMETHODIMP +nsHTMLContainer::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { - nsContentAttr ca = eContentAttr_NotThere; + nsresult ca = NS_CONTENT_ATTR_NOT_THERE; if (aValue.GetUnit() == eHTMLUnit_Enumerated) { if (aAttribute == nsHTMLAtoms::align) { DivAlignParamToString(aValue, aResult); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } else if (mTag == nsHTMLAtoms::li) { if (aAttribute == nsHTMLAtoms::type) { EnumValueToString(aValue, kListItemTypeTable, aResult); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } } else if ((mTag == nsHTMLAtoms::ul) || (mTag == nsHTMLAtoms::ol) || (mTag == nsHTMLAtoms::menu) || (mTag == nsHTMLAtoms::dir)) { if (aAttribute == nsHTMLAtoms::type) { EnumValueToString(aValue, kListTypeTable, aResult); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } } else if (mTag == nsHTMLAtoms::font) { @@ -541,7 +524,7 @@ nsContentAttr nsHTMLContainer::AttributeToString(nsIAtom* aAttribute, (aAttribute == nsHTMLAtoms::fontWeight)) { aResult.Truncate(); aResult.Append(aValue.GetIntValue(), 10); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } } } @@ -556,7 +539,7 @@ nsContentAttr nsHTMLContainer::AttributeToString(nsIAtom* aAttribute, aResult.Append('+'); } aResult.Append(value, 10); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } } } @@ -566,8 +549,9 @@ nsContentAttr nsHTMLContainer::AttributeToString(nsIAtom* aAttribute, return ca; } -void nsHTMLContainer::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsHTMLContainer::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { if (nsnull != mAttributes) { nsHTMLValue value; @@ -845,6 +829,7 @@ void nsHTMLContainer::MapAttributesInto(nsIStyleContext* aContext, font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(3, (PRInt32)defaultFixedFont.size, scaleFactor); } } + return NS_OK; } @@ -855,7 +840,7 @@ nsHTMLContainer::MapBackgroundAttributesInto(nsIStyleContext* aContext, nsHTMLValue value; // background - if (eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::background, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::background, value)) { if (eHTMLUnit_String == value.GetUnit()) { nsAutoString absURLSpec; nsAutoString spec; @@ -881,7 +866,7 @@ nsHTMLContainer::MapBackgroundAttributesInto(nsIStyleContext* aContext, } // bgcolor - if (eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::bgcolor, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) { if (eHTMLUnit_Color == value.GetUnit()) { nsStyleColor* color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); color->mBackgroundColor = value.GetColorValue(); @@ -966,9 +951,10 @@ static void SetDocumentInChildrenOf(nsIContent* aContent, nsIDocument* aDocument) { PRInt32 i, n; - n = aContent->ChildCount(); + aContent->ChildCount(n); for (i = 0; i < n; i++) { - nsIContent* child = aContent->ChildAt(i); + nsIContent* child; + aContent->ChildAt(i, child); if (nsnull != child) { child->SetDocument(aDocument); SetDocumentInChildrenOf(child, aDocument); @@ -1006,7 +992,8 @@ nsHTMLContainer::InsertBefore(nsIDOMNode* aNewChild, res = aRefChild->QueryInterface(kIContentIID, (void**)&refContent); NS_ASSERTION(NS_OK == res, "Ref child must be an nsIContent"); if (NS_OK == res) { - PRInt32 pos = IndexOf(refContent); + PRInt32 pos; + IndexOf(refContent, pos); if (pos >= 0) { SetDocumentInChildrenOf(newContent, mDocument); res = InsertChildAt(newContent, pos, PR_TRUE); @@ -1036,7 +1023,8 @@ nsHTMLContainer::ReplaceChild(nsIDOMNode* aNewChild, nsresult res = aOldChild->QueryInterface(kIContentIID, (void**)&content); NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); if (NS_OK == res) { - PRInt32 pos = IndexOf(content); + PRInt32 pos; + IndexOf(content, pos); if (pos >= 0) { nsIContent* newContent = nsnull; nsresult res = aNewChild->QueryInterface(kIContentIID, (void**)&newContent); @@ -1063,7 +1051,8 @@ nsHTMLContainer::RemoveChild(nsIDOMNode* aOldChild, nsresult res = aOldChild->QueryInterface(kIContentIID, (void**)&content); NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); if (NS_OK == res) { - PRInt32 pos = IndexOf(content); + PRInt32 pos; + IndexOf(content, pos); if (pos >= 0) { res = RemoveChildAt(pos, PR_TRUE); *aReturn = aOldChild; diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.h b/mozilla/layout/html/base/src/nsHTMLContainer.h index 2e9a1ec4858..b50f0a51c82 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.h +++ b/mozilla/layout/html/base/src/nsHTMLContainer.h @@ -29,26 +29,35 @@ public: nsHTMLContainer(nsIAtom* aTag); NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - virtual PRBool CanContainChildren() const; - virtual PRInt32 ChildCount() const; - virtual nsIContent* ChildAt(PRInt32 aIndex) const; - virtual PRInt32 IndexOf(nsIContent* aPossibleChild) 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& aIndex) 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); - virtual void Compact(); + NS_IMETHOD Compact(); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes); NS_IMETHOD GetHasChildNodes(PRBool* aHasChildNodes); @@ -70,9 +79,6 @@ protected: virtual ~nsHTMLContainer(); void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const; - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; /** * Helper method that maps "background" and "bgcolor" into diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index 504841ec65b..b8731fefbe0 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -114,7 +114,8 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresConte // Get child's cursor, if any nsContainerFrame::GetCursorAndContentAt(aPresContext, aPoint, aFrame, aContent, aCursor); if (aCursor != NS_STYLE_CURSOR_INHERIT) { - nsIAtom* tag = mContent->GetTag(); + nsIAtom* tag; + mContent->GetTag(tag); if (nsHTMLAtoms::a == tag) { // Anchor tags override their child cursors in some cases. if ((NS_STYLE_CURSOR_IBEAM == aCursor) && @@ -171,7 +172,8 @@ nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, // Find the frame that precedes the insertion point nsIFrame* prevSibling = nsnull; if (aIndexInParent > 0) { - nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1); + nsIContent* precedingContent; + aContainer->ChildAt(aIndexInParent - 1, precedingContent); prevSibling = aShell->FindFrameWithContent(precedingContent); NS_RELEASE(precedingContent); @@ -252,7 +254,8 @@ nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell, nsIFrame* deadFrame; nsIFrame* prevSibling; if (aIndexInParent > 0) { - nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1); + nsIContent* precedingContent; + aContainer->ChildAt(aIndexInParent - 1, precedingContent); prevSibling = aShell->FindFrameWithContent(precedingContent); NS_RELEASE(precedingContent); diff --git a/mozilla/layout/html/base/src/nsHTMLContent.cpp b/mozilla/layout/html/base/src/nsHTMLContent.cpp index e2b26a050f4..d477b32c931 100644 --- a/mozilla/layout/html/base/src/nsHTMLContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContent.cpp @@ -210,11 +210,13 @@ nsHTMLContent::IsSynthetic(PRBool& aResult) return NS_OK; } -void nsHTMLContent::Compact() +NS_IMETHODIMP +nsHTMLContent::Compact() { + return NS_OK; } -nsresult +NS_IMETHODIMP nsHTMLContent::GetDocument(nsIDocument*& aResult) const { aResult = mDocument; @@ -222,40 +224,54 @@ nsHTMLContent::GetDocument(nsIDocument*& aResult) const return NS_OK; } -void nsHTMLContent::SetDocument(nsIDocument* aDocument) +NS_IMETHODIMP +nsHTMLContent::SetDocument(nsIDocument* aDocument) { mDocument = aDocument; + return NS_OK; } -nsIContent* nsHTMLContent::GetParent() const +NS_IMETHODIMP +nsHTMLContent::GetParent(nsIContent*& aResult) const { NS_IF_ADDREF(mParent); - return mParent; + aResult = mParent; + return NS_OK; } -void nsHTMLContent::SetParent(nsIContent* aParent) +NS_IMETHODIMP +nsHTMLContent::SetParent(nsIContent* aParent) { mParent = aParent; + return NS_OK; } -PRBool nsHTMLContent::CanContainChildren() const +NS_IMETHODIMP +nsHTMLContent::CanContainChildren(PRBool& aResult) const { - return PR_FALSE; + aResult = PR_FALSE; + return NS_OK; } -PRInt32 nsHTMLContent::ChildCount() const +NS_IMETHODIMP +nsHTMLContent::ChildCount(PRInt32& aCount) const { - return 0; + aCount = 0; + return NS_OK; } -nsIContent* nsHTMLContent::ChildAt(PRInt32 aIndex) const +NS_IMETHODIMP +nsHTMLContent::ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { - return nsnull; + aResult = nsnull; + return NS_OK; } -PRInt32 nsHTMLContent::IndexOf(nsIContent* aPossibleChild) const +NS_IMETHODIMP +nsHTMLContent::IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { - return -1; + aResult = -1; + return NS_OK; } NS_IMETHODIMP @@ -282,79 +298,110 @@ nsHTMLContent::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) return NS_OK; } -void nsHTMLContent::SetAttribute(const nsString& aName, const nsString& aValue) +NS_IMETHODIMP +nsHTMLContent::SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify) { + return NS_OK; } -nsContentAttr nsHTMLContent::GetAttribute(const nsString& aName, - nsString& aResult) const +NS_IMETHODIMP +nsHTMLContent::GetAttribute(const nsString& aName, + nsString& aResult) const { aResult.SetLength(0); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -void nsHTMLContent::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsHTMLContent::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { + return NS_OK; } -nsContentAttr nsHTMLContent::GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const +NS_IMETHODIMP +nsHTMLContent::GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const { aResult.SetLength(0); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -void nsHTMLContent::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue) +NS_IMETHODIMP +nsHTMLContent::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue, + PRBool aNotify) { + return NS_OK; } -void nsHTMLContent::UnsetAttribute(nsIAtom* aAttribute) +NS_IMETHODIMP +nsHTMLContent::UnsetAttribute(nsIAtom* aAttribute) { + return NS_OK; } -nsContentAttr nsHTMLContent::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const +NS_IMETHODIMP +nsHTMLContent::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const { aValue.Reset(); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -PRInt32 nsHTMLContent::GetAllAttributeNames(nsISupportsArray* aArray) const +NS_IMETHODIMP +nsHTMLContent::GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const { - return 0; + aCount = 0; + return NS_OK; } -PRInt32 nsHTMLContent::GetAttributeCount(void) const +NS_IMETHODIMP +nsHTMLContent::GetAttributeCount(PRInt32& aCount) const { - return 0; + aCount = 0; + return NS_OK; } -void nsHTMLContent::SetID(nsIAtom* aID) +NS_IMETHODIMP +nsHTMLContent::SetID(nsIAtom* aID) { + return NS_OK; } -nsIAtom* nsHTMLContent::GetID(void) const +NS_IMETHODIMP +nsHTMLContent::GetID(nsIAtom*& aResult) const { - return nsnull; + aResult = nsnull; + return NS_OK; } -void nsHTMLContent::SetClass(nsIAtom* aClass) +NS_IMETHODIMP +nsHTMLContent::SetClass(nsIAtom* aClass) { + return NS_OK; } -nsIAtom* nsHTMLContent::GetClass(void) const +NS_IMETHODIMP +nsHTMLContent::GetClass(nsIAtom*& aResult) const { - return nsnull; + aResult = nsnull; + return NS_OK; } -nsIStyleRule* nsHTMLContent::GetStyleRule(void) +NS_IMETHODIMP +nsHTMLContent::GetStyleRule(nsIStyleRule*& aResult) { - return nsnull; + aResult = nsnull; + return NS_OK; } -void nsHTMLContent::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsHTMLContent::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { + return NS_OK; } @@ -362,9 +409,8 @@ void nsHTMLContent::ListAttributes(FILE* out) const { nsISupportsArray* attrs; if (NS_OK == NS_NewISupportsArray(&attrs)) { - GetAllAttributeNames(attrs); - PRInt32 count = attrs->Count(); - PRInt32 index; + PRInt32 index, count; + GetAllAttributeNames(attrs, count); for (index = 0; index < count; index++) { // name nsIAtom* attr = (nsIAtom*)attrs->ElementAt(index); @@ -385,14 +431,16 @@ void nsHTMLContent::ListAttributes(FILE* out) const } } -void nsHTMLContent::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +nsHTMLContent::List(FILE* out, PRInt32 aIndent) const { NS_PRECONDITION(nsnull != mDocument, "bad content"); PRInt32 index; for (index = aIndent; --index >= 0; ) fputs(" ", out); - nsIAtom* tag = GetTag(); + nsIAtom* tag; + GetTag(tag); if (tag != nsnull) { nsAutoString buf; tag->ToString(buf); @@ -404,10 +452,14 @@ void nsHTMLContent::List(FILE* out, PRInt32 aIndent) const fprintf(out, " RefCount=%d<\n", mRefCnt); - if (CanContainChildren()) { - PRInt32 kids = ChildCount(); + PRBool canHaveKids; + CanContainChildren(canHaveKids); + if (canHaveKids) { + PRInt32 kids; + ChildCount(kids); for (index = 0; index < kids; index++) { - nsIContent* kid = ChildAt(index); + nsIContent* kid; + ChildAt(index, kid); kid->List(out, aIndent + 1); NS_RELEASE(kid); } @@ -415,6 +467,7 @@ void nsHTMLContent::List(FILE* out, PRInt32 aIndent) const for (index = aIndent; --index >= 0; ) fputs(" ", out); fputs(">\n", out); + return NS_OK; } NS_IMETHODIMP @@ -431,16 +484,20 @@ nsHTMLContent::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const // XXX mScriptObject } -nsIAtom* nsHTMLContent::GetTag() const +NS_IMETHODIMP +nsHTMLContent::GetTag(nsIAtom*& aResult) const { - return nsnull; + aResult = nsnull; + return NS_OK; } -void nsHTMLContent::ToHTML(FILE* out) const +NS_IMETHODIMP +nsHTMLContent::ToHTML(FILE* out) const { nsAutoString tmp; ToHTMLString(tmp); fputs(tmp, out); + return NS_OK; } nsIContentDelegate* nsHTMLContent::GetDelegate(nsIPresContext* aCX) @@ -449,25 +506,6 @@ nsIContentDelegate* nsHTMLContent::GetDelegate(nsIPresContext* aCX) return gContentDelegate; } -void nsHTMLContent::NewGlobalAtom(const char* aString, nsIAtom** aAtomResult) -{ - if (nsnull == *aAtomResult) { - *aAtomResult = NS_NewAtom(aString); - } else { - NS_ADDREF(*aAtomResult); - } -} - -void nsHTMLContent::ReleaseGlobalAtom(nsIAtom** aAtomResult) -{ - nsIAtom* atom = *aAtomResult; - if (nsnull != atom) { - if (0 == atom->Release()) { - *aAtomResult = nsnull; - } - } -} - nsresult nsHTMLContent::ResetScriptObject() { mScriptObject = nsnull; @@ -524,9 +562,11 @@ NS_IMETHODIMP nsHTMLContent::GetPreviousSibling(nsIDOMNode** aNode) { if (nsnull != mParent) { - PRInt32 pos = mParent->IndexOf(this); + PRInt32 pos; + mParent->IndexOf(this, pos); if (pos > -1) { - nsIContent* prev = mParent->ChildAt(--pos); + nsIContent* prev; + mParent->ChildAt(--pos, prev); if (nsnull != prev) { nsresult res = prev->QueryInterface(kIDOMNodeIID, (void**)aNode); NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); @@ -546,9 +586,11 @@ NS_IMETHODIMP nsHTMLContent::GetNextSibling(nsIDOMNode** aNextSibling) { if (nsnull != mParent) { - PRInt32 pos = mParent->IndexOf(this); + PRInt32 pos; + mParent->IndexOf(this, pos); if (pos > -1 ) { - nsIContent* prev = mParent->ChildAt(++pos); + nsIContent* prev; + mParent->ChildAt(++pos, prev); if (nsnull != prev) { nsresult res = prev->QueryInterface(kIDOMNodeIID, (void**)aNextSibling); NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); diff --git a/mozilla/layout/html/base/src/nsHTMLContent.h b/mozilla/layout/html/base/src/nsHTMLContent.h index 3d33d5e62b1..5f37b6e3e60 100644 --- a/mozilla/layout/html/base/src/nsHTMLContent.h +++ b/mozilla/layout/html/base/src/nsHTMLContent.h @@ -33,7 +33,11 @@ class nsXIFConverter; * allocation from the malloc heap as well as from an arena. Note * that instances of this object are created with zero'd memory. */ -class nsHTMLContent : public nsIHTMLContent, public nsIDOMNode, public nsIScriptObjectOwner, public nsIDOMEventReceiver { +class nsHTMLContent : public nsIHTMLContent, + public nsIDOMNode, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver +{ public: /** * This new method allocates memory from the standard malloc heap @@ -58,71 +62,89 @@ public: NS_IMETHOD_(nsrefcnt) Release(); NS_IMETHOD GetDocument(nsIDocument*& aResult) const; - virtual void SetDocument(nsIDocument* aDocument); + NS_IMETHOD SetDocument(nsIDocument* aDocument); - virtual nsIContent* GetParent() const; - virtual void SetParent(nsIContent* aParent); + NS_IMETHOD GetParent(nsIContent*& aResult) const; + NS_IMETHOD SetParent(nsIContent* aParent); - virtual PRBool CanContainChildren() const; - virtual PRInt32 ChildCount() const; - virtual nsIContent* ChildAt(PRInt32 aIndex) const; - virtual PRInt32 IndexOf(nsIContent* aPossibleChild) 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& aIndex) const; + + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, + PRBool aNotify); + + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, + PRBool aNotify); - 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 IsSynthetic(PRBool& aResult); - virtual void Compact(); + NS_IMETHOD Compact(); - virtual void SetAttribute(const nsString& aName, const nsString& aValue); - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const; + NS_IMETHOD SetAttribute(const nsString& aName, + const nsString& aValue, + PRBool aNotify); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const; - virtual void SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue = nsHTMLValue::kNull); - virtual void UnsetAttribute(nsIAtom* aAttribute); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const; - virtual PRInt32 GetAttributeCount(void) const; + NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const; - virtual void SetID(nsIAtom* aID); - virtual nsIAtom* GetID(void) const; - virtual void SetClass(nsIAtom* aClass); // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const; // XXX this will have to change for CSS2 + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual nsIStyleRule* GetStyleRule(void); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute); - virtual void List(FILE* out, PRInt32 aIndent) const; + NS_IMETHOD GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const; + + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCountResult) const; + NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const; + + NS_IMETHOD SetID(nsIAtom* aID); + NS_IMETHOD GetID(nsIAtom*& aResult) const; + // XXX this will have to change for CSS2 + NS_IMETHOD SetClass(nsIAtom* aClass); + // XXX this will have to change for CSS2 + NS_IMETHOD GetClass(nsIAtom*& aResult) const; + + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult); + + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const = 0; + + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) = 0; + + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - virtual nsIAtom* GetTag() const; + NS_IMETHOD GetTag(nsIAtom*& aResult) const; - virtual void ToHTML(FILE* out) const; + NS_IMETHOD ToHTML(FILE* out) const; virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX); - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const = 0; - - static void NewGlobalAtom(const char* aString, nsIAtom** aAtomResult); - - static void ReleaseGlobalAtom(nsIAtom** aAtomResult); - static void QuoteForHTML(const nsString& aValue, nsString& aResult); -public: NS_IMETHOD ResetScriptObject(); // nsIDOMNode interface diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp index f40c91e91b7..c3a3223ce11 100644 --- a/mozilla/layout/html/base/src/nsHTMLImage.cpp +++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp @@ -64,14 +64,18 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; NS_FORWARD_IDOMNODE(nsHTMLImageSuper::) NS_FORWARD_IDOMELEMENT(nsHTMLImageSuper::) @@ -85,9 +89,6 @@ protected: virtual ~nsHTMLImage(); void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const; - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; void TriggerReflow(); }; @@ -432,9 +433,9 @@ ImageFrame::GetDesiredSize(nsIPresContext* aPresContext, // Setup url before starting the image load nsAutoString src, base; - if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", src)) { mImageLoader.SetURL(src); - if (eContentAttr_HasValue == + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(NS_HTML_BASE_HREF, base)) { mImageLoader.SetBaseHREF(base); } @@ -606,7 +607,7 @@ ImageFrame::Paint(nsIPresContext& aPresContext, // No image yet. Draw the icon that indicates we're loading, and display // the alt-text nsAutoString altText; - if (eContentAttr_HasValue == mContent->GetAttribute("ALT", altText)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ALT", altText)) { // Display a recessed one-pixel border in the inner area nsRect inner; GetInnerArea(&aPresContext, inner); @@ -711,14 +712,14 @@ PRBool ImageFrame::IsServerImageMap() { nsAutoString ismap; - return eContentAttr_HasValue == mContent->GetAttribute("ismap", ismap); + return NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ismap", ismap); } PRIntn ImageFrame::GetSuppress() { nsAutoString s; - if (eContentAttr_HasValue == mContent->GetAttribute("ismap", s)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ismap", s)) { if (s.EqualsIgnoreCase("true")) { return SUPPRESS; } else if (s.EqualsIgnoreCase("false")) { @@ -860,7 +861,7 @@ ImageFrame::ContentChanged(nsIPresShell* aShell, // Get src attribute's value and construct a new absolute url from it nsAutoString newSRC; - if (eContentAttr_HasValue == mContent->GetAttribute("SRC", newSRC)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", newSRC)) { if (!oldSRC.Equals(newSRC)) { mSizeFrozen = PR_TRUE; @@ -961,46 +962,49 @@ nsHTMLImage::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const { } -void -nsHTMLImage::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +nsHTMLImage::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { nsHTMLValue val; if (aAttribute == nsHTMLAtoms::ismap) { val.SetEmptyValue(); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::usemap) { nsAutoString usemap(aString); usemap.StripWhitespace(); val.SetStringValue(usemap); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::align) { if (ParseAlignParam(aString, val)) { // Reflect the attribute into the syle system - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else { val.SetStringValue(aString); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (aAttribute == nsHTMLAtoms::src) { nsAutoString src(aString); src.StripWhitespace(); val.SetStringValue(src); - nsHTMLTagContent::SetAttribute(aAttribute, val); + nsresult rv = nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); + // XXX use aNotify!!! TriggerReflow(); + return rv; } else if (aAttribute == nsHTMLAtoms::lowsrc) { nsAutoString lowsrc(aString); lowsrc.StripWhitespace(); val.SetStringValue(lowsrc); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::alt) { val.SetStringValue(aString); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::suppress) { PRIntn suppress = DEFAULT_SUPPRESS; @@ -1011,27 +1015,26 @@ nsHTMLImage::SetAttribute(nsIAtom* aAttribute, const nsString& aString) suppress = DONT_SUPPRESS; } val.SetIntValue(suppress, eHTMLUnit_Enumerated); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (ParseImageProperty(aAttribute, aString, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - } - else { - // Use default attribute catching code - nsHTMLImageSuper::SetAttribute(aAttribute, aString); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } + + // Use default attribute catching code + return nsHTMLImageSuper::SetAttribute(aAttribute, aString, aNotify); } -nsContentAttr +NS_IMETHODIMP nsHTMLImage::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { - nsContentAttr ca = eContentAttr_NotThere; + nsresult ca = NS_CONTENT_ATTR_NOT_THERE; if (aAttribute == nsHTMLAtoms::align) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { AlignParamToString(aValue, aResult); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } } else if (aAttribute == nsHTMLAtoms::suppress) { @@ -1041,15 +1044,15 @@ nsHTMLImage::AttributeToString(nsIAtom* aAttribute, case DONT_SUPPRESS: aResult.Append("false"); break; case DEFAULT_SUPPRESS: break; } - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } else if (ImagePropertyToString(aAttribute, aValue, aResult)) { - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } return ca; } -void +NS_IMETHODIMP nsHTMLImage::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -1085,6 +1088,7 @@ nsHTMLImage::MapAttributesInto(nsIStyleContext* aContext, } MapImagePropertiesInto(aContext, aPresContext); MapImageBorderInto(aContext, aPresContext, nsnull); + return NS_OK; } void @@ -1122,7 +1126,7 @@ nsHTMLImage::GetLowSrc(nsString& aLowSrc) NS_IMETHODIMP nsHTMLImage::SetLowSrc(const nsString& aLowSrc) { - SetAttribute(nsHTMLAtoms::lowsrc, aLowSrc); + SetAttribute(nsHTMLAtoms::lowsrc, aLowSrc, PR_TRUE); return NS_OK; } @@ -1138,7 +1142,7 @@ nsHTMLImage::GetName(nsString& aName) NS_IMETHODIMP nsHTMLImage::SetName(const nsString& aName) { - SetAttribute(nsHTMLAtoms::name, aName); + SetAttribute(nsHTMLAtoms::name, aName, PR_TRUE); return NS_OK; } @@ -1154,7 +1158,7 @@ nsHTMLImage::GetAlign(nsString& aAlign) NS_IMETHODIMP nsHTMLImage::SetAlign(const nsString& aAlign) { - SetAttribute(nsHTMLAtoms::align, aAlign); + SetAttribute(nsHTMLAtoms::align, aAlign, PR_TRUE); return NS_OK; } @@ -1170,7 +1174,7 @@ nsHTMLImage::GetAlt(nsString& aAlt) NS_IMETHODIMP nsHTMLImage::SetAlt(const nsString& aAlt) { - SetAttribute(nsHTMLAtoms::alt, aAlt); + SetAttribute(nsHTMLAtoms::alt, aAlt, PR_TRUE); return NS_OK; } @@ -1186,7 +1190,7 @@ nsHTMLImage::GetBorder(nsString& aBorder) NS_IMETHODIMP nsHTMLImage::SetBorder(const nsString& aBorder) { - SetAttribute(nsHTMLAtoms::border, aBorder); + SetAttribute(nsHTMLAtoms::border, aBorder, PR_TRUE); return NS_OK; } @@ -1202,7 +1206,7 @@ nsHTMLImage::GetHeight(nsString& aHeight) NS_IMETHODIMP nsHTMLImage::SetHeight(const nsString& aHeight) { - SetAttribute(nsHTMLAtoms::height, aHeight); + SetAttribute(nsHTMLAtoms::height, aHeight, PR_TRUE); return NS_OK; } @@ -1218,7 +1222,7 @@ nsHTMLImage::GetHspace(nsString& aHspace) NS_IMETHODIMP nsHTMLImage::SetHspace(const nsString& aHspace) { - SetAttribute(nsHTMLAtoms::hspace, aHspace); + SetAttribute(nsHTMLAtoms::hspace, aHspace, PR_TRUE); return NS_OK; } @@ -1228,7 +1232,7 @@ nsHTMLImage::GetIsMap(PRBool* aIsMap) { nsAutoString result; - *aIsMap = (PRBool)(eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::ismap, result)); + *aIsMap = (PRBool)(NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::ismap, result)); return NS_OK; } @@ -1237,7 +1241,7 @@ NS_IMETHODIMP nsHTMLImage::SetIsMap(PRBool aIsMap) { if (PR_TRUE == aIsMap) { - SetAttribute(nsHTMLAtoms::ismap, ""); + SetAttribute(nsHTMLAtoms::ismap, "", PR_TRUE); } else { UnsetAttribute(nsHTMLAtoms::ismap); @@ -1257,7 +1261,7 @@ nsHTMLImage::GetLongDesc(nsString& aLongDesc) NS_IMETHODIMP nsHTMLImage::SetLongDesc(const nsString& aLongDesc) { - SetAttribute(nsHTMLAtoms::longdesc, aLongDesc); + SetAttribute(nsHTMLAtoms::longdesc, aLongDesc, PR_TRUE); return NS_OK; } @@ -1273,7 +1277,7 @@ nsHTMLImage::GetSrc(nsString& aSrc) NS_IMETHODIMP nsHTMLImage::SetSrc(const nsString& aSrc) { - SetAttribute(nsHTMLAtoms::src, aSrc); + SetAttribute(nsHTMLAtoms::src, aSrc, PR_TRUE); return NS_OK; } @@ -1289,7 +1293,7 @@ nsHTMLImage::GetUseMap(nsString& aUseMap) NS_IMETHODIMP nsHTMLImage::SetUseMap(const nsString& aUseMap) { - SetAttribute(nsHTMLAtoms::usemap, aUseMap); + SetAttribute(nsHTMLAtoms::usemap, aUseMap, PR_TRUE); return NS_OK; } @@ -1305,7 +1309,7 @@ nsHTMLImage::GetVspace(nsString& aVspace) NS_IMETHODIMP nsHTMLImage::SetVspace(const nsString& aVspace) { - SetAttribute(nsHTMLAtoms::vspace, aVspace); + SetAttribute(nsHTMLAtoms::vspace, aVspace, PR_TRUE); return NS_OK; } @@ -1321,7 +1325,7 @@ nsHTMLImage::GetWidth(nsString& aWidth) NS_IMETHODIMP nsHTMLImage::SetWidth(const nsString& aWidth) { - SetAttribute(nsHTMLAtoms::width, aWidth); + SetAttribute(nsHTMLAtoms::width, aWidth, PR_TRUE); return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp index afe8cf7f56c..f4df5824944 100644 --- a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp @@ -66,7 +66,8 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); EndConvertToXIF */ -void nsHTMLTagContent::BeginConvertToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +nsHTMLTagContent::BeginConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) { @@ -74,8 +75,9 @@ void nsHTMLTagContent::BeginConvertToXIF(nsXIFConverter& aConverter) const mTag->ToString(name); - PRBool isLeaf = CanContainChildren() == PR_FALSE; - if (isLeaf) + PRBool isContainer; + CanContainChildren(isContainer); + if (!isContainer) aConverter.BeginLeaf(name); else aConverter.BeginContainer(name); @@ -88,8 +90,8 @@ void nsHTMLTagContent::BeginConvertToXIF(nsXIFConverter& aConverter) const nsresult rv = NS_NewISupportsArray(&attrs); if (NS_OK == rv) { - mAttributes->GetAllAttributeNames(attrs); - PRInt32 i, n = attrs->Count(); + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); nsAutoString name, value; for (i = 0; i < n; i++) { @@ -104,23 +106,27 @@ void nsHTMLTagContent::BeginConvertToXIF(nsXIFConverter& aConverter) const NS_RELEASE(attrs); } } + return NS_OK; } -void nsHTMLTagContent::FinishConvertToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +nsHTMLTagContent::FinishConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) { - PRBool isLeaf = CanContainChildren() == PR_FALSE; + PRBool isContainer; + CanContainChildren(isContainer); nsAutoString name; mTag->ToString(name); - if (isLeaf) + if (!isContainer) aConverter.EndLeaf(name); else aConverter.EndContainer(name); } + return NS_OK; } /** @@ -128,9 +134,11 @@ void nsHTMLTagContent::FinishConvertToXIF(nsXIFConverter& aConverter) const * XIF is an intermediate form of the content model, the buffer * will then be parsed into any number of formats including HTML, TXT, etc. */ -void nsHTMLTagContent::ConvertContentToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +nsHTMLTagContent::ConvertContentToXIF(nsXIFConverter& aConverter) const { // Do nothing, all conversion is handled in the StartConvertToXIF and FinishConvertToXIF + return NS_OK; } @@ -185,10 +193,11 @@ nsrefcnt nsHTMLTagContent::Release(void) return nsHTMLContent::Release(); } -nsIAtom* nsHTMLTagContent::GetTag() const +NS_IMETHODIMP nsHTMLTagContent::GetTag(nsIAtom*& aResult) const { NS_IF_ADDREF(mTag); - return mTag; + aResult = mTag; + return NS_OK; } NS_IMETHODIMP @@ -210,12 +219,14 @@ nsHTMLTagContent::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const } } -void nsHTMLTagContent::ToHTMLString(nsString& aBuf) const +NS_IMETHODIMP +nsHTMLTagContent::ToHTMLString(nsString& aBuf) const { aBuf.Truncate(0); aBuf.Append('<'); - nsIAtom* tag = GetTag(); + nsIAtom* tag; + GetTag(tag); if (nsnull != tag) { nsAutoString tmp; tag->ToString(tmp); @@ -228,8 +239,8 @@ void nsHTMLTagContent::ToHTMLString(nsString& aBuf) const nsISupportsArray* attrs; nsresult rv = NS_NewISupportsArray(&attrs); if (NS_OK == rv) { - mAttributes->GetAllAttributeNames(attrs); - PRInt32 i, n = attrs->Count(); + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); nsAutoString name, value, quotedValue; for (i = 0; i < n; i++) { nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i); @@ -249,73 +260,83 @@ void nsHTMLTagContent::ToHTMLString(nsString& aBuf) const } aBuf.Append('>'); + return NS_OK; } -void nsHTMLTagContent::SetDocument(nsIDocument* aDocument) +NS_IMETHODIMP +nsHTMLTagContent::SetDocument(nsIDocument* aDocument) { - nsHTMLContent::SetDocument(aDocument); + nsresult rv = nsHTMLContent::SetDocument(aDocument); + if (NS_OK != rv) { + return rv; + } // Once the element is added to the doc tree we need to check if event handler // were registered on it. Unfortunately, this means doing a GetAttribute for // every type of handler. if (nsnull != mAttributes) { nsHTMLValue mValue; - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onclick, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onclick, mValue)) AddScriptEventListener(nsHTMLAtoms::onclick, mValue, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::ondblclick, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::ondblclick, mValue)) AddScriptEventListener(nsHTMLAtoms::onclick, mValue, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmousedown, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmousedown, mValue)) AddScriptEventListener(nsHTMLAtoms::onmousedown, mValue, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmouseup, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseup, mValue)) AddScriptEventListener(nsHTMLAtoms::onmouseup, mValue, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmouseover, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseover, mValue)) AddScriptEventListener(nsHTMLAtoms::onmouseover, mValue, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmouseout, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseout, mValue)) AddScriptEventListener(nsHTMLAtoms::onmouseout, mValue, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onkeydown, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeydown, mValue)) AddScriptEventListener(nsHTMLAtoms::onkeydown, mValue, kIDOMKeyListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onkeyup, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeyup, mValue)) AddScriptEventListener(nsHTMLAtoms::onkeyup, mValue, kIDOMKeyListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onkeypress, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeypress, mValue)) AddScriptEventListener(nsHTMLAtoms::onkeypress, mValue, kIDOMKeyListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmousemove, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmousemove, mValue)) AddScriptEventListener(nsHTMLAtoms::onmousemove, mValue, kIDOMMouseMotionListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onload, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onload, mValue)) AddScriptEventListener(nsHTMLAtoms::onload, mValue, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onunload, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onunload, mValue)) AddScriptEventListener(nsHTMLAtoms::onunload, mValue, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onabort, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onabort, mValue)) AddScriptEventListener(nsHTMLAtoms::onabort, mValue, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onerror, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onerror, mValue)) AddScriptEventListener(nsHTMLAtoms::onerror, mValue, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onfocus, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onfocus, mValue)) AddScriptEventListener(nsHTMLAtoms::onfocus, mValue, kIDOMFocusListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onblur, mValue)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onblur, mValue)) AddScriptEventListener(nsHTMLAtoms::onblur, mValue, kIDOMFocusListenerIID); } + return rv; } -void nsHTMLTagContent::SetAttribute(const nsString& aName, - const nsString& aValue) +NS_IMETHODIMP +nsHTMLTagContent::SetAttribute(const nsString& aName, + const nsString& aValue, + PRBool aNotify) { nsAutoString upper; aName.ToUpperCase(upper); nsIAtom* attr = NS_NewAtom(upper); - SetAttribute(attr, aValue); + nsresult rv = SetAttribute(attr, aValue, aNotify); NS_RELEASE(attr); + return rv; } -nsContentAttr nsHTMLTagContent::GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const +NS_IMETHODIMP +nsHTMLTagContent::GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const { nsHTMLValue value; - nsContentAttr result = GetAttribute(aAttribute, value); + nsresult result = GetAttribute(aAttribute, value); char cbuf[20]; nscolor color; - if (eContentAttr_HasValue == result) { + if (NS_CONTENT_ATTR_HAS_VALUE == result) { // Try subclass conversion routine first - if (eContentAttr_HasValue == AttributeToString(aAttribute, value, aResult)) { + if (NS_CONTENT_ATTR_HAS_VALUE == AttributeToString(aAttribute, value, aResult)) { return result; } @@ -357,7 +378,7 @@ nsContentAttr nsHTMLTagContent::GetAttribute(nsIAtom *aAttribute, default: case eHTMLUnit_Enumerated: NS_NOTREACHED("no default enumerated value to string conversion"); - result = eContentAttr_NotThere; + result = NS_CONTENT_ATTR_NOT_THERE; break; } } @@ -365,21 +386,19 @@ nsContentAttr nsHTMLTagContent::GetAttribute(nsIAtom *aAttribute, return result; } -nsContentAttr nsHTMLTagContent::GetAttribute(const nsString& aName, - nsString& aResult) const +NS_IMETHODIMP +nsHTMLTagContent::GetAttribute(const nsString& aName, + nsString& aResult) const { nsAutoString upper; aName.ToUpperCase(upper); nsIAtom* attr = NS_NewAtom(upper); - nsContentAttr result; - - result = GetAttribute(attr, aResult); - + nsresult result = GetAttribute(attr, aResult); NS_RELEASE(attr); return result; } -nsContentAttr +NS_IMETHODIMP nsHTMLTagContent::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -389,20 +408,20 @@ nsHTMLTagContent::AttributeToString(nsIAtom* aAttribute, nsIStyleRule* rule = (nsIStyleRule*) aValue.GetISupportsValue(); // rule->ToString(str); aResult = "XXX style rule ToString goes here"; - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } aResult.Truncate(); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } // XXX temporary stub until this class is nuked -nsContentAttr +NS_IMETHODIMP nsHTMLTagContent::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } nsresult @@ -454,14 +473,19 @@ nsHTMLTagContent::AddScriptEventListener(nsIAtom* aAttribute, nsHTMLValue& aValu // Note: Subclasses should override to parse the value string; in // addition, when they see an unknown attribute they should call this // so that global attributes are handled (like CLASS, ID, STYLE, etc.) -void +NS_IMETHODIMP nsHTMLTagContent::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) + const nsString& aValue, + PRBool aNotify) { if (nsnull == mAttributes) { NS_NewHTMLAttributes(&mAttributes, this); + if (nsnull == mAttributes) { + return NS_ERROR_OUT_OF_MEMORY; + } } if (nsnull != mAttributes) { + PRInt32 na; if (nsHTMLAtoms::style == aAttribute) { // XXX the style sheet language is a document property that // should be used to lookup the style sheet parser to parse the @@ -469,134 +493,171 @@ nsHTMLTagContent::SetAttribute(nsIAtom* aAttribute, nsICSSParser* css; nsresult rv = NS_NewCSSParser(&css); if (NS_OK != rv) { - return; + return rv; } nsIStyleRule* rule; rv = css->ParseDeclarations(aValue, nsnull, rule); if ((NS_OK == rv) && (nsnull != rule)) { - mAttributes->SetAttribute(aAttribute, nsHTMLValue(rule)); + mAttributes->SetAttribute(aAttribute, nsHTMLValue(rule), na); NS_RELEASE(rule); } NS_RELEASE(css); } else { - mAttributes->SetAttribute(aAttribute, aValue); + mAttributes->SetAttribute(aAttribute, aValue, na); } } + return NS_OK; } -void nsHTMLTagContent::SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue) +NS_IMETHODIMP +nsHTMLTagContent::SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRBool aNotify) { if (nsnull == mAttributes) { NS_NewHTMLAttributes(&mAttributes, this); + if (nsnull == mAttributes) { + return NS_ERROR_OUT_OF_MEMORY; + } } if (nsnull != mAttributes) { - mAttributes->SetAttribute(aAttribute, aValue); + PRInt32 ix; + mAttributes->SetAttribute(aAttribute, aValue, ix); } + return NS_OK; } -void nsHTMLTagContent::UnsetAttribute(nsIAtom* aAttribute) +NS_IMETHODIMP +nsHTMLTagContent::UnsetAttribute(nsIAtom* aAttribute) { if (nsnull != mAttributes) { - PRInt32 count = mAttributes->UnsetAttribute(aAttribute); + PRInt32 count; + mAttributes->UnsetAttribute(aAttribute, count); if (0 == count) { NS_RELEASE(mAttributes); } } + return NS_OK; } -nsContentAttr nsHTMLTagContent::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const +NS_IMETHODIMP +nsHTMLTagContent::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const { if (nsnull != mAttributes) { return mAttributes->GetAttribute(aAttribute, aValue); } aValue.Reset(); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -PRInt32 nsHTMLTagContent::GetAllAttributeNames(nsISupportsArray* aArray) const +NS_IMETHODIMP +nsHTMLTagContent::GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const { if (nsnull != mAttributes) { - return mAttributes->GetAllAttributeNames(aArray); + return mAttributes->GetAllAttributeNames(aArray, aCount); } - return 0; + aCount = 0; + return NS_OK; } -PRInt32 nsHTMLTagContent::GetAttributeCount(void) const +NS_IMETHODIMP +nsHTMLTagContent::GetAttributeCount(PRInt32& aCount) const { if (nsnull != mAttributes) { - return mAttributes->Count(); + return mAttributes->Count(aCount); } - return 0; + aCount = 0; + return NS_OK; } -void nsHTMLTagContent::SetID(nsIAtom* aID) +NS_IMETHODIMP +nsHTMLTagContent::SetID(nsIAtom* aID) { if (nsnull != aID) { if (nsnull == mAttributes) { NS_NewHTMLAttributes(&mAttributes, this); + if (nsnull == mAttributes) { + return NS_ERROR_OUT_OF_MEMORY; + } } if (nsnull != mAttributes) { - mAttributes->SetID(aID); + PRInt32 na; + mAttributes->SetID(aID, na); } } else { if (nsnull != mAttributes) { - PRInt32 count = mAttributes->SetID(nsnull); + PRInt32 count; + mAttributes->SetID(nsnull, count); if (0 == count) { NS_RELEASE(mAttributes); } } } + return NS_OK; } -nsIAtom* nsHTMLTagContent::GetID(void) const +NS_IMETHODIMP +nsHTMLTagContent::GetID(nsIAtom*& aResult) const { if (nsnull != mAttributes) { - return mAttributes->GetID(); + return mAttributes->GetID(aResult); } - return nsnull; + aResult = nsnull; + return NS_OK; } -void nsHTMLTagContent::SetClass(nsIAtom* aClass) +NS_IMETHODIMP +nsHTMLTagContent::SetClass(nsIAtom* aClass) { if (nsnull != aClass) { if (nsnull == mAttributes) { NS_NewHTMLAttributes(&mAttributes, this); + if (nsnull == mAttributes) { + return NS_ERROR_OUT_OF_MEMORY; + } } if (nsnull != mAttributes) { - mAttributes->SetClass(aClass); + PRInt32 na; + mAttributes->SetClass(aClass, na); } } else { if (nsnull != mAttributes) { - PRInt32 count = mAttributes->SetClass(nsnull); + PRInt32 count; + mAttributes->SetClass(nsnull, count); if (0 == count) { NS_RELEASE(mAttributes); } } } + return NS_OK; } -nsIAtom* nsHTMLTagContent::GetClass(void) const +NS_IMETHODIMP +nsHTMLTagContent::GetClass(nsIAtom*& aResult) const { if (nsnull != mAttributes) { - return mAttributes->GetClass(); + return mAttributes->GetClass(aResult); } - return nsnull; + aResult = nsnull; + return NS_OK; } -nsIStyleRule* nsHTMLTagContent::GetStyleRule(void) +NS_IMETHODIMP +nsHTMLTagContent::GetStyleRule(nsIStyleRule*& aResult) { nsIStyleRule* result = nsnull; if (nsnull != mAttributes) { mAttributes->QueryInterface(kIStyleRuleIID, (void**)&result); } - return result; + aResult = result; + return NS_OK; } // @@ -890,7 +951,7 @@ nsHTMLTagContent::GetDOMAttribute(const nsString& aName, nsString& aReturn) NS_IMETHODIMP nsHTMLTagContent::SetDOMAttribute(const nsString& aName, const nsString& aValue) { - SetAttribute(aName, aValue); + SetAttribute(aName, aValue, PR_TRUE); return NS_OK; } @@ -908,7 +969,7 @@ NS_IMETHODIMP nsHTMLTagContent::GetAttributeNode(const nsString& aName, nsIDOMAttribute** aReturn) { nsAutoString value; - if(eContentAttr_NotThere != GetAttribute(aName, value)) { + if(NS_CONTENT_ATTR_NOT_THERE != GetAttribute(aName, value)) { *aReturn = new nsDOMAttribute(aName, value); } @@ -929,7 +990,7 @@ nsHTMLTagContent::SetAttributeNode(nsIDOMAttribute* aAttribute) if (NS_OK == res) { res = aAttribute->GetValue(value); if (NS_OK == res) { - SetAttribute(name, value); + SetAttribute(name, value, PR_TRUE); } } } @@ -984,7 +1045,7 @@ nsHTMLTagContent::GetId(nsString& aId) NS_IMETHODIMP nsHTMLTagContent::SetId(const nsString& aId) { - SetAttribute(nsHTMLAtoms::id, aId); + SetAttribute(nsHTMLAtoms::id, aId, PR_TRUE); return NS_OK; } @@ -1000,7 +1061,7 @@ nsHTMLTagContent::GetTitle(nsString& aTitle) NS_IMETHODIMP nsHTMLTagContent::SetTitle(const nsString& aTitle) { - SetAttribute(nsHTMLAtoms::title, aTitle); + SetAttribute(nsHTMLAtoms::title, aTitle, PR_TRUE); return NS_OK; } @@ -1016,7 +1077,7 @@ nsHTMLTagContent::GetLang(nsString& aLang) NS_IMETHODIMP nsHTMLTagContent::SetLang(const nsString& aLang) { - SetAttribute(nsHTMLAtoms::lang, aLang); + SetAttribute(nsHTMLAtoms::lang, aLang, PR_TRUE); return NS_OK; } @@ -1032,7 +1093,7 @@ nsHTMLTagContent::GetDir(nsString& aDir) NS_IMETHODIMP nsHTMLTagContent::SetDir(const nsString& aDir) { - SetAttribute(nsHTMLAtoms::dir, aDir); + SetAttribute(nsHTMLAtoms::dir, aDir, PR_TRUE); return NS_OK; } @@ -1048,7 +1109,7 @@ nsHTMLTagContent::GetClassName(nsString& aClassName) NS_IMETHODIMP nsHTMLTagContent::SetClassName(const nsString& aClassName) { - SetAttribute(nsHTMLAtoms::kClass, aClassName); + SetAttribute(nsHTMLAtoms::kClass, aClassName, PR_TRUE); return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.h b/mozilla/layout/html/base/src/nsHTMLTagContent.h index c521475006e..a85260861d7 100644 --- a/mozilla/layout/html/base/src/nsHTMLTagContent.h +++ b/mozilla/layout/html/base/src/nsHTMLTagContent.h @@ -35,14 +35,15 @@ class nsHTMLTagContent : public nsHTMLContent, public nsIDOMHTMLElement, public public: // nsIContent - virtual nsIAtom* GetTag() const; + NS_IMETHOD GetTag(nsIAtom*& aResult) const; + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; // nsIHTMLContent /** * Translate the content object into it's source html format */ - virtual void ToHTMLString(nsString& out) const; + NS_IMETHOD ToHTMLString(nsString& aResult) const; /** * Translate the content object into the (XIF) XML Interchange Format @@ -52,19 +53,19 @@ public: * BeginConvertToXIF -- opens a container and writes out the attributes * ConvertContentToXIF -- typically does nothing unless there is text content * FinishConvertToXIF -- closes a container - - - */ - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const; - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const; - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const; + */ + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const; /** * Generic implementation of SetAttribute that translates aName into * an uppercase'd atom and invokes SetAttribute(atom, aValue). */ - virtual void SetAttribute(const nsString& aName, const nsString& aValue); + NS_IMETHOD SetAttribute(const nsString& aName, + const nsString& aValue, + PRBool aNotify); /** * Generic implementation of GetAttribute that knows how to map @@ -76,40 +77,40 @@ public: * method if the default string conversions used don't apply * correctly to the given attribute. */ - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const; + NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const; + NS_IMETHOD GetAttribute(nsIAtom *aAttribute, nsString &aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const; - virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRBool aNotify); + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCountResult) const; + NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const; + NS_IMETHOD SetID(nsIAtom* aID); + NS_IMETHOD GetID(nsIAtom*& aResult) const; + // XXX this will have to change for CSS2 + NS_IMETHOD SetClass(nsIAtom* aClass); + // XXX this will have to change for CSS2 + NS_IMETHOD GetClass(nsIAtom*& aResult) const; - virtual void SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue); - virtual void UnsetAttribute(nsIAtom* aAttribute); + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult); - /** - * Subclasses must override to fill the value object for values that - * are not stored in mAttributes. If the returned value is of an - * enumerated type then the subclass must also override the - * AttributeToString method (see the comment on the other GetAttribute - * method) - */ - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const; + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const; - virtual PRInt32 GetAttributeCount(void) const; - - virtual void SetID(nsIAtom* aID); - virtual nsIAtom* GetID(void) const; - virtual void SetClass(nsIAtom* aClass); // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const; // XXX this will have to change for CSS2 - - virtual nsIStyleRule* GetStyleRule(void); + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult); // Override from nsHTMLContent to allow setting of event handlers once // tag content is added to the doc tree. - virtual void SetDocument(nsIDocument* aDocument); + NS_IMETHOD SetDocument(nsIDocument* aDocument); // nsIScriptObjectOwner interface NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); @@ -233,22 +234,6 @@ public: static PRBool TableCaptionAlignParamToString(const nsHTMLValue& aValue, nsString& aResult); - /** - * Helper method used by GetAttribute to map an attribute - * to a string value. - */ - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; - - /** - * Helper method used by SetAttribute to map a string to an - * attribute value. - */ - virtual nsContentAttr StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult); - protected: nsHTMLTagContent(); nsHTMLTagContent(nsIAtom* aTag); diff --git a/mozilla/layout/html/base/src/nsIHTMLContent.h b/mozilla/layout/html/base/src/nsIHTMLContent.h index 9198c695e20..794569b51cb 100644 --- a/mozilla/layout/html/base/src/nsIHTMLContent.h +++ b/mozilla/layout/html/base/src/nsIHTMLContent.h @@ -40,41 +40,47 @@ public: * If this html content is a container, then compact asks it to minimize * it's storage usage. */ - virtual void Compact() = 0; + NS_IMETHOD Compact() = 0; - virtual void SetAttribute(const nsString& aName, const nsString& aValue) = 0; - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue) = 0; - virtual void SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue=nsHTMLValue::kNull) = 0; + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify) = 0; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) = 0; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRBool aNotify) = 0; - virtual void UnsetAttribute(nsIAtom* aAttribute) = 0; + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) = 0; - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const = 0; - virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const = 0; - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const = 0; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const = 0; - virtual PRInt32 GetAttributeCount(void) const = 0; + NS_IMETHOD GetAttribute(const nsString& aName, + nsString& aResult) const = 0; + NS_IMETHOD GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const = 0; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const = 0; + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCountResult) const = 0; + NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0; - virtual void SetID(nsIAtom* aID) = 0; - virtual nsIAtom* GetID(void) const = 0; - virtual void SetClass(nsIAtom* aClass) = 0; // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const = 0; // XXX this will have to change for CSS2 + NS_IMETHOD SetID(nsIAtom* aID) = 0; + NS_IMETHOD GetID(nsIAtom*& aResult) const = 0; + // XXX this will have to change for CSS2 + NS_IMETHOD SetClass(nsIAtom* aClass) = 0; + // XXX this will have to change for CSS2 + NS_IMETHOD GetClass(nsIAtom*& aResult) const = 0; - virtual nsIStyleRule* GetStyleRule(void) = 0; + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult) = 0; - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) = 0; + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) = 0; - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const = 0; + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const = 0; - virtual nsContentAttr StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) = 0; + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) = 0; /** * Translate this piece of content to html. Note that this only @@ -84,20 +90,18 @@ public: */ // XXX add in output character set information so that we know how // to encode non 7 bit characters - virtual void ToHTMLString(nsString& aResult) const = 0; - - - virtual void ToHTML(FILE* out) const = 0; + NS_IMETHOD ToHTMLString(nsString& aResult) const = 0; + NS_IMETHOD ToHTML(FILE* out) const = 0; /** * Used by the html content's delegate to create a frame * for the content. */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) = 0; + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) = 0; }; #endif /* nsIHTMLContent_h___ */ diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 328508ef143..1bfae2e788c 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -220,7 +220,8 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, // XXX deal with border and padding the usual way...wrap it up! - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { //don't make a view for an applet since we know we can't support them yet... if (atom != nsHTMLAtoms::applet) { @@ -276,10 +277,10 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, //stream in the object source if there is one... - if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", src)) { SetURL(src); - if (eContentAttr_HasValue == mContent->GetAttribute(NS_HTML_BASE_HREF, base)) + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(NS_HTML_BASE_HREF, base)) SetBaseHREF(base); nsIPresShell *shell = aPresContext.GetShell(); @@ -367,7 +368,8 @@ nsObjectFrame::Paint(nsIPresContext& aPresContext, float p2t = aPresContext.GetPixelsToTwips(); nscoord px3 = NSIntPixelsToTwips(3, p2t); nsAutoString tmp; - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { atom->ToString(tmp); NS_RELEASE(atom); diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 3c2a7814c83..6712b0e02c4 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -35,12 +35,13 @@ void nsPageFrame::CreateFirstChild(nsIPresContext* aPresContext) // Create a frame for the body child PRInt32 i, n; - n = mContent->ChildCount(); + mContent->ChildCount(n); for (i = 0; i < n; i++) { - nsIContent* child = mContent->ChildAt(i); + nsIContent* child; + mContent->ChildAt(i, child); if (nsnull != child) { nsIAtom* tag; - tag = child->GetTag(); + child->GetTag(tag); // XXX added frameset check, is it necessary, what is a page frame anyway if ((nsHTMLAtoms::body == tag) || (nsHTMLAtoms::frameset == tag)) { // Create a frame diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index 654e0c71666..2340a74b125 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -106,7 +106,8 @@ nsPlaceholderFrame::InlineReflow(nsCSSLineLayout& aLineLayout, // content children rather than create a table frame and let it map the // children... PRBool select = PR_FALSE; - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); nsAutoString tmp; if (nsnull != atom) { atom->ToString(tmp); @@ -121,7 +122,9 @@ nsPlaceholderFrame::InlineReflow(nsCSSLineLayout& aLineLayout, } // XXX end hack - if (mContent->CanContainChildren() && !select) { + PRBool canHaveKids; + mContent->CanContainChildren(canHaveKids); + if (canHaveKids && !select) { nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this); // Use our style context for the pseudo-frame diff --git a/mozilla/layout/html/base/src/nsRootPart.cpp b/mozilla/layout/html/base/src/nsRootPart.cpp index b263f0d200d..04193cf523a 100644 --- a/mozilla/layout/html/base/src/nsRootPart.cpp +++ b/mozilla/layout/html/base/src/nsRootPart.cpp @@ -255,12 +255,13 @@ void RootContentFrame::CreateFirstChild(nsIPresContext* aPresContext) } else { // Create a frame for the body/frameset child PRInt32 i, n; - n = mContent->ChildCount(); + mContent->ChildCount(n); for (i = 0; i < n; i++) { - nsIContent* child = mContent->ChildAt(i); + nsIContent* child; + mContent->ChildAt(i, child); if (nsnull != child) { nsIAtom* tag; - tag = child->GetTag(); + child->GetTag(tag); if ((nsHTMLAtoms::body == tag) || (nsHTMLAtoms::frameset == tag)) { // Create a frame nsIContentDelegate* cd = child->GetDelegate(aPresContext); @@ -611,10 +612,10 @@ class RootPart : public nsHTMLContainer { public: RootPart(nsIDocument* aDoc); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 442848b1813..d1dfe5b641f 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -288,11 +288,13 @@ NS_IMETHODIMP nsScrollBodyFrame::ListTag(FILE* out) const { fputs("*scrollbodyframe<", out); - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { nsAutoString tmp; atom->ToString(tmp); fputs(tmp, out); + NS_RELEASE(atom); } PRInt32 contentIndex; GetContentIndex(contentIndex); @@ -420,11 +422,13 @@ NS_IMETHODIMP nsScrollInnerFrame::ListTag(FILE* out) const { fputs("*scrollinnerframe<", out); - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { nsAutoString tmp; atom->ToString(tmp); fputs(tmp, out); + NS_RELEASE(atom); } PRInt32 contentIndex; GetContentIndex(contentIndex); @@ -536,11 +540,13 @@ NS_IMETHODIMP nsScrollOuterFrame::ListTag(FILE* out) const { fputs("*scrollouterframe<", out); - nsIAtom* atom = mContent->GetTag(); + nsIAtom* atom; + mContent->GetTag(atom); if (nsnull != atom) { nsAutoString tmp; atom->ToString(tmp); fputs(tmp, out); + NS_RELEASE(atom); } PRInt32 contentIndex; GetContentIndex(contentIndex); diff --git a/mozilla/layout/html/base/src/nsSpacerPart.cpp b/mozilla/layout/html/base/src/nsSpacerPart.cpp index 11fbe57211a..dbddd35f40f 100644 --- a/mozilla/layout/html/base/src/nsSpacerPart.cpp +++ b/mozilla/layout/html/base/src/nsSpacerPart.cpp @@ -55,21 +55,22 @@ class SpacerPart : public nsHTMLTagContent { public: SpacerPart(nsIAtom* aTag); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; PRUint8 GetType(); protected: virtual ~SpacerPart(); - nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; }; //---------------------------------------------------------------------- @@ -114,23 +115,23 @@ SpacerFrame::InlineReflow(nsCSSLineLayout& aLineLayout, nscoord height = 0; SpacerPart* part = (SpacerPart*) mContent;/* XXX decouple */ PRUint8 type = part->GetType(); - nsContentAttr ca; + nsresult ca; if (type != TYPE_IMAGE) { nsHTMLValue val; ca = part->GetAttribute(nsHTMLAtoms::size, val); - if (eContentAttr_HasValue == ca) { + if (NS_CONTENT_ATTR_HAS_VALUE == ca) { width = val.GetPixelValue(); } } else { nsHTMLValue val; ca = part->GetAttribute(nsHTMLAtoms::width, val); - if (eContentAttr_HasValue == ca) { + if (NS_CONTENT_ATTR_HAS_VALUE == ca) { if (eHTMLUnit_Pixel == val.GetUnit()) { width = val.GetPixelValue(); } } ca = part->GetAttribute(nsHTMLAtoms::height, val); - if (eContentAttr_HasValue == ca) { + if (NS_CONTENT_ATTR_HAS_VALUE == ca) { if (eHTMLUnit_Pixel == val.GetUnit()) { height = val.GetPixelValue(); } @@ -207,7 +208,7 @@ SpacerPart::GetType() { PRUint8 type = TYPE_WORD; nsHTMLValue value; - if (eContentAttr_HasValue == + if (NS_CONTENT_ATTR_HAS_VALUE == nsHTMLTagContent::GetAttribute(nsHTMLAtoms::type, value)) { if (eHTMLUnit_Enumerated == value.GetUnit()) { type = value.GetIntValue(); @@ -224,34 +225,33 @@ static nsHTMLTagContent::EnumTable kTypeTable[] = { { 0 } }; -void -SpacerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +SpacerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { nsHTMLValue val; if (aAttribute == nsHTMLAtoms::type) { if (ParseEnumValue(aValue, kTypeTable, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (aAttribute == nsHTMLAtoms::size) { ParseValue(aValue, 0, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::align) { ParseAlignParam(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if ((aAttribute == nsHTMLAtoms::width) || (aAttribute == nsHTMLAtoms::height)) { ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - } - else { - nsHTMLTagContent::SetAttribute(aAttribute, aValue); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } + return nsHTMLTagContent::SetAttribute(aAttribute, aValue, aNotify); } -void +NS_IMETHODIMP SpacerPart::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -285,9 +285,10 @@ SpacerPart::MapAttributesInto(nsIStyleContext* aContext, break; } } + return NS_OK; } -nsContentAttr +NS_IMETHODIMP SpacerPart::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -295,16 +296,16 @@ SpacerPart::AttributeToString(nsIAtom* aAttribute, if (aAttribute == nsHTMLAtoms::align) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { EnumValueToString(aValue, kTypeTable, aResult); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } else if (aAttribute == nsHTMLAtoms::type) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { AlignParamToString(aValue, aResult); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } nsresult diff --git a/mozilla/layout/html/base/src/nsTextContent.cpp b/mozilla/layout/html/base/src/nsTextContent.cpp index 5613dfa1159..daada474549 100644 --- a/mozilla/layout/html/base/src/nsTextContent.cpp +++ b/mozilla/layout/html/base/src/nsTextContent.cpp @@ -247,14 +247,14 @@ public: virtual void GetText(nsStringBuf* aBuf, PRInt32 aOffset, PRInt32 aCount); #endif - virtual void List(FILE* out, PRInt32 aIndent) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; - virtual void ToHTMLString(nsString& aBuf) const; + NS_IMETHOD ToHTMLString(nsString& aBuf) const; - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); // nsIScriptObjectOwner interface NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); @@ -307,20 +307,20 @@ public: * FinishConvertToXIF -- closes a container */ - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const; - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const; - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const; - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const { - return eContentAttr_NotThere; + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { + return NS_CONTENT_ATTR_NOT_THERE; } - virtual nsContentAttr StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) { - return eContentAttr_NotThere; + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { + return NS_CONTENT_ATTR_NOT_THERE; } PRUnichar* mText; @@ -1824,7 +1824,8 @@ nsrefcnt Text::Release(void) return count; } -void Text::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +Text::List(FILE* out, PRInt32 aIndent) const { for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); fputs("Text", out); @@ -1836,12 +1837,15 @@ void Text::List(FILE* out, PRInt32 aIndent) const fputs(tmp, out); fputs("\">\n", out); + return NS_OK; } -void Text::ToHTMLString(nsString& aBuf) const +NS_IMETHODIMP +Text::ToHTMLString(nsString& aBuf) const { aBuf.SetLength(0); aBuf.Append(mText, mLength); + return NS_OK; } void Text::ToCString(nsString& aBuf, PRInt32 aOffset, PRInt32 aLen) const @@ -1864,12 +1868,17 @@ void Text::ToCString(nsString& aBuf, PRInt32 aOffset, PRInt32 aLen) const } } } -void Text::BeginConvertToXIF(nsXIFConverter& aConverter) const + +NS_IMETHODIMP +Text::BeginConvertToXIF(nsXIFConverter& aConverter) const { + return NS_OK; } -void Text::FinishConvertToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +Text::FinishConvertToXIF(nsXIFConverter& aConverter) const { + return NS_OK; } /** @@ -1877,7 +1886,8 @@ void Text::FinishConvertToXIF(nsXIFConverter& aConverter) const * XIF is an intermediate form of the content model, the buffer * will then be parsed into any number of formats including HTML, TXT, etc. */ -void Text::ConvertContentToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +Text::ConvertContentToXIF(nsXIFConverter& aConverter) const { const nsIContent* content = this; @@ -1924,6 +1934,7 @@ void Text::ConvertContentToXIF(nsXIFConverter& aConverter) const buffer.Append(mText, mLength); aConverter.AddContent(buffer); } + return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsWBRPart.cpp b/mozilla/layout/html/base/src/nsWBRPart.cpp index 0e19e67894f..3c6935ebebb 100644 --- a/mozilla/layout/html/base/src/nsWBRPart.cpp +++ b/mozilla/layout/html/base/src/nsWBRPart.cpp @@ -24,10 +24,10 @@ class WBRPart : public nsHTMLTagContent { public: WBRPart(nsIAtom* aTag); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~WBRPart(); diff --git a/mozilla/layout/html/content/src/nsHTMLAnchor.cpp b/mozilla/layout/html/content/src/nsHTMLAnchor.cpp index 1804c827740..ca6eeca93f6 100644 --- a/mozilla/layout/html/content/src/nsHTMLAnchor.cpp +++ b/mozilla/layout/html/content/src/nsHTMLAnchor.cpp @@ -159,8 +159,7 @@ nsHTMLAnchor::GetAccessKey(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetAccessKey(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::accesskey, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::accesskey, aValue, PR_TRUE); } NS_IMETHODIMP @@ -173,8 +172,7 @@ nsHTMLAnchor::GetCharset(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetCharset(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::charset, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::charset, aValue, PR_TRUE); } NS_IMETHODIMP @@ -187,8 +185,7 @@ nsHTMLAnchor::GetCoords(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetCoords(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::coords, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::coords, aValue, PR_TRUE); } NS_IMETHODIMP @@ -201,8 +198,7 @@ nsHTMLAnchor::GetHref(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetHref(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::href, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::href, aValue, PR_TRUE); } NS_IMETHODIMP @@ -215,8 +211,7 @@ nsHTMLAnchor::GetHreflang(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetHreflang(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::hreflang, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::hreflang, aValue, PR_TRUE); } NS_IMETHODIMP @@ -229,8 +224,7 @@ nsHTMLAnchor::GetName(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetName(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::name, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::name, aValue, PR_TRUE); } NS_IMETHODIMP @@ -243,8 +237,7 @@ nsHTMLAnchor::GetRel(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetRel(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::rel, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::rel, aValue, PR_TRUE); } NS_IMETHODIMP @@ -257,8 +250,7 @@ nsHTMLAnchor::GetRev(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetRev(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::rev, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::rev, aValue, PR_TRUE); } NS_IMETHODIMP @@ -271,8 +263,7 @@ nsHTMLAnchor::GetShape(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetShape(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::shape, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::shape, aValue, PR_TRUE); } NS_IMETHODIMP @@ -280,7 +271,7 @@ nsHTMLAnchor::GetTabIndex(PRInt32* aValue) { nsHTMLValue value; *aValue = -1; - if (eContentAttr_HasValue == + if (NS_CONTENT_ATTR_HAS_VALUE == mInner.GetAttribute(nsHTMLAtoms::tabindex, value)) { if (value.GetUnit() == eHTMLUnit_Integer) { *aValue = value.GetIntValue(); @@ -293,8 +284,7 @@ NS_IMETHODIMP nsHTMLAnchor::SetTabIndex(PRInt32 aValue) { nsHTMLValue value(aValue, eHTMLUnit_Integer); - mInner.SetAttribute(nsHTMLAtoms::tabindex, value); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::tabindex, value, PR_TRUE); } NS_IMETHODIMP @@ -307,8 +297,7 @@ nsHTMLAnchor::GetTarget(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetTarget(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::target, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::target, aValue, PR_TRUE); } NS_IMETHODIMP @@ -321,8 +310,7 @@ nsHTMLAnchor::GetType(nsString& aValue) NS_IMETHODIMP nsHTMLAnchor::SetType(const nsString& aValue) { - mInner.SetAttribute(nsHTMLAtoms::type, aValue); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::type, aValue, PR_TRUE); } NS_IMETHODIMP @@ -337,7 +325,7 @@ nsHTMLAnchor::Focus() return NS_OK; } -nsContentAttr +NS_IMETHODIMP nsHTMLAnchor::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) @@ -345,12 +333,12 @@ nsHTMLAnchor::StringToAttribute(nsIAtom* aAttribute, if (aAttribute == nsHTMLAtoms::tabindex) { nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult, eHTMLUnit_Integer); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -nsContentAttr +NS_IMETHODIMP nsHTMLAnchor::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -358,10 +346,11 @@ nsHTMLAnchor::AttributeToString(nsIAtom* aAttribute, return mInner.AttributeToString(aAttribute, aValue, aResult); } -void +NS_IMETHODIMP nsHTMLAnchor::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLComment.cpp b/mozilla/layout/html/content/src/nsHTMLComment.cpp index eb0f854c86f..59001306623 100644 --- a/mozilla/layout/html/content/src/nsHTMLComment.cpp +++ b/mozilla/layout/html/content/src/nsHTMLComment.cpp @@ -26,12 +26,12 @@ class nsHTMLComment : public nsHTMLCommentSuper { public: nsHTMLComment(nsIAtom* aTag, const nsString& aComment); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void List(FILE* out, PRInt32 aIndent) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; protected: virtual ~nsHTMLComment(); @@ -48,7 +48,7 @@ nsHTMLComment::~nsHTMLComment() { } -nsresult +NS_IMETHODIMP nsHTMLComment::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, @@ -64,7 +64,7 @@ nsHTMLComment::CreateFrame(nsIPresContext* aPresContext, return NS_OK; } -void +NS_IMETHODIMP nsHTMLComment::List(FILE* out, PRInt32 aIndent) const { NS_PRECONDITION(nsnull != mDocument, "bad content"); @@ -72,7 +72,8 @@ nsHTMLComment::List(FILE* out, PRInt32 aIndent) const PRInt32 index; for (index = aIndent; --index >= 0; ) fputs(" ", out); - nsIAtom* tag = GetTag(); + nsIAtom* tag; + GetTag(tag); if (tag != nsnull) { nsAutoString buf; tag->ToString(buf); @@ -85,6 +86,7 @@ nsHTMLComment::List(FILE* out, PRInt32 aIndent) const fprintf(out, " RefCount=%d<", mRefCnt); fputs(mComment, out); fputs(">\n", out); + return NS_OK; } nsresult diff --git a/mozilla/layout/html/content/src/nsHTMLGenericContent.cpp b/mozilla/layout/html/content/src/nsHTMLGenericContent.cpp index 749d1795d1f..8b03490e446 100644 --- a/mozilla/layout/html/content/src/nsHTMLGenericContent.cpp +++ b/mozilla/layout/html/content/src/nsHTMLGenericContent.cpp @@ -513,7 +513,7 @@ DOMAttributeMap::SetNamedItem(nsIDOMNode *aNode) attribute->GetValue(value); NS_RELEASE(attribute); - mContent.SetAttribute(name, value); + mContent.SetAttribute(name, value, PR_TRUE); return NS_OK; } @@ -538,7 +538,8 @@ DOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsAutoString name, value; nsISupportsArray *attributes = nsnull; if (NS_OK == NS_NewISupportsArray(&attributes)) { - PRInt32 count = mContent.GetAllAttributeNames(attributes); + PRInt32 count; + mContent.GetAllAttributeNames(attributes, count); if (count > 0) { if ((PRInt32)aIndex < count) { nsISupports *att = attributes->ElementAt(aIndex); @@ -546,7 +547,7 @@ DOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsIAtom *atName = nsnull; if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) { atName->ToString(name); - if (eContentAttr_NotThere != mContent.GetAttribute(name, value)) { + if (NS_CONTENT_ATTR_NOT_THERE != mContent.GetAttribute(name, value)) { *aReturn = (nsIDOMNode *)new DOMAttribute(name, value); res = NS_OK; } @@ -563,8 +564,10 @@ DOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsresult DOMAttributeMap::GetLength(PRUint32 *aLength) { - *aLength = mContent.GetAttributeCount(); - return NS_OK; + PRInt32 n; + nsresult rv = mContent.GetAttributeCount(n); + *aLength = PRUint32(n); + return rv; } //---------------------------------------------------------------------- @@ -662,9 +665,11 @@ nsresult nsHTMLGenericContent::GetPreviousSibling(nsIDOMNode** aNode) { if (nsnull != mParent) { - PRInt32 pos = mParent->IndexOf(mContent); + PRInt32 pos; + mParent->IndexOf(mContent, pos); if (pos > -1) { - nsIContent* prev = mParent->ChildAt(--pos); + nsIContent* prev; + mParent->ChildAt(--pos, prev); if (nsnull != prev) { nsresult res = prev->QueryInterface(kIDOMNodeIID, (void**)aNode); NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); @@ -681,9 +686,11 @@ nsresult nsHTMLGenericContent::GetNextSibling(nsIDOMNode** aNextSibling) { if (nsnull != mParent) { - PRInt32 pos = mParent->IndexOf(mContent); + PRInt32 pos; + mParent->IndexOf(mContent, pos); if (pos > -1 ) { - nsIContent* prev = mParent->ChildAt(++pos); + nsIContent* prev; + mParent->ChildAt(++pos, prev); if (nsnull != prev) { nsresult res = prev->QueryInterface(kIDOMNodeIID,(void**)aNextSibling); NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); @@ -734,7 +741,7 @@ nsresult nsHTMLGenericContent::SetDOMAttribute(const nsString& aName, const nsString& aValue) { - SetAttribute(aName, aValue); + SetAttribute(aName, aValue, PR_TRUE); return NS_OK; } @@ -754,7 +761,7 @@ nsHTMLGenericContent::GetAttributeNode(const nsString& aName, nsIDOMAttribute** aReturn) { nsAutoString value; - if (eContentAttr_NotThere != GetAttribute(aName, value)) { + if (NS_CONTENT_ATTR_NOT_THERE != GetAttribute(aName, value)) { *aReturn = new DOMAttribute(aName, value); } return NS_OK; @@ -773,7 +780,7 @@ nsHTMLGenericContent::SetAttributeNode(nsIDOMAttribute* aAttribute) if (NS_OK == res) { res = aAttribute->GetValue(value); if (NS_OK == res) { - SetAttribute(name, value); + SetAttribute(name, value, PR_TRUE); } } } @@ -824,7 +831,7 @@ nsHTMLGenericContent::GetId(nsString& aId) nsresult nsHTMLGenericContent::SetId(const nsString& aId) { - SetAttribute(nsHTMLAtoms::id, aId); + SetAttribute(nsHTMLAtoms::id, aId, PR_TRUE); return NS_OK; } @@ -838,7 +845,7 @@ nsHTMLGenericContent::GetTitle(nsString& aTitle) nsresult nsHTMLGenericContent::SetTitle(const nsString& aTitle) { - SetAttribute(nsHTMLAtoms::title, aTitle); + SetAttribute(nsHTMLAtoms::title, aTitle, PR_TRUE); return NS_OK; } @@ -852,7 +859,7 @@ nsHTMLGenericContent::GetLang(nsString& aLang) nsresult nsHTMLGenericContent::SetLang(const nsString& aLang) { - SetAttribute(nsHTMLAtoms::lang, aLang); + SetAttribute(nsHTMLAtoms::lang, aLang, PR_TRUE); return NS_OK; } @@ -866,7 +873,7 @@ nsHTMLGenericContent::GetDir(nsString& aDir) nsresult nsHTMLGenericContent::SetDir(const nsString& aDir) { - SetAttribute(nsHTMLAtoms::dir, aDir); + SetAttribute(nsHTMLAtoms::dir, aDir, PR_TRUE); return NS_OK; } @@ -880,7 +887,7 @@ nsHTMLGenericContent::GetClassName(nsString& aClassName) nsresult nsHTMLGenericContent::SetClassName(const nsString& aClassName) { - SetAttribute(nsHTMLAtoms::kClass, aClassName); + SetAttribute(nsHTMLAtoms::kClass, aClassName, PR_TRUE); return NS_OK; } @@ -892,7 +899,7 @@ nsHTMLGenericContent::GetDocument(nsIDocument*& aResult) const return NS_OK; } -void +nsresult nsHTMLGenericContent::SetDocument(nsIDocument* aDocument) { mDocument = aDocument; @@ -902,52 +909,56 @@ nsHTMLGenericContent::SetDocument(nsIDocument* aDocument) // doing a GetAttribute for every type of handler. if (nsnull != mAttributes) { nsHTMLValue val; - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onclick, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onclick, val)) AddScriptEventListener(nsHTMLAtoms::onclick, val, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::ondblclick, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::ondblclick, val)) AddScriptEventListener(nsHTMLAtoms::onclick, val, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmousedown, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmousedown, val)) AddScriptEventListener(nsHTMLAtoms::onmousedown, val, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmouseup, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseup, val)) AddScriptEventListener(nsHTMLAtoms::onmouseup, val, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmouseover, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseover, val)) AddScriptEventListener(nsHTMLAtoms::onmouseover, val, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmouseout, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseout, val)) AddScriptEventListener(nsHTMLAtoms::onmouseout, val, kIDOMMouseListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onkeydown, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeydown, val)) AddScriptEventListener(nsHTMLAtoms::onkeydown, val, kIDOMKeyListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onkeyup, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeyup, val)) AddScriptEventListener(nsHTMLAtoms::onkeyup, val, kIDOMKeyListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onkeypress, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeypress, val)) AddScriptEventListener(nsHTMLAtoms::onkeypress, val, kIDOMKeyListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onmousemove, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmousemove, val)) AddScriptEventListener(nsHTMLAtoms::onmousemove, val, kIDOMMouseMotionListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onload, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onload, val)) AddScriptEventListener(nsHTMLAtoms::onload, val, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onunload, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onunload, val)) AddScriptEventListener(nsHTMLAtoms::onunload, val, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onabort, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onabort, val)) AddScriptEventListener(nsHTMLAtoms::onabort, val, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onerror, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onerror, val)) AddScriptEventListener(nsHTMLAtoms::onerror, val, kIDOMLoadListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onfocus, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onfocus, val)) AddScriptEventListener(nsHTMLAtoms::onfocus, val, kIDOMFocusListenerIID); - if (eContentAttr_HasValue == mAttributes->GetAttribute(nsHTMLAtoms::onblur, val)) + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onblur, val)) AddScriptEventListener(nsHTMLAtoms::onblur, val, kIDOMFocusListenerIID); } + + return NS_OK; } -nsIContent* -nsHTMLGenericContent::GetParent() const +nsresult +nsHTMLGenericContent::GetParent(nsIContent*& aResult) const { NS_IF_ADDREF(mParent); - return mParent; + aResult = mParent; + return NS_OK;; } -void +nsresult nsHTMLGenericContent::SetParent(nsIContent* aParent) { mParent = aParent; + return NS_OK; } nsresult @@ -956,11 +967,13 @@ nsHTMLGenericContent::IsSynthetic(PRBool& aResult) return PR_FALSE; } -nsIAtom* -nsHTMLGenericContent::GetTag() const + +nsresult +nsHTMLGenericContent::GetTag(nsIAtom*& aResult) const { NS_IF_ADDREF(mTag); - return mTag; + aResult = mTag; + return NS_OK; } //void @@ -1027,101 +1040,115 @@ nsHTMLGenericContent::HandleDOMEvent(nsIPresContext& aPresContext, return ret; } -void +nsresult nsHTMLGenericContent::SetAttribute(const nsString& aName, - const nsString& aValue) + const nsString& aValue, + PRBool aNotify) { nsAutoString upper; aName.ToUpperCase(upper); nsIAtom* attr = NS_NewAtom(upper); - SetAttribute(attr, aValue); + nsresult rv = SetAttribute(attr, aValue, aNotify); NS_RELEASE(attr); + return rv; } -void +nsresult nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) + const nsString& aValue, + PRBool aNotify) { + nsresult rv = NS_OK; if (nsnull == mAttributes) { - NS_NewHTMLAttributes(&mAttributes, mContent); + rv = NS_NewHTMLAttributes(&mAttributes, mContent); + if (NS_OK != rv) { + return rv; + } } if (nsnull != mAttributes) { + PRInt32 na; nsHTMLValue hval; - if (eContentAttr_HasValue == + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->StringToAttribute(aAttribute, aValue, hval)) { - mAttributes->SetAttribute(aAttribute, hval); + rv = mAttributes->SetAttribute(aAttribute, hval, na); } else if (nsHTMLAtoms::style == aAttribute) { // XXX the style sheet language is a document property that // should be used to lookup the style sheet parser to parse the // attribute. nsICSSParser* css; - nsresult rv = NS_NewCSSParser(&css); + rv = NS_NewCSSParser(&css); if (NS_OK != rv) { - return; + return rv; } nsIStyleRule* rule; rv = css->ParseDeclarations(aValue, nsnull, rule); if ((NS_OK == rv) && (nsnull != rule)) { - mAttributes->SetAttribute(aAttribute, nsHTMLValue(rule)); + rv = mAttributes->SetAttribute(aAttribute, nsHTMLValue(rule), na); NS_RELEASE(rule); } NS_RELEASE(css); } else { - mAttributes->SetAttribute(aAttribute, aValue); + rv = mAttributes->SetAttribute(aAttribute, aValue, na); } } + return rv; } -void +nsresult nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue) + const nsHTMLValue& aValue, + PRBool aNotify) { + nsresult rv = NS_OK; if (nsnull == mAttributes) { - NS_NewHTMLAttributes(&mAttributes, mContent); + rv = NS_NewHTMLAttributes(&mAttributes, mContent); } if (nsnull != mAttributes) { - mAttributes->SetAttribute(aAttribute, aValue); + PRInt32 na; + rv = mAttributes->SetAttribute(aAttribute, aValue, na); } + return rv; } -void +nsresult nsHTMLGenericContent::UnsetAttribute(nsIAtom* aAttribute) { if (nsnull != mAttributes) { - PRInt32 count = mAttributes->UnsetAttribute(aAttribute); + PRInt32 count; + mAttributes->UnsetAttribute(aAttribute, count); if (0 == count) { NS_RELEASE(mAttributes); } } + return NS_OK; } -nsContentAttr +nsresult nsHTMLGenericContent::GetAttribute(const nsString& aName, nsString& aResult) const { nsAutoString upper; aName.ToUpperCase(upper); nsIAtom* attr = NS_NewAtom(upper); - nsContentAttr result = GetAttribute(attr, aResult); + nsresult result = GetAttribute(attr, aResult); NS_RELEASE(attr); return result; } - -nsContentAttr +nsresult nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute, nsString &aResult) const { nsHTMLValue value; - nsContentAttr result = GetAttribute(aAttribute, value); + nsresult result = GetAttribute(aAttribute, value); char cbuf[20]; nscolor color; - if (eContentAttr_HasValue == result) { + if (NS_CONTENT_ATTR_HAS_VALUE == result) { // Try subclass conversion routine first - if (eContentAttr_HasValue == + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->AttributeToString(aAttribute, value, aResult)) { return result; } @@ -1164,14 +1191,14 @@ nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute, default: case eHTMLUnit_Enumerated: NS_NOTREACHED("no default enumerated value to string conversion"); - result = eContentAttr_NotThere; + result = NS_CONTENT_ATTR_NOT_THERE; break; } } return result; } -nsContentAttr +nsresult nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const { @@ -1179,96 +1206,116 @@ nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute, return mAttributes->GetAttribute(aAttribute, aValue); } aValue.Reset(); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -PRInt32 -nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray) const +nsresult +nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const { if (nsnull != mAttributes) { - return mAttributes->GetAllAttributeNames(aArray); + return mAttributes->GetAllAttributeNames(aArray, aCount); } - return 0; + aCount = 0; + return NS_OK; } -PRInt32 -nsHTMLGenericContent::GetAttributeCount(void) const +nsresult +nsHTMLGenericContent::GetAttributeCount(PRInt32& aCount) const { if (nsnull != mAttributes) { - return mAttributes->Count(); + return mAttributes->Count(aCount); } - return 0; + aCount = 0; + return NS_OK; } -void +nsresult nsHTMLGenericContent::SetID(nsIAtom* aID) { + nsresult rv = NS_OK; if (nsnull != aID) { if (nsnull == mAttributes) { - NS_NewHTMLAttributes(&mAttributes, mContent); + rv = NS_NewHTMLAttributes(&mAttributes, mContent); + if (NS_OK != rv) { + return rv; + } } if (nsnull != mAttributes) { - mAttributes->SetID(aID); + PRInt32 na; + rv = mAttributes->SetID(aID, na); } } else { if (nsnull != mAttributes) { - PRInt32 count = mAttributes->SetID(nsnull); + PRInt32 count; + rv = mAttributes->SetID(nsnull, count); if (0 == count) { NS_RELEASE(mAttributes); } } } + return rv; } -nsIAtom* -nsHTMLGenericContent::GetID(void) const +nsresult +nsHTMLGenericContent::GetID(nsIAtom*& aResult) const { if (nsnull != mAttributes) { - return mAttributes->GetID(); + return mAttributes->GetID(aResult); } - return nsnull; + aResult = nsnull; + return NS_OK; } -void +nsresult nsHTMLGenericContent::SetClass(nsIAtom* aClass) { + nsresult rv = NS_OK; if (nsnull != aClass) { if (nsnull == mAttributes) { - NS_NewHTMLAttributes(&mAttributes, mContent); + rv = NS_NewHTMLAttributes(&mAttributes, mContent); + if (NS_OK != rv) { + return rv; + } } if (nsnull != mAttributes) { - mAttributes->SetClass(aClass); + PRInt32 na; + rv = mAttributes->SetClass(aClass, na); } } else { if (nsnull != mAttributes) { - PRInt32 count = mAttributes->SetClass(nsnull); + PRInt32 count; + rv = mAttributes->SetClass(nsnull, count); if (0 == count) { NS_RELEASE(mAttributes); } } } + return rv; } -nsIAtom* -nsHTMLGenericContent::GetClass(void) const +nsresult +nsHTMLGenericContent::GetClass(nsIAtom*& aResult) const { if (nsnull != mAttributes) { - return mAttributes->GetClass(); + return mAttributes->GetClass(aResult); } - return nsnull; + aResult = nsnull; + return NS_OK; } -nsIStyleRule* -nsHTMLGenericContent::GetStyleRule(void) +nsresult +nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult) { nsIStyleRule* result = nsnull; if (nsnull != mAttributes) { mAttributes->QueryInterface(kIStyleRuleIID, (void**)&result); } - return result; + aResult = result; + return NS_OK; } nsIContentDelegate* @@ -1283,9 +1330,8 @@ nsHTMLGenericContent::ListAttributes(FILE* out) const { nsISupportsArray* attrs; if (NS_OK == NS_NewISupportsArray(&attrs)) { - GetAllAttributeNames(attrs); - PRInt32 count = attrs->Count(); - PRInt32 index; + PRInt32 index, count; + GetAllAttributeNames(attrs, count); for (index = 0; index < count; index++) { // name nsIAtom* attr = (nsIAtom*)attrs->ElementAt(index); @@ -1306,7 +1352,7 @@ nsHTMLGenericContent::ListAttributes(FILE* out) const } } -void +nsresult nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const { NS_PRECONDITION(nsnull != mDocument, "bad content"); @@ -1314,7 +1360,8 @@ nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const PRInt32 index; for (index = aIndent; --index >= 0; ) fputs(" ", out); - nsIAtom* tag = GetTag(); + nsIAtom* tag; + GetTag(tag); if (tag != nsnull) { nsAutoString buf; tag->ToString(buf); @@ -1328,26 +1375,34 @@ nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const mContent->Release(); fprintf(out, " refcount=%d<", r); - if (mContent->CanContainChildren()) { + PRBool canHaveKids; + mContent->CanContainChildren(canHaveKids); + if (canHaveKids) { fputs("\n", out); - PRInt32 kids = mContent->ChildCount(); + PRInt32 kids; + mContent->ChildCount(kids); for (index = 0; index < kids; index++) { - nsIContent* kid = mContent->ChildAt(index); + nsIContent* kid; + mContent->ChildAt(index, kid); kid->List(out, aIndent + 1); NS_RELEASE(kid); } for (index = aIndent; --index >= 0; ) fputs(" ", out); } fputs(">\n", out); + + return NS_OK; } -void +nsresult nsHTMLGenericContent::ToHTML(FILE* out) const { nsAutoString tmp; - ToHTMLString(tmp); + nsresult rv = ToHTMLString(tmp); fputs(tmp, out); + return rv; } + // XXX i18n: this is wrong (?) because we need to know the outgoing // character set (I think) static void @@ -1376,7 +1431,7 @@ QuoteForHTML(const nsString& aValue, nsString& aResult) aResult.Append('"'); } -void +nsresult nsHTMLGenericContent::ToHTMLString(nsString& aBuf) const { aBuf.Truncate(0); @@ -1394,8 +1449,8 @@ nsHTMLGenericContent::ToHTMLString(nsString& aBuf) const nsISupportsArray* attrs; nsresult rv = NS_NewISupportsArray(&attrs); if (NS_OK == rv) { - mAttributes->GetAllAttributeNames(attrs); - PRInt32 i, n = attrs->Count(); + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); nsAutoString name, value, quotedValue; for (i = 0; i < n; i++) { nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i); @@ -1415,6 +1470,7 @@ nsHTMLGenericContent::ToHTMLString(nsString& aBuf) const } aBuf.Append('>'); + return NS_OK; } //---------------------------------------------------------------------- @@ -1608,7 +1664,7 @@ nsHTMLGenericContent::AddScriptEventListener(nsIAtom* aAttribute, return ret; } -nsContentAttr +nsresult nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -1618,11 +1674,11 @@ nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute, nsIStyleRule* rule = (nsIStyleRule*) aValue.GetISupportsValue(); // rule->ToString(str); aResult = "XXX style rule ToString goes here"; - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } aResult.Truncate(); - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } PRBool @@ -1851,9 +1907,10 @@ nsHTMLGenericLeafContent::Equals(nsIDOMNode* aNode, PRBool aDeep, return NS_OK; } -void +nsresult nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const { + nsresult rv = NS_OK; if (nsnull != mTag) { nsAutoString name; @@ -1865,11 +1922,11 @@ nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const if (nsnull != mAttributes) { nsISupportsArray* attrs; - nsresult rv = NS_NewISupportsArray(&attrs); + rv = NS_NewISupportsArray(&attrs); if (NS_OK == rv) { - mAttributes->GetAllAttributeNames(attrs); - PRInt32 i, n = attrs->Count(); + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); nsAutoString name, value; for (i = 0; i < n; i++) { @@ -1884,14 +1941,16 @@ nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const NS_RELEASE(attrs); } } + return rv; } -void +nsresult nsHTMLGenericLeafContent::ConvertContentToXIF(nsXIFConverter& aConverter) const { + return NS_OK; } -void +nsresult nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) @@ -1900,6 +1959,7 @@ nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const mTag->ToString(name); aConverter.EndLeaf(name); } + return NS_OK; } // XXX not really implemented (yet) @@ -2006,9 +2066,10 @@ static void SetDocumentInChildrenOf(nsIContent* aContent, nsIDocument* aDocument) { PRInt32 i, n; - n = aContent->ChildCount(); + aContent->ChildCount(n); for (i = 0; i < n; i++) { - nsIContent* child = aContent->ChildAt(i); + nsIContent* child; + aContent->ChildAt(i, child); if (nsnull != child) { child->SetDocument(aDocument); SetDocumentInChildrenOf(child, aDocument); @@ -2046,7 +2107,8 @@ nsHTMLGenericContainerContent::InsertBefore(nsIDOMNode* aNewChild, res = aRefChild->QueryInterface(kIContentIID, (void**)&refContent); NS_ASSERTION(NS_OK == res, "Ref child must be an nsIContent"); if (NS_OK == res) { - PRInt32 pos = IndexOf(refContent); + PRInt32 pos; + IndexOf(refContent, pos); if (pos >= 0) { SetDocumentInChildrenOf(newContent, mDocument); res = InsertChildAt(newContent, pos, PR_TRUE); @@ -2076,7 +2138,8 @@ nsHTMLGenericContainerContent::ReplaceChild(nsIDOMNode* aNewChild, nsresult res = aOldChild->QueryInterface(kIContentIID, (void**)&content); NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); if (NS_OK == res) { - PRInt32 pos = IndexOf(content); + PRInt32 pos; + IndexOf(content, pos); if (pos >= 0) { nsIContent* newContent = nsnull; nsresult res = aNewChild->QueryInterface(kIContentIID, (void**)&newContent); @@ -2102,7 +2165,8 @@ nsHTMLGenericContainerContent::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** a nsresult res = aOldChild->QueryInterface(kIContentIID, (void**)&content); NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); if (NS_OK == res) { - PRInt32 pos = IndexOf(content); + PRInt32 pos; + IndexOf(content, pos); if (pos >= 0) { res = RemoveChildAt(pos, PR_TRUE); *aReturn = aOldChild; @@ -2127,9 +2191,10 @@ nsHTMLGenericContainerContent::SizeOf(nsISizeOfHandler* aHandler) const return NS_OK; } -void +nsresult nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) const { + nsresult rv = NS_OK; if (nsnull != mTag) { nsAutoString name; @@ -2141,11 +2206,11 @@ nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) con if (nsnull != mAttributes) { nsISupportsArray* attrs; - nsresult rv = NS_NewISupportsArray(&attrs); + rv = NS_NewISupportsArray(&attrs); if (NS_OK == rv) { - mAttributes->GetAllAttributeNames(attrs); - PRInt32 i, n = attrs->Count(); + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); nsAutoString name, value; for (i = 0; i < n; i++) { @@ -2160,14 +2225,16 @@ nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) con NS_RELEASE(attrs); } } + return NS_OK; } -void +nsresult nsHTMLGenericContainerContent::ConvertContentToXIF(nsXIFConverter& aConverter) const { + return NS_OK; } -void +nsresult nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) @@ -2176,41 +2243,49 @@ nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) co mTag->ToString(name); aConverter.EndContainer(name); } + return NS_OK; } -void +nsresult nsHTMLGenericContainerContent::Compact() { mChildren.Compact(); + return NS_OK; } -PRBool -nsHTMLGenericContainerContent::CanContainChildren() const +nsresult +nsHTMLGenericContainerContent::CanContainChildren(PRBool& aResult) const { - return PR_TRUE; + aResult = PR_TRUE; + return NS_OK; } -PRInt32 -nsHTMLGenericContainerContent::ChildCount() const +nsresult +nsHTMLGenericContainerContent::ChildCount(PRInt32& aCount) const { - return mChildren.Count(); + aCount = mChildren.Count(); + return NS_OK; } -nsIContent* -nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex) const +nsresult +nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex, + nsIContent*& aResult) const { nsIContent *child = (nsIContent*) mChildren.ElementAt(aIndex); if (nsnull != child) { NS_ADDREF(child); } - return child; + aResult = child; + return NS_OK; } -PRInt32 -nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild) const +nsresult +nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild, + PRInt32& aIndex) const { NS_PRECONDITION(nsnull != aPossibleChild, "null ptr"); - return mChildren.IndexOf(aPossibleChild); + aIndex = mChildren.IndexOf(aPossibleChild); + return NS_OK; } nsresult diff --git a/mozilla/layout/html/content/src/nsHTMLGenericContent.h b/mozilla/layout/html/content/src/nsHTMLGenericContent.h index e0a0a1923ef..d17a0b69e42 100644 --- a/mozilla/layout/html/content/src/nsHTMLGenericContent.h +++ b/mozilla/layout/html/content/src/nsHTMLGenericContent.h @@ -98,15 +98,16 @@ struct nsHTMLGenericContent { // Implementation for nsIContent nsresult GetDocument(nsIDocument*& aResult) const; - void SetDocument(nsIDocument* aDocument); - nsIContent* GetParent() const; - void SetParent(nsIContent* aParent); + nsresult SetDocument(nsIDocument* aDocument); + nsresult GetParent(nsIContent*& aResult) const; + nsresult SetParent(nsIContent* aParent); nsresult IsSynthetic(PRBool& aResult); - nsIAtom* GetTag() const; - void SetAttribute(const nsString& aName, const nsString& aValue); - nsContentAttr GetAttribute(const nsString& aName, nsString& aResult) const; + nsresult GetTag(nsIAtom*& aResult) const; + nsresult SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify); + nsresult GetAttribute(const nsString& aName, nsString& aResult) const; nsIContentDelegate* GetDelegate(nsIPresContext* aCX); - void List(FILE* out, PRInt32 aIndent) const; + nsresult List(FILE* out, PRInt32 aIndent) const; nsresult HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, @@ -114,25 +115,26 @@ struct nsHTMLGenericContent { nsEventStatus& aEventStatus); // Implementation for nsIHTMLContent - void Compact(); - void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - void SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue); - void UnsetAttribute(nsIAtom* aAttribute); - nsContentAttr GetAttribute(nsIAtom *aAttribute, - nsString &aResult) const; - nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const; - PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const; - PRInt32 GetAttributeCount(void) const; - void SetID(nsIAtom* aID); - nsIAtom* GetID(void) const; - void SetClass(nsIAtom* aClass); - nsIAtom* GetClass(void) const; - nsIStyleRule* GetStyleRule(void); - void MapAttributesInto(nsIStyleContext* aStyleContext, - nsIPresContext* aPresContext); - void ToHTMLString(nsString& aResult) const; - void ToHTML(FILE* out) const; + nsresult Compact(); + nsresult SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue, + PRBool aNotify); + nsresult UnsetAttribute(nsIAtom* aAttribute); + nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const; + nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const; + nsresult GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const; + nsresult GetAttributeCount(PRInt32& aResult) const; + nsresult SetID(nsIAtom* aID); + nsresult GetID(nsIAtom*& aResult) const; + nsresult SetClass(nsIAtom* aClass); + nsresult GetClass(nsIAtom*& aResult) const; + nsresult GetStyleRule(nsIStyleRule*& aResult); + nsresult MapAttributesInto(nsIStyleContext* aStyleContext, + nsIPresContext* aPresContext); + nsresult ToHTMLString(nsString& aResult) const; + nsresult ToHTML(FILE* out) const; nsresult CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, @@ -144,9 +146,9 @@ struct nsHTMLGenericContent { nsHTMLValue& aValue, REFNSIID aIID); - nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; + nsresult AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; void ListAttributes(FILE* out) const; @@ -253,22 +255,27 @@ struct nsHTMLGenericLeafContent : public nsHTMLGenericContent { // Remainder of nsIHTMLContent (and nsIContent) nsresult SizeOf(nsISizeOfHandler* aHandler) const; - void BeginConvertToXIF(nsXIFConverter& aConverter) const; - void ConvertContentToXIF(nsXIFConverter& aConverter) const; - void FinishConvertToXIF(nsXIFConverter& aConverter) const; - void Compact() { + nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const; + nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const; + nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const; + nsresult Compact() { + return NS_OK; } - PRBool CanContainChildren() const { - return PR_FALSE; + nsresult CanContainChildren(PRBool& aResult) const { + aResult = PR_FALSE; + return NS_OK; } - PRInt32 ChildCount() const { - return 0; + nsresult ChildCount(PRInt32& aResult) const { + aResult = 0; + return NS_OK; } - nsIContent* ChildAt(PRInt32 aIndex) const { - return nsnull; + nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { + aResult = nsnull; + return NS_OK; } - PRInt32 IndexOf(nsIContent* aPossibleChild) const { - return -1; + nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { + aResult = -1; + return NS_OK; } nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { return NS_OK; @@ -308,14 +315,14 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent { // Remainder of nsIHTMLContent (and nsIContent) nsresult SizeOf(nsISizeOfHandler* aHandler) const; - void BeginConvertToXIF(nsXIFConverter& aConverter) const; - void ConvertContentToXIF(nsXIFConverter& aConverter) const; - void FinishConvertToXIF(nsXIFConverter& aConverter) const; - void Compact(); - PRBool CanContainChildren() const; - PRInt32 ChildCount() const; - nsIContent* ChildAt(PRInt32 aIndex) const; - PRInt32 IndexOf(nsIContent* aPossibleChild) const; + nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const; + nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const; + nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const; + nsresult Compact(); + nsresult CanContainChildren(PRBool& aResult) const; + nsresult ChildCount(PRInt32& aResult) const; + nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const; + nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const; nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify); @@ -498,146 +505,149 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent { return _g.ResetScriptObject(); \ } -#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \ - NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ - return _g.GetDocument(aResult); \ - } \ - virtual void SetDocument(nsIDocument* aDocument) { \ - _g.SetDocument(aDocument); \ - } \ - virtual nsIContent* GetParent() const { \ - return _g.GetParent(); \ - } \ - virtual void SetParent(nsIContent* aParent) { \ - _g.SetParent(aParent); \ - } \ - virtual PRBool CanContainChildren() const { \ - return _g.CanContainChildren(); \ - } \ - virtual PRInt32 ChildCount() const { \ - return _g.ChildCount(); \ - } \ - virtual nsIContent* ChildAt(PRInt32 aIndex) const { \ - return _g.ChildAt(aIndex); \ - } \ - virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const { \ - return _g.IndexOf(aPossibleChild); \ - } \ - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \ - PRBool aNotify) { \ - return _g.InsertChildAt(aKid, aIndex, aNotify); \ - } \ - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \ - PRBool aNotify) { \ - return _g.ReplaceChildAt(aKid, aIndex, aNotify); \ - } \ - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \ - return _g.AppendChildTo(aKid, aNotify); \ - } \ - NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \ - return _g.RemoveChildAt(aIndex, aNotify); \ - } \ - NS_IMETHOD IsSynthetic(PRBool& aResult) { \ - return _g.IsSynthetic(aResult); \ - } \ - virtual nsIAtom* GetTag() const { \ - return _g.GetTag(); \ - } \ - virtual void SetAttribute(const nsString& aName, const nsString& aValue) { \ - _g.SetAttribute(aName, aValue); \ - } \ - virtual nsContentAttr GetAttribute(const nsString& aName, \ - nsString& aResult) const { \ - return _g.GetAttribute(aName, aResult); \ - } \ - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { \ - return _g.GetDelegate(aCX); \ - } \ - virtual void List(FILE* out, PRInt32 aIndent) const { \ - _g.List(out, aIndent); \ - } \ - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const { \ - _g.BeginConvertToXIF(aConverter); \ - } \ - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const { \ - _g.ConvertContentToXIF(aConverter); \ - } \ - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const { \ - _g.FinishConvertToXIF(aConverter); \ - } \ - NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \ - return _g.SizeOf(aHandler); \ - } \ - NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \ - nsEvent* aEvent, \ - nsIDOMEvent** aDOMEvent, \ - PRUint32 aFlags, \ +#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \ + NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ + return _g.GetDocument(aResult); \ + } \ + NS_IMETHOD SetDocument(nsIDocument* aDocument) { \ + return _g.SetDocument(aDocument); \ + } \ + NS_IMETHOD GetParent(nsIContent*& aResult) const { \ + return _g.GetParent(aResult); \ + } \ + NS_IMETHOD SetParent(nsIContent* aParent) { \ + return _g.SetParent(aParent); \ + } \ + NS_IMETHOD CanContainChildren(PRBool& aResult) const { \ + return _g.CanContainChildren(aResult); \ + } \ + NS_IMETHOD ChildCount(PRInt32& aResult) const { \ + return _g.ChildCount(aResult); \ + } \ + NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \ + return _g.ChildAt(aIndex, aResult); \ + } \ + NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \ + return _g.IndexOf(aPossibleChild, aResult); \ + } \ + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \ + PRBool aNotify) { \ + return _g.InsertChildAt(aKid, aIndex, aNotify); \ + } \ + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \ + PRBool aNotify) { \ + return _g.ReplaceChildAt(aKid, aIndex, aNotify); \ + } \ + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \ + return _g.AppendChildTo(aKid, aNotify); \ + } \ + NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \ + return _g.RemoveChildAt(aIndex, aNotify); \ + } \ + NS_IMETHOD IsSynthetic(PRBool& aResult) { \ + return _g.IsSynthetic(aResult); \ + } \ + NS_IMETHOD GetTag(nsIAtom*& aResult) const { \ + return _g.GetTag(aResult); \ + } \ + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \ + PRBool aNotify) { \ + return _g.SetAttribute(aName, aValue, aNotify); \ + } \ + NS_IMETHOD GetAttribute(const nsString& aName, \ + nsString& aResult) const { \ + return _g.GetAttribute(aName, aResult); \ + } \ + virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { \ + return _g.GetDelegate(aCX); \ + } \ + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \ + return _g.List(out, aIndent); \ + } \ + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \ + return _g.BeginConvertToXIF(aConverter); \ + } \ + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \ + return _g.ConvertContentToXIF(aConverter); \ + } \ + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \ + return _g.FinishConvertToXIF(aConverter); \ + } \ + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \ + return _g.SizeOf(aHandler); \ + } \ + NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \ + nsEvent* aEvent, \ + nsIDOMEvent** aDOMEvent, \ + PRUint32 aFlags, \ nsEventStatus& aEventStatus); -#define NS_IMPL_IHTMLCONTENT_USING_GENERIC(_g) \ - virtual void Compact() { \ - _g.Compact(); \ - } \ - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue) { \ - _g.SetAttribute(aAttribute, aValue); \ - } \ - virtual void SetAttribute(nsIAtom* aAttribute, \ - const nsHTMLValue& aValue) { \ - _g.SetAttribute(aAttribute, aValue); \ - } \ - virtual void UnsetAttribute(nsIAtom* aAttribute) { \ - _g.UnsetAttribute(aAttribute); \ - } \ - virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, \ - nsString &aResult) const { \ - return _g.GetAttribute(aAttribute, aResult); \ - } \ - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, \ - nsHTMLValue& aValue) const { \ - return _g.GetAttribute(aAttribute, aValue); \ - } \ - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const { \ - return _g.GetAllAttributeNames(aArray); \ - } \ - virtual PRInt32 GetAttributeCount(void) const { \ - return _g.GetAttributeCount(); \ - } \ - virtual void SetID(nsIAtom* aID) { \ - _g.SetID(aID); \ - } \ - virtual nsIAtom* GetID() const { \ - return _g.GetID(); \ - } \ - virtual void SetClass(nsIAtom* aClass) { \ - _g.SetClass(aClass); \ - } \ - virtual nsIAtom* GetClass() const { \ - return _g.GetClass(); \ - } \ - virtual nsIStyleRule* GetStyleRule() { \ - return _g.GetStyleRule(); \ - } \ - virtual void ToHTMLString(nsString& aResult) const { \ - _g.ToHTMLString(aResult); \ - } \ - virtual void ToHTML(FILE* out) const { \ - _g.ToHTML(out); \ - } \ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, \ - nsIFrame* aParentFrame, \ - nsIStyleContext* aStyleContext, \ - nsIFrame*& aResult) { \ - return _g.CreateFrame(aPresContext, aParentFrame, aStyleContext, \ - aResult); \ - } \ - virtual nsContentAttr StringToAttribute(nsIAtom* aAttribute, \ - const nsString& aValue, \ - nsHTMLValue& aResult); \ - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, \ - nsHTMLValue& aValue, \ - nsString& aResult) const; \ - virtual void MapAttributesInto(nsIStyleContext* aContext, \ - nsIPresContext* aPresContext); +#define NS_IMPL_IHTMLCONTENT_USING_GENERIC(_g) \ + NS_IMETHOD Compact() { \ + return _g.Compact(); \ + } \ + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, \ + PRBool aNotify) { \ + return _g.SetAttribute(aAttribute, aValue, aNotify); \ + } \ + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, \ + const nsHTMLValue& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aAttribute, aValue, aNotify); \ + } \ + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \ + return _g.UnsetAttribute(aAttribute); \ + } \ + NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \ + nsString &aResult) const { \ + return _g.GetAttribute(aAttribute, aResult); \ + } \ + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, \ + nsHTMLValue& aValue) const { \ + return _g.GetAttribute(aAttribute, aValue); \ + } \ + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \ + PRInt32& aResult) const { \ + return _g.GetAllAttributeNames(aArray, aResult); \ + } \ + NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \ + return _g.GetAttributeCount(aResult); \ + } \ + NS_IMETHOD SetID(nsIAtom* aID) { \ + return _g.SetID(aID); \ + } \ + NS_IMETHOD GetID(nsIAtom*& aResult) const { \ + return _g.GetID(aResult); \ + } \ + NS_IMETHOD SetClass(nsIAtom* aClass) { \ + return _g.SetClass(aClass); \ + } \ + NS_IMETHOD GetClass(nsIAtom*& aResult) const { \ + return _g.GetClass(aResult); \ + } \ + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult) { \ + return _g.GetStyleRule(aResult); \ + } \ + NS_IMETHOD ToHTMLString(nsString& aResult) const { \ + return _g.ToHTMLString(aResult); \ + } \ + NS_IMETHOD ToHTML(FILE* out) const { \ + return _g.ToHTML(out); \ + } \ + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, \ + nsIFrame* aParentFrame, \ + nsIStyleContext* aStyleContext, \ + nsIFrame*& aResult) { \ + return _g.CreateFrame(aPresContext, aParentFrame, aStyleContext, \ + aResult); \ + } \ + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \ + const nsString& aValue, \ + nsHTMLValue& aResult); \ + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \ + nsHTMLValue& aValue, \ + nsString& aResult) const; \ + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \ + nsIPresContext* aPresContext); /** * This macro implements the portion of query interface that is diff --git a/mozilla/layout/html/content/src/nsHTMLHR.cpp b/mozilla/layout/html/content/src/nsHTMLHR.cpp index 47cdc43a5a9..21cad4d0248 100644 --- a/mozilla/layout/html/content/src/nsHTMLHR.cpp +++ b/mozilla/layout/html/content/src/nsHTMLHR.cpp @@ -136,8 +136,7 @@ nsHTMLHR::GetAlign(nsString& aAlign) { NS_IMETHODIMP nsHTMLHR::SetAlign(const nsString& aAlign) { - mInner.SetAttribute(nsHTMLAtoms::align, aAlign); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::align, aAlign, PR_TRUE); } NS_IMETHODIMP @@ -145,7 +144,7 @@ nsHTMLHR::GetNoShade(PRBool* aNoShade) { nsHTMLValue val; *aNoShade = - eContentAttr_HasValue == mInner.GetAttribute(nsHTMLAtoms::noshade, val); + NS_CONTENT_ATTR_HAS_VALUE == mInner.GetAttribute(nsHTMLAtoms::noshade, val); return NS_OK; } @@ -153,8 +152,7 @@ NS_IMETHODIMP nsHTMLHR::SetNoShade(PRBool aNoShade) { nsAutoString empty; - mInner.SetAttribute(nsHTMLAtoms::noshade, empty); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::noshade, empty, PR_TRUE); } NS_IMETHODIMP @@ -167,8 +165,7 @@ nsHTMLHR::GetSize(nsString& aSize) NS_IMETHODIMP nsHTMLHR::SetSize(const nsString& aSize) { - mInner.SetAttribute(nsHTMLAtoms::size, aSize); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::size, aSize, PR_TRUE); } NS_IMETHODIMP @@ -181,8 +178,7 @@ nsHTMLHR::GetWidth(nsString& aWidth) NS_IMETHODIMP nsHTMLHR::SetWidth(const nsString& aWidth) { - mInner.SetAttribute(nsHTMLAtoms::width, aWidth); - return NS_OK; + return mInner.SetAttribute(nsHTMLAtoms::width, aWidth, PR_TRUE); } static nsHTMLGenericContent::EnumTable kAlignTable[] = { @@ -192,7 +188,7 @@ static nsHTMLGenericContent::EnumTable kAlignTable[] = { { 0 } }; -nsContentAttr +NS_IMETHODIMP nsHTMLHR::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) @@ -200,25 +196,25 @@ nsHTMLHR::StringToAttribute(nsIAtom* aAttribute, if (aAttribute == nsHTMLAtoms::width) { nsHTMLGenericContent::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::size) { nsHTMLGenericContent::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::noshade) { aResult.SetEmptyValue(); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::align) { if (nsHTMLGenericContent::ParseEnumValue(aValue, kAlignTable, aResult)) { - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -nsContentAttr +NS_IMETHODIMP nsHTMLHR::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -226,13 +222,13 @@ nsHTMLHR::AttributeToString(nsIAtom* aAttribute, if (aAttribute == nsHTMLAtoms::align) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { nsHTMLGenericContent::EnumValueToString(aValue, kAlignTable, aResult); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } return mInner.AttributeToString(aAttribute, aValue, aResult); } -void +NS_IMETHODIMP nsHTMLHR::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -259,6 +255,7 @@ nsHTMLHR::MapAttributesInto(nsIStyleContext* aContext, pos->mWidth.SetPercentValue(value.GetPercentValue()); } } + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLHead.cpp b/mozilla/layout/html/content/src/nsHTMLHead.cpp index 1b3bcf3ab3c..7735d18138d 100644 --- a/mozilla/layout/html/content/src/nsHTMLHead.cpp +++ b/mozilla/layout/html/content/src/nsHTMLHead.cpp @@ -24,10 +24,10 @@ class nsHTMLHead : public nsHTMLContainer { public: nsHTMLHead(nsIAtom* aTag); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~nsHTMLHead(); @@ -42,7 +42,7 @@ nsHTMLHead::~nsHTMLHead() { } -nsresult +NS_IMETHODIMP nsHTMLHead::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/content/src/nsHTMLLayer.cpp b/mozilla/layout/html/content/src/nsHTMLLayer.cpp index 3daecd50d2c..d06649a327d 100644 --- a/mozilla/layout/html/content/src/nsHTMLLayer.cpp +++ b/mozilla/layout/html/content/src/nsHTMLLayer.cpp @@ -36,20 +36,20 @@ class LayerPart : public nsHTMLContainer { public: LayerPart(nsIAtom* aTag); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aString); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); -protected: - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; }; // ----------------------------------------------------------- @@ -65,8 +65,9 @@ static nsHTMLTagContent::EnumTable kVisibilityTable[] = { {0} }; -void -LayerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +LayerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { // XXX CLIP nsHTMLValue val; @@ -74,50 +75,49 @@ LayerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString) nsAutoString src(aString); src.StripWhitespace(); val.SetStringValue(src); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if ((aAttribute == nsHTMLAtoms::left) || (aAttribute == nsHTMLAtoms::top)) { nsHTMLValue val; if (ParseValue(aString, _I32_MIN, val, eHTMLUnit_Pixel)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if ((aAttribute == nsHTMLAtoms::width) || (aAttribute == nsHTMLAtoms::height)) { nsHTMLValue val; if (ParseValueOrPercent(aString, val, eHTMLUnit_Pixel)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (aAttribute == nsHTMLAtoms::zindex) { nsHTMLValue val; if (ParseValue(aString, 0, val, eHTMLUnit_Integer)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (aAttribute == nsHTMLAtoms::visibility) { if (ParseEnumValue(aString, kVisibilityTable, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (aAttribute == nsHTMLAtoms::bgcolor) { ParseColor(aString, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::background) { nsAutoString url(aString); url.StripWhitespace(); val.SetStringValue(url); - nsHTMLTagContent::SetAttribute(aAttribute, val); - } - else { - // ABOVE, BELOW, OnMouseOver, OnMouseOut, OnFocus, OnBlur, OnLoad - nsHTMLTagContent::SetAttribute(aAttribute, aString); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } + + // ABOVE, BELOW, OnMouseOver, OnMouseOut, OnFocus, OnBlur, OnLoad + return nsHTMLTagContent::SetAttribute(aAttribute, aString, aNotify); } -void +NS_IMETHODIMP LayerPart::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -180,9 +180,10 @@ LayerPart::MapAttributesInto(nsIStyleContext* aContext, // Background and bgcolor MapBackgroundAttributesInto(aContext, aPresContext); } + return NS_OK; } -nsContentAttr +NS_IMETHODIMP LayerPart::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const @@ -190,13 +191,13 @@ LayerPart::AttributeToString(nsIAtom* aAttribute, if (aAttribute == nsHTMLAtoms::visibility) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { EnumValueToString(aValue, kVisibilityTable, aResult); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -nsresult +NS_IMETHODIMP LayerPart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/content/src/nsHTMLMeta.cpp b/mozilla/layout/html/content/src/nsHTMLMeta.cpp index 76e27fc2d42..3333954d733 100644 --- a/mozilla/layout/html/content/src/nsHTMLMeta.cpp +++ b/mozilla/layout/html/content/src/nsHTMLMeta.cpp @@ -26,10 +26,10 @@ class nsHTMLMeta : public nsHTMLMetaSuper { public: nsHTMLMeta(nsIAtom* aTag); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~nsHTMLMeta(); @@ -44,7 +44,7 @@ nsHTMLMeta::~nsHTMLMeta() { } -nsresult +NS_IMETHODIMP nsHTMLMeta::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/content/src/nsHTMLTitle.cpp b/mozilla/layout/html/content/src/nsHTMLTitle.cpp index e49265e36f8..f69d9b8667f 100644 --- a/mozilla/layout/html/content/src/nsHTMLTitle.cpp +++ b/mozilla/layout/html/content/src/nsHTMLTitle.cpp @@ -27,71 +27,23 @@ class nsHTMLTitle : public nsHTMLTitleSuper { public: nsHTMLTitle(nsIAtom* aTag, const nsString& aTitle); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void List(FILE* out, PRInt32 aIndent) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; - virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const; - virtual void ConvertContentToXIF(nsXIFConverter& aConverter) const; - virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const; protected: virtual ~nsHTMLTitle(); nsString mTitle; }; -nsHTMLTitle::nsHTMLTitle(nsIAtom* aTag, const nsString& aTitle) - : nsHTMLTitleSuper(aTag), mTitle(aTitle) -{ -} - -nsHTMLTitle::~nsHTMLTitle() -{ -} - -nsresult -nsHTMLTitle::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - nsIFrame* frame; - nsFrame::NewFrame(&frame, this, aParentFrame); - if (nsnull == frame) { - return NS_ERROR_OUT_OF_MEMORY; - } - frame->SetStyleContext(aPresContext, aStyleContext); - aResult = frame; - return NS_OK; -} - -void -nsHTMLTitle::List(FILE* out, PRInt32 aIndent) const -{ - NS_PRECONDITION(nsnull != mDocument, "bad content"); - - PRInt32 index; - for (index = aIndent; --index >= 0; ) fputs(" ", out); - - nsIAtom* tag = GetTag(); - if (tag != nsnull) { - nsAutoString buf; - tag->ToString(buf); - fputs(buf, out); - NS_RELEASE(tag); - } - - ListAttributes(out); - - fprintf(out, " RefCount=%d<", mRefCnt); - fputs(mTitle, out); - fputs(">\n", out); -} - nsresult NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag, const nsString& aTitle) @@ -107,6 +59,56 @@ NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult, return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); } +nsHTMLTitle::nsHTMLTitle(nsIAtom* aTag, const nsString& aTitle) + : nsHTMLTitleSuper(aTag), mTitle(aTitle) +{ +} + +nsHTMLTitle::~nsHTMLTitle() +{ +} + +NS_IMETHODIMP +nsHTMLTitle::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) +{ + nsIFrame* frame; + nsFrame::NewFrame(&frame, this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTitle::List(FILE* out, PRInt32 aIndent) const +{ + NS_PRECONDITION(nsnull != mDocument, "bad content"); + + PRInt32 index; + for (index = aIndent; --index >= 0; ) fputs(" ", out); + + nsIAtom* tag; + GetTag(tag); + if (tag != nsnull) { + nsAutoString buf; + tag->ToString(buf); + fputs(buf, out); + NS_RELEASE(tag); + } + + ListAttributes(out); + + fprintf(out, " RefCount=%d<", mRefCnt); + fputs(mTitle, out); + fputs(">\n", out); + return NS_OK; +} + /** * Translate the content object into the (XIF) XML Interchange Format * XIF is an intermediate form of the content model, the buffer @@ -118,7 +120,8 @@ NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult, EndConvertToXIF */ -void nsHTMLTitle::BeginConvertToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +nsHTMLTitle::BeginConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) { @@ -126,15 +129,18 @@ void nsHTMLTitle::BeginConvertToXIF(nsXIFConverter& aConverter) const mTag->ToString(name); aConverter.BeginContainer(name); } - + return NS_OK; } -void nsHTMLTitle::ConvertContentToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +nsHTMLTitle::ConvertContentToXIF(nsXIFConverter& aConverter) const { aConverter.AddContent(mTitle); + return NS_OK; } -void nsHTMLTitle::FinishConvertToXIF(nsXIFConverter& aConverter) const +NS_IMETHODIMP +nsHTMLTitle::FinishConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) { @@ -142,4 +148,5 @@ void nsHTMLTitle::FinishConvertToXIF(nsXIFConverter& aConverter) const mTag->ToString(name); aConverter.EndContainer(name); } + return NS_OK; } diff --git a/mozilla/layout/html/content/src/nsObjectContent.cpp b/mozilla/layout/html/content/src/nsObjectContent.cpp index ca9fd1bf73b..a14a4147896 100644 --- a/mozilla/layout/html/content/src/nsObjectContent.cpp +++ b/mozilla/layout/html/content/src/nsObjectContent.cpp @@ -33,7 +33,7 @@ nsObjectContent::~nsObjectContent() { } -nsresult +NS_IMETHODIMP nsObjectContent::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, @@ -49,43 +49,42 @@ nsObjectContent::CreateFrame(nsIPresContext* aPresContext, return NS_OK; } -void -nsObjectContent::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +nsObjectContent::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { nsHTMLValue val; if (aAttribute == nsHTMLAtoms::align) { if (ParseAlignParam(aString, val)) { // Reflect the attribute into the syle system - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } } else if (ParseImageProperty(aAttribute, aString, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - } - else { - nsObjectContentSuper::SetAttribute(aAttribute, aString); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } + return nsObjectContentSuper::SetAttribute(aAttribute, aString, aNotify); } -nsContentAttr +NS_IMETHODIMP nsObjectContent::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { - nsContentAttr ca = eContentAttr_NotThere; + nsresult ca = NS_CONTENT_ATTR_NOT_THERE; if (aAttribute == nsHTMLAtoms::align) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { AlignParamToString(aValue, aResult); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } } else if (ImagePropertyToString(aAttribute, aValue, aResult)) { - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } return ca; } -void +NS_IMETHODIMP nsObjectContent::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -121,4 +120,5 @@ nsObjectContent::MapAttributesInto(nsIStyleContext* aContext, } MapImagePropertiesInto(aContext, aPresContext); MapImageBorderInto(aContext, aPresContext, nsnull); + return NS_OK; } diff --git a/mozilla/layout/html/content/src/nsObjectContent.h b/mozilla/layout/html/content/src/nsObjectContent.h index 922a437e6d6..727b649bf55 100644 --- a/mozilla/layout/html/content/src/nsObjectContent.h +++ b/mozilla/layout/html/content/src/nsObjectContent.h @@ -26,23 +26,21 @@ class nsObjectContent : public nsObjectContentSuper { public: - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); - - void SetAttribute(nsIAtom* aAttribute, const nsString& aString); - - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; protected: nsObjectContent(nsIAtom* aTag); virtual ~nsObjectContent(); - - nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; }; #endif /* nsObjectContent_h___ */ diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 78f3103463c..818f60dbc7b 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -320,7 +320,7 @@ AddAttributes(const nsIParserNode& aNode, GetAttributeValueAt(aNode, i, v); // Add attribute to content - content->SetAttribute(k, v); + content->SetAttribute(k, v, PR_FALSE); } return NS_OK; } @@ -1651,11 +1651,11 @@ HTMLContentSink::AddBaseTagInfo(nsIHTMLContent* aContent) { if (mBaseHREF.Length() > 0) { nsHTMLValue value(mBaseHREF); - aContent->SetAttribute(nsHTMLAtoms::_baseHref, value); + aContent->SetAttribute(nsHTMLAtoms::_baseHref, value, PR_FALSE); } if (mBaseTarget.Length() > 0) { nsHTMLValue value(mBaseTarget); - aContent->SetAttribute(nsHTMLAtoms::_baseTarget, value); + aContent->SetAttribute(nsHTMLAtoms::_baseTarget, value, PR_FALSE); } } diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 0f0146d298b..4eccd1e9963 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -539,14 +539,15 @@ nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets) PRBool nsHTMLDocument::MatchLinks(nsIContent *aContent) { - nsIAtom *name = aContent->GetTag(); + nsIAtom *name; + aContent->GetTag(name); static nsAutoString area("AREA"), anchor("A"); nsAutoString attr; PRBool result = PR_FALSE; if ((nsnull != name) && (area.EqualsIgnoreCase(name) || anchor.EqualsIgnoreCase(name)) && - (eContentAttr_HasValue == aContent->GetAttribute("HREF", attr))) { + (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute("HREF", attr))) { result = PR_TRUE; } @@ -625,14 +626,15 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) PRBool nsHTMLDocument::MatchAnchors(nsIContent *aContent) { - nsIAtom *name = aContent->GetTag(); + nsIAtom *name; + aContent->GetTag(name); static nsAutoString anchor("A"); nsAutoString attr; PRBool result = PR_FALSE; if ((nsnull != name) && anchor.EqualsIgnoreCase(name) && - (eContentAttr_HasValue == aContent->GetAttribute("NAME", attr))) { + (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute("NAME", attr))) { result = PR_TRUE; } @@ -764,19 +766,20 @@ nsHTMLDocument::MatchName(nsIContent *aContent, const nsString& aName) nsAutoString value; nsIContent *result = nsnull; - if ((eContentAttr_HasValue == aContent->GetAttribute(id, value)) && + if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(id, value)) && aName.Equals(value)) { return aContent; } - else if ((eContentAttr_HasValue == aContent->GetAttribute(name, value)) && + else if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(name, value)) && aName.Equals(value)) { return aContent; } PRInt32 i, count; - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count && result == nsnull; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); result = MatchName(child, aName); NS_RELEASE(child); } @@ -939,7 +942,8 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent, PRBool aInForm) { static nsAutoString name("NAME"); nsAutoString value; - nsIAtom *tag = aContent->GetTag(); + nsIAtom *tag; + aContent->GetTag(tag); PRBool inForm; // Only the content types reflected in Level 0 with a NAME @@ -949,7 +953,7 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent, PRBool aInForm) if ((tag == nsHTMLAtoms::img) || (tag == nsHTMLAtoms::form) || (!aInForm && ((tag == nsHTMLAtoms::applet) || (tag == nsHTMLAtoms::embed)))) { - if (eContentAttr_HasValue == aContent->GetAttribute(name, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(name, value)) { char *nameStr = value.ToNewCString(); PL_HashTableAdd(mNamedItems, nameStr, aContent); } @@ -959,9 +963,10 @@ nsHTMLDocument::RegisterNamedItems(nsIContent *aContent, PRBool aInForm) NS_IF_RELEASE(tag); PRInt32 i, count; - count = aContent->ChildCount(); + aContent->ChildCount(count); for (i = 0; i < count; i++) { - nsIContent *child = aContent->ChildAt(i); + nsIContent *child; + aContent->ChildAt(i, child); RegisterNamedItems(child, inForm); NS_RELEASE(child); } @@ -984,7 +989,7 @@ nsHTMLDocument::NamedItem(const nsString& aName, nsIDOMElement** aReturn) nsIFormManager *form = (nsIFormManager *)mTempForms.ElementAt(i); if (NS_OK == form->QueryInterface(kIContentIID, (void **)&content)) { nsAutoString value; - if (eContentAttr_HasValue == content->GetAttribute(name, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(name, value)) { char *nameStr = value.ToNewCString(); PL_HashTableAdd(mNamedItems, nameStr, content); } @@ -1253,7 +1258,8 @@ PRBool nsHTMLDocument::SearchBlock(BlockText & aBlockText, PRBool nsHTMLDocument::ContentIsBlock(nsIContent * aContent) { PRBool isBlock = PR_FALSE; - nsIAtom * atom = aContent->GetTag(); + nsIAtom * atom; + aContent->GetTag(atom); if (atom != nsnull) { nsString str; atom->ToString(str); @@ -1280,7 +1286,8 @@ nsIContent * nsHTMLDocument::FindBlockParent(nsIContent * aContent, NS_RELEASE(mChildStack[i]); } mStackInx = 0; - nsIContent * parent = aContent->GetParent(); + nsIContent * parent; + aContent->GetParent(parent); nsIContent * child; if (parent == nsnull) { @@ -1298,18 +1305,21 @@ nsIContent * nsHTMLDocument::FindBlockParent(nsIContent * aContent, child = aContent; PRBool done = PR_FALSE; while (!done) { - PRInt32 inx = parent->IndexOf(child) + (mSearchDirection == kForward?1:-1); - if (inx < 0 || inx >= parent->ChildCount()) { + PRInt32 inx, numKids; + parent->IndexOf(child, inx); + inx += (mSearchDirection == kForward?1:-1); + parent->ChildCount(numKids); + if (inx < 0 || inx >= numKids) { NS_RELEASE(child); child = parent; - parent = child->GetParent(); + child->GetParent(parent); if (parent == nsnull) { NS_RELEASE(child); return nsnull; } } else { NS_RELEASE(child); - child = parent->ChildAt(inx); + parent->ChildAt(inx, child); done = PR_TRUE; } } @@ -1334,7 +1344,7 @@ nsIContent * nsHTMLDocument::FindBlockParent(nsIContent * aContent, nsIContent * oldChild = child; child = parent; - parent = child->GetParent(); + child->GetParent(parent); NS_RELEASE(oldChild); } while (parent != nsnull); @@ -1382,13 +1392,17 @@ PRBool nsHTMLDocument::BuildBlockFromContent(nsIContent * aContent, PRBool nsHTMLDocument::BuildBlockTraversing(nsIContent * aParent, BlockText & aBlockText) { - nsIAtom * atom = aParent->GetTag(); + nsIAtom * atom; + aParent->GetTag(atom); if (atom != nsnull) { - if (aParent->ChildCount() > 0) { + PRInt32 numKids; + aParent->ChildCount(numKids); + if (numKids > 0) { PRInt32 i; if (mSearchDirection == kForward) { - for (i=0;iChildCount();i++) { - nsIContent * child = aParent->ChildAt(i); + for (i=0;iChildAt(i, child); if (BuildBlockFromContent(child, aBlockText)) { NS_IF_RELEASE(child); return PR_TRUE; @@ -1396,8 +1410,9 @@ PRBool nsHTMLDocument::BuildBlockTraversing(nsIContent * aParent, NS_RELEASE(child); } } else { // Backward - for (i=aParent->ChildCount()-1;i>=0;i--) { - nsIContent * child = aParent->ChildAt(i); + for (i=numKids-1;i>=0;i--) { + nsIContent * child; + aParent->ChildAt(i, child); if (BuildBlockFromContent(child, aBlockText)) { NS_IF_RELEASE(child); return PR_TRUE; @@ -1432,13 +1447,17 @@ PRBool nsHTMLDocument::BuildBlockFromStack(nsIContent * aParent, nsIContent * stackParent = mParentStack[aStackInx]; nsIContent * stackChild = mChildStack[aStackInx]; - PRInt32 inx = aParent->IndexOf(stackChild); + PRInt32 inx; PRInt32 j; + aParent->IndexOf(stackChild, inx); // Forward if (mSearchDirection == kForward) { - for (j=inx;jChildCount();j++) { - nsIContent * child = aParent->ChildAt(j); + PRInt32 numKids; + aParent->ChildCount(numKids); + for (j=inx;jChildAt(j, child); if (child == stackChild && aStackInx < mStackInx) { if (BuildBlockFromStack(child, aBlockText, aStackInx+1)) { NS_IF_RELEASE(child); @@ -1459,7 +1478,8 @@ PRBool nsHTMLDocument::BuildBlockFromStack(nsIContent * aParent, } } else { // Backward for (j=inx;j>=0;j--) { - nsIContent * child = aParent->ChildAt(j); + nsIContent * child; + aParent->ChildAt(j, child); if (child == stackChild && aStackInx < mStackInx) { if (BuildBlockFromStack(child, aBlockText, aStackInx+1)) { NS_IF_RELEASE(child); @@ -1493,12 +1513,16 @@ PRBool nsHTMLDocument::BuildBlock(nsIContent * aParent, { nsIContent * stackParent = mParentStack[0]; nsIContent * stackChild = mChildStack[0]; - PRInt32 inx = stackParent->IndexOf(stackChild); + PRInt32 inx; PRInt32 j; + stackParent->IndexOf(stackChild, inx); if (mSearchDirection == kForward) { - for (j=inx;jChildCount();j++) { - nsIContent * child = stackParent->ChildAt(j); + PRInt32 numKids; + stackParent->ChildCount(numKids); + for (j=inx;jChildAt(j, child); if (child == stackChild && mStackInx > 1) { if (BuildBlockFromStack(child, aBlockText, 1)) { NS_IF_RELEASE(child); @@ -1520,7 +1544,8 @@ PRBool nsHTMLDocument::BuildBlock(nsIContent * aParent, } else { for (j=inx;j>=0;j--) { BlockText blockText; - nsIContent * child = stackParent->ChildAt(j); + nsIContent * child; + stackParent->ChildAt(j, child); if (child == stackChild && mStackInx > 1) { if (BuildBlockFromStack(child, blockText, 1)) { NS_IF_RELEASE(child); @@ -1564,13 +1589,16 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch nsIContent * body = nsnull; nsString bodyStr("BODY"); - PRInt32 i; - for (i=0;iChildCount();i++) { - nsIContent * child = mRootContent->ChildAt(i); + PRInt32 i, n; + mRootContent->ChildCount(n); + for (i=0;iChildAt(i, child); PRBool isSynthetic; child->IsSynthetic(isSynthetic); if (!isSynthetic) { - nsIAtom * atom = child->GetTag(); + nsIAtom * atom; + child->GetTag(atom);/* XXX leak */ if (bodyStr.EqualsIgnoreCase(atom)) { body = child; break; @@ -1587,21 +1615,24 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch start = body; NS_ADDREF(body); // Find Very first Piece of Content - while (start->ChildCount() > 0) { + PRInt32 snc; + start->ChildCount(snc); + while (snc > 0) { nsIContent * child = start; - start = child->ChildAt(0); + child->ChildAt(0, start); NS_RELEASE(child); } end = body; NS_ADDREF(body); // Last piece of Content - PRInt32 count = end->ChildCount(); + PRInt32 count; + end->ChildCount(count); while (count > 0) { nsIContent * child = end; - end = child->ChildAt(count-1); + child->ChildAt(count-1, end); NS_RELEASE(child); - count = end->ChildCount(); + end->ChildCount(count); } nsSelectionRange * range = mSelection->GetRange(); diff --git a/mozilla/layout/html/document/src/nsHTMLFrame.cpp b/mozilla/layout/html/document/src/nsHTMLFrame.cpp index a8c381c949c..f84f1aff17b 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFrame.cpp @@ -176,21 +176,22 @@ protected: class nsHTMLFrame : public nsHTMLContainer { public: - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); PRBool GetURL(nsString& aURLSpec); PRBool GetName(nsString& aName); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; nsScrollPreference GetScrolling(); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); nsFrameborder GetFrameBorder(); PRBool IsInline() { return mInline; } - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); PRInt32 GetMarginWidth(nsIPresContext* aPresContext); PRInt32 GetMarginHeight(nsIPresContext* aPresContext); @@ -652,7 +653,8 @@ nsHTMLFrame::~nsHTMLFrame() mParentWebWidget = nsnull; } -void nsHTMLFrame::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +nsHTMLFrame::List(FILE* out, PRInt32 aIndent) const { for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent fprintf(out, "%X ", this); @@ -661,24 +663,27 @@ void nsHTMLFrame::List(FILE* out, PRInt32 aIndent) const } else { fprintf(out, "\n"); } - nsHTMLContent::List(out, aIndent); + return nsHTMLContent::List(out, aIndent); } -void nsHTMLFrame::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +nsHTMLFrame::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { nsHTMLValue val; if (ParseImageProperty(aAttribute, aString, val)) { // convert width or height to pixels - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - nsHTMLContainer::SetAttribute(aAttribute, aString); + return nsHTMLContainer::SetAttribute(aAttribute, aString, aNotify); } -void nsHTMLFrame::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsHTMLFrame::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { MapImagePropertiesInto(aContext, aPresContext); + return NS_OK; } PRInt32 nsHTMLFrame::GetMargin(nsIAtom* aType, nsIPresContext* aPresContext) @@ -687,7 +692,7 @@ PRInt32 nsHTMLFrame::GetMargin(nsIAtom* aType, nsIPresContext* aPresContext) nsAutoString strVal; PRInt32 intVal; - if (eContentAttr_HasValue == (GetAttribute(aType, strVal))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (GetAttribute(aType, strVal))) { PRInt32 status; intVal = strVal.ToInteger(&status); if (intVal < 0) { @@ -727,7 +732,7 @@ nsHTMLFrame::CreateFrame(nsIPresContext* aPresContext, PRBool nsHTMLFrame::GetURL(nsString& aURLSpec) { nsHTMLValue value; - if (eContentAttr_HasValue == (GetAttribute(nsHTMLAtoms::src, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (GetAttribute(nsHTMLAtoms::src, value))) { if (eHTMLUnit_String == value.GetUnit()) { value.GetStringValue(aURLSpec); return PR_TRUE; @@ -740,7 +745,7 @@ PRBool nsHTMLFrame::GetURL(nsString& aURLSpec) PRBool nsHTMLFrame::GetName(nsString& aName) { nsHTMLValue value; - if (eContentAttr_HasValue == (GetAttribute(nsHTMLAtoms::name, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (GetAttribute(nsHTMLAtoms::name, value))) { if (eHTMLUnit_String == value.GetUnit()) { value.GetStringValue(aName); return PR_TRUE; @@ -753,7 +758,7 @@ PRBool nsHTMLFrame::GetName(nsString& aName) nsScrollPreference nsHTMLFrame::GetScrolling() { nsHTMLValue value; - if (eContentAttr_HasValue == (GetAttribute(nsHTMLAtoms::scrolling, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (GetAttribute(nsHTMLAtoms::scrolling, value))) { if (eHTMLUnit_String == value.GetUnit()) { nsAutoString scrolling; value.GetStringValue(scrolling); @@ -771,7 +776,7 @@ nsScrollPreference nsHTMLFrame::GetScrolling() nsFrameborder nsHTMLFrame::GetFrameBorder() { nsHTMLValue value; - if (eContentAttr_HasValue == (GetAttribute(nsHTMLAtoms::frameborder, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (GetAttribute(nsHTMLAtoms::frameborder, value))) { if (eHTMLUnit_String == value.GetUnit()) { nsAutoString frameborder; value.GetStringValue(frameborder); diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp index 68bac4d6973..e0af813be59 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp @@ -319,7 +319,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext) nsHTMLValue htmlVal; PRInt32 intVal; nsHTMLTagContent* content = (nsHTMLTagContent*)mContent; - if (eContentAttr_HasValue == (content->GetAttribute(nsHTMLAtoms::border, htmlVal))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::border, htmlVal))) { if (eHTMLUnit_Pixel == htmlVal.GetUnit()) { intVal = htmlVal.GetPixelValue(); } else { @@ -370,8 +370,10 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild) { nsIContent* content; aChild->GetContent(content); - nsIContent* contentParent = content->GetParent(); - nsIAtom* tag = ((nsHTMLTagContent*)contentParent)->GetTag(); + nsIContent* contentParent; + content->GetParent(contentParent); + nsIAtom* tag; + ((nsHTMLTagContent*)contentParent)->GetTag(tag); nsHTMLFramesetFrame* parent = nsnull; if (nsHTMLAtoms::frameset == tag) { aChild->GetGeometricParent((nsIFrame*&)parent); @@ -432,7 +434,7 @@ void nsHTMLFramesetFrame::ParseRowCol(nsIAtom* aAttrType, PRInt32& aNumSpecs, ns nsHTMLValue value; nsAutoString rowsCols; nsHTMLFrameset* content = (nsHTMLFrameset*)mContent; - if (eContentAttr_HasValue == content->GetAttribute(aAttrType, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(aAttrType, value)) { if (eHTMLUnit_String == value.GetUnit()) { value.GetStringValue(rowsCols); nsFramesetSpec* specs = new nsFramesetSpec[gMaxNumRowColSpecs]; @@ -545,7 +547,7 @@ nsFrameborder nsHTMLFramesetFrame::GetFrameborder() { nsHTMLTagContent* content = (nsHTMLTagContent*)mContent; nsHTMLValue value; - if (eContentAttr_HasValue == (content->GetAttribute(nsHTMLAtoms::frameborder, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::frameborder, value))) { if (eHTMLUnit_String == value.GetUnit()) { nsAutoString frameborder; value.GetStringValue(frameborder); @@ -562,7 +564,7 @@ nsFrameborder nsHTMLFramesetFrame::GetFrameborder() nsFrameborder nsHTMLFramesetFrame::GetFrameborder(nsHTMLTagContent* aContent) { nsHTMLValue value; - if (eContentAttr_HasValue == (aContent->GetAttribute(nsHTMLAtoms::frameborder, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetAttribute(nsHTMLAtoms::frameborder, value))) { if (eHTMLUnit_String == value.GetUnit()) { nsAutoString frameborder; value.GetStringValue(frameborder); @@ -647,13 +649,16 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, mChildCount = 0; nsHTMLFrameset* content = (nsHTMLFrameset*)mContent; nsIFrame* frame; - PRInt32 numChildren = content->ChildCount(); + PRInt32 numChildren; + content->ChildCount(numChildren); for (int childX = 0; childX < numChildren; childX++) { - nsHTMLTagContent* child = (nsHTMLTagContent*)(content->ChildAt(childX)); + nsHTMLTagContent* child; + content->ChildAt(childX, (nsIContent*&)child); if (nsnull == child) { continue; } - nsIAtom* tag = child->GetTag(); + nsIAtom* tag; + child->GetTag(tag);/* XXX leak */ if ((nsHTMLAtoms::frameset == tag) || (nsHTMLAtoms::frame == tag)) { nsresult result = nsHTMLBase::CreateFrame(&aPresContext, this, child, nsnull, frame); @@ -851,31 +856,35 @@ nsHTMLFrameset::~nsHTMLFrameset() mParentWebShell = nsnull; } -void nsHTMLFrameset::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +nsHTMLFrameset::List(FILE* out, PRInt32 aIndent) const { for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent fprintf(out, "%X \n", this); - nsHTMLContainer::List(out, aIndent); + return nsHTMLContainer::List(out, aIndent); } -void nsHTMLFrameset::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +nsHTMLFrameset::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { nsHTMLValue val; if (ParseImageProperty(aAttribute, aString, val)) { // convert width or height to pixels - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - nsHTMLContainer::SetAttribute(aAttribute, aString); + return nsHTMLContainer::SetAttribute(aAttribute, aString, aNotify); } -void nsHTMLFrameset::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsHTMLFrameset::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { MapImagePropertiesInto(aContext, aPresContext); MapImageBorderInto(aContext, aPresContext, nsnull); + return NS_OK; } -nsresult +NS_IMETHODIMP nsHTMLFrameset::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.h b/mozilla/layout/html/document/src/nsHTMLFrameset.h index f65ba2b6561..3e661647a93 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrameset.h +++ b/mozilla/layout/html/document/src/nsHTMLFrameset.h @@ -128,15 +128,16 @@ protected: class nsHTMLFrameset : public nsHTMLContainer { public: - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); protected: nsHTMLFrameset(nsIAtom* aTag, nsIWebShell* aParentWebShell); diff --git a/mozilla/layout/html/document/src/nsImageDocument.cpp b/mozilla/layout/html/document/src/nsImageDocument.cpp index c5a45c72ec7..3edc31b6949 100644 --- a/mozilla/layout/html/document/src/nsImageDocument.cpp +++ b/mozilla/layout/html/document/src/nsImageDocument.cpp @@ -230,8 +230,8 @@ nsImageDocument::CreateSyntheticDocument() nsAutoString src; mDocumentURL->ToString(src); nsHTMLValue val(src); - image->SetAttribute(nsHTMLAtoms::src, val); - image->SetAttribute(nsHTMLAtoms::alt, val); + image->SetAttribute(nsHTMLAtoms::src, val, PR_FALSE); + image->SetAttribute(nsHTMLAtoms::alt, val, PR_FALSE); root->AppendChildTo(body, PR_FALSE); center->AppendChildTo(image, PR_FALSE); diff --git a/mozilla/layout/html/document/src/nsMarkupDocument.cpp b/mozilla/layout/html/document/src/nsMarkupDocument.cpp index 35eaad98766..653a883d7b6 100644 --- a/mozilla/layout/html/document/src/nsMarkupDocument.cpp +++ b/mozilla/layout/html/document/src/nsMarkupDocument.cpp @@ -222,16 +222,15 @@ void nsMarkupDocument::FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode content->IsSynthetic(isSynthetic); if (PR_FALSE == isSynthetic) { - nsIAtom* tag = content->GetTag(); + nsIAtom* tag; + content->GetTag(tag); if (tag != nsnull) { - if (tag != nsnull) - { - nsString str; - tag->ToString(str); - if (str.EqualsIgnoreCase("Head")) - StyleSheetsToXIF(aConverter); - } + nsString str; + tag->ToString(str); + if (str.EqualsIgnoreCase("Head")) + StyleSheetsToXIF(aConverter); + NS_RELEASE(tag); } } } diff --git a/mozilla/layout/html/forms/public/nsIFormControl.h b/mozilla/layout/html/forms/public/nsIFormControl.h index 9f74d634bae..371fbd209cf 100644 --- a/mozilla/layout/html/forms/public/nsIFormControl.h +++ b/mozilla/layout/html/forms/public/nsIFormControl.h @@ -25,6 +25,8 @@ class nsIFormManager; { 0x282ff440, 0xcd7e, 0x11d1, \ {0x89, 0xad, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} } +// XXX XPCOM'ize me + /** * Interface which all form controls (e.g. buttons, checkboxes, text, * radio buttons, select, etc) implement. diff --git a/mozilla/layout/html/forms/public/nsIFormManager.h b/mozilla/layout/html/forms/public/nsIFormManager.h index cec730869d1..6459498ec89 100644 --- a/mozilla/layout/html/forms/public/nsIFormManager.h +++ b/mozilla/layout/html/forms/public/nsIFormManager.h @@ -36,6 +36,8 @@ enum nsFormRenderingMode { kForwardMode // newest }; +// XXX XPCOM'ize me + /** * Abstract form manager interface. Form managers are responsible for * the management of form controls. This includes gathering of data @@ -116,30 +118,14 @@ public: // methods accessing attributes - /** - * Get the named attribute of this manager - * @param aName the name of the attribute - * @param aResult the value of the attribute - * @return
    - * - *
  • If the attribute is not set and has no default value, return - * eContentAttr_NotThere. - * - *
  • If the attribute exists, but has no value, return - * eContentAttr_NoValue. - * - *
  • If the attribute has a value, empty or otherwise, set ret to - * be the value, and return eContentAttr_HasValue. - * - *
*/ - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const = 0; + NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0; + /** * Set the named attribute of this manager * @param aName the name of the attribute * @param aValue the value of the attribute */ - virtual void SetAttribute(const nsString& aName, const nsString& aValue) = 0; + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue) = 0; // misc methods diff --git a/mozilla/layout/html/forms/src/nsForm.cpp b/mozilla/layout/html/forms/src/nsForm.cpp index 54298b65f87..3889be43c90 100644 --- a/mozilla/layout/html/forms/src/nsForm.cpp +++ b/mozilla/layout/html/forms/src/nsForm.cpp @@ -152,10 +152,12 @@ public: virtual PRBool RemoveFormControl(nsIFormControl* aFormControl, PRBool aChildIsRef = PR_TRUE); - virtual void SetAttribute(const nsString& aName, const nsString& aValue); + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue); + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify); - virtual nsContentAttr GetAttribute(const nsString& aName, - nsString& aResult) const; + NS_IMETHOD GetAttribute(const nsString& aName, + nsString& aResult) const; virtual nsresult GetRefCount() const; @@ -808,7 +810,16 @@ nsForm::OnTab() { } -void nsForm::SetAttribute(const nsString& aName, const nsString& aValue) +NS_IMETHODIMP +nsForm::SetAttribute(const nsString& aName, const nsString& aValue) +{ + return SetAttribute(aName, aValue, PR_FALSE); +} + +// XXX return error status properly +NS_IMETHODIMP +nsForm::SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify) { nsAutoString tmp(aName); tmp.ToUpperCase(); @@ -858,35 +869,39 @@ void nsForm::SetAttribute(const nsString& aName, const nsString& aValue) NS_NewHTMLAttributes(&mAttributes, nsnull); } if (nsnull != mAttributes) { - mAttributes->SetAttribute(atom, aValue); + PRInt32 na; + mAttributes->SetAttribute(atom, aValue, na); } } NS_RELEASE(atom); + + return NS_OK; } -nsContentAttr nsForm::GetAttribute(const nsString& aName, - nsString& aResult) const +NS_IMETHODIMP +nsForm::GetAttribute(const nsString& aName, + nsString& aResult) const { nsAutoString tmp(aName); tmp.ToUpperCase(); nsIAtom* atom = NS_NewAtom(tmp); - nsContentAttr rv = eContentAttr_NoValue; + nsresult rv = NS_CONTENT_ATTR_NO_VALUE; if (atom == nsHTMLAtoms::action) { if (nsnull != mAction) { aResult = *mAction; - rv = eContentAttr_HasValue; + rv = NS_CONTENT_ATTR_HAS_VALUE; } } else if (atom == nsHTMLAtoms::encoding) { if (nsnull != mEncoding) { aResult = *mEncoding; - rv = eContentAttr_HasValue; + rv = NS_CONTENT_ATTR_HAS_VALUE; } } else if (atom == nsHTMLAtoms::target) { if (nsnull != mTarget) { aResult = *mTarget; - rv = eContentAttr_HasValue; + rv = NS_CONTENT_ATTR_HAS_VALUE; } } else if (atom == nsHTMLAtoms::method) { @@ -897,7 +912,7 @@ nsContentAttr nsForm::GetAttribute(const nsString& aName, else { aResult = "get"; } - rv = eContentAttr_HasValue; + rv = NS_CONTENT_ATTR_HAS_VALUE; } } else { @@ -905,12 +920,12 @@ nsContentAttr nsForm::GetAttribute(const nsString& aName, if (nsnull != mAttributes) { nsHTMLValue value; rv = mAttributes->GetAttribute(atom, value); - if (eContentAttr_HasValue == rv) { + if (NS_CONTENT_ATTR_HAS_VALUE == rv) { if (value.GetUnit() == eHTMLUnit_String) { value.GetStringValue(aResult); } else { - rv = eContentAttr_NoValue; + rv = NS_CONTENT_ATTR_NO_VALUE; } } } @@ -1054,7 +1069,7 @@ nsForm::GetAcceptCharset(nsString& aAcceptCharset) NS_IMETHODIMP nsForm::SetAcceptCharset(const nsString& aAcceptCharset) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::acceptcharset, aAcceptCharset); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::acceptcharset, aAcceptCharset, PR_TRUE); return NS_OK; } @@ -1070,7 +1085,7 @@ nsForm::GetAction(nsString& aAction) NS_IMETHODIMP nsForm::SetAction(const nsString& aAction) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::action, aAction); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::action, aAction, PR_TRUE); return NS_OK; } @@ -1086,7 +1101,7 @@ nsForm::GetEnctype(nsString& aEnctype) NS_IMETHODIMP nsForm::SetEnctype(const nsString& aEnctype) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::enctype, aEnctype); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::enctype, aEnctype, PR_TRUE); return NS_OK; } @@ -1102,7 +1117,7 @@ nsForm::GetMethod(nsString& aMethod) NS_IMETHODIMP nsForm::SetMethod(const nsString& aMethod) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::method, aMethod); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::method, aMethod, PR_TRUE); return NS_OK; } @@ -1118,7 +1133,7 @@ nsForm::GetTarget(nsString& aTarget) NS_IMETHODIMP nsForm::SetTarget(const nsString& aTarget) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::target, aTarget); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::target, aTarget, PR_TRUE); return NS_OK; } @@ -1187,9 +1202,9 @@ nsForm::NamedItem(const nsString& aName, nsIDOMElement** aReturn) if (NS_OK == result) { nsAutoString name; // XXX Should it be an EqualsIgnoreCase? - if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) && + if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name))) || - ((content->GetAttribute("ID", name) == eContentAttr_HasValue) && + ((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name)))) { result = control->QueryInterface(kIDOMElementIID, (void **)aReturn); } @@ -1505,9 +1520,9 @@ nsFormElementList::NamedItem(const nsString& aName, nsIDOMNode** aReturn) if (NS_OK == result) { nsAutoString name; // XXX Should it be an EqualsIgnoreCase? - if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) && + if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name))) || - ((content->GetAttribute("ID", name) == eContentAttr_HasValue) && + ((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name)))) { result = control->QueryInterface(kIDOMNodeIID, (void **)aReturn); } diff --git a/mozilla/layout/html/forms/src/nsHTMLForms.h b/mozilla/layout/html/forms/src/nsHTMLForms.h index fe5a00cefef..51d922ba814 100644 --- a/mozilla/layout/html/forms/src/nsHTMLForms.h +++ b/mozilla/layout/html/forms/src/nsHTMLForms.h @@ -139,7 +139,7 @@ NS_NewHTMLInputRadio(nsIHTMLContent** aInstancePtrResult, */ extern nsresult NS_NewHTMLSelect(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag, nsIFormManager* aManager, PRInt32 aHackIndex = -1); + nsIAtom* aTag, nsIFormManager* aManager); /** * Construct an nsIHTMLContent with behavior of an html input text diff --git a/mozilla/layout/html/forms/src/nsInput.cpp b/mozilla/layout/html/forms/src/nsInput.cpp index 70703cf0689..475fc17915f 100644 --- a/mozilla/layout/html/forms/src/nsInput.cpp +++ b/mozilla/layout/html/forms/src/nsInput.cpp @@ -101,8 +101,9 @@ void nsInput::SetContent(const nsString& aValue) } } -void nsInput::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsInput::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { if (ALIGN_UNSET != mAlign) { nsStyleDisplay* display = (nsStyleDisplay*) @@ -122,6 +123,7 @@ void nsInput::MapAttributesInto(nsIStyleContext* aContext, } } MapImagePropertiesInto(aContext, aPresContext); + return NS_OK; } @@ -308,7 +310,9 @@ void nsInput::CacheAttribute(const nsString& aValue, PRInt32 aMinValue, PRInt32& aLoc = ((NS_OK == status) && (intVal >= aMinValue)) ? intVal : aMinValue; } -void nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::type) { // You cannot set the type of a form element ; @@ -327,33 +331,35 @@ void nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) if (ParseAlignParam(aValue, val)) { mAlign = val.GetIntValue(); // Reflect the attribute into the syle system - nsHTMLTagContent::SetAttribute(aAttribute, val); // is this needed? + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); // is this needed? } else { mAlign = ALIGN_UNSET; } - return; } + // XXX the following is necessary so that MapAttributesInto gets called - nsInputSuper::SetAttribute(aAttribute, aValue); + return nsInputSuper::SetAttribute(aAttribute, aValue, aNotify); } -nsContentAttr nsInput::GetCacheAttribute(nsString* const& aLoc, nsHTMLValue& aValue) const +nsresult nsInput::GetCacheAttribute(nsString* const& aLoc, nsHTMLValue& aValue) const { aValue.Reset(); if (nsnull == aLoc) { - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } else { aValue.SetStringValue(*aLoc); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } -nsContentAttr nsInput::GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHTMLUnit aUnit) const +nsresult +nsInput::GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, + nsHTMLUnit aUnit) const { aValue.Reset(); if (aLoc <= ATTR_NOTSET) { - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } else { if (eHTMLUnit_Pixel == aUnit) { @@ -364,22 +370,23 @@ nsContentAttr nsInput::GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHT aValue.SetEmptyValue(); } else { - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } } else { aValue.SetIntValue(aLoc, aUnit); } - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } -nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const +NS_IMETHODIMP +nsInput::GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const { nsHTMLValue htmlValue; - nsContentAttr result = GetAttribute(aAttribute, htmlValue); - if (eContentAttr_HasValue == result) { + nsresult result = GetAttribute(aAttribute, htmlValue); + if (NS_CONTENT_ATTR_HAS_VALUE == result) { if (eHTMLUnit_Empty == htmlValue.GetUnit()) { aValue = 1; } @@ -389,27 +396,28 @@ nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const else { aValue = htmlValue.GetIntValue(); } - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } else { aValue = ATTR_NOTSET; // XXX for bool values, this should return 0 - return eContentAttr_NoValue; + return NS_CONTENT_ATTR_NO_VALUE; } } -nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const +NS_IMETHODIMP +nsInput::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const { if (aAttribute == nsHTMLAtoms::type) { nsAutoString tmp; GetType(tmp); if (tmp.Length() == 0) { // derivatives that don't support type return zero length string - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } else { aValue.SetStringValue(tmp); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } } else if (aAttribute == nsHTMLAtoms::name) { @@ -449,7 +457,7 @@ nsInput::GetDefaultValue(nsString& aDefaultValue) NS_IMETHODIMP nsInput::SetDefaultValue(const nsString& aDefaultValue) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::value, aDefaultValue); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::value, aDefaultValue, PR_TRUE); return NS_OK; } @@ -493,7 +501,7 @@ nsInput::GetAccept(nsString& aAccept) NS_IMETHODIMP nsInput::SetAccept(const nsString& aAccept) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::accept, aAccept); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::accept, aAccept, PR_TRUE); return NS_OK; } @@ -509,7 +517,7 @@ nsInput::GetAccessKey(nsString& aAccessKey) NS_IMETHODIMP nsInput::SetAccessKey(const nsString& aAccessKey) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::accesskey, aAccessKey); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::accesskey, aAccessKey, PR_TRUE); return NS_OK; } @@ -525,7 +533,7 @@ nsInput::GetAlign(nsString& aAlign) NS_IMETHODIMP nsInput::SetAlign(const nsString& aAlign) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::align, aAlign); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::align, aAlign, PR_TRUE); return NS_OK; } @@ -541,7 +549,7 @@ nsInput::GetAlt(nsString& aAlt) NS_IMETHODIMP nsInput::SetAlt(const nsString& aAlt) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::alt, aAlt); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::alt, aAlt, PR_TRUE); return NS_OK; } @@ -567,7 +575,7 @@ nsInput::GetDisabled(PRBool* aDisabled) { nsAutoString result; - *aDisabled = (PRBool)(eContentAttr_HasValue == ((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::disabled, result)); + *aDisabled = (PRBool)(NS_CONTENT_ATTR_HAS_VALUE == ((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::disabled, result)); return NS_OK; } @@ -576,7 +584,7 @@ NS_IMETHODIMP nsInput::SetDisabled(PRBool aDisabled) { if (PR_TRUE == aDisabled) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::disabled, ""); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::disabled, "", PR_TRUE); } else { UnsetAttribute(nsHTMLAtoms::disabled); @@ -602,7 +610,7 @@ nsInput::SetMaxLength(PRInt32 aMaxLength) nsHTMLValue val; val.SetIntValue(aMaxLength, eHTMLUnit_Integer); - ((nsHTMLTagContent *)this)->SetAttribute(nsHTMLAtoms::maxlength, val); + ((nsHTMLTagContent *)this)->SetAttribute(nsHTMLAtoms::maxlength, val, PR_TRUE); return NS_OK; } @@ -610,7 +618,7 @@ nsInput::SetMaxLength(PRInt32 aMaxLength) NS_IMETHODIMP nsInput::SetName(const nsString& aName) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::name, aName); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::name, aName, PR_TRUE); return NS_OK; } @@ -620,7 +628,7 @@ nsInput::GetReadOnly(PRBool* aReadOnly) { nsAutoString result; - *aReadOnly = (PRBool)(eContentAttr_HasValue == ((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::readonly, result)); + *aReadOnly = (PRBool)(NS_CONTENT_ATTR_HAS_VALUE == ((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::readonly, result)); return NS_OK; } @@ -629,7 +637,7 @@ NS_IMETHODIMP nsInput::SetReadOnly(PRBool aReadOnly) { if (PR_TRUE == aReadOnly) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::readonly, ""); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::readonly, "", PR_TRUE); } else { UnsetAttribute(nsHTMLAtoms::readonly); @@ -649,7 +657,7 @@ nsInput::GetSize(nsString& aSize) NS_IMETHODIMP nsInput::SetSize(const nsString& aSize) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::size, aSize); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::size, aSize, PR_TRUE); return NS_OK; } @@ -665,7 +673,7 @@ nsInput::GetSrc(nsString& aSrc) NS_IMETHODIMP nsInput::SetSrc(const nsString& aSrc) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::src, aSrc); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::src, aSrc, PR_TRUE); return NS_OK; } @@ -687,7 +695,7 @@ nsInput::SetTabIndex(PRInt32 aTabIndex) nsHTMLValue val; val.SetIntValue(aTabIndex, eHTMLUnit_Integer); - ((nsHTMLTagContent *)this)->SetAttribute(nsHTMLAtoms::tabindex, val); + ((nsHTMLTagContent *)this)->SetAttribute(nsHTMLAtoms::tabindex, val, PR_TRUE); return NS_OK; } @@ -711,7 +719,7 @@ nsInput::GetUseMap(nsString& aUseMap) NS_IMETHODIMP nsInput::SetUseMap(const nsString& aUseMap) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::usemap, aUseMap); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::usemap, aUseMap, PR_TRUE); return NS_OK; } @@ -727,7 +735,7 @@ nsInput::GetValue(nsString& aValue) NS_IMETHODIMP nsInput::SetValue(const nsString& aValue) { - ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::value, aValue); + ((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::value, aValue, PR_TRUE); return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsInput.h b/mozilla/layout/html/forms/src/nsInput.h index b6cd183cc40..f29b97ea2d1 100644 --- a/mozilla/layout/html/forms/src/nsInput.h +++ b/mozilla/layout/html/forms/src/nsInput.h @@ -47,13 +47,13 @@ public: /** * @see nsIContentDelegate CreateFrame */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) = 0; + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) = 0; - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); /** * @see nsISupports QueryInterface @@ -120,17 +120,17 @@ public: * if there is an attribute but no value, or eContentAttr_HasValue * if there is no attribute. */ - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const; - - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const; /** * Set the named attribute of this input * @param aAttribute the name of the attribute * @param aValue the value of the attribute */ - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); NS_FORWARD_IDOMNODE(nsHTMLContainer::) NS_FORWARD_IDOMELEMENT(nsHTMLContainer::) @@ -186,8 +186,8 @@ protected: void CacheAttribute(const nsString& aValue, nsString*& aLoc); void CacheAttribute(const nsString& aValue, PRInt32 aMinValue, PRInt32& aLoc); - nsContentAttr GetCacheAttribute(nsString* const& aLoc, nsHTMLValue& aValue) const; - nsContentAttr GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHTMLUnit aUnit) const; + nsresult GetCacheAttribute(nsString* const& aLoc, nsHTMLValue& aValue) const; + nsresult GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHTMLUnit aUnit) const; // Attributes common to all html form elements nsString* mName; diff --git a/mozilla/layout/html/forms/src/nsInputButton.cpp b/mozilla/layout/html/forms/src/nsInputButton.cpp index e7b9e6ac952..13ad6c90546 100644 --- a/mozilla/layout/html/forms/src/nsInputButton.cpp +++ b/mozilla/layout/html/forms/src/nsInputButton.cpp @@ -69,14 +69,15 @@ public: nsInputButton (nsIAtom* aTag, nsIFormManager* aManager, nsButtonType aType); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); nsButtonType GetButtonType() { return mType; } nsButtonTagType GetButtonTagType() { return mTagType; } @@ -303,18 +304,18 @@ nsInputButton::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, } } -void -nsInputButton::SetAttribute(nsIAtom* aAttribute, const nsString& aString) +NS_IMETHODIMP +nsInputButton::SetAttribute(nsIAtom* aAttribute, const nsString& aString, + PRBool aNotify) { nsHTMLValue val; if (ParseImageProperty(aAttribute, aString, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - nsInputButtonSuper::SetAttribute(aAttribute, aString); + return nsInputButtonSuper::SetAttribute(aAttribute, aString, aNotify); } -void +NS_IMETHODIMP nsInputButton::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { @@ -330,6 +331,7 @@ nsInputButton::MapAttributesInto(nsIStyleContext* aContext, MapImageBorderInto(aContext, aPresContext, blue); } nsInputButtonSuper::MapAttributesInto(aContext, aPresContext); + return NS_OK; } //---------------------------------------------------------------------- @@ -514,7 +516,7 @@ nsInputButtonFrame::GetDesiredSize(nsIPresContext* aPresContext, if (kButton_Image == GetButtonType()) { // there is an image // Setup url before starting the image load nsAutoString src; - if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) { + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", src)) { mImageLoader.SetURL(src); } mImageLoader.GetDesiredSize(aPresContext, aReflowState, aDesiredLayoutSize); @@ -589,8 +591,8 @@ nsInputButtonFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aVie } nsString value; - nsContentAttr status = ((nsHTMLTagContent*)content)->GetAttribute(nsHTMLAtoms::value, value); - if (eContentAttr_HasValue == status) { + nsresult status = ((nsHTMLTagContent*)content)->GetAttribute(nsHTMLAtoms::value, value); + if (NS_CONTENT_ATTR_HAS_VALUE == status) { button->SetLabel(value); } else { @@ -685,6 +687,6 @@ NS_NewHTMLInputBrowse(nsIHTMLContent** aInstancePtrResult, nsAutoString label; nsInputButton* button = (nsInputButton *)*aInstancePtrResult; button->GetDefaultLabel(label); - button->SetAttribute(nsHTMLAtoms::value, label); + button->SetAttribute(nsHTMLAtoms::value, label, PR_FALSE); return result; } diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp index c66be56f136..9ba78f0c642 100644 --- a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp +++ b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp @@ -103,8 +103,8 @@ nsInputCheckboxFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aV // get the intial state of the checkbox nsInputCheckbox* content = (nsInputCheckbox *)mContent; // this must be an nsCheckbox nsHTMLValue value; - nsContentAttr result = content->GetAttribute(nsHTMLAtoms::checked, value); - PRBool checked = (result != eContentAttr_NotThere) ? PR_TRUE : PR_FALSE; + nsresult result = content->GetAttribute(nsHTMLAtoms::checked, value); + PRBool checked = (result != NS_CONTENT_ATTR_NOT_THERE) ? PR_TRUE : PR_FALSE; // set the widget to the initial state nsICheckButton* checkbox; @@ -153,8 +153,9 @@ nsInputCheckbox::~nsInputCheckbox() } -void nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { float p2t = aPresContext->GetPixelsToTwips(); nscoord pad = NSIntPixelsToTwips(3, p2t); @@ -180,6 +181,8 @@ void nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext, nsInput::MapAttributesInto(aContext, aPresContext); } NS_IF_RELEASE(formMan); + + return NS_OK; } PRInt32 @@ -242,17 +245,20 @@ void nsInputCheckbox::GetType(nsString& aResult) const aResult = "checkbox"; } -void nsInputCheckbox::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) +NS_IMETHODIMP +nsInputCheckbox::SetAttribute(nsIAtom* aAttribute, + const nsString& aValue, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::checked) { mChecked = PR_TRUE; } - nsInputCheckboxSuper::SetAttribute(aAttribute, aValue); + return nsInputCheckboxSuper::SetAttribute(aAttribute, aValue, aNotify); } -nsContentAttr nsInputCheckbox::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const +NS_IMETHODIMP +nsInputCheckbox::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const { aResult.Reset(); if (aAttribute == nsHTMLAtoms::checked) { diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.h b/mozilla/layout/html/forms/src/nsInputCheckbox.h index 4fda1cdac0a..e6f58381f29 100644 --- a/mozilla/layout/html/forms/src/nsInputCheckbox.h +++ b/mozilla/layout/html/forms/src/nsInputCheckbox.h @@ -28,23 +28,24 @@ public: typedef nsInput nsInputCheckboxSuper; nsInputCheckbox (nsIAtom* aTag, nsIFormManager* aManager); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const; virtual PRInt32 GetMaxNumValues(); virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsString* aValues, nsString* aNames); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); virtual void Reset(); protected: @@ -52,7 +53,7 @@ protected: virtual void GetType(nsString& aResult) const; - PRBool mChecked; // initial checked flag value + PRBool mChecked; // initial checked flag value }; #endif diff --git a/mozilla/layout/html/forms/src/nsInputFile.cpp b/mozilla/layout/html/forms/src/nsInputFile.cpp index 39218c81967..e0e82aede53 100644 --- a/mozilla/layout/html/forms/src/nsInputFile.cpp +++ b/mozilla/layout/html/forms/src/nsInputFile.cpp @@ -254,17 +254,19 @@ nsInputFile::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, return PR_TRUE; } -void nsInputFile::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsInputFile::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { // get the text and set its relevant attributes if ((aAttribute == nsHTMLAtoms::size) || (aAttribute == nsHTMLAtoms::maxlength) || (aAttribute == nsHTMLAtoms::value) || (aAttribute == nsHTMLAtoms::disabled) || (aAttribute == nsHTMLAtoms::readonly)) { - mTextField->SetAttribute(aAttribute, aValue); + mTextField->SetAttribute(aAttribute, aValue, aNotify); } - nsInputFileSuper::SetAttribute(aAttribute, aValue); + return nsInputFileSuper::SetAttribute(aAttribute, aValue, aNotify); } nsresult diff --git a/mozilla/layout/html/forms/src/nsInputFile.h b/mozilla/layout/html/forms/src/nsInputFile.h index 60f93f90d76..449f47ed57a 100644 --- a/mozilla/layout/html/forms/src/nsInputFile.h +++ b/mozilla/layout/html/forms/src/nsInputFile.h @@ -51,12 +51,13 @@ public: nsInputFile (nsIAtom* aTag, nsIFormManager* aManager); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); virtual PRInt32 GetMaxNumValues(); virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsString* aValues, nsString* aNames); diff --git a/mozilla/layout/html/forms/src/nsInputFrame.cpp b/mozilla/layout/html/forms/src/nsInputFrame.cpp index fa7a999f7b8..d0f9771f956 100644 --- a/mozilla/layout/html/forms/src/nsInputFrame.cpp +++ b/mozilla/layout/html/forms/src/nsInputFrame.cpp @@ -532,12 +532,12 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, aFrame->GetContent((nsIContent*&) content); nsAutoString valAttr; - nsContentAttr valStatus = eContentAttr_NotThere; + nsresult valStatus = NS_CONTENT_ATTR_NOT_THERE; if (nsnull != aSpec.mColValueAttr) { valStatus = ((nsHTMLTagContent*)content)->GetAttribute(aSpec.mColValueAttr, valAttr); } nsHTMLValue colAttr; - nsContentAttr colStatus = eContentAttr_NotThere; + nsresult colStatus = NS_CONTENT_ATTR_NOT_THERE; if (nsnull != aSpec.mColSizeAttr) { colStatus = content->GetAttribute(aSpec.mColSizeAttr, colAttr); } @@ -545,7 +545,7 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, // determine the width nscoord adjSize; - if (eContentAttr_HasValue == colStatus) { // col attr will provide width + if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width if (aSpec.mColSizeAttrInPixels) { adjSize = (colAttr.GetPixelValue() > 0) ? colAttr.GetPixelValue() : 15; aBounds.width = NSIntPixelsToTwips(adjSize, p2t); @@ -568,7 +568,7 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, aWidthExplicit = PR_TRUE; } else { - if (eContentAttr_HasValue == valStatus) { // use width of initial value + if (NS_CONTENT_ATTR_HAS_VALUE == valStatus) { // use width of initial value charWidth = GetTextSize(*aPresContext, aFrame, valAttr, aBounds); } else if (aSpec.mColDefaultValue) { // use default value @@ -587,11 +587,11 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, // determine the height nsHTMLValue rowAttr; - nsContentAttr rowStatus = eContentAttr_NotThere; + nsresult rowStatus = NS_CONTENT_ATTR_NOT_THERE; if (nsnull != aSpec.mRowSizeAttr) { rowStatus = content->GetAttribute(aSpec.mRowSizeAttr, rowAttr); } - if (eContentAttr_HasValue == rowStatus) { // row attr will provide height + if (NS_CONTENT_ATTR_HAS_VALUE == rowStatus) { // row attr will provide height PRInt32 rowAttrInt = ((rowAttr.GetUnit() == eHTMLUnit_Pixel) ? rowAttr.GetPixelValue() : rowAttr.GetIntValue()); adjSize = (rowAttrInt > 0) ? rowAttrInt : 1; if (0 == charWidth) { diff --git a/mozilla/layout/html/forms/src/nsInputRadio.cpp b/mozilla/layout/html/forms/src/nsInputRadio.cpp index ae3ed25a912..51857e47ecc 100644 --- a/mozilla/layout/html/forms/src/nsInputRadio.cpp +++ b/mozilla/layout/html/forms/src/nsInputRadio.cpp @@ -135,8 +135,9 @@ nsInputRadio::~nsInputRadio() { } -void nsInputRadio::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsInputRadio::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { float p2t = aPresContext->GetPixelsToTwips(); nscoord pad = NSIntPixelsToTwips(3, p2t); @@ -162,6 +163,8 @@ void nsInputRadio::MapAttributesInto(nsIStyleContext* aContext, nsInput::MapAttributesInto(aContext, aPresContext); } NS_IF_RELEASE(formMan); + + return NS_OK; } static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID); @@ -240,18 +243,21 @@ void nsInputRadio::GetType(nsString& aResult) const aResult = "radio"; } -void nsInputRadio::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) +NS_IMETHODIMP +nsInputRadio::SetAttribute(nsIAtom* aAttribute, + const nsString& aValue, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::checked) { mInitialChecked = PR_TRUE; mForcedChecked = PR_TRUE; } - nsInputRadioSuper::SetAttribute(aAttribute, aValue); + return nsInputRadioSuper::SetAttribute(aAttribute, aValue, aNotify); } -nsContentAttr nsInputRadio::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const +NS_IMETHODIMP +nsInputRadio::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const { aResult.Reset(); if (aAttribute == nsHTMLAtoms::checked) { diff --git a/mozilla/layout/html/forms/src/nsInputRadio.h b/mozilla/layout/html/forms/src/nsInputRadio.h index bf136f7e981..73c7d07e407 100644 --- a/mozilla/layout/html/forms/src/nsInputRadio.h +++ b/mozilla/layout/html/forms/src/nsInputRadio.h @@ -32,15 +32,16 @@ public: typedef nsInput nsInputRadioSuper; nsInputRadio (nsIAtom* aTag, nsIFormManager* aManager); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const; static const nsString* kTYPE; @@ -52,8 +53,8 @@ public: virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsString* aValues, nsString* aNames); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); virtual void Reset(); protected: diff --git a/mozilla/layout/html/forms/src/nsInputText.cpp b/mozilla/layout/html/forms/src/nsInputText.cpp index ac18bbb7d56..8b67057932f 100644 --- a/mozilla/layout/html/forms/src/nsInputText.cpp +++ b/mozilla/layout/html/forms/src/nsInputText.cpp @@ -219,7 +219,7 @@ nsInputTextFrame::GetDesiredSize(nsIPresContext* aPresContext, (kInputText_FileText == textType)) { nsHTMLValue sizeAttr; PRInt32 width = 21; - if (eContentAttr_HasValue == ((nsInput*)mContent)->GetAttribute(nsHTMLAtoms::size, sizeAttr)) { + if (NS_CONTENT_ATTR_HAS_VALUE == ((nsInput*)mContent)->GetAttribute(nsHTMLAtoms::size, sizeAttr)) { width = (sizeAttr.GetUnit() == eHTMLUnit_Pixel) ? sizeAttr.GetPixelValue() : sizeAttr.GetIntValue(); if (kBackwardMode == GetMode()) { width += 1; @@ -287,7 +287,7 @@ nsInputTextFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView) nsInputText* content; GetContent((nsIContent *&) content); nsAutoString valAttr; - nsContentAttr valStatus = ((nsHTMLTagContent *)content)->GetAttribute(nsHTMLAtoms::value, valAttr); + nsresult valStatus = ((nsHTMLTagContent *)content)->GetAttribute(nsHTMLAtoms::value, valAttr); text->SetText(valAttr); PRInt32 maxLength = content->GetMaxLength(); if (ATTR_NOTSET != maxLength) { @@ -386,7 +386,9 @@ void nsInputText::GetType(nsString& aResult) const } } -void nsInputText::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsInputText::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::maxlength) { CacheAttribute(aValue, ATTR_NOTSET, mMaxLength); @@ -397,11 +399,12 @@ void nsInputText::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) else if ((aAttribute == nsHTMLAtoms::cols) && (kInputText_Area == mType)) { CacheAttribute(aValue, ATTR_NOTSET, mNumCols); } - nsInputTextSuper::SetAttribute(aAttribute, aValue); + return nsInputTextSuper::SetAttribute(aAttribute, aValue, aNotify); } -nsContentAttr nsInputText::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const +NS_IMETHODIMP +nsInputText::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const { if (aAttribute == nsHTMLAtoms::maxlength) { return GetCacheAttribute(mMaxLength, aResult, eHTMLUnit_Integer); diff --git a/mozilla/layout/html/forms/src/nsInputText.h b/mozilla/layout/html/forms/src/nsInputText.h index 38cee90b2d4..c412ad20f17 100644 --- a/mozilla/layout/html/forms/src/nsInputText.h +++ b/mozilla/layout/html/forms/src/nsInputText.h @@ -39,15 +39,16 @@ public: typedef nsInput nsInputTextSuper; nsInputText (nsIAtom* aTag, nsIFormManager* aManager, nsInputTextType aType); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const; virtual PRInt32 GetMaxNumValues(); diff --git a/mozilla/layout/html/forms/src/nsSelect.cpp b/mozilla/layout/html/forms/src/nsSelect.cpp index 0d08ebe3f00..784a66faed4 100644 --- a/mozilla/layout/html/forms/src/nsSelect.cpp +++ b/mozilla/layout/html/forms/src/nsSelect.cpp @@ -89,17 +89,18 @@ public: typedef nsInput nsSelectSuper; nsSelect (nsIAtom* aTag, nsIFormManager* aFormMan); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); nsOption* GetNthOption(PRInt32 aIndex); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const; virtual PRInt32 GetMaxNumValues(); @@ -129,17 +130,18 @@ public: nsOption (nsIAtom* aTag); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const; + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const; virtual PRInt32 GetMaxNumValues(); @@ -254,9 +256,11 @@ nsSelectFrame::GetDesiredSize(nsIPresContext* aPresContext, // get the size of the longest option child PRInt32 maxWidth = 1; - PRInt32 numChildren = select->ChildCount(); + PRInt32 numChildren; + select->ChildCount(numChildren); for (int childX = 0; childX < numChildren; childX++) { - nsIContent* child = select->ChildAt(childX); + nsIContent* child; + select->ChildAt(childX, child); nsOption* option; nsresult result = child->QueryInterface(kOptionIID, (void**)&option); if (NS_OK == result) { @@ -292,7 +296,7 @@ nsSelectFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredLayoutSize.width = calcSize.width; // account for vertical scrollbar, if present - if (!widthExplicit && ((numRows < select->ChildCount()) || select->mIsComboBox)) { + if (!widthExplicit && ((numRows < numChildren) || select->mIsComboBox)) { float p2t = aPresContext->GetPixelsToTwips(); aDesiredLayoutSize.width += GetScrollbarWidth(p2t); } @@ -379,10 +383,12 @@ nsSelectFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView) list->SetFont(widgetFont); } - PRInt32 numChildren = select->ChildCount(); + PRInt32 numChildren; + select->ChildCount(numChildren); int optionX = -1; for (int childX = 0; childX < numChildren; childX++) { - nsIContent* child = select->ChildAt(childX); + nsIContent* child; + select->ChildAt(childX, child); nsOption* option; nsresult result = child->QueryInterface(kOptionIID, (void**)&option); if (NS_OK == result) { @@ -434,17 +440,20 @@ nsSelect::CreateFrame(nsIPresContext* aPresContext, return NS_OK; } -void nsSelect::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) +NS_IMETHODIMP +nsSelect::SetAttribute(nsIAtom* aAttribute, + const nsString& aValue, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::multiple) { mMultiple = PR_TRUE; } - nsSelectSuper::SetAttribute(aAttribute, aValue); + return nsSelectSuper::SetAttribute(aAttribute, aValue, aNotify); } -nsContentAttr nsSelect::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const +NS_IMETHODIMP +nsSelect::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const { aResult.Reset(); if (aAttribute == nsHTMLAtoms::multiple) { @@ -460,7 +469,9 @@ PRInt32 nsSelect::GetMaxNumValues() { if (mMultiple) { - return ChildCount(); + PRInt32 n; + ChildCount(n); + return n; } else { return 1; @@ -470,9 +481,11 @@ nsSelect::GetMaxNumValues() nsOption* nsSelect::GetNthOption(PRInt32 aIndex) { int optionX = -1; - PRInt32 numChildren = ChildCount(); + PRInt32 numChildren; + ChildCount(numChildren); for (int childX = 0; childX < numChildren; childX++) { - nsIContent* child = ChildAt(childX); + nsIContent* child; + ChildAt(childX, child); nsOption* option; nsresult result = child->QueryInterface(kOptionIID, (void**)&option); if (NS_OK == result) { @@ -558,7 +571,8 @@ nsSelect::Reset() { // PRBool allowMultiple; // super::GetAttribute(nsHTMLAtoms::multiple, allowMultiple); - PRInt32 numChildren = ChildCount(); + PRInt32 numChildren; + ChildCount(numChildren); nsIListWidget* list; nsresult stat = mWidget->QueryInterface(kListWidgetIID, (void **) &list); @@ -569,7 +583,8 @@ nsSelect::Reset() PRInt32 selIndex = -1; int optionX = -1; for (int childX = 0; childX < numChildren; childX++) { - nsIContent* child = ChildAt(childX); + nsIContent* child; + ChildAt(childX, child); nsOption* option; nsresult result = child->QueryInterface(kOptionIID, (void**)&option); if (NS_OK == result) { @@ -643,19 +658,24 @@ nsresult nsOption::QueryInterface(REFNSIID aIID, void** aInstancePtr) return nsInput::QueryInterface(aIID, aInstancePtr); } -void nsOption::SetAttribute(nsIAtom* aAttribute, - const nsString& aValue) +NS_IMETHODIMP +nsOption::SetAttribute(nsIAtom* aAttribute, + const nsString& aValue, + PRBool aNotify) { if (aAttribute == nsHTMLAtoms::selected) { mSelected = PR_TRUE; + // XXX aNotify + return NS_OK; } else { - nsOptionSuper::SetAttribute(aAttribute, aValue); + return nsOptionSuper::SetAttribute(aAttribute, aValue, aNotify); } } -nsContentAttr nsOption::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aResult) const +NS_IMETHODIMP +nsOption::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aResult) const { aResult.Reset(); if (aAttribute == nsHTMLAtoms::selected) { @@ -710,8 +730,8 @@ nsOption::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, } nsString valAttr; - nsContentAttr stat = nsHTMLTagContent::GetAttribute(nsHTMLAtoms::value, valAttr); - if (eContentAttr_HasValue == stat) { + nsresult stat = nsHTMLTagContent::GetAttribute(nsHTMLAtoms::value, valAttr); + if (NS_CONTENT_ATTR_HAS_VALUE == stat) { aValues[0] = valAttr; aNumValues = 1; return PR_TRUE; @@ -727,13 +747,11 @@ nsOption::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, } } -void HACK(nsSelect* aSel, PRInt32); - // FACTORY functions nsresult NS_NewHTMLSelect(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag, nsIFormManager* aFormMan, PRInt32 aHackIndex) + nsIAtom* aTag, nsIFormManager* aFormMan) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { @@ -741,11 +759,6 @@ NS_NewHTMLSelect(nsIHTMLContent** aInstancePtrResult, } nsIHTMLContent* it = new nsSelect(aTag, aFormMan); - - if (aHackIndex > 0) { - HACK((nsSelect*)it, aHackIndex); - } - if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -768,43 +781,3 @@ NS_NewHTMLOption(nsIHTMLContent** aInstancePtrResult, } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } - -void HACK(nsSelect* aSel, PRInt32 aIndex) -{ - char buf[100]; - - nsIAtom* nameAttr = NS_NewAtom("NAME"); - sprintf(&buf[0], "select %d", aIndex); - nsString name(&buf[0]); - aSel->SetAttribute(nameAttr, name); - nsIAtom* sizeAttr = NS_NewAtom("SIZE"); - int numOpt = 2; - if (aIndex == 1) { - nsString size("2"); - aSel->SetAttribute(sizeAttr, size); - } else if (aIndex == 2) { - nsString size("4"); - aSel->SetAttribute(sizeAttr, size); - nsIAtom* multAttr = NS_NewAtom("MULTIPLE"); - nsString mult("1"); - aSel->SetAttribute(multAttr, mult); - numOpt = 8; - } else { - nsString size("1"); - aSel->SetAttribute(sizeAttr, size); - } - - for (int i = 0; i < numOpt; i++) { - nsIAtom* atom = NS_NewAtom("OPTION"); - nsOption* option; - NS_NewHTMLOption((nsIHTMLContent**)&option, atom); - sprintf(&buf[0], "option %d", i); - nsString label(&buf[0]); - option->SetContent(label); - aSel->AppendChildTo(option, PR_FALSE); - } -} - - - - diff --git a/mozilla/layout/html/style/src/nsCSSStyleRule.cpp b/mozilla/layout/html/style/src/nsCSSStyleRule.cpp index 798fe8f243a..43280f8b622 100644 --- a/mozilla/layout/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/layout/html/style/src/nsCSSStyleRule.cpp @@ -169,7 +169,7 @@ public: nsIPresContext* aPresContext); virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; private: // These are not supported and are not implemented! @@ -1053,7 +1053,8 @@ static void ListSelector(FILE* out, const nsCSSSelector* aSelector) } } -void CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const { // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); @@ -1079,6 +1080,8 @@ void CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const fputs("{ null declaration }", out); } fputs("\n", out); + + return NS_OK; } NS_HTML nsresult diff --git a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp index c17c8d281eb..e40334568fe 100644 --- a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp @@ -402,15 +402,18 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, nsCSSSelector* aSelector, nsIContent* aContent) { PRBool result = PR_FALSE; - nsIAtom* contentTag = aContent->GetTag(); + nsIAtom* contentTag; + aContent->GetTag(contentTag); if ((nsnull == aSelector->mTag) || (aSelector->mTag == contentTag)) { if ((nsnull != aSelector->mClass) || (nsnull != aSelector->mID) || (nsnull != aSelector->mPseudoClass)) { nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - nsIAtom* contentClass = htmlContent->GetClass(); - nsIAtom* contentID = htmlContent->GetID(); + nsIAtom* contentClass; + htmlContent->GetClass(contentClass); + nsIAtom* contentID; + htmlContent->GetID(contentID); if ((nsnull == aSelector->mClass) || (aSelector->mClass == contentClass)) { if ((nsnull == aSelector->mID) || (aSelector->mID == contentID)) { if ((contentTag == nsHTMLAtoms::a) && (nsnull != aSelector->mPseudoClass)) { @@ -420,9 +423,9 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) && (nsnull != linkHandler)) { nsAutoString base, href; // XXX base?? - nsContentAttr attrState = htmlContent->GetAttribute("href", href); + nsresult attrState = htmlContent->GetAttribute("href", href); - if (eContentAttr_HasValue == attrState) { + if (NS_CONTENT_ATTR_HAS_VALUE == attrState) { nsIURL* docURL = nsnull; nsIDocument* doc = nsnull; aContent->GetDocument(doc); @@ -563,14 +566,15 @@ PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, BuildHash(); } ContentEnumData data(aPresContext, aContent, aParentFrame, aResults); - nsIAtom* tagAtom = aContent->GetTag(); + nsIAtom* tagAtom; + aContent->GetTag(tagAtom); nsIAtom* idAtom = nsnull; nsIAtom* classAtom = nsnull; nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - idAtom = htmlContent->GetID(); - classAtom = htmlContent->GetClass(); + htmlContent->GetID(idAtom); + htmlContent->GetClass(classAtom); NS_RELEASE(htmlContent); } diff --git a/mozilla/layout/html/style/src/nsHTMLAttributes.cpp b/mozilla/layout/html/style/src/nsHTMLAttributes.cpp index abdd9f00b7b..849942ed333 100644 --- a/mozilla/layout/html/style/src/nsHTMLAttributes.cpp +++ b/mozilla/layout/html/style/src/nsHTMLAttributes.cpp @@ -150,32 +150,29 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); + // nsIHTMLAttributes + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRInt32& aCount); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRInt32& aCount); + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRInt32& aCount); + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const; + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const; + NS_IMETHOD Count(PRInt32& aCount) const; + NS_IMETHOD SetID(nsIAtom* aID, PRInt32& aIndex); + NS_IMETHOD GetID(nsIAtom*& aResult) const; + NS_IMETHOD SetClass(nsIAtom* aClass, PRInt32& aIndex); + NS_IMETHOD GetClass(nsIAtom*& aResult) const; + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; + virtual PRBool Equals(const nsIStyleRule* aRule) const; virtual PRUint32 HashValue(void) const; - - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, const nsString& aValue); - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue = nsHTMLValue::kNull); - virtual PRInt32 UnsetAttribute(nsIAtom* aAttribute); - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const; - virtual PRInt32 Count(void) const; - - virtual PRInt32 SetID(nsIAtom* aID); - virtual nsIAtom* GetID(void) const; - virtual PRInt32 SetClass(nsIAtom* aClass); // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const; // XXX this will have to change for CSS2 - virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - /** - * Add this object's size information to the sizeof handler. - */ - NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; - private: HTMLAttributesImpl(const HTMLAttributesImpl& aCopy); HTMLAttributesImpl& operator=(const HTMLAttributesImpl& aCopy); @@ -321,19 +318,21 @@ PRUint32 HTMLAttributesImpl::HashValue(void) const return (PRUint32)this; } -PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRInt32& aCount) { if (nsHTMLAtoms::id == aAttribute) { nsIAtom* id = NS_NewAtom(aValue); - PRInt32 result = SetID(id); + nsresult rv = SetID(id, aCount); NS_RELEASE(id); - return result; + return rv; } if (nsHTMLAtoms::kClass == aAttribute) { nsIAtom* classA = NS_NewAtom(aValue); - PRInt32 result = SetClass(classA); + nsresult rv = SetClass(classA, aCount); NS_RELEASE(classA); - return result; + return rv; } HTMLAttribute* last = nsnull; @@ -342,37 +341,45 @@ PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aV while (nsnull != attr) { if (attr->mAttribute == aAttribute) { attr->mValue.SetStringValue(aValue); - return mCount; + aCount = mCount; + return NS_OK; } last = attr; attr = attr->mNext; } attr = new HTMLAttribute(aAttribute, aValue); + if (nsnull == attr) { + return NS_ERROR_OUT_OF_MEMORY; + } if (nsnull == last) { mFirst = attr; } else { last->mNext = attr; } - return ++mCount; + aCount = ++mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue) +NS_IMETHODIMP +HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRInt32& aCount) { if (nsHTMLAtoms::id == aAttribute) { nsAutoString buffer; nsIAtom* id = NS_NewAtom(aValue.GetStringValue(buffer)); - PRInt32 result = SetID(id); + nsresult rv = SetID(id, aCount); NS_RELEASE(id); - return result; + return rv; } if (nsHTMLAtoms::kClass == aAttribute) { nsAutoString buffer; nsIAtom* classA = NS_NewAtom(aValue.GetStringValue(buffer)); - PRInt32 result = SetClass(classA); + nsresult rv = SetClass(classA, aCount); NS_RELEASE(classA); - return result; + return rv; } HTMLAttribute* last = nsnull; @@ -381,29 +388,36 @@ PRInt32 HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& while (nsnull != attr) { if (attr->mAttribute == aAttribute) { attr->mValue = aValue; - return mCount; + aCount = mCount; + return NS_OK; } last = attr; attr = attr->mNext; } attr = new HTMLAttribute(aAttribute, aValue); + if (nsnull == attr) { + return NS_ERROR_OUT_OF_MEMORY; + } if (nsnull == last) { mFirst = attr; } else { last->mNext = attr; } - return ++mCount; + aCount = ++mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::UnsetAttribute(nsIAtom* aAttribute) +NS_IMETHODIMP +HTMLAttributesImpl::UnsetAttribute(nsIAtom* aAttribute, + PRInt32& aCount) { if (nsHTMLAtoms::id == aAttribute) { - return SetID (nsnull); + return SetID (nsnull, aCount); } if (nsHTMLAtoms::kClass == aAttribute) { - return SetClass (nsnull); + return SetClass (nsnull, aCount); } HTMLAttribute* prev = nsnull; @@ -424,34 +438,38 @@ PRInt32 HTMLAttributesImpl::UnsetAttribute(nsIAtom* aAttribute) prev = attr; attr = attr->mNext; } - return mCount; + aCount = mCount; + return NS_OK; } -nsContentAttr HTMLAttributesImpl::GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const +NS_IMETHODIMP +HTMLAttributesImpl::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const { aValue.Reset(); if (nsHTMLAtoms::id == aAttribute) { - nsIAtom* id = GetID(); + nsIAtom* id; + GetID(id); if (nsnull != id) { nsAutoString buffer; id->ToString(buffer); aValue.SetStringValue(buffer); NS_RELEASE(id); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } if (nsHTMLAtoms::kClass == aAttribute) { - nsIAtom* classA = GetClass(); + nsIAtom* classA; + GetClass(classA); if (nsnull != classA) { nsAutoString buffer; classA->ToString(buffer); aValue.SetStringValue(buffer); NS_RELEASE(classA); - return eContentAttr_HasValue; + return NS_CONTENT_ATTR_HAS_VALUE; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } HTMLAttribute* attr = mFirst; @@ -459,19 +477,24 @@ nsContentAttr HTMLAttributesImpl::GetAttribute(nsIAtom* aAttribute, while (nsnull != attr) { if (attr->mAttribute == aAttribute) { aValue = attr->mValue; - return ((attr->mValue.GetUnit() == eHTMLUnit_Null) ? eContentAttr_NoValue : eContentAttr_HasValue); + return (attr->mValue.GetUnit() == eHTMLUnit_Null) + ? NS_CONTENT_ATTR_NO_VALUE + : NS_CONTENT_ATTR_HAS_VALUE; } attr = attr->mNext; } - return eContentAttr_NotThere; + return NS_CONTENT_ATTR_NOT_THERE; } -PRInt32 HTMLAttributesImpl::GetAllAttributeNames(nsISupportsArray* aArray) const +NS_IMETHODIMP +HTMLAttributesImpl::GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const { NS_ASSERTION(nsnull != aArray, "null arg"); if (nsnull == aArray) { - return 0; + aCount = 0; + return NS_ERROR_NULL_POINTER; } if (nsnull != mID) { @@ -487,15 +510,19 @@ PRInt32 HTMLAttributesImpl::GetAllAttributeNames(nsISupportsArray* aArray) const aArray->AppendElement(attr->mAttribute); attr = attr->mNext; } - return mCount; + aCount = mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::Count(void) const +NS_IMETHODIMP +HTMLAttributesImpl::Count(PRInt32& aCount) const { - return mCount; + aCount = mCount; + return NS_OK; } -PRInt32 HTMLAttributesImpl::SetID(nsIAtom* aID) +NS_IMETHODIMP +HTMLAttributesImpl::SetID(nsIAtom* aID, PRInt32& aCount) { if (aID != mID) { if (nsnull != mID) { @@ -508,16 +535,20 @@ PRInt32 HTMLAttributesImpl::SetID(nsIAtom* aID) mCount++; } } - return mCount; + aCount = mCount; + return NS_OK; } -nsIAtom* HTMLAttributesImpl::GetID(void) const +NS_IMETHODIMP +HTMLAttributesImpl::GetID(nsIAtom*& aResult) const { NS_IF_ADDREF(mID); - return mID; + aResult = mID; + return NS_OK; } -PRInt32 HTMLAttributesImpl::SetClass(nsIAtom* aClass) +NS_IMETHODIMP +HTMLAttributesImpl::SetClass(nsIAtom* aClass, PRInt32& aCount) { if (aClass != mClass) { if (nsnull != mClass) { @@ -530,13 +561,16 @@ PRInt32 HTMLAttributesImpl::SetClass(nsIAtom* aClass) mCount++; } } - return mCount; + aCount = mCount; + return NS_OK; } -nsIAtom* HTMLAttributesImpl::GetClass(void) const +NS_IMETHODIMP +HTMLAttributesImpl::GetClass(nsIAtom*& aResult) const { NS_IF_ADDREF(mClass); - return mClass; + aResult = mClass; + return NS_OK; } void HTMLAttributesImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) @@ -558,7 +592,8 @@ HTMLAttributesImpl::SizeOf(nsISizeOfHandler* aHandler) const return NS_OK; } -void HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const { HTMLAttribute* attr = mFirst; nsString buffer; @@ -570,6 +605,7 @@ void HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const fputs("\n", out); attr = attr->mNext; } + return NS_OK; } extern NS_HTML nsresult diff --git a/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp index 7b76e770fa5..ec655f2b333 100644 --- a/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp @@ -175,7 +175,7 @@ PRInt32 HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, // just get the one and only style rule from the content's STYLE attribute if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { nsHTMLValue value; - if (eContentAttr_HasValue == htmlContent->GetAttribute(nsHTMLAtoms::style, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetAttribute(nsHTMLAtoms::style, value)) { if (eHTMLUnit_ISupports == value.GetUnit()) { nsISupports* rule = value.GetISupportsValue(); if (nsnull != rule) { diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp index 45b0719ba65..316a253418d 100644 --- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -51,7 +51,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; nscolor mColor; }; @@ -86,8 +86,10 @@ void HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPr } } -void HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const { + return NS_OK; } // ----------------------------------------------------------- @@ -295,7 +297,8 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, if (aContent != parentContent) { // if not a pseudo frame... nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - nsIAtom* tag = htmlContent->GetTag(); + nsIAtom* tag; + htmlContent->GetTag(tag); // if we have anchor colors, check if this is an anchor with an href if (tag == nsHTMLAtoms::a) { if ((nsnull != mLinkRule) || (nsnull != mVisitedRule) || (nsnull != mActiveRule)) { @@ -305,9 +308,9 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) && (nsnull != linkHandler)) { nsAutoString base, href; // XXX base?? - nsContentAttr attrState = htmlContent->GetAttribute("href", href); + nsresult attrState = htmlContent->GetAttribute("href", href); - if (eContentAttr_HasValue == attrState) { + if (NS_CONTENT_ATTR_HAS_VALUE == attrState) { nsIURL* docURL = nsnull; nsIDocument* doc = nsnull; aContent->GetDocument(doc); @@ -375,8 +378,8 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, } // end TD/TH tag // just get the one and only style rule from the content - nsIStyleRule* rule = htmlContent->GetStyleRule(); - + nsIStyleRule* rule; + htmlContent->GetStyleRule(rule); if (nsnull != rule) { aResults->AppendElement(rule); NS_RELEASE(rule); diff --git a/mozilla/layout/html/style/src/nsICSSStyleRule.h b/mozilla/layout/html/style/src/nsICSSStyleRule.h index 153397fe876..2d1fa38ee98 100644 --- a/mozilla/layout/html/style/src/nsICSSStyleRule.h +++ b/mozilla/layout/html/style/src/nsICSSStyleRule.h @@ -54,9 +54,6 @@ public: class nsICSSStyleRule : public nsIStyleRule { public: - virtual PRBool Equals(const nsIStyleRule* aRule) const = 0; - virtual PRUint32 HashValue(void) const = 0; - virtual nsCSSSelector* FirstSelector(void) = 0; virtual void AddSelector(const nsCSSSelector& aSelector) = 0; virtual void DeleteSelector(nsCSSSelector* aSelector) = 0; @@ -66,8 +63,6 @@ public: virtual PRInt32 GetWeight(void) const = 0; virtual void SetWeight(PRInt32 aWeight) = 0; - - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; extern NS_HTML nsresult diff --git a/mozilla/layout/html/style/src/nsIHTMLAttributes.h b/mozilla/layout/html/style/src/nsIHTMLAttributes.h index 1c867644735..b2372ebfc5a 100644 --- a/mozilla/layout/html/style/src/nsIHTMLAttributes.h +++ b/mozilla/layout/html/style/src/nsIHTMLAttributes.h @@ -35,27 +35,38 @@ class nsIHTMLContent; class nsIHTMLAttributes : public nsISupports { public: - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, const nsString& aValue) = 0; - virtual PRInt32 SetAttribute(nsIAtom* aAttribute, - const nsHTMLValue& aValue = nsHTMLValue::kNull) = 0; - virtual PRInt32 UnsetAttribute(nsIAtom* aAttribute) = 0; - virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const = 0; - virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const = 0; + // XXX why is this part of the interface? + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRInt32& aCount) = 0; - virtual PRInt32 Count(void) const = 0; + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRInt32& aCount) = 0; - virtual PRInt32 SetID(nsIAtom* aID) = 0; - virtual nsIAtom* GetID(void) const = 0; - virtual PRInt32 SetClass(nsIAtom* aClass) = 0; // XXX this will have to change for CSS2 - virtual nsIAtom* GetClass(void) const = 0; // XXX this will have to change for CSS2 + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRInt32& aCount) = 0; + + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const = 0; + + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const = 0; + + NS_IMETHOD Count(PRInt32& aCount) const = 0; + + NS_IMETHOD SetID(nsIAtom* aID, PRInt32& aIndex) = 0; + + NS_IMETHOD GetID(nsIAtom*& aResult) const = 0; + + NS_IMETHOD SetClass(nsIAtom* aClass, PRInt32& aIndex) = 0; // XXX this will have to change for CSS2 + + NS_IMETHOD GetClass(nsIAtom*& aResult) const = 0; // XXX this will have to change for CSS2 /** * Add this object's size information to the sizeof handler. */ NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; extern NS_HTML nsresult diff --git a/mozilla/layout/html/table/src/nsTableCaption.cpp b/mozilla/layout/html/table/src/nsTableCaption.cpp index a60637e6313..61499af76d8 100644 --- a/mozilla/layout/html/table/src/nsTableCaption.cpp +++ b/mozilla/layout/html/table/src/nsTableCaption.cpp @@ -76,21 +76,23 @@ int nsTableCaption::GetType() return nsITableContent::kTableCaptionType; } -void nsTableCaption::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsTableCaption::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { nsHTMLValue val; if (aAttribute == nsHTMLAtoms::align) { if (ParseTableCaptionAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } - nsTableContent::SetAttribute(aAttribute, aValue); + return nsTableContent::SetAttribute(aAttribute, aValue, aNotify); } -void nsTableCaption::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsTableCaption::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); @@ -121,10 +123,11 @@ void nsTableCaption::MapAttributesInto(nsIStyleContext* aContext, textStyle->mTextAlign = alignValue; } } + return NS_OK; } -nsresult +NS_IMETHODIMP nsTableCaption::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/table/src/nsTableCaption.h b/mozilla/layout/html/table/src/nsTableCaption.h index fecc8a10b3e..248ebe5b02a 100644 --- a/mozilla/layout/html/table/src/nsTableCaption.h +++ b/mozilla/layout/html/table/src/nsTableCaption.h @@ -59,16 +59,17 @@ public: virtual int GetType(); /* ---------- overrides ---------- */ - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); /** @see nsIHTMLContent::CreateFrame */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); }; #endif diff --git a/mozilla/layout/html/table/src/nsTableCell.cpp b/mozilla/layout/html/table/src/nsTableCell.cpp index ad29429db94..5fdaa340f5d 100644 --- a/mozilla/layout/html/table/src/nsTableCell.cpp +++ b/mozilla/layout/html/table/src/nsTableCell.cpp @@ -180,66 +180,61 @@ nsTableCell::CreateFrame(nsIPresContext* aPresContext, return rv; } -void nsTableCell::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsTableCell::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { NS_PRECONDITION(nsnull!=aAttribute, "bad attribute arg"); nsHTMLValue val; if ((aAttribute == nsHTMLAtoms::align) && ParseDivAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if ((aAttribute == nsHTMLAtoms::valign) && ParseAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::background) { nsAutoString href(aValue); href.StripWhitespace(); - nsHTMLTagContent::SetAttribute(aAttribute, href); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, href, aNotify); } if (aAttribute == nsHTMLAtoms::bgcolor) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::rowspan) { ParseValue(aValue, 1, 10000, val, eHTMLUnit_Integer); SetRowSpan(val.GetIntValue()); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::colspan) { ParseValue(aValue, 1, 1000, val, eHTMLUnit_Integer); SetColSpan(val.GetIntValue()); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::width) { ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::height) { ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if (aAttribute == nsHTMLAtoms::nowrap) { val.SetEmptyValue(); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } + // Use default attribute catching code - nsTableContent::SetAttribute(aAttribute, aValue); + return nsTableContent::SetAttribute(aAttribute, aValue, aNotify); } -void nsTableCell::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsTableCell::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); @@ -299,6 +294,8 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext, textStyle->mWhiteSpace = NS_STYLE_WHITESPACE_NOWRAP; } } + + return NS_OK; } void @@ -309,7 +306,7 @@ nsTableCell::MapBackgroundAttributesInto(nsIStyleContext* aContext, nsStyleColor* color=nsnull; // background - if (eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::background, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::background, value)) { if (eHTMLUnit_String == value.GetUnit()) { color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); SetBackgroundFromAttribute(color, &value); @@ -317,7 +314,7 @@ nsTableCell::MapBackgroundAttributesInto(nsIStyleContext* aContext, } // bgcolor - if (eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::bgcolor, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) { if (eHTMLUnit_Color == value.GetUnit()) { if (nsnull==color) color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); @@ -361,15 +358,15 @@ void nsTableCell::SetBackgroundFromAttribute(nsStyleColor *aColor, nsHTMLValue * aColor->mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY; } -nsContentAttr +NS_IMETHODIMP nsTableCell::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { - nsContentAttr ca = eContentAttr_NotThere; + nsresult ca = NS_CONTENT_ATTR_NOT_THERE; if (aAttribute == nsHTMLAtoms::valign) { AlignParamToString(aValue, aResult); - ca = eContentAttr_HasValue; + ca = NS_CONTENT_ATTR_HAS_VALUE; } else { ca = nsTableContent::AttributeToString(aAttribute, aValue, aResult); diff --git a/mozilla/layout/html/table/src/nsTableCell.h b/mozilla/layout/html/table/src/nsTableCell.h index da289383100..35633e061f0 100644 --- a/mozilla/layout/html/table/src/nsTableCell.h +++ b/mozilla/layout/html/table/src/nsTableCell.h @@ -87,15 +87,20 @@ public: virtual int GetType(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; virtual void MapBackgroundAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); @@ -136,10 +141,6 @@ public: protected: virtual void Init(); - - virtual nsContentAttr AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; }; #endif diff --git a/mozilla/layout/html/table/src/nsTableCol.cpp b/mozilla/layout/html/table/src/nsTableCol.cpp index 9957028e278..0c9c7e8f90a 100644 --- a/mozilla/layout/html/table/src/nsTableCol.cpp +++ b/mozilla/layout/html/table/src/nsTableCol.cpp @@ -90,41 +90,42 @@ nsrefcnt nsTableCol::Release(void) return mRefCnt; } -void nsTableCol::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsTableCol::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { nsHTMLValue val; if (aAttribute == nsHTMLAtoms::width) { ParseValueOrPercentOrProportional(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if ( aAttribute == nsHTMLAtoms::repeat) { ParseValue(aValue, 0, val, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); SetRepeat(val.GetIntValue()); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::align) { nsHTMLValue val; if (ParseTableAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } else if (aAttribute == nsHTMLAtoms::valign) { nsHTMLValue val; if (ParseTableAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } // unknown attributes are handled by my parent - nsTableContent::SetAttribute(aAttribute, aValue); + return nsTableContent::SetAttribute(aAttribute, aValue, aNotify); } -void nsTableCol::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsTableCol::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); @@ -168,11 +169,12 @@ void nsTableCol::MapAttributesInto(nsIStyleContext* aContext, textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated); } } + return NS_OK; } -nsresult +NS_IMETHODIMP nsTableCol::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/table/src/nsTableCol.h b/mozilla/layout/html/table/src/nsTableCol.h index 590c1a3352e..f260561ac18 100644 --- a/mozilla/layout/html/table/src/nsTableCol.h +++ b/mozilla/layout/html/table/src/nsTableCol.h @@ -75,16 +75,17 @@ public: /** returns nsITableContent::kTableCellType */ virtual int GetType(); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); /** @see nsIHTMLContent::CreateFrame */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** return the number of columns this content object represents. always >= 1*/ virtual int GetRepeat (); diff --git a/mozilla/layout/html/table/src/nsTableColGroup.cpp b/mozilla/layout/html/table/src/nsTableColGroup.cpp index a390d0300b4..8c3c1348608 100644 --- a/mozilla/layout/html/table/src/nsTableColGroup.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroup.cpp @@ -88,12 +88,14 @@ int nsTableColGroup::GetColumnCount () { if (0 == mColCount) { - int count = ChildCount (); + int count; + ChildCount (count); if (0 < count) { for (int index = 0; index < count; index++) { - nsIContent * child = ChildAt (index); // child: REFCNT++ + nsIContent * child; + ChildAt (index, child); // child: REFCNT++ NS_ASSERTION(nsnull!=child, "bad child"); // is child a column? nsTableContent *tableContent = (nsTableContent *)child; @@ -143,10 +145,12 @@ nsTableColGroup::AppendChildTo (nsIContent *aContent, PRBool aNotify) * and if we already have an implicit column for this actual column, * then replace the implicit col with this actual col. */ - PRInt32 childCount = ChildCount(); + PRInt32 childCount; + ChildCount(childCount); for (PRInt32 colIndex=0; colIndexIsSynthetic(colIsImplicit); @@ -201,9 +205,11 @@ NS_IMETHODIMP nsTableColGroup::ReplaceChildAt (nsIContent * aContent, PRInt32 aIndex, PRBool aNotify) { + PRInt32 numKids; + ChildCount(numKids); NS_ASSERTION(nsnull!=aContent, "bad arg"); - NS_ASSERTION((0<=aIndex && ChildCount()>aIndex), "bad arg"); - if ((nsnull==aContent) || !(0<=aIndex && ChildCount()>aIndex)) + NS_ASSERTION((0<=aIndex && numKids>aIndex), "bad arg"); + if ((nsnull==aContent) || !(0<=aIndex && numKids>aIndex)) return PR_FALSE; // is aContent a TableRow? @@ -216,7 +222,8 @@ nsTableColGroup::ReplaceChildAt (nsIContent * aContent, PRInt32 aIndex, return NS_OK; } - nsIContent * lastChild = ChildAt (aIndex); // lastChild : REFCNT++ + nsIContent * lastChild; + ChildAt (aIndex, lastChild); // lastChild : REFCNT++ NS_ASSERTION(nsnull!=lastChild, "bad child"); nsresult result = nsTableContent::ReplaceChildAt (aContent, aIndex, aNotify); if (NS_OK==result) @@ -238,8 +245,14 @@ nsTableColGroup::ReplaceChildAt (nsIContent * aContent, PRInt32 aIndex, NS_IMETHODIMP nsTableColGroup::RemoveChildAt (PRInt32 aIndex, PRBool aNotify) { - NS_ASSERTION((0<=aIndex && ChildCount()>aIndex), "bad arg"); - nsIContent * lastChild = ChildAt (aIndex); // lastChild: REFCNT++ +#ifdef NS_DEBUG + PRInt32 numKids; + ChildCount(numKids); + NS_ASSERTION((0<=aIndex && numKids>aIndex), "bad arg"); +#endif + + nsIContent * lastChild; + ChildAt (aIndex, lastChild); // lastChild: REFCNT++ NS_ASSERTION(nsnull!=lastChild, "bad child"); nsresult result = nsTableContent::RemoveChildAt (aIndex, aNotify); if (NS_OK==result) @@ -275,40 +288,41 @@ PRBool nsTableColGroup::IsCol(nsIContent * aContent) const return result; } -void nsTableColGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsTableColGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { nsHTMLValue val; if (aAttribute == nsHTMLAtoms::width) { ParseValueOrPercentOrProportional(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if ( aAttribute == nsHTMLAtoms::span) { ParseValue(aValue, 0, val, eHTMLUnit_Integer); - nsHTMLTagContent::SetAttribute(aAttribute, val); SetSpan(val.GetIntValue()); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::align) { nsHTMLValue val; if (ParseTableAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } else if (aAttribute == nsHTMLAtoms::valign) { nsHTMLValue val; if (ParseTableAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } - nsTableContent::SetAttribute(aAttribute, aValue); + return nsTableContent::SetAttribute(aAttribute, aValue, aNotify); } -void nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); @@ -352,9 +366,10 @@ void nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext, textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated); } } + return NS_OK; } -nsresult +NS_IMETHODIMP nsTableColGroup::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, diff --git a/mozilla/layout/html/table/src/nsTableColGroup.h b/mozilla/layout/html/table/src/nsTableColGroup.h index 5610d1c2d35..bb209e4f91a 100644 --- a/mozilla/layout/html/table/src/nsTableColGroup.h +++ b/mozilla/layout/html/table/src/nsTableColGroup.h @@ -76,16 +76,17 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); /** @see nsIHTMLContent::CreateFrame */ - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** returns nsITableContent::kTableColGroupType */ virtual int GetType(); @@ -171,7 +172,9 @@ inline void nsTableColGroup::SetStartColumnIndex (int aIndex) inline void nsTableColGroup::SetSpan (int aSpan) { mSpan = aSpan; - if (0 < ChildCount ()) // span is only relevant if we don't have children + PRInt32 n; + ChildCount (n); + if (0 < n) // span is only relevant if we don't have children ResetColumns (); } diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp index d665e896107..d2f7cd02537 100644 --- a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp @@ -75,7 +75,8 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, for (;;) { // get the next content child, breaking if there is none - nsIContentPtr kid = mContent->ChildAt(kidIndex); // kid: REFCNT++ + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); // kid: REFCNT++ if (kid.IsNull()) { break; } diff --git a/mozilla/layout/html/table/src/nsTableContent.cpp b/mozilla/layout/html/table/src/nsTableContent.cpp index f0bb6081d8b..ecc584a13ae 100644 --- a/mozilla/layout/html/table/src/nsTableContent.cpp +++ b/mozilla/layout/html/table/src/nsTableContent.cpp @@ -110,10 +110,12 @@ void nsTableContent::SetTableForChildren(nsTablePart *aTable) { if (aTable != nsnull) { - PRInt32 count = ChildCount(); + PRInt32 count; + ChildCount(count); for (PRInt32 index = 0; index < count; index++) { - nsIContent* child = ChildAt(index); + nsIContent* child; + ChildAt(index, child); SetTableForTableContent(child,aTable); NS_RELEASE(child); } @@ -157,11 +159,13 @@ void nsTableContent::SetTableForTableContent(nsIContent* aContent, nsTablePart * /* ----- overridable methods from nsHTMLContainer ----- */ -void nsTableContent::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +nsTableContent::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; for (i = aIndent; --i >= 0; ) fputs(" ", out); - nsIAtom* tag = GetTag(); + nsIAtom* tag; + GetTag(tag); if (tag != nsnull) { nsAutoString buf; tag->ToString(buf); @@ -177,16 +181,21 @@ void nsTableContent::List(FILE* out, PRInt32 aIndent) const fprintf(out, " RefCount=%d<%s\n", mRefCnt, isImplicitString); - if (CanContainChildren()) { - PRInt32 kids = ChildCount(); + PRBool canHaveKids; + CanContainChildren(canHaveKids); + if (canHaveKids) { + PRInt32 kids; + ChildCount(kids); for (i = 0; i < kids; i++) { - nsIContent* kid = ChildAt(i); + nsIContent* kid; + ChildAt(i, kid); kid->List(out, aIndent + 1); NS_RELEASE(kid); } } for (i = aIndent; --i >= 0; ) fputs(" ", out); fputs(">\n", out); + return NS_OK; } NS_IMETHODIMP @@ -202,7 +211,8 @@ nsTableContent::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) NS_IMETHODIMP nsTableContent::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { - nsIContent* child = ChildAt(aIndex); + nsIContent* child; + ChildAt(aIndex, child); nsresult rv = nsHTMLContainer::ReplaceChildAt(aKid, aIndex, aNotify); if (NS_OK == rv) { @@ -226,7 +236,8 @@ nsTableContent::AppendChildTo(nsIContent* aKid, PRBool aNotify) NS_IMETHODIMP nsTableContent::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { - nsTableContent* child = (nsTableContent*)ChildAt(aIndex); + nsTableContent* child; + ChildAt(aIndex, (nsIContent*&) child); nsresult rv = nsHTMLContainer::RemoveChildAt(aIndex, aNotify); if (NS_OK == rv) SetTableForTableContent(child,nsnull); diff --git a/mozilla/layout/html/table/src/nsTableContent.h b/mozilla/layout/html/table/src/nsTableContent.h index dc77d69cc9b..4af0813b51a 100644 --- a/mozilla/layout/html/table/src/nsTableContent.h +++ b/mozilla/layout/html/table/src/nsTableContent.h @@ -29,7 +29,7 @@ * within a table. * * @author sclark - * @version $Revision: 3.7 $ + * @version $Revision: 3.8 $ * @see */ class nsTableContent : public nsHTMLContainer, public nsITableContent @@ -96,7 +96,7 @@ public: virtual int GetType()=0; /** debug method prints out this and all child frames */ - void List(FILE* out, PRInt32 aIndent) const; + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index ed61217a0e5..495b5a12152 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -1526,7 +1526,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nscoord maxAscent = 0; nscoord maxDescent = 0; PRInt32 kidIndex = 0; - PRInt32 lastIndex = mContent->ChildCount(); + PRInt32 lastIndex; + mContent->ChildCount(lastIndex); PRInt32 contentOffset=0; nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */ @@ -1550,7 +1551,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, * TBody, in order */ for (;;) { - nsIContentPtr kid = mContent->ChildAt(kidIndex); // kid: REFCNT++ + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); // kid: REFCNT++ if (kid.IsNull()) { result = NS_FRAME_COMPLETE; break; @@ -1698,7 +1700,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext, nsSize kidMaxSize(0,0); PRInt32 kidIndex = 0; - PRInt32 lastIndex = c->ChildCount(); + PRInt32 lastIndex; + c->ChildCount(lastIndex); nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */ #ifdef NS_DEBUG @@ -1722,16 +1725,19 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext, // Did we successfully reflow our mapped children? if (PR_TRUE == reflowMappedOK) { // Any space left? + PRInt32 numKids; + mContent->ChildCount(numKids); if (state.availSize.height <= 0) { // No space left. Don't try to pull-up children or reflow unmapped - if (NextChildOffset() < mContent->ChildCount()) { + if (NextChildOffset() < numKids) { status = NS_FRAME_NOT_COMPLETE; } - } else if (NextChildOffset() < mContent->ChildCount()) { + } else if (NextChildOffset() < numKids) { // Try and pull-up some children from a next-in-flow if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) { // If we still have unmapped children then create some new frames - if (NextChildOffset() < mContent->ChildCount()) { + mContent->ChildCount(numKids); + if (NextChildOffset() < numKids) { status = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize); } } else { @@ -2366,7 +2372,8 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, LastChild(prevKidFrame); for (;;) { // Get the next content object - nsIContentPtr kid = mContent->ChildAt(kidIndex); + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); if (kid.IsNull()) { result = NS_FRAME_COMPLETE; break; @@ -2882,7 +2889,8 @@ nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, nsIContent *content = nsnull; rg->GetContent(content); // content: REFCNT++ NS_ASSERTION(nsnull!=content, "bad frame, returned null content."); - nsIAtom * rgTag = content->GetTag(); + nsIAtom * rgTag; + content->GetTag(rgTag); // if we've found a header or a footer, replicate it if (tHeadTag==rgTag || tFootTag==rgTag) { @@ -2909,6 +2917,7 @@ nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, duplicateFrame->SetNextSibling(bodyRowGroupFromOverflow); lastSib = duplicateFrame; } + NS_IF_RELEASE(rgTag); NS_RELEASE(content); // content: REFCNT-- // get the next row group rg->GetNextSibling(rg); @@ -3055,7 +3064,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) nsHTMLValue border_value; - nsContentAttr border_result; + nsresult border_result; nscoord padding = 0; nscoord spacing = 0; @@ -3072,7 +3081,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing); border_result = table->GetAttribute(nsHTMLAtoms::border,border_value); - if (border_result == eContentAttr_HasValue) + if (border_result == NS_CONTENT_ATTR_HAS_VALUE) { PRInt32 intValue = 0; diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index bea7e691974..09e955bb369 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -608,7 +608,8 @@ nsresult nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext) // ignore all but the first for (PRInt32 kidIndex = 0; /* nada */ ; kidIndex++) { - nsIContentPtr caption = mContent->ChildAt(kidIndex); + nsIContentPtr caption; + mContent->ChildAt(kidIndex, caption.AssignRef()); if (PR_TRUE==caption.IsNull()) { break; } diff --git a/mozilla/layout/html/table/src/nsTablePart.cpp b/mozilla/layout/html/table/src/nsTablePart.cpp index e46229f51f6..4847ba67c54 100644 --- a/mozilla/layout/html/table/src/nsTablePart.cpp +++ b/mozilla/layout/html/table/src/nsTablePart.cpp @@ -198,10 +198,12 @@ nsTablePart::AppendChildTo (nsIContent * aContent, PRBool aNotify) } // find last row group, if ! implicit, make one, append there nsTableRowGroup *group = nsnull; - int index = ChildCount (); + int index; + ChildCount (index); while ((0 < index) && (nsnull==group)) { - nsIContent *child = ChildAt (--index); // child: REFCNT++ + nsIContent *child; + ChildAt (--index, child); // child: REFCNT++ if (nsnull != child) { nsTableContent * content = (nsTableContent *)child; @@ -265,7 +267,10 @@ nsTablePart::AppendChildTo (nsIContent * aContent, PRBool aNotify) { if (gsDebug==PR_TRUE) printf ("nsTablePart::AppendChildTo -- content not handled!!!\n"); nsTableCaption *caption = nsnull; - nsIContent *lastChild = ChildAt (ChildCount() - 1); // lastChild: REFCNT++ + nsIContent *lastChild; + PRInt32 numKids; + ChildCount(numKids); + ChildAt (numKids - 1, lastChild); // lastChild: REFCNT++ if (nsnull != lastChild) { nsTableContent * content = (nsTableContent *)lastChild; @@ -320,9 +325,11 @@ NS_IMETHODIMP nsTablePart::ReplaceChildAt (nsIContent *aContent, PRInt32 aIndex, PRBool aNotify) { + PRInt32 numKids; + ChildCount(numKids); NS_PRECONDITION(nsnull!=aContent, "bad aContent arg to ReplaceChildAt"); - NS_PRECONDITION(0<=aIndex && aIndexGetTag(); - int childCount = ChildCount (); + nsIAtom * rowGroupTag; + aContent->GetTag(rowGroupTag); + PRInt32 childCount; + ChildCount (childCount); nsIAtom * tHeadTag = NS_NewAtom(kRowGroupHeadTagString); // tHeadTag: REFCNT++ nsIAtom * tFootTag = NS_NewAtom(kRowGroupFootTagString); // tFootTag: REFCNT++ nsIAtom * tBodyTag = NS_NewAtom(kRowGroupBodyTagString); // tBodyTag: REFCNT++ for (childIndex = 0; childIndex < childCount; childIndex++) { nsITableContent *tableContentInterface = nsnull; - nsIContent * child = ChildAt(childIndex); // tableChild: REFCNT++ + nsIContent * child; + ChildAt(childIndex, child); // tableChild: REFCNT++ nsresult rv = child->QueryInterface(kITableContentIID, (void **)&tableContentInterface); // tableContentInterface: REFCNT++ if (NS_FAILED(rv)) @@ -415,7 +429,9 @@ PRBool nsTablePart::AppendRowGroup (nsTableRowGroup *aContent) // if we've found a row group, our action depends on what kind of row group else if (tableChildType == nsITableContent::kTableRowGroupType) { - nsIAtom * tableChildTag = tableChild->GetTag(); + // XXX we are leaking tableChildTag + nsIAtom * tableChildTag; + tableChild->GetTag(tableChildTag); NS_RELEASE(child); // tableChild: REFCNT-- (c) NS_RELEASE(tableContentInterface); // tableContentInterface: REFCNT-- // if aContent is a header and the current child is a header, keep going @@ -478,10 +494,12 @@ PRBool nsTablePart::AppendColGroup(nsTableColGroup *aContent) // find the last column group and insert this column group after it. // if there is no column group already in the table, make this the first child // after any caption - int childCount = ChildCount (); + PRInt32 childCount; + ChildCount (childCount); for (childIndex = 0; childIndex < childCount; childIndex++) { - nsIContent *child = ChildAt(childIndex); // child: REFCNT++ + nsIContent *child; + ChildAt(childIndex, child); // child: REFCNT++ nsITableContent *tableContentInterface = nsnull; nsresult rv = child->QueryInterface(kITableContentIID, (void **)&tableContentInterface); // tableContentInterface: REFCNT++ @@ -535,11 +553,13 @@ PRBool nsTablePart::AppendColumn(nsTableCol *aContent) // find last col group, if ! implicit, make one, append there nsTableColGroup *group = nsnull; PRBool foundColGroup = PR_FALSE; - int index = ChildCount (); + PRInt32 index; + ChildCount (index); while ((0 < index) && (PR_FALSE==foundColGroup)) { nsITableContent *tableContentInterface = nsnull; - nsIContent *child = ChildAt (--index); // child: REFCNT++ + nsIContent *child; + ChildAt (--index, child); // child: REFCNT++ nsresult rv = child->QueryInterface(kITableContentIID, (void **)&tableContentInterface); // tableContentInterface: REFCNT++ NS_RELEASE(child); // tableChild: REFCNT-- (a) @@ -585,11 +605,13 @@ PRBool nsTablePart::AppendCaption(nsTableCaption *aContent) printf ("nsTablePart::AppendCaption -- adding a caption.\n"); // find the last caption and insert this caption after it. // if there is no caption already in the table, make this the first child - int childCount = ChildCount (); + PRInt32 childCount; + ChildCount (childCount); for (childIndex = 0; childIndex < childCount; childIndex++) { nsITableContent *tableContentInterface = nsnull; - nsIContent *child = ChildAt (childIndex); // child: REFCNT++ + nsIContent *child; + ChildAt (childIndex, child); // child: REFCNT++ nsresult rv = child->QueryInterface(kITableContentIID, (void **)&tableContentInterface); // tableContentInterface: REFCNT++ NS_RELEASE(child); // tableChild: REFCNT-- (a) @@ -630,7 +652,9 @@ nsTablePart::CreateFrame(nsIPresContext* aPresContext, return rv; } -void nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { nsHTMLValue val; @@ -638,8 +662,7 @@ void nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) if (aAttribute == nsHTMLAtoms::width) { ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if ( aAttribute == nsHTMLAtoms::cols) { // it'll either be empty, or have an integer value @@ -652,8 +675,7 @@ void nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) { ParseValue(aValue, 0, val, eHTMLUnit_Integer); } - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if ( aAttribute == nsHTMLAtoms::border) { @@ -667,42 +689,38 @@ void nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) { ParseValue(aValue, 0, val, eHTMLUnit_Pixel); } - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::cellspacing || aAttribute == nsHTMLAtoms::cellpadding) { ParseValue(aValue, 0, val, eHTMLUnit_Pixel); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::bgcolor) { ParseColor(aValue, val); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } else if (aAttribute == nsHTMLAtoms::align) { if (ParseTableAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - return; } /* HTML 4 attributes */ // TODO: only partially implemented else if (aAttribute == nsHTMLAtoms::summary) { val.SetStringValue(aValue); - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } // Use default attribute catching code - nsHTMLTagContent::SetAttribute(aAttribute, aValue); + return nsHTMLTagContent::SetAttribute(aAttribute, aValue, aNotify); } -void nsTablePart::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsTablePart::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); @@ -780,6 +798,8 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext, //background: color MapBackgroundAttributesInto(aContext, aPresContext); + + return NS_OK; } void nsTablePart::GetTableBorder(nsIHTMLContent* aContent, diff --git a/mozilla/layout/html/table/src/nsTablePart.h b/mozilla/layout/html/table/src/nsTablePart.h index 64ccc822718..a7e3a3121bd 100644 --- a/mozilla/layout/html/table/src/nsTablePart.h +++ b/mozilla/layout/html/table/src/nsTablePart.h @@ -69,10 +69,11 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); - virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); - virtual void MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); /* overrides from nsHTMLContainer */ @@ -82,10 +83,10 @@ public: NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify); NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify); - virtual nsresult CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); static void GetTableBorder(nsIHTMLContent* aContent, diff --git a/mozilla/layout/html/table/src/nsTableRow.cpp b/mozilla/layout/html/table/src/nsTableRow.cpp index e84695ed578..201722f6e09 100644 --- a/mozilla/layout/html/table/src/nsTableRow.cpp +++ b/mozilla/layout/html/table/src/nsTableRow.cpp @@ -169,9 +169,11 @@ nsTableRow::ReplaceChildAt (nsIContent *aContent, PRInt32 aIndex, { nsresult rv = NS_OK; + PRInt32 numKids; + ChildCount(numKids); NS_PRECONDITION(nsnull!=aContent, "bad aContent arg to ReplaceChildAt"); - NS_PRECONDITION(0<=aIndex && aIndexChildAt(kidIndex); + nsIContent* cell; + mContent->ChildAt(kidIndex, cell); if (nsnull == cell) { break; // no more content } diff --git a/mozilla/layout/html/table/src/nsTableRowGroup.cpp b/mozilla/layout/html/table/src/nsTableRowGroup.cpp index 8c8ae2027c1..65b324632d2 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroup.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroup.cpp @@ -79,25 +79,26 @@ nsrefcnt nsTableRowGroup::Release(void) return mRefCnt; } -void nsTableRowGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) +NS_IMETHODIMP +nsTableRowGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify) { NS_PRECONDITION(nsnull!=aAttribute, "bad attribute arg"); nsHTMLValue val; if ((aAttribute == nsHTMLAtoms::align) && ParseDivAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } if ((aAttribute == nsHTMLAtoms::valign) && ParseAlignParam(aValue, val)) { - nsHTMLTagContent::SetAttribute(aAttribute, val); - return; + return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); } - nsTableContent::SetAttribute(aAttribute, aValue); + return nsTableContent::SetAttribute(aAttribute, aValue, aNotify); } -void nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +NS_IMETHODIMP +nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); @@ -122,6 +123,7 @@ void nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext, textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated); } } + return NS_OK; } nsresult @@ -168,10 +170,12 @@ nsTableRowGroup::AppendChildTo (nsIContent *aContent, PRBool aNotify) { // find last row, if ! implicit, make one, append there nsTableRow *row = nsnull; - int index = ChildCount (); + PRInt32 index; + ChildCount (index); while ((0 < index) && (nsnull==row)) { - nsIContent *child = ChildAt (--index); // child: REFCNT++ + nsIContent *child; + ChildAt (--index, child); // child: REFCNT++ if (nsnull != child) { if (IsRow(child)) @@ -234,9 +238,11 @@ NS_IMETHODIMP nsTableRowGroup::ReplaceChildAt (nsIContent *aContent, PRInt32 aIndex, PRBool aNotify) { + PRInt32 numKids; + ChildCount(numKids); NS_PRECONDITION(nsnull!=aContent, "bad aContent arg to ReplaceChildAt"); - NS_PRECONDITION(0<=aIndex && aIndexGetTag(); // mType: REFCNT++ + aContent->GetTag(mType); // mType: REFCNT++ } nsTableRowGroupFrame::~nsTableRowGroupFrame() { - if (nsnull!=mType) - NS_RELEASE(mType); // mType: REFCNT-- + NS_IF_RELEASE(mType); // mType: REFCNT-- } NS_METHOD nsTableRowGroupFrame::GetRowGroupType(nsIAtom *& aType) @@ -740,7 +739,8 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, for (;;) { // Get the next content object - nsIContentPtr kid = mContent->ChildAt(kidIndex); + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); if (kid.IsNull()) { result = NS_FRAME_COMPLETE; break; @@ -1113,16 +1113,18 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext, // Did we successfully reflow our mapped children? if (PR_TRUE == reflowMappedOK) { // Any space left? + PRInt32 numKids; + mContent->ChildCount(numKids); if (state.availSize.height <= 0) { // No space left. Don't try to pull-up children or reflow unmapped - if (NextChildOffset() < mContent->ChildCount()) { + if (NextChildOffset() < numKids) { aStatus = NS_FRAME_NOT_COMPLETE; } - } else if (NextChildOffset() < mContent->ChildCount()) { + } else if (NextChildOffset() < numKids) { // Try and pull-up some children from a next-in-flow if (PullUpChildren(&aPresContext, state, aDesiredSize.maxElementSize)) { // If we still have unmapped children then create some new frames - if (NextChildOffset() < mContent->ChildCount()) { + if (NextChildOffset() < numKids) { aStatus = ReflowUnmappedChildren(&aPresContext, state, aDesiredSize.maxElementSize); } } else { diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index f6723be8651..cf8f99ac03a 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -39,25 +39,25 @@ void testAttributes(nsIHTMLContent* content) { nsString sempty(""); nsString sfoo_gif("foo.gif"); - content->SetAttribute(sBORDER); - content->SetAttribute(sWIDTH, nsHTMLValue(5, eHTMLUnit_Pixel)); - content->SetAttribute(sHEIGHT, sempty); - content->SetAttribute(sSRC, sfoo_gif); + content->SetAttribute(sBORDER, nsHTMLValue::kNull, PR_FALSE); + content->SetAttribute(sWIDTH, nsHTMLValue(5, eHTMLUnit_Pixel), PR_FALSE); + content->SetAttribute(sHEIGHT, sempty, PR_FALSE); + content->SetAttribute(sSRC, sfoo_gif, PR_FALSE); nsHTMLValue ret; - nsContentAttr rv; + nsresult rv; rv = content->GetAttribute(sBORDER, ret); - if ((rv != eContentAttr_NoValue) || (ret.GetUnit() != eHTMLUnit_Null)) { + if ((rv != NS_CONTENT_ATTR_NO_VALUE) || (ret.GetUnit() != eHTMLUnit_Null)) { printf("test 0 failed\n"); } rv = content->GetAttribute(sWIDTH, ret); - if ((rv != eContentAttr_HasValue) || (! (ret == nsHTMLValue(5, eHTMLUnit_Pixel)))) { + if ((rv != NS_CONTENT_ATTR_HAS_VALUE) || (! (ret == nsHTMLValue(5, eHTMLUnit_Pixel)))) { printf("test 1 failed\n"); } rv = content->GetAttribute(sBAD, ret); - if (rv != eContentAttr_NotThere) { + if (rv != NS_CONTENT_ATTR_NOT_THERE) { printf("test 2 failed\n"); } @@ -66,7 +66,7 @@ void testAttributes(nsIHTMLContent* content) { nsString sborder("border"); nsString strRet; rv = ((nsIContent*)content)->GetAttribute(sborder, strRet); - if (rv != eContentAttr_NoValue) { + if (rv != NS_CONTENT_ATTR_NO_VALUE) { printf("test 3 (case comparison) failed\n"); } @@ -75,8 +75,9 @@ void testAttributes(nsIHTMLContent* content) { nsISupportsArray* allNames; NS_NewISupportsArray(&allNames); - content->GetAllAttributeNames(allNames); - if (allNames->Count() != 3) { + PRInt32 na; + content->GetAllAttributeNames(allNames, na); + if (na != 3) { printf("test 5 (unset attriubte) failed\n"); } @@ -225,7 +226,9 @@ int main(int argc, char** argv) printf("Could not create text content.\n"); return -1; } - NS_ASSERTION(!text->CanContainChildren(),""); + PRBool canHaveKids; + text->CanContainChildren(canHaveKids); + NS_ASSERTION(!canHaveKids,""); text->SetDocument(myDoc); #if 0 @@ -255,11 +258,14 @@ int main(int argc, char** argv) printf("Could not create container.\n"); return -1; } - NS_ASSERTION(container->CanContainChildren(),""); + container->CanContainChildren(canHaveKids); + NS_ASSERTION(canHaveKids,""); container->SetDocument(myDoc); container->AppendChildTo(text, PR_FALSE); - if (container->ChildCount() != 1) { + PRInt32 nk; + container->ChildCount(nk); + if (nk != 1) { printf("Container has wrong number of children."); } diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp index 798fe8f243a..43280f8b622 100644 --- a/mozilla/layout/style/nsCSSStyleRule.cpp +++ b/mozilla/layout/style/nsCSSStyleRule.cpp @@ -169,7 +169,7 @@ public: nsIPresContext* aPresContext); virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; private: // These are not supported and are not implemented! @@ -1053,7 +1053,8 @@ static void ListSelector(FILE* out, const nsCSSSelector* aSelector) } } -void CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const { // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); @@ -1079,6 +1080,8 @@ void CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const fputs("{ null declaration }", out); } fputs("\n", out); + + return NS_OK; } NS_HTML nsresult diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index c17c8d281eb..e40334568fe 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -402,15 +402,18 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, nsCSSSelector* aSelector, nsIContent* aContent) { PRBool result = PR_FALSE; - nsIAtom* contentTag = aContent->GetTag(); + nsIAtom* contentTag; + aContent->GetTag(contentTag); if ((nsnull == aSelector->mTag) || (aSelector->mTag == contentTag)) { if ((nsnull != aSelector->mClass) || (nsnull != aSelector->mID) || (nsnull != aSelector->mPseudoClass)) { nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - nsIAtom* contentClass = htmlContent->GetClass(); - nsIAtom* contentID = htmlContent->GetID(); + nsIAtom* contentClass; + htmlContent->GetClass(contentClass); + nsIAtom* contentID; + htmlContent->GetID(contentID); if ((nsnull == aSelector->mClass) || (aSelector->mClass == contentClass)) { if ((nsnull == aSelector->mID) || (aSelector->mID == contentID)) { if ((contentTag == nsHTMLAtoms::a) && (nsnull != aSelector->mPseudoClass)) { @@ -420,9 +423,9 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) && (nsnull != linkHandler)) { nsAutoString base, href; // XXX base?? - nsContentAttr attrState = htmlContent->GetAttribute("href", href); + nsresult attrState = htmlContent->GetAttribute("href", href); - if (eContentAttr_HasValue == attrState) { + if (NS_CONTENT_ATTR_HAS_VALUE == attrState) { nsIURL* docURL = nsnull; nsIDocument* doc = nsnull; aContent->GetDocument(doc); @@ -563,14 +566,15 @@ PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, BuildHash(); } ContentEnumData data(aPresContext, aContent, aParentFrame, aResults); - nsIAtom* tagAtom = aContent->GetTag(); + nsIAtom* tagAtom; + aContent->GetTag(tagAtom); nsIAtom* idAtom = nsnull; nsIAtom* classAtom = nsnull; nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - idAtom = htmlContent->GetID(); - classAtom = htmlContent->GetClass(); + htmlContent->GetID(idAtom); + htmlContent->GetClass(classAtom); NS_RELEASE(htmlContent); } diff --git a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp index 7b76e770fa5..ec655f2b333 100644 --- a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp @@ -175,7 +175,7 @@ PRInt32 HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, // just get the one and only style rule from the content's STYLE attribute if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { nsHTMLValue value; - if (eContentAttr_HasValue == htmlContent->GetAttribute(nsHTMLAtoms::style, value)) { + if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetAttribute(nsHTMLAtoms::style, value)) { if (eHTMLUnit_ISupports == value.GetUnit()) { nsISupports* rule = value.GetISupportsValue(); if (nsnull != rule) { diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 45b0719ba65..316a253418d 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -51,7 +51,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; nscolor mColor; }; @@ -86,8 +86,10 @@ void HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPr } } -void HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const +NS_IMETHODIMP +HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const { + return NS_OK; } // ----------------------------------------------------------- @@ -295,7 +297,8 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, if (aContent != parentContent) { // if not a pseudo frame... nsIHTMLContent* htmlContent; if (NS_OK == aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent)) { - nsIAtom* tag = htmlContent->GetTag(); + nsIAtom* tag; + htmlContent->GetTag(tag); // if we have anchor colors, check if this is an anchor with an href if (tag == nsHTMLAtoms::a) { if ((nsnull != mLinkRule) || (nsnull != mVisitedRule) || (nsnull != mActiveRule)) { @@ -305,9 +308,9 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) && (nsnull != linkHandler)) { nsAutoString base, href; // XXX base?? - nsContentAttr attrState = htmlContent->GetAttribute("href", href); + nsresult attrState = htmlContent->GetAttribute("href", href); - if (eContentAttr_HasValue == attrState) { + if (NS_CONTENT_ATTR_HAS_VALUE == attrState) { nsIURL* docURL = nsnull; nsIDocument* doc = nsnull; aContent->GetDocument(doc); @@ -375,8 +378,8 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext, } // end TD/TH tag // just get the one and only style rule from the content - nsIStyleRule* rule = htmlContent->GetStyleRule(); - + nsIStyleRule* rule; + htmlContent->GetStyleRule(rule); if (nsnull != rule) { aResults->AppendElement(rule); NS_RELEASE(rule); diff --git a/mozilla/layout/style/nsICSSStyleRule.h b/mozilla/layout/style/nsICSSStyleRule.h index 153397fe876..2d1fa38ee98 100644 --- a/mozilla/layout/style/nsICSSStyleRule.h +++ b/mozilla/layout/style/nsICSSStyleRule.h @@ -54,9 +54,6 @@ public: class nsICSSStyleRule : public nsIStyleRule { public: - virtual PRBool Equals(const nsIStyleRule* aRule) const = 0; - virtual PRUint32 HashValue(void) const = 0; - virtual nsCSSSelector* FirstSelector(void) = 0; virtual void AddSelector(const nsCSSSelector& aSelector) = 0; virtual void DeleteSelector(nsCSSSelector* aSelector) = 0; @@ -66,8 +63,6 @@ public: virtual PRInt32 GetWeight(void) const = 0; virtual void SetWeight(PRInt32 aWeight) = 0; - - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; extern NS_HTML nsresult diff --git a/mozilla/layout/style/nsIStyleRule.h b/mozilla/layout/style/nsIStyleRule.h index e79eff7dae8..d54cf4d4723 100644 --- a/mozilla/layout/style/nsIStyleRule.h +++ b/mozilla/layout/style/nsIStyleRule.h @@ -37,7 +37,7 @@ public: virtual void MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) = 0; - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0; }; #endif /* nsIStyleRule_h___ */ diff --git a/mozilla/layout/tables/nsTableColGroupFrame.cpp b/mozilla/layout/tables/nsTableColGroupFrame.cpp index d665e896107..d2f7cd02537 100644 --- a/mozilla/layout/tables/nsTableColGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableColGroupFrame.cpp @@ -75,7 +75,8 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, for (;;) { // get the next content child, breaking if there is none - nsIContentPtr kid = mContent->ChildAt(kidIndex); // kid: REFCNT++ + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); // kid: REFCNT++ if (kid.IsNull()) { break; } diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index ed61217a0e5..495b5a12152 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1526,7 +1526,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nscoord maxAscent = 0; nscoord maxDescent = 0; PRInt32 kidIndex = 0; - PRInt32 lastIndex = mContent->ChildCount(); + PRInt32 lastIndex; + mContent->ChildCount(lastIndex); PRInt32 contentOffset=0; nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */ @@ -1550,7 +1551,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, * TBody, in order */ for (;;) { - nsIContentPtr kid = mContent->ChildAt(kidIndex); // kid: REFCNT++ + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); // kid: REFCNT++ if (kid.IsNull()) { result = NS_FRAME_COMPLETE; break; @@ -1698,7 +1700,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext, nsSize kidMaxSize(0,0); PRInt32 kidIndex = 0; - PRInt32 lastIndex = c->ChildCount(); + PRInt32 lastIndex; + c->ChildCount(lastIndex); nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */ #ifdef NS_DEBUG @@ -1722,16 +1725,19 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext, // Did we successfully reflow our mapped children? if (PR_TRUE == reflowMappedOK) { // Any space left? + PRInt32 numKids; + mContent->ChildCount(numKids); if (state.availSize.height <= 0) { // No space left. Don't try to pull-up children or reflow unmapped - if (NextChildOffset() < mContent->ChildCount()) { + if (NextChildOffset() < numKids) { status = NS_FRAME_NOT_COMPLETE; } - } else if (NextChildOffset() < mContent->ChildCount()) { + } else if (NextChildOffset() < numKids) { // Try and pull-up some children from a next-in-flow if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) { // If we still have unmapped children then create some new frames - if (NextChildOffset() < mContent->ChildCount()) { + mContent->ChildCount(numKids); + if (NextChildOffset() < numKids) { status = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize); } } else { @@ -2366,7 +2372,8 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, LastChild(prevKidFrame); for (;;) { // Get the next content object - nsIContentPtr kid = mContent->ChildAt(kidIndex); + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); if (kid.IsNull()) { result = NS_FRAME_COMPLETE; break; @@ -2882,7 +2889,8 @@ nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, nsIContent *content = nsnull; rg->GetContent(content); // content: REFCNT++ NS_ASSERTION(nsnull!=content, "bad frame, returned null content."); - nsIAtom * rgTag = content->GetTag(); + nsIAtom * rgTag; + content->GetTag(rgTag); // if we've found a header or a footer, replicate it if (tHeadTag==rgTag || tFootTag==rgTag) { @@ -2909,6 +2917,7 @@ nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, duplicateFrame->SetNextSibling(bodyRowGroupFromOverflow); lastSib = duplicateFrame; } + NS_IF_RELEASE(rgTag); NS_RELEASE(content); // content: REFCNT-- // get the next row group rg->GetNextSibling(rg); @@ -3055,7 +3064,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) nsHTMLValue border_value; - nsContentAttr border_result; + nsresult border_result; nscoord padding = 0; nscoord spacing = 0; @@ -3072,7 +3081,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing); border_result = table->GetAttribute(nsHTMLAtoms::border,border_value); - if (border_result == eContentAttr_HasValue) + if (border_result == NS_CONTENT_ATTR_HAS_VALUE) { PRInt32 intValue = 0; diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index bea7e691974..09e955bb369 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -608,7 +608,8 @@ nsresult nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext) // ignore all but the first for (PRInt32 kidIndex = 0; /* nada */ ; kidIndex++) { - nsIContentPtr caption = mContent->ChildAt(kidIndex); + nsIContentPtr caption; + mContent->ChildAt(kidIndex, caption.AssignRef()); if (PR_TRUE==caption.IsNull()) { break; } diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 7b88dcf6ac0..bb8b72bc7f3 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -511,7 +511,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, for (;;) { // Get the next content object - nsIContent* cell = mContent->ChildAt(kidIndex); + nsIContent* cell; + mContent->ChildAt(kidIndex, cell); if (nsnull == cell) { break; // no more content } diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index b1ff31ee8e8..d143ed3a3d8 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -92,13 +92,12 @@ struct RowGroupReflowState { nsTableRowGroupFrame::nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame) : nsContainerFrame(aContent, aParentFrame) { - mType = aContent->GetTag(); // mType: REFCNT++ + aContent->GetTag(mType); // mType: REFCNT++ } nsTableRowGroupFrame::~nsTableRowGroupFrame() { - if (nsnull!=mType) - NS_RELEASE(mType); // mType: REFCNT-- + NS_IF_RELEASE(mType); // mType: REFCNT-- } NS_METHOD nsTableRowGroupFrame::GetRowGroupType(nsIAtom *& aType) @@ -740,7 +739,8 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, for (;;) { // Get the next content object - nsIContentPtr kid = mContent->ChildAt(kidIndex); + nsIContentPtr kid; + mContent->ChildAt(kidIndex, kid.AssignRef()); if (kid.IsNull()) { result = NS_FRAME_COMPLETE; break; @@ -1113,16 +1113,18 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext, // Did we successfully reflow our mapped children? if (PR_TRUE == reflowMappedOK) { // Any space left? + PRInt32 numKids; + mContent->ChildCount(numKids); if (state.availSize.height <= 0) { // No space left. Don't try to pull-up children or reflow unmapped - if (NextChildOffset() < mContent->ChildCount()) { + if (NextChildOffset() < numKids) { aStatus = NS_FRAME_NOT_COMPLETE; } - } else if (NextChildOffset() < mContent->ChildCount()) { + } else if (NextChildOffset() < numKids) { // Try and pull-up some children from a next-in-flow if (PullUpChildren(&aPresContext, state, aDesiredSize.maxElementSize)) { // If we still have unmapped children then create some new frames - if (NextChildOffset() < mContent->ChildCount()) { + if (NextChildOffset() < numKids) { aStatus = ReflowUnmappedChildren(&aPresContext, state, aDesiredSize.maxElementSize); } } else {