From b26f9f52fb3221608733c347de602bae070281f5 Mon Sep 17 00:00:00 2001 From: "cvshook%sicking.cc" Date: Fri, 28 Oct 2005 11:25:24 +0000 Subject: [PATCH] Bug 311827: Make GetAttr return a bool rather then an nsresult. r/sr=bz git-svn-id: svn://10.0.0.236/trunk@183185 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/base/nsAccessibilityService.cpp | 3 +- mozilla/accessible/src/base/nsAccessible.cpp | 37 ++- .../src/html/nsHTMLAreaAccessible.cpp | 8 +- .../src/html/nsHTMLFormControlAccessible.cpp | 20 +- .../src/html/nsHTMLImageAccessible.cpp | 10 +- .../accessible/src/msaa/nsAccessNodeWrap.cpp | 7 +- .../src/msaa/nsXULMenuAccessibleWrap.cpp | 5 +- .../src/xul/nsXULTextAccessible.cpp | 7 +- mozilla/content/base/public/nsContentErrors.h | 13 -- mozilla/content/base/public/nsIContent.h | 15 +- mozilla/content/base/src/nsContentUtils.cpp | 3 +- mozilla/content/base/src/nsDOMAttribute.cpp | 10 +- mozilla/content/base/src/nsDocument.cpp | 7 +- .../content/base/src/nsDocumentFragment.cpp | 6 +- .../content/base/src/nsGenericDOMDataNode.cpp | 4 +- .../content/base/src/nsGenericDOMDataNode.h | 4 +- mozilla/content/base/src/nsGenericElement.cpp | 24 +- mozilla/content/base/src/nsGenericElement.h | 4 +- .../base/src/nsObjectLoadingContent.cpp | 14 +- .../base/src/nsPlainTextSerializer.cpp | 3 +- mozilla/content/base/src/nsScriptLoader.cpp | 31 +-- .../events/src/nsEventListenerManager.cpp | 78 ++++--- .../content/events/src/nsXMLEventsManager.cpp | 27 +-- .../html/content/src/nsGenericHTMLElement.cpp | 40 +--- .../html/content/src/nsGenericHTMLElement.h | 2 - .../html/content/src/nsHTMLAnchorElement.cpp | 5 +- .../html/content/src/nsHTMLAppletElement.cpp | 3 +- .../html/content/src/nsHTMLAreaElement.cpp | 6 +- .../html/content/src/nsHTMLBodyElement.cpp | 6 +- .../html/content/src/nsHTMLButtonElement.cpp | 8 +- .../html/content/src/nsHTMLFormElement.cpp | 17 +- .../html/content/src/nsHTMLImageElement.cpp | 3 +- .../html/content/src/nsHTMLInputElement.cpp | 38 +--- .../html/content/src/nsHTMLObjectElement.cpp | 15 +- .../html/content/src/nsHTMLOptionElement.cpp | 3 +- .../html/content/src/nsHTMLSelectElement.cpp | 17 +- .../html/content/src/nsHTMLSharedElement.cpp | 3 +- .../content/src/nsHTMLTableCellElement.cpp | 4 +- .../content/src/nsHTMLTextAreaElement.cpp | 16 +- .../html/document/src/nsHTMLContentSink.cpp | 6 +- .../html/document/src/nsHTMLDocument.cpp | 11 +- .../src/nsHTMLFragmentContentSink.cpp | 4 +- .../content/svg/content/src/nsSVGElement.cpp | 4 +- .../svg/content/src/nsSVGScriptElement.cpp | 4 +- .../content/xbl/src/nsXBLPrototypeBinding.cpp | 8 +- .../content/xml/content/src/nsXMLElement.cpp | 23 +- .../xml/document/src/nsXMLContentSink.cpp | 6 +- .../xtf/public/nsIXTFAttributeHandler.idl | 4 +- .../content/xtf/src/nsXTFElementWrapper.cpp | 18 +- mozilla/content/xtf/src/nsXTFElementWrapper.h | 4 +- .../content/xul/content/src/nsXULElement.cpp | 26 +-- .../content/xul/content/src/nsXULElement.h | 4 +- .../xul/document/src/nsXULDocument.cpp | 133 ++++------- .../xul/templates/src/nsXULContentBuilder.cpp | 33 +-- .../xul/templates/src/nsXULContentUtils.cpp | 21 +- .../xul/templates/src/nsXULSortService.cpp | 213 +++++++----------- .../templates/src/nsXULTemplateBuilder.cpp | 38 ++-- .../composer/src/nsComposeTxtSrvFilter.cpp | 29 ++- .../composer/src/nsComposeTxtSrvFilter.h | 4 +- .../source/xpath/txMozillaXPathTreeWalker.cpp | 3 +- .../source/xslt/txXSLTPatterns.cpp | 4 +- .../extensions/webdav/src/nsWebDAVUtils.cpp | 2 +- mozilla/extensions/xforms/nsXFormsUtils.cpp | 6 +- mozilla/layout/base/nsCSSFrameConstructor.cpp | 53 ++--- mozilla/layout/base/nsLayoutAtomList.h | 7 + .../layout/forms/nsButtonFrameRenderer.cpp | 8 +- .../layout/forms/nsComboboxControlFrame.cpp | 27 +-- mozilla/layout/forms/nsFileControlFrame.cpp | 7 +- mozilla/layout/forms/nsFormControlFrame.cpp | 81 +------ mozilla/layout/forms/nsFormControlFrame.h | 33 +-- mozilla/layout/forms/nsFormControlHelper.cpp | 42 ++-- mozilla/layout/forms/nsFormControlHelper.h | 68 +----- .../layout/forms/nsGfxButtonControlFrame.cpp | 18 +- .../layout/forms/nsHTMLButtonControlFrame.cpp | 8 +- mozilla/layout/forms/nsImageControlFrame.cpp | 4 +- mozilla/layout/forms/nsListControlFrame.cpp | 34 +-- mozilla/layout/forms/nsTextControlFrame.cpp | 45 ++-- mozilla/layout/forms/nsTextControlFrame.h | 4 +- mozilla/layout/generic/nsBlockReflowState.cpp | 20 +- mozilla/layout/generic/nsGfxScrollFrame.cpp | 13 +- mozilla/layout/generic/nsImageFrame.cpp | 4 +- mozilla/layout/generic/nsObjectFrame.cpp | 36 ++- mozilla/layout/generic/nsSpacerFrame.cpp | 3 +- .../base/src/nsMathMLContainerFrame.cpp | 6 +- .../layout/mathml/base/src/nsMathMLFrame.cpp | 46 ++-- .../layout/mathml/base/src/nsMathMLFrame.h | 7 +- .../mathml/base/src/nsMathMLTokenFrame.cpp | 4 +- .../mathml/base/src/nsMathMLmactionFrame.cpp | 25 +- .../mathml/base/src/nsMathMLmfencedFrame.cpp | 65 +++--- .../mathml/base/src/nsMathMLmfracFrame.cpp | 38 ++-- .../base/src/nsMathMLmmultiscriptsFrame.cpp | 10 +- .../mathml/base/src/nsMathMLmoFrame.cpp | 99 ++++---- .../mathml/base/src/nsMathMLmoverFrame.cpp | 12 +- .../mathml/base/src/nsMathMLmpaddedFrame.cpp | 16 +- .../mathml/base/src/nsMathMLmspaceFrame.cpp | 15 +- .../mathml/base/src/nsMathMLmstyleFrame.cpp | 22 +- .../mathml/base/src/nsMathMLmsubFrame.cpp | 5 +- .../mathml/base/src/nsMathMLmsubsupFrame.cpp | 10 +- .../mathml/base/src/nsMathMLmsupFrame.cpp | 5 +- .../mathml/base/src/nsMathMLmtableFrame.cpp | 36 ++- .../mathml/base/src/nsMathMLmunderFrame.cpp | 12 +- .../base/src/nsMathMLmunderoverFrame.cpp | 24 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 25 +- mozilla/layout/xul/base/src/nsBox.cpp | 29 +-- mozilla/layout/xul/base/src/nsBoxFrame.cpp | 93 ++++---- mozilla/layout/xul/base/src/nsDeckFrame.cpp | 2 +- mozilla/layout/xul/base/src/nsGrippyFrame.cpp | 25 +- .../layout/xul/base/src/nsLeafBoxFrame.cpp | 12 +- .../layout/xul/base/src/nsResizerFrame.cpp | 3 +- .../xul/base/src/nsScrollbarButtonFrame.cpp | 3 +- mozilla/layout/xul/base/src/nsSliderFrame.cpp | 4 +- .../layout/xul/base/src/nsSplitterFrame.cpp | 20 +- mozilla/layout/xul/base/src/nsStackLayout.cpp | 6 +- .../manager/ssl/src/nsKeygenHandler.cpp | 4 +- mozilla/widget/src/gtk/nsNativeThemeGTK.cpp | 14 +- mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp | 14 +- .../widget/src/xpwidgets/nsNativeTheme.cpp | 12 +- 117 files changed, 894 insertions(+), 1478 deletions(-) diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index ddde4afa440..cd4da4ad3a3 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -469,8 +469,7 @@ nsAccessibilityService::CreateHTMLButtonAccessibleXBL(nsIDOMNode *aNode, nsIAcce PRBool nsAccessibilityService::GetRole(nsIContent *aContent, nsAString& aRole) { - return NS_CONTENT_ATTR_HAS_VALUE == - aContent->GetAttr(kNameSpaceID_XHTML2_Unofficial, + return aContent->GetAttr(kNameSpaceID_XHTML2_Unofficial, nsAccessibilityAtoms::role, aRole); } diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 6966a26a959..81036608bd6 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -233,8 +233,7 @@ NS_IMETHODIMP nsAccessible::GetDescription(nsAString& aDescription) if (description.IsEmpty()) { nsIAtom *descAtom = isXUL ? nsAccessibilityAtoms::tooltiptext : nsAccessibilityAtoms::title; - if (NS_CONTENT_ATTR_HAS_VALUE == - content->GetAttr(kNameSpaceID_None, descAtom, description)) { + if (content->GetAttr(kNameSpaceID_None, descAtom, description)) { nsAutoString name; GetName(name); if (name.IsEmpty() || description == name) { @@ -315,10 +314,8 @@ NS_IMETHODIMP nsAccessible::Init() { nsIContent *content = GetRoleContent(mDOMNode); nsAutoString roleString; - if (content && - NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_XHTML2_Unofficial, - nsAccessibilityAtoms::role, - roleString)) { + if (content && content->GetAttr(kNameSpaceID_XHTML2_Unofficial, + nsAccessibilityAtoms::role, roleString)) { // QI to nsIDOM3Node causes some overhead. Unfortunately we need to do this each // time there is a role attribute, because the prefixe to namespace mappings // can change within any subtree via the xmlns attribute @@ -1294,10 +1291,9 @@ nsresult nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsA aContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, textEquivalent); } - else if (NS_CONTENT_ATTR_HAS_VALUE != - aContent->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::tooltiptext, - textEquivalent)) { + else if (!aContent->GetAttr(kNameSpaceID_None, + nsAccessibilityAtoms::tooltiptext, textEquivalent) || + textEquivalent.IsEmpty()) { AppendNameFromAccessibleFor(aContent, aFlatString, PR_TRUE /* use value */); } return AppendStringWithSpaces(aFlatString, textEquivalent); @@ -1457,8 +1453,7 @@ nsresult nsAccessible::GetTextFromRelationID(nsIAtom *aIDAttrib, nsString &aName NS_ASSERTION(content, "Called from shutdown accessible"); nsAutoString id; - if (NS_CONTENT_ATTR_HAS_VALUE != - content->GetAttr(kNameSpaceID_WAIProperties, aIDAttrib, id)) { + if (!content->GetAttr(kNameSpaceID_WAIProperties, aIDAttrib, id)) { return NS_ERROR_FAILURE; } @@ -1557,8 +1552,8 @@ nsresult nsAccessible::GetHTMLName(nsAString& aLabel, PRBool aCanAggregateSubtre } // Still try the title as as fallback method in that case. - if (NS_CONTENT_ATTR_NOT_THERE == - content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, aLabel)) { + if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, + aLabel)) { aLabel.SetIsVoid(PR_TRUE); } return NS_OK; @@ -1647,9 +1642,7 @@ nsresult nsAccessible::GetXULName(nsAString& aLabel, PRBool aCanAggregateSubtree nsIContent *parent = bindingParent? bindingParent->GetParent() : content->GetParent(); if (parent && parent->Tag() == nsAccessibilityAtoms::toolbaritem && - NS_CONTENT_ATTR_HAS_VALUE == parent->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::title, - label)) { + parent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, label)) { label.CompressWhitespace(); aLabel = label; return NS_OK; @@ -1815,9 +1808,7 @@ PRBool nsAccessible::MappedAttrState(nsIContent *aContent, PRUint32 *aStateInOut nsAutoString attribValue; nsCOMPtr attribAtom = do_GetAtom(aStateMapEntry->attributeName); // XXX put atoms directly in entry - if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttr(kNameSpaceID_WAIProperties, - attribAtom, - attribValue)) { + if (aContent->GetAttr(kNameSpaceID_WAIProperties, attribAtom, attribValue)) { if (aStateMapEntry->attributeValue == BOOL_STATE) { // No attribute value map specified in state map entry indicates state cleared if (attribValue.EqualsLiteral("false")) { @@ -1881,10 +1872,8 @@ NS_IMETHODIMP nsAccessible::GetFinalValue(nsAString& aValue) return NS_OK; } nsCOMPtr content(do_QueryInterface(mDOMNode)); - if (content && - NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_WAIProperties, - nsAccessibilityAtoms::valuenow, - aValue)) { + if (content && content->GetAttr(kNameSpaceID_WAIProperties, + nsAccessibilityAtoms::valuenow, aValue)) { return NS_OK; } } diff --git a/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp b/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp index f56b7ab000c..a9de6866b1c 100644 --- a/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp @@ -70,10 +70,10 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetName(nsAString & aName) return rv; } } - if (NS_CONTENT_ATTR_NO_VALUE == - content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, aName) && - NS_CONTENT_ATTR_NO_VALUE == - content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, aName)) { + if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, + aName) && + !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, + aName)) { return GetValue(aName); } diff --git a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp index c593816f731..accb44f762c 100644 --- a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -197,12 +197,10 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetName(nsAString& aName) } nsAutoString name; - if (NS_CONTENT_ATTR_HAS_VALUE != content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::value, - name) && - NS_CONTENT_ATTR_HAS_VALUE != content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::alt, - name)) { + if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, + name) && + !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, + name)) { if (mRoleMapEntry) { // Use HTML label or DHTML accessibility's labelledby attribute for name GetHTMLName(name, PR_FALSE); @@ -220,12 +218,10 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetName(nsAString& aName) } } if (name.IsEmpty() && - NS_CONTENT_ATTR_HAS_VALUE != content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::title, - name) && - NS_CONTENT_ATTR_HAS_VALUE != content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::src, - name)) { + !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, + name) && + !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::src, + name)) { content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::data, name); } } diff --git a/mozilla/accessible/src/html/nsHTMLImageAccessible.cpp b/mozilla/accessible/src/html/nsHTMLImageAccessible.cpp index b7db486476a..bf0673a1f6b 100644 --- a/mozilla/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLImageAccessible.cpp @@ -109,17 +109,15 @@ NS_IMETHODIMP nsHTMLImageAccessible::GetName(nsAString& aName) return NS_ERROR_FAILURE; // Node has been shut down } - if (NS_CONTENT_ATTR_HAS_VALUE != content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::alt, - aName)) { + if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, + aName)) { if (mRoleMapEntry) { // Use HTML label or DHTML accessibility's labelledby attribute for name // GetHTMLName will also try title attribute as a last resort return GetHTMLName(aName, PR_FALSE); } - if (NS_CONTENT_ATTR_HAS_VALUE != content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::title, - aName)) { + if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, + aName)) { aName.SetIsVoid(PR_TRUE); // No alt or title } } diff --git a/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp b/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp index 66c7c3ce076..cd390ca008f 100644 --- a/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/mozilla/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -203,8 +203,8 @@ STDMETHODIMP nsAccessNodeWrap::get_attributes( aNameSpaceIDs[index] = NS_STATIC_CAST(short, nameSpaceID); nameAtom->GetUTF8String(&pszAttributeName); aAttribNames[index] = ::SysAllocString(NS_ConvertUTF8toUCS2(pszAttributeName).get()); - if (NS_SUCCEEDED(content->GetAttr(nameSpaceID, nameAtom, attributeValue))) - aAttribValues[index] = ::SysAllocString(attributeValue.get()); + content->GetAttr(nameSpaceID, nameAtom, attributeValue); + aAttribValues[index] = ::SysAllocString(attributeValue.get()); } } @@ -526,8 +526,7 @@ nsAccessNodeWrap::get_language(BSTR __RPC_FAR *aLanguage) nsAutoString language; for (nsIContent *walkUp = content; walkUp = walkUp->GetParent(); walkUp) { - if (NS_CONTENT_ATTR_HAS_VALUE == - walkUp->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::lang, language)) { + if (walkUp->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::lang, language)) { break; } } diff --git a/mozilla/accessible/src/msaa/nsXULMenuAccessibleWrap.cpp b/mozilla/accessible/src/msaa/nsXULMenuAccessibleWrap.cpp index 09ea45db8bc..30b908269da 100755 --- a/mozilla/accessible/src/msaa/nsXULMenuAccessibleWrap.cpp +++ b/mozilla/accessible/src/msaa/nsXULMenuAccessibleWrap.cpp @@ -59,9 +59,8 @@ NS_IMETHODIMP nsXULMenuitemAccessibleWrap::GetName(nsAString& aName) NS_ASSERTION(content, "Should not have gotten past nsXULMenuitemAccessible::GetName"); nsAutoString accel; - rv = content->GetAttr(kNameSpaceID_None, - nsAccessibilityAtoms::acceltext, accel); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::acceltext, accel); + if (!accel.IsEmpty()) { aName += NS_LITERAL_STRING("\t") + accel; } diff --git a/mozilla/accessible/src/xul/nsXULTextAccessible.cpp b/mozilla/accessible/src/xul/nsXULTextAccessible.cpp index 4588acf8682..528e886cbf2 100644 --- a/mozilla/accessible/src/xul/nsXULTextAccessible.cpp +++ b/mozilla/accessible/src/xul/nsXULTextAccessible.cpp @@ -60,8 +60,8 @@ NS_IMETHODIMP nsXULTextAccessible::GetName(nsAString& aName) if (!content) { return NS_ERROR_FAILURE; // Node shut down } - nsresult rv = content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, aName); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, + aName)) { // if the value doesn't exist, flatten the inner content as the name (for descriptions) return AppendFlatStringFromSubtree(content, &aName); } @@ -117,7 +117,8 @@ nsXULTextAccessible(aDomNode, aShell) NS_IMETHODIMP nsXULLinkAccessible::GetValue(nsAString& aValue) { if (mIsLink) { - return mActionContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::href, aValue); + mActionContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::href, aValue); + return NS_OK; } return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/content/base/public/nsContentErrors.h b/mozilla/content/base/public/nsContentErrors.h index 0ae6f8d8793..523e387a8a5 100644 --- a/mozilla/content/base/public/nsContentErrors.h +++ b/mozilla/content/base/public/nsContentErrors.h @@ -40,19 +40,6 @@ #ifndef nsContentErrors_h___ #define nsContentErrors_h___ -/** Error codes for nsIContent::GetAttr */ -// Returned if the attr exists and has a value -#define NS_CONTENT_ATTR_HAS_VALUE NS_OK - -// Returned if the attr exists but has no value -#define NS_CONTENT_ATTR_NO_VALUE \ - NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 0) - -// Returned if the attr does not exist -#define NS_CONTENT_ATTR_NOT_THERE \ - NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 1) - - /** Error codes for nsHTMLStyleSheet */ // XXX this is not really used #define NS_HTML_STYLE_PROPERTY_NOT_THERE \ diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index e32f7e88e48..e3ff3e2256e 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -61,8 +61,8 @@ class nsIURI; // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x1666277a, 0xf6f1, 0x4c7e, \ - { 0xb0, 0x63, 0x95, 0x77, 0x53, 0xd2, 0xac, 0x52 } } +{ 0xe5417db2, 0xfc59, 0x4b43, \ + { 0x8c, 0x9a, 0xed, 0xc3, 0x17, 0x3a, 0x85, 0x40 } } /** * A node of content in a document's content model. This interface @@ -331,14 +331,11 @@ public: * @param aNameSpaceID the namespace of the attr * @param aName the name of the attr * @param aResult the value (may legitimately be the empty string) [OUT] - * @throws NS_CONTENT_ATTR_NOT_THERE if the attribute is not set and has no - * default value - * @throws NS_CONTENT_ATTR_NO_VALUE if the attribute exists but has no value - * @throws NS_CONTENT_ATTR_HAS_VALUE if the attribute exists and has a - * non-empty value (==NS_OK) + * @returns PR_TRUE if the attribute was set (even when set to empty string) + * PR_FALSE when not set. */ - virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAString& aResult) const = 0; + virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsAString& aResult) const = 0; /** * Determine if an attribute has been set (empty string or otherwise). diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 73771cb4e76..7aeebb0086c 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -1680,8 +1680,7 @@ nsContentUtils::LookupNamespaceURI(nsIContent* aNamespaceResolver, // declaration that declares aNamespacePrefix. for (nsIContent* content = aNamespaceResolver; content; content = content->GetParent()) { - if (content->GetAttr(kNameSpaceID_XMLNS, name, aNamespaceURI) == - NS_CONTENT_ATTR_HAS_VALUE) + if (content->GetAttr(kNameSpaceID_XMLNS, name, aNamespaceURI)) return NS_OK; } return NS_ERROR_FAILURE; diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index 9a70973cbd7..db2c847661a 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -125,10 +125,9 @@ nsDOMAttribute::GetValue(nsAString& aValue) nsIContent* content = GetContentInternal(); if (content) { nsAutoString tmpValue; - nsresult attrResult = content->GetAttr(mNodeInfo->NamespaceID(), - mNodeInfo->NameAtom(), - tmpValue); - if (NS_CONTENT_ATTR_NOT_THERE != attrResult) { + if (content->GetAttr(mNodeInfo->NamespaceID(), + mNodeInfo->NameAtom(), + tmpValue)) { mValue = tmpValue; } } @@ -428,8 +427,7 @@ nsDOMAttribute::SetPrefix(const nsAString& aPrefix) PRInt32 nameSpaceID = mNodeInfo->NamespaceID(); nsAutoString tmpValue; - rv = content->GetAttr(nameSpaceID, name, tmpValue); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (content->GetAttr(nameSpaceID, name, tmpValue)) { content->UnsetAttr(nameSpaceID, name, PR_TRUE); content->SetAttr(newNodeInfo->NamespaceID(), newNodeInfo->NameAtom(), diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index f9a51ef2c0a..e9b50716cec 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -2995,10 +2995,9 @@ GetElementByAttribute(nsIContent* aContent, nsIAtom* aAttrName, const nsAString& aAttrValue, PRBool aUniversalMatch, nsIDOMElement** aResult) { - nsAutoString value; - nsresult rv = aContent->GetAttr(kNameSpaceID_None, aAttrName, value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && - (aUniversalMatch || value.Equals(aAttrValue))) { + if (aUniversalMatch ? aContent->HasAttr(kNameSpaceID_None, aAttrName) : + aContent->AttrValueIs(kNameSpaceID_None, aAttrName, + aAttrValue, eCaseMatters)) { return CallQueryInterface(aContent, aResult); } diff --git a/mozilla/content/base/src/nsDocumentFragment.cpp b/mozilla/content/base/src/nsDocumentFragment.cpp index 7411547123a..8c820e7a2e9 100644 --- a/mozilla/content/base/src/nsDocumentFragment.cpp +++ b/mozilla/content/base/src/nsDocumentFragment.cpp @@ -139,10 +139,10 @@ public: { return NS_OK; } - virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAString& aResult) const + virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsAString& aResult) const { - return NS_CONTENT_ATTR_NOT_THERE; + return PR_FALSE; } virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 1800ecb69b8..c0794a0f6a5 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -770,13 +770,13 @@ nsGenericDOMDataNode::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr, return NS_OK; } -nsresult +PRBool nsGenericDOMDataNode::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttr, nsAString& aResult) const { aResult.Truncate(); - return NS_CONTENT_ATTR_NOT_THERE; + return PR_FALSE; } PRBool diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index be51bc8ad42..1410084e8f7 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -195,8 +195,8 @@ public: PRBool aNotify); virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); - virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute, - nsAString& aResult) const; + virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute, + nsAString& aResult) const; virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const; virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID, nsIAtom** aName, nsIAtom** aPrefix) const; diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 95afbde4f47..f17b93c101c 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -487,9 +487,8 @@ nsNode3Tearoff::LookupPrefix(const nsAString& aNamespaceURI, getter_AddRefs(prefix)); if (namespace_id == kNameSpaceID_XMLNS) { - nsresult rv = content->GetAttr(namespace_id, name, ns); - - if (rv == NS_CONTENT_ATTR_HAS_VALUE && ns.Equals(aNamespaceURI)) { + if (content->AttrValueIs(namespace_id, name, aNamespaceURI, + eCaseMatters)) { name->ToString(aPrefix); return NS_OK; @@ -2427,18 +2426,18 @@ nsGenericElement::GetBaseURI() const // Now check for an xml:base attr nsAutoString value; - nsresult rv = GetAttr(kNameSpaceID_XML, nsHTMLAtoms::base, value); - if (rv != NS_CONTENT_ATTR_HAS_VALUE) { + GetAttr(kNameSpaceID_XML, nsHTMLAtoms::base, value); + if (value.IsEmpty()) { // No xml:base, so we just use the parent's base URL - nsIURI *base = parentBase; - NS_IF_ADDREF(base); + nsIURI *base = nsnull; + parentBase.swap(base); return base; } nsCOMPtr ourBase; - rv = NS_NewURI(getter_AddRefs(ourBase), value, - doc->GetDocumentCharacterSet().get(), parentBase); + nsresult rv = NS_NewURI(getter_AddRefs(ourBase), value, + doc->GetDocumentCharacterSet().get(), parentBase); if (NS_SUCCEEDED(rv)) { // do a security check, almost the same as nsDocument::SetBaseURL() rv = nsContentUtils::GetSecurityManager()-> @@ -4172,7 +4171,7 @@ nsGenericElement::GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const } -nsresult +PRBool nsGenericElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsAString& aResult) const { @@ -4187,13 +4186,12 @@ nsGenericElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // given us a non-empty string). aResult.Truncate(); - return NS_CONTENT_ATTR_NOT_THERE; + return PR_FALSE; } val->ToString(aResult); - return aResult.IsEmpty() ? NS_CONTENT_ATTR_NO_VALUE : - NS_CONTENT_ATTR_HAS_VALUE; + return PR_TRUE; } PRBool diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 5880330e84a..d86bec8706b 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -394,8 +394,8 @@ public: } virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); - virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAString& aResult) const; + virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsAString& aResult) const; virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const; virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString& aValue, diff --git a/mozilla/content/base/src/nsObjectLoadingContent.cpp b/mozilla/content/base/src/nsObjectLoadingContent.cpp index 9018638fbd9..bf8db4fdfa1 100644 --- a/mozilla/content/base/src/nsObjectLoadingContent.cpp +++ b/mozilla/content/base/src/nsObjectLoadingContent.cpp @@ -569,9 +569,8 @@ nsObjectLoadingContent::ObjectURIChanged(const nsAString& aURI, nsCOMPtr baseURI = thisContent->GetBaseURI(); nsCOMPtr codebaseURI; nsAutoString codebase; - nsresult rv = thisContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, - codebase); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + thisContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codebase); + if (!codebase.IsEmpty()) { nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(codebaseURI), codebase, doc, baseURI); } else { @@ -749,12 +748,15 @@ nsObjectLoadingContent::ObjectURIChanged(nsIURI* aURI, // If the class ID specifies a supported plugin, or if we have no explicit URI // but a type, immediately instantiate the plugin. PRBool isSupportedClassID = PR_FALSE; + PRBool hasID = PR_FALSE; if (GetCapabilities() & eSupportClassID) { nsAutoString classid; - rv = thisContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::classid, classid); + thisContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::classid, classid); nsCAutoString typeForID; - if (rv == NS_CONTENT_ATTR_HAS_VALUE) + if (!classid.IsEmpty()) { + hasID = PR_TRUE; isSupportedClassID = NS_SUCCEEDED(TypeForClassID(classid, typeForID)); + } } if (isSupportedClassID || (!aURI && !aTypeHint.IsEmpty() && @@ -777,7 +779,7 @@ nsObjectLoadingContent::ObjectURIChanged(nsIURI* aURI, } // If we get here, and we had a class ID, then it must have been unsupported. // Fallback in that case. - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (hasID) { mInstantiating = PR_FALSE; rv = NS_ERROR_NOT_AVAILABLE; return NS_OK; diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index 302f82710e9..357186df817 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -1763,8 +1763,7 @@ nsPlainTextSerializer::GetAttributeValue(const nsIParserNode* aNode, nsString& aValueRet) { if (mContent) { - if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttr(kNameSpaceID_None, - aName, aValueRet)) { + if (mContent->GetAttr(kNameSpaceID_None, aName, aValueRet)) { return NS_OK; } } diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp index 0f99f0dbd03..eb69770502c 100644 --- a/mozilla/content/base/src/nsScriptLoader.cpp +++ b/mozilla/content/base/src/nsScriptLoader.cpp @@ -288,36 +288,21 @@ PRBool nsScriptLoader::IsScriptEventHandler(nsIScriptElement *aScriptElement) { nsCOMPtr contElement = do_QueryInterface(aScriptElement); - if (!contElement || - !contElement->HasAttr(kNameSpaceID_None, nsHTMLAtoms::_event) || - !contElement->HasAttr(kNameSpaceID_None, nsHTMLAtoms::_for)) { - return PR_FALSE; + NS_ASSERTION(contElement, "nsIScriptElement isn't nsIContent"); + + nsAutoString forAttr, eventAttr; + if (!contElement->GetAttr(kNameSpaceID_None, nsHTMLAtoms::_for, forAttr) || + !contElement->GetAttr(kNameSpaceID_None, nsHTMLAtoms::_event, eventAttr)) { + return PR_FALSE; } - nsAutoString str; - nsresult rv = contElement->GetAttr(kNameSpaceID_None, nsHTMLAtoms::_for, - str); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - - const nsAString& for_str = nsContentUtils::TrimWhitespace(str); - + const nsAString& for_str = nsContentUtils::TrimWhitespace(forAttr); if (!for_str.LowerCaseEqualsLiteral("window")) { return PR_TRUE; } // We found for="window", now check for event="onload". - - rv = contElement->GetAttr(kNameSpaceID_None, nsHTMLAtoms::_event, str); - NS_ENSURE_SUCCESS(rv, PR_FALSE); - - const nsAString& event_str = nsContentUtils::TrimWhitespace(str, PR_FALSE); - - if (event_str.Length() < 6) { - // String too short, can't be "onload". - - return PR_TRUE; - } - + const nsAString& event_str = nsContentUtils::TrimWhitespace(eventAttr, PR_FALSE); if (!StringBeginsWith(event_str, NS_LITERAL_STRING("onload"), nsCaseInsensitiveStringComparator())) { // It ain't "onload.*". diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index c41f61931bd..e8ddd0dc502 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -1581,48 +1581,46 @@ nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext, attrName = nsSVGAtoms::onzoom; #endif // MOZ_SVG - result = content->GetAttr(kNameSpaceID_None, attrName, handlerBody); + content->GetAttr(kNameSpaceID_None, attrName, handlerBody); + + PRUint32 lineNo = 0; + nsCAutoString url (NS_LITERAL_CSTRING("javascript:alert('TODO: FIXME')")); + nsCOMPtr doc = do_QueryInterface(aCurrentTarget); + if (!doc) { + nsCOMPtr content = do_QueryInterface(aCurrentTarget); + if (content) + doc = content->GetOwnerDoc(); + } + if (doc) { + nsIURI *uri = doc->GetDocumentURI(); + if (uri) { + uri->GetSpec(url); + lineNo = 1; + } + } + + if (handlerOwner) { + // Always let the handler owner compile the event + // handler, as it may want to use a special + // context or scope object. + result = handlerOwner->CompileEventHandler(aContext, jsobj, aName, + handlerBody, + url.get(), lineNo, + &handler); + } + else { + const char *eventName = + nsContentUtils::GetEventArgName(content->GetNameSpaceID()); + + result = aContext->CompileEventHandler(jsobj, aName, eventName, + handlerBody, + url.get(), lineNo, + (handlerOwner != nsnull), + &handler); + } if (NS_SUCCEEDED(result)) { - PRUint32 lineNo = 0; - nsCAutoString url (NS_LITERAL_CSTRING("javascript:alert('TODO: FIXME')")); - nsCOMPtr doc = do_QueryInterface(aCurrentTarget); - if (!doc) { - nsCOMPtr content = do_QueryInterface(aCurrentTarget); - if (content) - doc = content->GetOwnerDoc(); - } - if (doc) { - nsIURI *uri = doc->GetDocumentURI(); - if (uri) { - uri->GetSpec(url); - lineNo = 1; - } - } - - if (handlerOwner) { - // Always let the handler owner compile the event - // handler, as it may want to use a special - // context or scope object. - result = handlerOwner->CompileEventHandler(aContext, jsobj, aName, - handlerBody, - url.get(), lineNo, - &handler); - } - else { - const char *eventName = - nsContentUtils::GetEventArgName(content->GetNameSpaceID()); - - result = aContext->CompileEventHandler(jsobj, aName, eventName, - handlerBody, - url.get(), lineNo, - (handlerOwner != nsnull), - &handler); - } - - if (NS_SUCCEEDED(result)) { - aListenerStruct->mHandlerIsString &= ~aSubType; - } + aListenerStruct->mHandlerIsString &= ~aSubType; } } } diff --git a/mozilla/content/events/src/nsXMLEventsManager.cpp b/mozilla/content/events/src/nsXMLEventsManager.cpp index f265425b1a5..2d160618869 100644 --- a/mozilla/content/events/src/nsXMLEventsManager.cpp +++ b/mozilla/content/events/src/nsXMLEventsManager.cpp @@ -49,11 +49,13 @@ #include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIStyledContent.h" +#include "nsLayoutAtoms.h" PRBool nsXMLEventsListener::InitXMLEventsListener(nsIDocument * aDocument, nsXMLEventsManager * aManager, nsIContent * aContent) { + nsresult rv; PRInt32 nameSpaceID; if (aContent->GetDocument() != aDocument) return PR_FALSE; @@ -63,8 +65,8 @@ PRBool nsXMLEventsListener::InitXMLEventsListener(nsIDocument * aDocument, else nameSpaceID = kNameSpaceID_XMLEvents; nsAutoString eventType; - nsresult rv = aContent->GetAttr(nameSpaceID, nsHTMLAtoms::_event, eventType); - if (rv != NS_CONTENT_ATTR_HAS_VALUE) + aContent->GetAttr(nameSpaceID, nsHTMLAtoms::_event, eventType); + if (eventType.IsEmpty()) return PR_FALSE; nsAutoString handlerURIStr; PRBool hasHandlerURI = PR_FALSE; @@ -72,8 +74,7 @@ PRBool nsXMLEventsListener::InitXMLEventsListener(nsIDocument * aDocument, nsAutoString observerID; nsAutoString targetIdref; - if (aContent->GetAttr(nameSpaceID, nsHTMLAtoms::handler, handlerURIStr) != - NS_CONTENT_ATTR_NOT_THERE) { + if (aContent->GetAttr(nameSpaceID, nsHTMLAtoms::handler, handlerURIStr)) { hasHandlerURI = PR_TRUE; nsCAutoString handlerRef; nsCOMPtr handlerURI; @@ -108,23 +109,19 @@ PRBool nsXMLEventsListener::InitXMLEventsListener(nsIDocument * aDocument, aContent->GetAttr(nameSpaceID, nsHTMLAtoms::target, targetIdref); PRBool hasObserver = - aContent->GetAttr(nameSpaceID, nsHTMLAtoms::observer, observerID) != - NS_CONTENT_ATTR_NOT_THERE; + aContent->GetAttr(nameSpaceID, nsHTMLAtoms::observer, observerID); - nsAutoString phase; PRBool capture = - aContent->GetAttr(nameSpaceID, nsHTMLAtoms::phase, phase) != - NS_CONTENT_ATTR_NOT_THERE && phase.Equals(NS_LITERAL_STRING("capture")); + aContent->AttrValueIs(nameSpaceID, nsHTMLAtoms::phase, + nsLayoutAtoms::capture, eCaseMatters); - nsAutoString prop; PRBool stopPropagation = - aContent->GetAttr(nameSpaceID, nsHTMLAtoms::propagate, prop) != - NS_CONTENT_ATTR_NOT_THERE && prop.Equals(NS_LITERAL_STRING("stop")); + aContent->AttrValueIs(nameSpaceID, nsHTMLAtoms::propagate, + nsLayoutAtoms::stop, eCaseMatters); - nsAutoString cancel; PRBool cancelDefault = - aContent->GetAttr(nameSpaceID, nsHTMLAtoms::defaultAction, cancel) != - NS_CONTENT_ATTR_NOT_THERE && cancel.Equals(NS_LITERAL_STRING("cancel")); + aContent->AttrValueIs(nameSpaceID, nsHTMLAtoms::defaultAction, + nsLayoutAtoms::cancel, eCaseMatters); nsCOMPtr observer; if (!hasObserver) { diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index b01317c580e..a5954f8d421 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1783,26 +1783,6 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, return nsGenericElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify); } -nsresult -nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute, - nsAString& aResult) const -{ - NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, - "must have a real namespace ID!"); - - aResult.Truncate(); - - const nsAttrValue* attrValue = - mAttrsAndChildren.GetAttr(aAttribute, aNameSpaceID); - if (!attrValue) { - return NS_CONTENT_ATTR_NOT_THERE; - } - - attrValue->ToString(aResult); - - return NS_CONTENT_ATTR_HAS_VALUE; -} - const nsAttrValue* nsGenericHTMLElement::GetClasses() const { @@ -1869,7 +1849,7 @@ nsGenericHTMLElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, // XXXbz if the old rule points to the same declaration as the new one, // this is getting the new attr value, not the old one.... modification = GetAttr(kNameSpaceID_None, nsHTMLAtoms::style, - oldValueStr) != NS_CONTENT_ATTR_NOT_THERE; + oldValueStr); } else if (aNotify) { modification = !!mAttrsAndChildren.GetAttr(nsHTMLAtoms::style); @@ -2933,8 +2913,7 @@ nsGenericHTMLElement::GetStringAttrWithDefault(nsIAtom* aAttr, const char* aDefault, nsAString& aResult) { - nsresult rv = GetAttr(kNameSpaceID_None, aAttr, aResult); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, aAttr, aResult)) { CopyASCIItoUTF16(aDefault, aResult); } return NS_OK; @@ -2983,8 +2962,7 @@ nsresult nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult) { nsAutoString attrValue; - nsresult rv = GetAttr(kNameSpaceID_None, aAttr, attrValue); - if (rv != NS_CONTENT_ATTR_HAS_VALUE) { + if (!GetAttr(kNameSpaceID_None, aAttr, attrValue)) { aResult.Truncate(); return NS_OK; @@ -2992,9 +2970,10 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult) nsCOMPtr baseURI = GetBaseURI(); nsCOMPtr attrURI; - rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI), - attrValue, GetOwnerDoc(), - baseURI); + nsresult rv = + nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI), + attrValue, GetOwnerDoc(), + baseURI); if (NS_FAILED(rv)) { // Just use the attr value as the result... aResult = attrValue; @@ -3594,9 +3573,8 @@ nsGenericHTMLElement::RegUnRegAccessKey(PRBool aDoReg) { // first check to see if we have an access key nsAutoString accessKey; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, accessKey); - if (NS_FAILED(rv) || NS_CONTENT_ATTR_NOT_THERE == rv || - accessKey.IsEmpty()) { + GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, accessKey); + if (accessKey.IsEmpty()) { return; } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index a0bdbaec809..79c12a2c458 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -185,8 +185,6 @@ public: virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, PRBool aCompileEventHandlers); - virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAString& aResult) const; virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify); #ifdef DEBUG diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index e2af9d75398..0d86dfcb945 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -294,10 +294,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsPresContext* aPresContext, NS_IMETHODIMP nsHTMLAnchorElement::GetTarget(nsAString& aValue) { - aValue.Truncate(); - - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue)) { GetBaseTarget(aValue); } return NS_OK; diff --git a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp index a217fb0b917..ca5f7f03c40 100644 --- a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp @@ -295,8 +295,7 @@ void nsHTMLAppletElement::StartAppletLoad(PRBool aNotify) { nsAutoString uri; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, uri); - if (rv != NS_CONTENT_ATTR_NOT_THERE) { + if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, uri)) { ObjectURIChanged(uri, aNotify, NS_LITERAL_CSTRING("application/x-java-vm"), PR_TRUE); } else { diff --git a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp index d1abbbe1bd0..b69c5d47b86 100644 --- a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp @@ -152,11 +152,7 @@ NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLAreaElement, TabIndex, tabindex, 0) NS_IMETHODIMP nsHTMLAreaElement::GetTarget(nsAString& aValue) { - aValue.Truncate(); - - nsresult rv; - rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue)) { GetBaseTarget(aValue); } return NS_OK; diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 1c3ca3ae602..e2d47b9672d 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -315,8 +315,7 @@ nsHTMLBodyElement::Get##func_(nsAString& aColor) \ aColor.Truncate(); \ nsAutoString color; \ nscolor attrColor; \ - if (NS_CONTENT_ATTR_NOT_THERE == \ - GetAttr(kNameSpaceID_None, nsHTMLAtoms::attr_, color)) { \ + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::attr_, color)) { \ \ nsPresContext *presContext = GetPresContext(); \ if (presContext) { \ @@ -351,11 +350,10 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor) nsAutoString attr; nscolor bgcolor; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::bgcolor, attr); // If we don't have an attribute, find the actual color used for // (generally from the user agent style sheet) for compatibility - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::bgcolor, attr)) { nsIDocument *document = GetCurrentDoc(); if (document) { // Make sure the style is up-to-date, since we need it diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index be70d7f3246..85edc2ddc51 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -480,7 +480,8 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext, nsresult nsHTMLButtonElement::GetDefaultValue(nsAString& aDefaultValue) { - return GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aDefaultValue); + GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aDefaultValue); + return NS_OK; } nsresult @@ -521,9 +522,8 @@ nsHTMLButtonElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // Get the name (if no name, no submit) // nsAutoString name; - rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name); - if (NS_FAILED(rv) || rv == NS_CONTENT_ATTR_NOT_THERE) { - return rv; + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name)) { + return NS_OK; } // diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 3e3c43c1831..aa503c959a7 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -573,8 +573,7 @@ NS_IMPL_STRING_ATTR(nsHTMLFormElement, Name, name) NS_IMETHODIMP nsHTMLFormElement::GetAction(nsAString& aValue) { - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::action, aValue); - NS_ENSURE_SUCCESS(rv, rv); + GetAttr(kNameSpaceID_None, nsHTMLAtoms::action, aValue); if (aValue.IsEmpty()) { // Avoid resolving action="" to the base uri, bug 297761. return NS_OK; @@ -591,9 +590,7 @@ nsHTMLFormElement::SetAction(const nsAString& aValue) NS_IMETHODIMP nsHTMLFormElement::GetTarget(nsAString& aValue) { - aValue.Truncate(); - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue)) { GetBaseTarget(aValue); } return NS_OK; @@ -1676,14 +1673,8 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName, if (control->GetType() == NS_FORM_INPUT_RADIO) { nsCOMPtr controlContent(do_QueryInterface(control)); if (controlContent) { - // - // XXX This is a particularly frivolous string copy just to determine - // if the string is empty or not - // - nsAutoString name; - if (controlContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, - name) != NS_CONTENT_ATTR_NOT_THERE && - name.IsEmpty()) { + if (controlContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::name, + EmptyString(), eCaseMatters)) { aVisitor->Visit(control, &stopIterating); if (stopIterating) { break; diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index f582bba65ce..bce4737bb2b 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -597,8 +597,7 @@ nsHTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, // Our base URI may have changed; claim that our URI changed, and the // nsImageLoadingContent will decide whether a new image load is warranted. nsAutoString uri; - nsresult result = GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri); - if (result == NS_CONTENT_ATTR_HAS_VALUE) { + if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) { // Note: no need to notify here; since we're just now being bound // we don't have any frames or anything yet. ImageURIChanged(uri, PR_FALSE, PR_FALSE); diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 0ebb25959d0..47e0db9560b 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -238,8 +238,7 @@ protected: * @param true if the name existed, false if not */ PRBool GetNameIfExists(nsAString& aName) { - return GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, aName) != - NS_CONTENT_ATTR_NOT_THERE; + return GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, aName); } /** @@ -524,8 +523,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // We just got switched to be an image input; we should see // whether we have an image to load; nsAutoString src; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src)) { ImageURIChanged(src, PR_FALSE, aNotify); } } @@ -622,17 +620,13 @@ nsHTMLInputElement::GetValue(nsAString& aValue) } // Treat value == defaultValue for other input elements - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue); - - if (rv == NS_CONTENT_ATTR_NOT_THERE && + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue) && (mType == NS_FORM_INPUT_RADIO || mType == NS_FORM_INPUT_CHECKBOX)) { // The default value of a radio or checkbox input is "on". aValue.AssignLiteral("on"); - - return NS_OK; } - return rv; + return NS_OK; } NS_IMETHODIMP @@ -1056,9 +1050,7 @@ nsHTMLInputElement::SetFocus(nsPresContext* aPresContext) return; // first see if we are disabled or not. If disabled then do nothing. - nsAutoString disabled; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttr(kNameSpaceID_None, - nsHTMLAtoms::disabled, disabled)) { + if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) { return; } @@ -1099,10 +1091,8 @@ nsHTMLInputElement::Select() return NS_OK; // first see if we are disabled or not. If disabled then do nothing. - nsAutoString disabled; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttr(kNameSpaceID_None, - nsHTMLAtoms::disabled, disabled)) { - return rv; + if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) { + return NS_OK; } if (mType == NS_FORM_INPUT_PASSWORD || mType == NS_FORM_INPUT_TEXT) { @@ -1197,9 +1187,8 @@ nsHTMLInputElement::Click() // first see if we are disabled or not. If disabled then do nothing. nsAutoString disabled; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttr(kNameSpaceID_None, - nsHTMLAtoms::disabled, disabled)) { - return rv; + if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) { + return NS_OK; } // see what type of input we are. Only click button, checkbox, radio, @@ -1696,8 +1685,7 @@ nsHTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, // Our base URI may have changed; claim that our URI changed, and the // nsImageLoadingContent will decide whether a new image load is warranted. nsAutoString uri; - nsresult result = GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri); - if (result == NS_CONTENT_ATTR_HAS_VALUE) { + if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) { // Note: no need to notify here; since we're just now being bound // we don't have any frames or anything yet. ImageURIChanged(uri, PR_FALSE, PR_FALSE); @@ -2157,11 +2145,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // Get the name // nsAutoString name; - rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name); - if (NS_FAILED(rv)) { - return rv; - } - PRBool nameThere = (rv != NS_CONTENT_ATTR_NOT_THERE); + PRBool nameThere = GetNameIfExists(name); // // Submit .x, .y for input type=image diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index a5ca3dfb3ff..91097a10e5f 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -268,12 +268,7 @@ nsHTMLObjectElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement) { nsAutoString name; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name); - if (NS_FAILED(rv)) { - return rv; - } - - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name)) { // No name, don't submit. return NS_OK; @@ -304,7 +299,7 @@ nsHTMLObjectElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, } nsAutoString value; - rv = pi_internal->GetFormValue(value); + nsresult rv = pi_internal->GetFormValue(value); NS_ENSURE_SUCCESS(rv, rv); return aFormSubmission->AddNameValuePair(this, name, value); @@ -410,16 +405,14 @@ nsHTMLObjectElement::GetAttributeMappingFunction() const void nsHTMLObjectElement::StartObjectLoad(PRBool aNotify) { - nsAutoString uri; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, uri); - nsAutoString type; + nsAutoString uri, type; GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type); NS_ConvertUTF16toUTF8 ctype(type); // Be sure to call the nsIURI version if we have no attribute // That handles the case where no URI is specified. An empty string would get // interpreted as the page itself, instead of absence of URI. - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, uri)) { ObjectURIChanged(nsnull, aNotify, ctype); } else { ObjectURIChanged(uri, aNotify, ctype); diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 89289393945..c4cc0db2416 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -248,10 +248,9 @@ nsHTMLOptionElement::SetValue(const nsAString& aValue) NS_IMETHODIMP nsHTMLOptionElement::GetValue(nsAString& aValue) { - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue); // If the value attr is there, that is *exactly* what we use. If it is // not, we compress whitespace .text. - if (NS_CONTENT_ATTR_NOT_THERE == rv) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue)) { GetText(aValue); } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index bedce87f23a..ceb4791a5c5 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -1967,9 +1967,8 @@ nsHTMLSelectElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // Get the name (if no name, no submit) // nsAutoString name; - rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name); - if (NS_FAILED(rv) || rv == NS_CONTENT_ATTR_NOT_THERE) { - return rv; + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name)) { + return NS_OK; } // @@ -2209,14 +2208,10 @@ nsHTMLOptionCollection::NamedItem(const nsAString& aName, nsCOMPtr content = do_QueryInterface(mElements.ObjectAt(i)); if (content) { - nsAutoString name; - - if (((content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, - name) == NS_CONTENT_ATTR_HAS_VALUE) && - aName.Equals(name)) || - ((content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id, - name) == NS_CONTENT_ATTR_HAS_VALUE) && - aName.Equals(name))) { + if (content->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::name, aName, + eCaseMatters) || + content->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::id, aName, + eCaseMatters)) { rv = CallQueryInterface(content, aReturn); break; diff --git a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp index 60f19d1bf8e..f6a7eb04e90 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp @@ -526,8 +526,7 @@ nsHTMLSharedElement::BindToTree(nsIDocument* aDocument, GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type); nsAutoString uri; - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri); - if (rv != NS_CONTENT_ATTR_NOT_THERE) { + if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) { // Don't notify: We aren't in a document yet, so we have no frames ObjectURIChanged(uri, PR_FALSE, NS_ConvertUTF16toUTF8(type), PR_TRUE); } else { diff --git a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp index 1fb0687d3b2..5cec9f39f0a 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp @@ -228,9 +228,7 @@ NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Width, width) NS_IMETHODIMP nsHTMLTableCellElement::GetAlign(nsAString& aValue) { - nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, aValue); - - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, aValue)) { // There's no align attribute, ask the row for the alignment. nsCOMPtr row; diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index f36e9adea86..926f6cfaa09 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -243,11 +243,7 @@ nsHTMLTextAreaElement::SetFocus(nsPresContext* aPresContext) return; // first see if we are disabled or not. If disabled then do nothing. - nsAutoString disabled; - - if (NS_CONTENT_ATTR_HAS_VALUE == - nsGenericHTMLFormElement::GetAttr(kNameSpaceID_None, - nsHTMLAtoms::disabled, disabled)) { + if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) { return; } @@ -267,10 +263,7 @@ nsHTMLTextAreaElement::Select() nsresult rv = NS_OK; // first see if we are disabled or not. If disabled then do nothing. - nsAutoString disabled; - if (NS_CONTENT_ATTR_HAS_VALUE == - nsGenericHTMLFormElement::GetAttr(kNameSpaceID_None, - nsHTMLAtoms::disabled, disabled)) { + if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) { return rv; } @@ -793,9 +786,8 @@ nsHTMLTextAreaElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // Get the name (if no name, no submit) // nsAutoString name; - rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name); - if (NS_FAILED(rv) || rv == NS_CONTENT_ATTR_NOT_THERE) { - return rv; + if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, name)) { + return NS_OK; } // diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 41275cec43e..ee24449694c 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -3647,13 +3647,11 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) parent->AppendChildTo(element, PR_FALSE); if (!mInsideNoXXXTag) { nsAutoString value; - if (element->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, - value) == NS_CONTENT_ATTR_HAS_VALUE) { + if (element->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value)) { ProcessBaseHref(value); } - if (element->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, - value) == NS_CONTENT_ATTR_HAS_VALUE) { + if (element->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, value)) { ProcessBaseTarget(value); } } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 6028508ee85..29ba4864bc8 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -2446,15 +2446,8 @@ nsHTMLDocument::MatchNameAttribute(nsIContent* aContent, PRInt32 aNamespaceID, { NS_PRECONDITION(aContent, "Must have content node to work with!"); - // Getting attrs is expensive, so use HasAttr() first. - if (!aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::name)) { - return PR_FALSE; - } - - nsAutoString value; - nsresult rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, value); - - return NS_SUCCEEDED(rv) && value.Equals(aData); + return aContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::name, aData, + eCaseMatters); } NS_IMETHODIMP diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index 4e45d306783..34562e8ed0a 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -298,10 +298,10 @@ void nsHTMLFragmentContentSink::ProcessBaseTag(nsIContent* aContent) { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value)) { + if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value)) { mBaseHREF = value; } - if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, value)) { + if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, value)) { mBaseTarget = value; } } diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 573588ece5d..57f55329e8b 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -424,7 +424,9 @@ nsSVGElement::IsSupported(const nsAString& aFeature, const nsAString& aVersion, /* attribute DOMString id; */ NS_IMETHODIMP nsSVGElement::GetId(nsAString & aId) { - return GetAttr(kNameSpaceID_None, nsSVGAtoms::id, aId); + GetAttr(kNameSpaceID_None, nsSVGAtoms::id, aId); + + return NS_OK; } NS_IMETHODIMP nsSVGElement::SetId(const nsAString & aId) diff --git a/mozilla/content/svg/content/src/nsSVGScriptElement.cpp b/mozilla/content/svg/content/src/nsSVGScriptElement.cpp index fa3472d648e..d0427904e42 100644 --- a/mozilla/content/svg/content/src/nsSVGScriptElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGScriptElement.cpp @@ -191,7 +191,9 @@ NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGScriptElement) NS_IMETHODIMP nsSVGScriptElement::GetType(nsAString & aType) { - return GetAttr(kNameSpaceID_None, nsSVGAtoms::type, aType); + GetAttr(kNameSpaceID_None, nsSVGAtoms::type, aType); + + return NS_OK; } NS_IMETHODIMP nsSVGScriptElement::SetType(const nsAString & aType) diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index 022f67de66a..71a00abfe42 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -494,9 +494,7 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, attrPresent = PR_FALSE; } else { - nsresult result = aChangedElement->GetAttr(aNameSpaceID, aAttribute, value); - attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE || - result == NS_CONTENT_ATTR_HAS_VALUE); + attrPresent = aChangedElement->GetAttr(aNameSpaceID, aAttribute, value); } if (attrPresent) @@ -863,9 +861,7 @@ PRBool PR_CALLBACK SetAttrs(nsHashKey* aKey, void* aData, void* aClosure) attrPresent = PR_FALSE; } else { - nsresult result = changeData->mBoundElement->GetAttr(srcNs, src, value); - attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE || - result == NS_CONTENT_ATTR_HAS_VALUE); + attrPresent = changeData->mBoundElement->GetAttr(srcNs, src, value); } if (attrPresent) { diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index 7c3766098ef..77927bb7622 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -66,6 +66,7 @@ #include "nsIDOMViewCSS.h" #include "nsIXBLService.h" #include "nsIBindingManager.h" +#include "nsLayoutAtoms.h" nsresult NS_NewXMLElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo) @@ -191,14 +192,11 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell) nsresult rv = NS_OK; if (mIsLink) { - NS_NAMED_LITERAL_STRING(onloadString, "onLoad"); do { // actuate="onLoad" ? nsAutoString value; - rv = nsGenericElement::GetAttr(kNameSpaceID_XLink, - nsLayoutAtoms::actuate, value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && - value.Equals(onloadString)) { + if (AttrValueIs(kNameSpaceID_XLink, nsLayoutAtoms::actuate, + nsLayoutAtoms::onLoad, eCaseMatters)) { // Disable in Mail/News for now. We may want a pref to control // this at some point. @@ -218,10 +216,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell) // show= ? nsLinkVerb verb = eLinkVerb_Undefined; // basically means same as replace - rv = nsGenericElement::GetAttr(kNameSpaceID_XLink, - nsLayoutAtoms::show, value); - if (NS_FAILED(rv)) - break; + GetAttr(kNameSpaceID_XLink, nsLayoutAtoms::show, value); // XXX Should probably do this using atoms if (value.EqualsLiteral("new")) { @@ -252,9 +247,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell) break; // href= ? - rv = nsGenericElement::GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, - value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && !value.IsEmpty()) { + if (GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, value)) { nsCOMPtr uri; rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), value, @@ -320,8 +313,7 @@ nsXMLElement::HandleDOMEvent(nsPresContext* aPresContext, break; } - nsGenericElement::GetAttr(kNameSpaceID_XLink, nsLayoutAtoms::show, - show); + GetAttr(kNameSpaceID_XLink, nsLayoutAtoms::show, show); // XXX Should probably do this using atoms if (show.EqualsLiteral("new")) { @@ -379,8 +371,7 @@ nsXMLElement::HandleDOMEvent(nsPresContext* aPresContext, case NS_MOUSE_ENTER_SYNTH: { nsAutoString href; - nsGenericElement::GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, - href); + GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::href, href); if (href.IsEmpty()) { *aEventStatus = nsEventStatus_eConsumeDoDefault; break; diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index edeee5d87b3..930e929b4ab 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -692,13 +692,11 @@ nsXMLContentSink::ProcessBASETag(nsIContent* aContent) if (mDocument) { nsAutoString value; - if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, value) == - NS_CONTENT_ATTR_HAS_VALUE) { + if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, value)) { mDocument->SetBaseTarget(value); } - if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value) == - NS_CONTENT_ATTR_HAS_VALUE) { + if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value)) { nsCOMPtr baseURI; rv = NS_NewURI(getter_AddRefs(baseURI), value); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/content/xtf/public/nsIXTFAttributeHandler.idl b/mozilla/content/xtf/public/nsIXTFAttributeHandler.idl index d4073159a08..e769f7a94ad 100644 --- a/mozilla/content/xtf/public/nsIXTFAttributeHandler.idl +++ b/mozilla/content/xtf/public/nsIXTFAttributeHandler.idl @@ -55,9 +55,9 @@ interface nsIXTFAttributeHandler : nsISupports // If the attribute 'name' is unknown the implementation should mark // the returned string as being 'null' (i.e. return 'null' in JS; // call SetIsVoid(PR_TRUE) in C++) rather than throw an exception. - // A 'void' result will be translated into NS_CONTENT_ATTR_NOT_THERE + // A 'void' result will be translated into the attribute missing // by the wrapper. An empty result will be translated into - // NS_CONTENT_ATTR_NO_VALUE. + // the attribute having no value. AString getAttribute(in nsIAtom name); boolean hasAttribute(in nsIAtom name); diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp index d941b10af0d..ece24730de7 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp @@ -283,22 +283,14 @@ nsXTFElementWrapper::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, return rv; } -nsresult +PRBool nsXTFElementWrapper::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsAString& aResult) const { if (aNameSpaceID==kNameSpaceID_None && HandledByInner(aName)) { // XXX we don't do namespaced attributes yet - if (aNameSpaceID != kNameSpaceID_None) { - NS_WARNING("getattr: xtf elements don't do namespaced attribs yet!"); - return NS_CONTENT_ATTR_NOT_THERE; - } nsresult rv = mAttributeHandler->GetAttribute(aName, aResult); - if (NS_FAILED(rv)) return rv; - if (aResult.IsVoid()) return NS_CONTENT_ATTR_NOT_THERE; - if (aResult.IsEmpty()) return NS_CONTENT_ATTR_NO_VALUE; - - return NS_CONTENT_ATTR_HAS_VALUE; + return NS_SUCCEEDED(rv) && !aResult.IsVoid(); } else { // try wrapper return nsXTFElementWrapperBase::GetAttr(aNameSpaceID, aName, aResult); @@ -329,8 +321,7 @@ nsXTFElementWrapper::AttrValueIs(PRInt32 aNameSpaceID, if (aNameSpaceID == kNameSpaceID_None && HandledByInner(aName)) { nsAutoString ourVal; - nsresult rv = GetAttr(aNameSpaceID, aName, ourVal); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(aNameSpaceID, aName, ourVal)) { return PR_FALSE; } return aCaseSensitive == eCaseMatters ? @@ -354,8 +345,7 @@ nsXTFElementWrapper::AttrValueIs(PRInt32 aNameSpaceID, if (aNameSpaceID == kNameSpaceID_None && HandledByInner(aName)) { nsAutoString ourVal; - nsresult rv = GetAttr(aNameSpaceID, aName, ourVal); - if (rv == NS_CONTENT_ATTR_NOT_THERE) { + if (!GetAttr(aNameSpaceID, aName, ourVal)) { return PR_FALSE; } if (aCaseSensitive == eCaseMatters) { diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.h b/mozilla/content/xtf/src/nsXTFElementWrapper.h index 5f749f9d3db..e09d3b28f9d 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.h +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.h @@ -90,8 +90,8 @@ public: nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); - nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAString& aResult) const; + PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsAString& aResult) const; PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const; virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString& aValue, diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 68c037be840..0bfc5de6d77 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1285,7 +1285,7 @@ nsXULElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const return nsnull; } -nsresult +PRBool nsXULElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsAString& aResult) const { @@ -1300,13 +1300,12 @@ nsXULElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // something about the out parameters (someone may have // given us a non-empty string). aResult.Truncate(); - return NS_CONTENT_ATTR_NOT_THERE; + return PR_FALSE; } val->ToString(aResult); - return aResult.IsEmpty() ? NS_CONTENT_ATTR_NO_VALUE : - NS_CONTENT_ATTR_HAS_VALUE; + return PR_TRUE; } PRBool @@ -2030,20 +2029,16 @@ NS_IMETHODIMP nsXULElement::GetResource(nsIRDFResource** aResource) { nsAutoString id; - nsresult rv = GetAttr(kNameSpaceID_None, nsXULAtoms::ref, id); - - if (rv != NS_CONTENT_ATTR_HAS_VALUE) { - rv = GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); + GetAttr(kNameSpaceID_None, nsXULAtoms::ref, id); + if (id.IsEmpty()) { + GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); } - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - rv = nsXULContentUtils::RDFService()-> + if (!id.IsEmpty()) { + return nsXULContentUtils::RDFService()-> GetUnicodeResource(id, aResource); - NS_ENSURE_SUCCESS(rv, rv); - } - else { - *aResource = nsnull; } + *aResource = nsnull; return NS_OK; } @@ -2310,7 +2305,8 @@ nsXULElement::GetBoxObject(nsIBoxObject** aResult) NS_IMETHODIMP \ nsXULElement::Get##_method(nsAString& aReturn) \ { \ - return GetAttr(kNameSpaceID_None, nsXULAtoms::_atom, aReturn); \ + GetAttr(kNameSpaceID_None, nsXULAtoms::_atom, aReturn); \ + return NS_OK; \ } \ NS_IMETHODIMP \ nsXULElement::Set##_method(const nsAString& aValue) \ diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 15b661fce28..f8213d0b92f 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -478,8 +478,8 @@ public: virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); virtual nsIAtom *GetIDAttributeName() const; virtual nsIAtom *GetClassAttributeName() const; - virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAString& aResult) const; + virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsAString& aResult) const; virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const; virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString& aValue, diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 19d4496a8fa..10d75dd96f4 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -864,10 +864,7 @@ nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster, nsCOMPtr name = do_GetAtom(aAttr); nsAutoString value; - nsresult rv = broadcaster->GetAttr(kNameSpaceID_None, name, value); - - if (rv == NS_CONTENT_ATTR_NO_VALUE || - rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (broadcaster->GetAttr(kNameSpaceID_None, name, value)) { listener->SetAttr(kNameSpaceID_None, name, value, PR_FALSE); } else { @@ -1109,7 +1106,7 @@ nsXULDocument::AttributeChanged(nsIStyledContent* aElement, if (PL_DHASH_ENTRY_IS_BUSY(entry)) { // We've got listeners: push the value. nsAutoString value; - rv = aElement->GetAttr(kNameSpaceID_None, aAttribute, value); + PRBool attrSet = aElement->GetAttr(kNameSpaceID_None, aAttribute, value); for (PRInt32 i = entry->mListeners.Count() - 1; i >= 0; --i) { BroadcastListener* bl = @@ -1120,8 +1117,7 @@ nsXULDocument::AttributeChanged(nsIStyledContent* aElement, nsCOMPtr listener = do_QueryInterface(bl->mListener); - if (rv == NS_CONTENT_ATTR_NO_VALUE || - rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (attrSet) { listener->SetAttr(kNameSpaceID_None, aAttribute, value, PR_TRUE); } @@ -1148,10 +1144,8 @@ nsXULDocument::AttributeChanged(nsIStyledContent* aElement, // // XXX Namespace handling broken :-( nsAutoString persist; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::persist, persist); - if (NS_FAILED(rv)) return; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::persist, persist); + if (!persist.IsEmpty()) { nsAutoString attr; rv = aAttribute->ToString(attr); if (NS_FAILED(rv)) return; @@ -1437,17 +1431,14 @@ nsXULDocument::Persist(nsIContent* aElement, PRInt32 aNameSpaceID, // Turn the value into a literal nsAutoString valuestr; - rv = aElement->GetAttr(kNameSpaceID_None, aAttribute, valuestr); - if (NS_FAILED(rv)) return rv; - - PRBool novalue = (rv != NS_CONTENT_ATTR_HAS_VALUE); + aElement->GetAttr(kNameSpaceID_None, aAttribute, valuestr); // See if there was an old value... nsCOMPtr oldvalue; rv = mLocalStore->GetTarget(element, attr, PR_TRUE, getter_AddRefs(oldvalue)); if (NS_FAILED(rv)) return rv; - if (oldvalue && novalue) { + if (oldvalue && valuestr.IsEmpty()) { // ...there was an oldvalue, and they've removed it. XXXThis // handling isn't quite right... rv = mLocalStore->Unassert(element, attr, oldvalue); @@ -1704,11 +1695,8 @@ nsXULDocument::AddElementToDocumentPre(nsIContent* aElement) // 2. If the element is a 'command updater' (i.e., has a // "commandupdater='true'" attribute), then add the element to the // document's command dispatcher - nsAutoString value; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::commandupdater, - value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && - value.EqualsLiteral("true")) { + if (aElement->AttrValueIs(kNameSpaceID_None, nsXULAtoms::commandupdater, + nsXULAtoms::_true, eCaseMatters)) { rv = nsXULContentUtils::SetCommandUpdater(this, aElement); if (NS_FAILED(rv)) return rv; } @@ -1827,11 +1815,8 @@ nsXULDocument::RemoveSubtreeFromDocument(nsIContent* aElement) // 3. If the element is a 'command updater', then remove the // element from the document's command dispatcher. - nsAutoString value; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::commandupdater, - value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && - value.EqualsLiteral("true")) { + if (aElement->AttrValueIs(kNameSpaceID_None, nsXULAtoms::commandupdater, + nsXULAtoms::_true, eCaseMatters)) { nsCOMPtr domelement = do_QueryInterface(aElement); NS_ASSERTION(domelement != nsnull, "not a DOM element"); if (! domelement) @@ -1909,11 +1894,8 @@ nsXULDocument::AddElementToMap(nsIContent* aElement) for (PRInt32 i = 0; kIdentityAttrs[i] != nsnull; ++i) { nsAutoString value; - rv = aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get attribute"); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value); + if (!value.IsEmpty()) { rv = mElementMap.Add(value, aElement); if (NS_FAILED(rv)) return rv; } @@ -1931,11 +1913,8 @@ nsXULDocument::RemoveElementFromMap(nsIContent* aElement) for (PRInt32 i = 0; kIdentityAttrs[i] != nsnull; ++i) { nsAutoString value; - rv = aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get attribute"); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value); + if (!value.IsEmpty()) { rv = mElementMap.Remove(value, aElement); if (NS_FAILED(rv)) return rv; } @@ -2100,20 +2079,10 @@ nsXULDocument::MatchAttribute(nsIContent* aContent, { NS_PRECONDITION(aContent, "Must have content node to work with!"); - // Getting attrs is expensive, so use HasAttr() first. - if (!aContent->HasAttr(aNamespaceID, aAttrName)) { - return PR_FALSE; - } - - if (aAttrValue.EqualsLiteral("*")) { - // Wildcard. We already know we have this attr, so we match - return PR_TRUE; - } - - nsAutoString value; - nsresult rv = aContent->GetAttr(aNamespaceID, aAttrName, value); - - return NS_SUCCEEDED(rv) && value.Equals(aAttrValue); + return aAttrValue.EqualsLiteral("*") ? + aContent->HasAttr(aNamespaceID, aAttrName) : + aContent->AttrValueIs(aNamespaceID, aAttrName, aAttrValue, + eCaseMatters); } nsresult @@ -3764,9 +3733,7 @@ nsXULDocument::OverlayForwardReference::Resolve() shell->GetDidInitialReflow(¬ify); nsAutoString id; - rv = mOverlay->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); - if (NS_FAILED(rv)) return eResolve_Error; - + mOverlay->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); if (id.IsEmpty()) { // overlay had no id, use the root element mDocument->InsertElement(mDocument->mRootContent, mOverlay, notify); @@ -3853,8 +3820,7 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode, continue; nsAutoString value; - rv = aOverlayNode->GetAttr(nameSpaceID, attr, value); - if (NS_FAILED(rv)) return rv; + aOverlayNode->GetAttr(nameSpaceID, attr, value); // Element in the overlay has the 'removeelement' attribute set // so remove it from the actual document. @@ -3889,11 +3855,10 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode, currContent = aOverlayNode->GetChildAt(0); nsAutoString id; - rv = currContent->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); - if (NS_FAILED(rv)) return rv; + currContent->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); nsCOMPtr nodeInDocument; - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (!id.IsEmpty()) { nsCOMPtr domDocument( do_QueryInterface(aTargetNode->GetDocument())); if (!domDocument) return NS_ERROR_FAILURE; @@ -3914,9 +3879,8 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode, // also has aTargetNode as its parent. nsAutoString documentParentID; - rv = aTargetNode->GetAttr(kNameSpaceID_None, nsXULAtoms::id, - documentParentID); - if (NS_FAILED(rv)) return rv; + aTargetNode->GetAttr(kNameSpaceID_None, nsXULAtoms::id, + documentParentID); nsCOMPtr nodeParent; rv = nodeInDocument->GetParentNode(getter_AddRefs(nodeParent)); @@ -3997,16 +3961,11 @@ nsXULDocument::BroadcasterHookup::~BroadcasterHookup() nsAutoString attribute; if (tag == nsXULAtoms::observes) { - rv = mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::element, broadcasterID); - if (NS_FAILED(rv)) return; - - rv = mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::attribute, attribute); - if (NS_FAILED(rv)) return; + mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::element, broadcasterID); + mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::attribute, attribute); } else { - rv = mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::observes, broadcasterID); - if (NS_FAILED(rv)) return; - + mObservesElement->GetAttr(kNameSpaceID_None, nsXULAtoms::observes, broadcasterID); attribute.AssignLiteral("*"); } @@ -4086,28 +4045,21 @@ nsXULDocument::FindBroadcaster(nsIContent* aElement, if (NS_FAILED(CallQueryInterface(parent, aListener))) *aListener = nsnull; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::element, aBroadcasterID); - if (NS_FAILED(rv)) return rv; - - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::attribute, - aAttribute); - if (NS_FAILED(rv)) return rv; + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::element, aBroadcasterID); + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::attribute, aAttribute); } else { // It's a generic element, which means that we'll use the // value of the 'observes' attribute to determine the ID of // the broadcaster element, and we'll watch _all_ of its // values. - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::observes, aBroadcasterID); - if (NS_FAILED(rv)) return rv; + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::observes, aBroadcasterID); // Bail if there's no aBroadcasterID - if ((rv != NS_CONTENT_ATTR_HAS_VALUE) || (aBroadcasterID.IsEmpty())) { + if (aBroadcasterID.IsEmpty()) { // Try the command attribute next. - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::command, aBroadcasterID); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE && !aBroadcasterID.IsEmpty()) { + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::command, aBroadcasterID); + if (!aBroadcasterID.IsEmpty()) { // We've got something in the command attribute. We // only treat this as a normal broadcaster if we are // not a menuitem or a key. @@ -4222,18 +4174,15 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild, PRBool aNo PRBool wasInserted = PR_FALSE; // insert after an element of a given id - rv = aChild->GetAttr(kNameSpaceID_None, nsXULAtoms::insertafter, posStr); - if (NS_FAILED(rv)) return rv; + aChild->GetAttr(kNameSpaceID_None, nsXULAtoms::insertafter, posStr); PRBool isInsertAfter = PR_TRUE; - if (rv != NS_CONTENT_ATTR_HAS_VALUE) { - rv = aChild->GetAttr(kNameSpaceID_None, nsXULAtoms::insertbefore, - posStr); - if (NS_FAILED(rv)) return rv; + if (posStr.IsEmpty()) { + aChild->GetAttr(kNameSpaceID_None, nsXULAtoms::insertbefore, posStr); isInsertAfter = PR_FALSE; } - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (!posStr.IsEmpty()) { nsCOMPtr domDocument( do_QueryInterface(aParent->GetDocument())); nsCOMPtr domElement; @@ -4275,10 +4224,8 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild, PRBool aNo if (!wasInserted) { - rv = aChild->GetAttr(kNameSpaceID_None, nsXULAtoms::position, posStr); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + aChild->GetAttr(kNameSpaceID_None, nsXULAtoms::position, posStr); + if (!posStr.IsEmpty()) { // Positions are one-indexed. PRInt32 pos = posStr.ToInteger(NS_REINTERPRET_CAST(PRInt32*, &rv)); // Note: if the insertion index (which is |pos - 1|) would be less diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index a67c44b6969..c01dffbd5e0 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -645,10 +645,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, // given node. PRUnichar attrbuf[128]; nsFixedString attrValue(attrbuf, NS_ARRAY_LENGTH(attrbuf), 0); - rv = tmplKid->GetAttr(kNameSpaceID_None, nsXULAtoms::value, attrValue); - if (NS_FAILED(rv)) return rv; - - if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (!attrValue.IsEmpty())) { + tmplKid->GetAttr(kNameSpaceID_None, nsXULAtoms::value, attrValue); + if (!attrValue.IsEmpty()) { nsAutoString value; rv = SubstituteText(*aMatch, attrValue, value); if (NS_FAILED(rv)) return rv; @@ -729,10 +727,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, // longish. PRUnichar attrbuf[128]; nsFixedString attribValue(attrbuf, NS_ARRAY_LENGTH(attrbuf), 0); - rv = tmplKid->GetAttr(attribNameSpaceID, attribName, attribValue); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + tmplKid->GetAttr(attribNameSpaceID, attribName, attribValue); + if (!attribValue.IsEmpty()) { nsAutoString value; rv = SubstituteText(*aMatch, attribValue, value); if (NS_FAILED(rv)) return rv; @@ -826,14 +822,9 @@ nsXULContentBuilder::AddPersistentAttributes(nsIContent* aTemplateNode, { nsresult rv; - nsAutoString persist; - rv = aTemplateNode->GetAttr(kNameSpaceID_None, nsXULAtoms::persist, persist); - if (NS_FAILED(rv)) return rv; + nsAutoString attribute, persist; + aTemplateNode->GetAttr(kNameSpaceID_None, nsXULAtoms::persist, persist); - if (rv != NS_CONTENT_ATTR_HAS_VALUE) - return NS_OK; - - nsAutoString attribute; while (!persist.IsEmpty()) { attribute.Truncate(); @@ -923,9 +914,7 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode, continue; nsAutoString attribValue; - rv = aTemplateNode->GetAttr(attribNameSpaceID, - attribName, - attribValue); + aTemplateNode->GetAttr(attribNameSpaceID, attribName, attribValue); if (! IsAttrImpactedByVars(aMatch, attribValue, aModifiedVars)) continue; @@ -1349,12 +1338,8 @@ nsXULContentBuilder::IsOpen(nsIContent* aElement) (tag != nsXULAtoms::button)) return PR_TRUE; - nsAutoString value; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::open, value); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get open attribute"); - - return (rv == NS_CONTENT_ATTR_HAS_VALUE && - value.EqualsLiteral("true")); + return aElement->AttrValueIs(kNameSpaceID_None, nsXULAtoms::open, + nsXULAtoms::_true, eCaseMatters); } diff --git a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp index 8d75f8fe81c..a8a2a321e70 100644 --- a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp @@ -197,11 +197,8 @@ nsXULContentUtils::GetElementResource(nsIContent* aElement, nsIRDFResource** aRe PRUnichar buf[128]; nsFixedString id(buf, NS_ARRAY_LENGTH(buf), 0); - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); - NS_ASSERTION(NS_SUCCEEDED(rv), "severe error retrieving attribute"); - if (NS_FAILED(rv)) return rv; - - if (rv != NS_CONTENT_ATTR_HAS_VALUE) + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); + if (id.IsEmpty()) return NS_ERROR_FAILURE; // Since the element will store its ID attribute as a document-relative value, @@ -230,10 +227,7 @@ nsXULContentUtils::GetElementRefResource(nsIContent* aElement, nsIRDFResource** nsFixedString uri(buf, NS_ARRAY_LENGTH(buf), 0); rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::ref, uri); - NS_ASSERTION(NS_SUCCEEDED(rv), "severe error retrieving attribute"); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (!uri.IsEmpty()) { // We'll use rdf_MakeAbsolute() to translate this to a URL. nsCOMPtr doc = aElement->GetDocument(); @@ -497,15 +491,14 @@ nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElemen return NS_ERROR_UNEXPECTED; nsAutoString events; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::events, events); - - if (rv != NS_CONTENT_ATTR_HAS_VALUE) + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::events, events); + if (events.IsEmpty()) events.AssignLiteral("*"); nsAutoString targets; - rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::targets, targets); + aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::targets, targets); - if (rv != NS_CONTENT_ATTR_HAS_VALUE) + if (targets.IsEmpty()) targets.AssignLiteral("*"); nsCOMPtr domelement = do_QueryInterface(aElement); diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index 34cf1bb6f0e..fbf8b8758be 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -99,8 +99,6 @@ static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID); static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID); static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, BookmarkSeparator); - typedef struct _sortStruct { PRBool firstFlag; nsCOMPtr sortProperty, sortProperty2; @@ -167,9 +165,9 @@ private: nsresult FindDatabaseElement(nsIContent* aElement, nsIContent** aDatabaseElement); nsresult FindSortableContainer(nsIContent *tree, nsIContent **treeBody); -nsresult SetSortHints(nsIContent *tree, const nsAString &sortResource, const nsAString &sortDirection, const nsAString &sortResource2, PRBool inbetweenSeparatorSort, PRBool found); +void SetSortHints(nsIContent *tree, const nsAString &sortResource, const nsAString &sortDirection, const nsAString &sortResource2, PRBool inbetweenSeparatorSort, PRBool found); nsresult SetSortColumnHints(nsIContent *content, const nsAString &sortResource, const nsAString &sortDirection); -nsresult GetSortColumnInfo(nsIContent *tree, nsAString &sortResource, nsAString &sortDirection, nsAString &sortResource2, PRBool &inbetweenSeparatorSort); +void GetSortColumnInfo(nsIContent *tree, nsAString &sortResource, nsAString &sortDirection, nsAString &sortResource2, PRBool &inbetweenSeparatorSort); nsresult SortContainer(nsIContent *container, sortPtr sortInfo, PRBool merelyInvertFlag); nsresult InvertSortInfo(contentSortInfo **data, PRInt32 numItems); @@ -330,7 +328,7 @@ XULSortServiceImpl::FindSortableContainer(nsIContent *aRoot, return NS_ERROR_FAILURE; } -nsresult +void XULSortServiceImpl::SetSortHints(nsIContent *tree, const nsAString &sortResource, const nsAString &sortDirection, @@ -361,8 +359,6 @@ XULSortServiceImpl::SetSortHints(nsIContent *tree, tree->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortSeparators, PR_FALSE); SetSortColumnHints(tree, sortResource, sortDirection); - - return NS_OK; } nsresult @@ -388,24 +384,19 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content, tag == nsXULAtoms::listcol || tag == nsXULAtoms::listheader) { nsAutoString value; - - if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, - nsXULAtoms::resource, value)) - && rv == NS_CONTENT_ATTR_HAS_VALUE) - { - if (value == sortResource) { - child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, - *kTrueStr, PR_TRUE); - child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, - sortDirection, PR_TRUE); - // Note: don't break out of loop; want to set/unset - // attribs on ALL sort columns - } else { - child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, - PR_TRUE); - child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, - PR_TRUE); - } + child->GetAttr(kNameSpaceID_None, nsXULAtoms::resource, value); + if (value == sortResource) { + child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, + *kTrueStr, PR_TRUE); + child->SetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, + sortDirection, PR_TRUE); + // Note: don't break out of loop; want to set/unset + // attribs on ALL sort columns + } else if (!value.IsEmpty()) { + child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, + PR_TRUE); + child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, + PR_TRUE); } } } @@ -414,61 +405,38 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content, return NS_OK; } -nsresult +void XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsAString &sortResource, nsAString &sortDirection, nsAString &sortResource2, PRBool &inbetweenSeparatorSort) { - nsresult rv = NS_ERROR_FAILURE; inbetweenSeparatorSort = PR_FALSE; - nsAutoString value; - if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, - nsXULAtoms::sortActive, value)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { - if (value.EqualsLiteral("true")) - { - if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, - nsXULAtoms::sortResource, - sortResource)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { - if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, - nsXULAtoms::sortDirection, - sortDirection)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { - rv = NS_OK; - - // sort separator flag is optional - if (NS_SUCCEEDED(rv = tree->GetAttr(kNameSpaceID_None, - nsXULAtoms::sortSeparators, - value)) && - (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { - if (value.EqualsLiteral("true")) - { - inbetweenSeparatorSort = PR_TRUE; - } - } - - // secondary sort info is optional - if (NS_FAILED(rv = tree->GetAttr(kNameSpaceID_None, - nsXULAtoms::sortResource2, - sortResource2)) || - (rv != NS_CONTENT_ATTR_HAS_VALUE)) - { - sortResource2.Truncate(); - } - } - } - } + if (!tree->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortActive, + nsXULAtoms::_true, eCaseMatters)) { + return; } - - return rv; + + tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource, sortResource); + if (sortResource.IsEmpty()) { + return; + } + + tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, sortDirection); + if (sortDirection.IsEmpty()) { + return; + } + + // sort separator flag is optional + inbetweenSeparatorSort = + tree->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortSeparators, + nsXULAtoms::_true, eCaseMatters); + + // secondary sort info is optional + tree->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource2, + sortResource2); } nsresult @@ -805,9 +773,8 @@ XULSortServiceImpl::GetNodeValue(nsIContent *node1, sortPtr sortInfo, PRBool fir nsCOMPtr htmlDom = do_QueryInterface(node1); if (htmlDom) { nsAutoString htmlID; - if (NS_SUCCEEDED(rv = node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { + node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID); + if (!htmlID.IsEmpty()) { if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID, getter_AddRefs(res1)))) res1 = nsnull; } @@ -883,9 +850,8 @@ XULSortServiceImpl::GetNodeValue(contentSortInfo *info1, sortPtr sortInfo, PRBoo nsCOMPtr htmlDom = do_QueryInterface(node1); if (htmlDom) { nsAutoString htmlID; - if (NS_SUCCEEDED(rv = node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { + node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID); + if (!htmlID.IsEmpty()) { if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID, getter_AddRefs(res1)))) res1 = nsnull; info1->resource = res1; @@ -1135,7 +1101,6 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo, // were to do this in a forward-looking manner it would be harder // (since we also skip over non XUL:treeitem nodes) - nsresult rv; currentElement = numChildren; PRUint32 childIndex; // childIndex is unsigned, so childIndex >= 0 would always test true @@ -1167,22 +1132,20 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo, /* smart sorting (sort within separators) on name column */ if (sortInfo->inbetweenSeparatorSort) { PRUint32 startIndex = currentElement; - nsAutoString type; for (loop = currentElement; loop < currentElement + numElements; ++loop) { - if (NS_SUCCEEDED(rv = contentSortInfoArray[loop]->content->GetAttr(kNameSpaceID_RDF, - nsXULAtoms::type, type)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { - if (type.EqualsASCII(kURINC_BookmarkSeparator)) { - if (loop > startIndex + 1) { - if (merelyInvertFlag) - InvertSortInfo(&contentSortInfoArray[startIndex], loop-startIndex); - else - NS_QuickSort((void*)&contentSortInfoArray[startIndex], loop-startIndex, - sizeof(contentSortInfo*), testSortCallback, (void*)sortInfo); - startIndex = loop+1; - } - } + + if (contentSortInfoArray[loop]->content-> + AttrValueIs(kNameSpaceID_RDF, nsXULAtoms::type, + NS_LITERAL_STRING("http://home.netscape.com/NC-rdf#BookmarkSeparator"), + eCaseMatters) && + loop > startIndex + 1) { + if (merelyInvertFlag) + InvertSortInfo(&contentSortInfoArray[startIndex], loop-startIndex); + else + NS_QuickSort((void*)&contentSortInfoArray[startIndex], loop-startIndex, + sizeof(contentSortInfo*), testSortCallback, (void*)sortInfo); + startIndex = loop+1; } } @@ -1234,8 +1197,8 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo, delete contentSortInfo; // if it's a container, find its treechildren nodes, and sort those - if (NS_FAILED(rv = parentNode->GetAttr(kNameSpaceID_None, nsXULAtoms::container, value)) || - (rv != NS_CONTENT_ATTR_HAS_VALUE) || !value.EqualsLiteral("true")) + if (!parentNode->AttrValueIs(kNameSpaceID_None, nsXULAtoms::container, + nsXULAtoms::_true, eCaseMatters)) continue; numChildren = parentNode->GetChildCount(); @@ -1308,19 +1271,14 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort // look for sorting info on root node - if (NS_SUCCEEDED(rv = root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource, sortResource)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) + root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource, sortResource); + if (!sortResource.IsEmpty()) { - if (NS_SUCCEEDED(rv = root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, sortDirection)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) + root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, sortDirection); + if (!sortDirection.IsEmpty()) { sortInfoAvailable = PR_TRUE; - - if (NS_FAILED(rv = root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource2, sortResource2)) - || (rv != NS_CONTENT_ATTR_HAS_VALUE)) - { - sortResource2.Truncate(); - } + root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource2, sortResource2); } } @@ -1419,9 +1377,9 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort if (parent) { nsAutoString id; - rv = trueParent->GetAttr(kNameSpaceID_None, nsXULAtoms::ref, id); + trueParent->GetAttr(kNameSpaceID_None, nsXULAtoms::ref, id); if (id.IsEmpty()) - rv = trueParent->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); + trueParent->GetAttr(kNameSpaceID_None, nsXULAtoms::id, id); if (!id.IsEmpty()) { nsCOMPtr containerRes; @@ -1447,8 +1405,8 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort PRInt32 staticCount = 0; nsAutoString staticValue; - if (NS_SUCCEEDED(rv = container->GetAttr(kNameSpaceID_None, nsXULAtoms::staticHint, staticValue)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) + container->GetAttr(kNameSpaceID_None, nsXULAtoms::staticHint, staticValue); + if (!staticValue.IsEmpty()) { // found "static" XUL element count hint PRInt32 strErr=0; @@ -1457,20 +1415,20 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort staticCount = 0; } else { // compute the "static" XUL element count - nsAutoString valueStr; + nsAutoString valueStr; for (PRUint32 childLoop = 0; childLoop < numChildren; ++childLoop) { child = container->GetChildAt(childLoop); if (!child) break; - if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, nsXULAtoms::templateAtom, valueStr)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) + child->GetAttr(kNameSpaceID_None, nsXULAtoms::templateAtom, valueStr); + if (!valueStr.IsEmpty()) break; else ++staticCount; } - if (NS_SUCCEEDED(rv = root->GetAttr(kNameSpaceID_None, nsXULAtoms::sortStaticsLast, valueStr)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE) && valueStr.EqualsLiteral("true")) + if (root->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortStaticsLast, + nsXULAtoms::_true, eCaseMatters)) { // indicate that static XUL comes after RDF-generated content by making negative staticCount = -staticCount; @@ -1583,24 +1541,17 @@ XULSortServiceImpl::Sort(nsIDOMNode* node, const nsAString& sortResource, const // then just reverse-index the current tree PRBool invertTreeFlag = PR_FALSE; nsAutoString value; - if (NS_SUCCEEDED(rv = dbNode->GetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, value)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE) - && value.EqualsLiteral("true")) - { - if (NS_SUCCEEDED(rv = dbNode->GetAttr(kNameSpaceID_None, nsXULAtoms::sortResource, value)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE) - && (value.Equals(sortResource))) - { - if (NS_SUCCEEDED(rv = dbNode->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, value)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE)) - { - if ((value.Equals(*kDescendingStr) && sortDirection.Equals(*kAscendingStr)) - || (value.Equals(*kAscendingStr) && sortDirection.Equals(*kDescendingStr))) - { - invertTreeFlag = PR_TRUE; - } - } - } + if (dbNode->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortActive, + nsXULAtoms::_true, eCaseMatters) && + dbNode->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortResource, + sortResource, eCaseMatters) && + ((sortDirection.Equals(*kAscendingStr) && + dbNode->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortDirection, + *kDescendingStr, eCaseMatters)) || + (sortDirection.Equals(*kDescendingStr) && + dbNode->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortDirection, + *kAscendingStr, eCaseMatters)))) { + invertTreeFlag = PR_TRUE; } // remove any sort hints on tree root node diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index a8394254dfe..d72f54a85af 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1350,8 +1350,7 @@ nsXULTemplateBuilder::ComputeContainmentProperties() mContainmentProperties.Clear(); nsAutoString containment; - rv = mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::containment, containment); - if (NS_FAILED(rv)) return rv; + mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::containment, containment); PRUint32 len = containment.Length(); PRUint32 offset = 0; @@ -2111,8 +2110,7 @@ nsXULTemplateBuilder::CompileSimpleRule(nsIContent* aRuleElement, continue; nsAutoString value; - rv = aRuleElement->GetAttr(attrNameSpaceID, attr, value); - if (NS_FAILED(rv)) return rv; + aRuleElement->GetAttr(attrNameSpaceID, attr, value); TestNode* testnode = nsnull; @@ -2130,31 +2128,23 @@ nsXULTemplateBuilder::CompileSimpleRule(nsIContent* aRuleElement, nsRDFConInstanceTestNode::Test iscontainer = nsRDFConInstanceTestNode::eDontCare; - rv = aRuleElement->GetAttr(kNameSpaceID_None, nsXULAtoms::iscontainer, value); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - if (value.EqualsLiteral("true")) { - iscontainer = nsRDFConInstanceTestNode::eTrue; - } - else if (value.EqualsLiteral("false")) { - iscontainer = nsRDFConInstanceTestNode::eFalse; - } + aRuleElement->GetAttr(kNameSpaceID_None, nsXULAtoms::iscontainer, value); + if (value.EqualsLiteral("true")) { + iscontainer = nsRDFConInstanceTestNode::eTrue; + } + else if (value.EqualsLiteral("false")) { + iscontainer = nsRDFConInstanceTestNode::eFalse; } nsRDFConInstanceTestNode::Test isempty = nsRDFConInstanceTestNode::eDontCare; - rv = aRuleElement->GetAttr(kNameSpaceID_None, nsXULAtoms::isempty, value); - if (NS_FAILED(rv)) return rv; - - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - if (value.EqualsLiteral("true")) { - isempty = nsRDFConInstanceTestNode::eTrue; - } - else if (value.EqualsLiteral("false")) { - isempty = nsRDFConInstanceTestNode::eFalse; - } + aRuleElement->GetAttr(kNameSpaceID_None, nsXULAtoms::isempty, value); + if (value.EqualsLiteral("true")) { + isempty = nsRDFConInstanceTestNode::eTrue; + } + else if (value.EqualsLiteral("false")) { + isempty = nsRDFConInstanceTestNode::eFalse; } testnode = new nsRDFConInstanceTestNode(aParentNode, diff --git a/mozilla/editor/composer/src/nsComposeTxtSrvFilter.cpp b/mozilla/editor/composer/src/nsComposeTxtSrvFilter.cpp index 269db5197f9..4ddba2f1cb2 100644 --- a/mozilla/editor/composer/src/nsComposeTxtSrvFilter.cpp +++ b/mozilla/editor/composer/src/nsComposeTxtSrvFilter.cpp @@ -56,6 +56,9 @@ nsComposeTxtSrvFilter::nsComposeTxtSrvFilter() : mTextAreaAtom = do_GetAtom("textarea"); mSelectAreaAtom = do_GetAtom("select"); mMapAtom = do_GetAtom("map"); + mCiteAtom = do_GetAtom("cite"); + mTrueAtom = do_GetAtom("true"); + mMozSignatureAtom= do_GetAtom("moz-signature"); } NS_IMPL_ISUPPORTS1(nsComposeTxtSrvFilter, nsITextServicesFilter) @@ -73,22 +76,16 @@ nsComposeTxtSrvFilter::Skip(nsIDOMNode* aNode, PRBool *_retval) nsIAtom *tag = content->Tag(); if (tag == mBlockQuoteAtom) { if (mIsForMail) { - nsAutoString cite; - if (NS_SUCCEEDED(content->GetAttr(kNameSpaceID_None, mTypeAtom, cite))) { - *_retval = cite.LowerCaseEqualsLiteral("cite"); - } + *_retval = content->AttrValueIs(kNameSpaceID_None, mTypeAtom, + mCiteAtom, eIgnoreCase); } } else if (tag == mPreAtom || tag == mSpanAtom) { if (mIsForMail) { - nsAutoString mozQuote; - if (NS_SUCCEEDED(content->GetAttr(kNameSpaceID_None, mMozQuoteAtom, mozQuote))) { - *_retval = mozQuote.LowerCaseEqualsLiteral("true"); - } - + *_retval = content->AttrValueIs(kNameSpaceID_None, mMozQuoteAtom, + mTrueAtom, eIgnoreCase); if (!*_retval) { - nsAutoString className; - if (NS_SUCCEEDED(content->GetAttr(kNameSpaceID_None, mClassAtom, className))) - *_retval = className.EqualsLiteral("moz-signature"); + *_retval = content->AttrValueIs(kNameSpaceID_None, mClassAtom, + mMozSignatureAtom, eCaseMatters); } } } else if (tag == mScriptAtom || @@ -98,10 +95,10 @@ nsComposeTxtSrvFilter::Skip(nsIDOMNode* aNode, PRBool *_retval) *_retval = PR_TRUE; } else if (tag == mTableAtom) { if (mIsForMail) { - nsAutoString className; - if (NS_SUCCEEDED(content->GetAttr(kNameSpaceID_None, mClassAtom, className))) { - *_retval = className.EqualsLiteral("moz-email-headers-table"); - } + *_retval = + content->AttrValueIs(kNameSpaceID_None, mClassAtom, + NS_LITERAL_STRING("moz-email-headers-table"), + eCaseMatters); } } } diff --git a/mozilla/editor/composer/src/nsComposeTxtSrvFilter.h b/mozilla/editor/composer/src/nsComposeTxtSrvFilter.h index 2b0201f5354..05cbce1a276 100644 --- a/mozilla/editor/composer/src/nsComposeTxtSrvFilter.h +++ b/mozilla/editor/composer/src/nsComposeTxtSrvFilter.h @@ -76,7 +76,9 @@ protected: nsCOMPtr mTextAreaAtom; nsCOMPtr mSelectAreaAtom; nsCOMPtr mMapAtom; - + nsCOMPtr mCiteAtom; + nsCOMPtr mTrueAtom; + nsCOMPtr mMozSignatureAtom; }; #define NS_COMPOSERTXTSRVFILTER_CID \ diff --git a/mozilla/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp b/mozilla/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp index 3b8d3a9e2ac..112741e5d8b 100644 --- a/mozilla/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp +++ b/mozilla/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp @@ -352,8 +352,7 @@ txXPathNodeUtils::getAttr(const txXPathNode& aNode, nsIAtom* aLocalName, return PR_FALSE; } - nsresult rv = aNode.mContent->GetAttr(aNSID, aLocalName, aValue); - return NS_SUCCEEDED(rv) && rv != NS_CONTENT_ATTR_NOT_THERE; + return aNode.mContent->GetAttr(aNSID, aLocalName, aValue); } /* static */ diff --git a/mozilla/extensions/transformiix/source/xslt/txXSLTPatterns.cpp b/mozilla/extensions/transformiix/source/xslt/txXSLTPatterns.cpp index 50d29983177..518f8afbf4f 100644 --- a/mozilla/extensions/transformiix/source/xslt/txXSLTPatterns.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txXSLTPatterns.cpp @@ -370,8 +370,8 @@ MBool txIdPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext) if (!idAttr) { return MB_FALSE; // no ID for this element defined, can't match } - nsresult rv = content->GetAttr(kNameSpaceID_None, idAttr, value); - if (rv != NS_CONTENT_ATTR_HAS_VALUE) { + content->GetAttr(kNameSpaceID_None, idAttr, value); + if (value.IsEmpty()) { return MB_FALSE; // no ID attribute given } #endif // TX_EXE diff --git a/mozilla/extensions/webdav/src/nsWebDAVUtils.cpp b/mozilla/extensions/webdav/src/nsWebDAVUtils.cpp index 9c20f5389b4..995d2dd18f5 100644 --- a/mozilla/extensions/webdav/src/nsWebDAVUtils.cpp +++ b/mozilla/extensions/webdav/src/nsWebDAVUtils.cpp @@ -68,7 +68,7 @@ NS_WD_GetElementByTagName(nsIDOMElement *parentElt, const nsAString &tagName, NS_ENSURE_SUCCESS(rv, rv); if (!node) { - return NS_CONTENT_ATTR_NO_VALUE; + return NS_OK; } return CallQueryInterface(node, elt); diff --git a/mozilla/extensions/xforms/nsXFormsUtils.cpp b/mozilla/extensions/xforms/nsXFormsUtils.cpp index 17105016bf8..8b5b798ca64 100644 --- a/mozilla/extensions/xforms/nsXFormsUtils.cpp +++ b/mozilla/extensions/xforms/nsXFormsUtils.cpp @@ -1521,7 +1521,6 @@ nsXFormsUtils::GetElementById(nsIDOMDocument *aDoc, PRUint32 i; PRUint16 type; - nsAutoString idVal; nsCOMPtr childNode; for (i = 0; i < elements; ++i) { descendants->Item(i, getter_AddRefs(childNode)); @@ -1529,9 +1528,8 @@ nsXFormsUtils::GetElementById(nsIDOMDocument *aDoc, if (type == nsIDOMNode::ELEMENT_NODE) { nsCOMPtr content(do_QueryInterface(childNode)); NS_ASSERTION(content, "An ELEMENT_NODE not implementing nsIContent?!"); - rv = content->GetAttr(kNameSpaceID_None, content->GetIDAttributeName(), - idVal); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && idVal.Equals(aId)) { + if (content->AttrValueIs(kNameSpaceID_None, content->GetIDAttributeName(), + aId, eCaseMatters)) { element = do_QueryInterface(childNode); break; } diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 3891af1a4c5..1e3757428af 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -6476,10 +6476,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, // register tooltip support if needed nsAutoString value; if (aTag == nsXULAtoms::treechildren || // trees always need titletips - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext, value) != - NS_CONTENT_ATTR_NOT_THERE || - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltip, value) != - NS_CONTENT_ATTR_NOT_THERE) + aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext, value) || + aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltip, value)) { nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame(); if (rootFrame) @@ -7352,7 +7350,6 @@ nsCSSFrameConstructor::TestSVGConditions(nsIContent* aContent, PRBool& aHasRequiredFeatures, PRBool& aHasSystemLanguage) { - nsresult rv = NS_OK; nsAutoString value; // Only elements can have tests on them @@ -7360,7 +7357,7 @@ nsCSSFrameConstructor::TestSVGConditions(nsIContent* aContent, aHasRequiredExtensions = PR_FALSE; aHasRequiredFeatures = PR_FALSE; aHasSystemLanguage = PR_FALSE; - return rv; + return NS_OK; } // Required Extensions @@ -7369,25 +7366,17 @@ nsCSSFrameConstructor::TestSVGConditions(nsIContent* aContent, // extensions. Language extensions are capabilities within a user agent that // go beyond the feature set defined in the SVG specification. // Each extension is identified by a URI reference. - rv = aContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::requiredExtensions, value); - if (NS_FAILED(rv)) - return rv; - - aHasRequiredExtensions = PR_TRUE; - if (NS_CONTENT_ATTR_HAS_VALUE == rv) { - // For now, claim that mozilla's SVG implementation supports - // no extensions. So, if extensions are required, we don't have - // them available. - aHasRequiredExtensions = PR_FALSE; - } + // For now, claim that mozilla's SVG implementation supports + // no extensions. So, if extensions are required, we don't have + // them available. Empty-string should always set aHasRequiredExtensions to + // false. + aHasRequiredExtensions = !aContent->HasAttr(kNameSpaceID_None, + nsSVGAtoms::requiredExtensions); // Required Features aHasRequiredFeatures = PR_TRUE; - rv = aContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::requiredFeatures, value); - if (NS_FAILED(rv)) - return rv; - if (NS_CONTENT_ATTR_HAS_VALUE == rv) { - aHasRequiredFeatures = NS_SVG_TestFeatures(value); + if (aContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::requiredFeatures, value)) { + aHasRequiredFeatures = !value.IsEmpty() && NS_SVG_TestFeatures(value); } // systemLanguage @@ -7398,8 +7387,8 @@ nsCSSFrameConstructor::TestSVGConditions(nsIContent* aContent, // prefix of one of the languages given in the value of this parameter such // that the first tag character following the prefix is "-". aHasSystemLanguage = PR_TRUE; - rv = aContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::systemLanguage, value); - if (NS_CONTENT_ATTR_HAS_VALUE == rv) { + if (aContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::systemLanguage, + value)) { // Get our language preferences nsAutoString langPrefs(nsContentUtils::GetLocalizedStringPref("intl.accept_languages")); if (!langPrefs.IsEmpty()) { @@ -7413,11 +7402,10 @@ nsCSSFrameConstructor::TestSVGConditions(nsIContent* aContent, } else { // For now, evaluate to true. NS_WARNING("no default language specified for systemLanguage conditional test"); - aHasSystemLanguage = PR_TRUE; + aHasSystemLanguage = !value.IsEmpty(); } - return NS_OK; } - return rv; + return NS_OK; } nsresult @@ -10808,21 +10796,16 @@ void nsCSSFrameConstructor::GetAlternateTextFor(nsIContent* aContent, nsIAtom* aTag, // content object's tag nsXPIDLString& aAltText) { - nsresult rv; - // The "alt" attribute specifies alternate text that is rendered // when the image can not be displayed - rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::alt, aAltText); // If there's no "alt" attribute, and aContent is an input // element, then use the value of the "value" attribute - if ((NS_CONTENT_ATTR_NOT_THERE == rv) && (nsHTMLAtoms::input == aTag)) { - rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, - aAltText); - + if (!aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::alt, aAltText) && + nsHTMLAtoms::input == aTag) { // If there's no "value" attribute either, then use the localized string // for "Submit" as the alternate text. - if (NS_CONTENT_ATTR_NOT_THERE == rv) { + if (!aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aAltText)) { nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, "Submit", aAltText); } diff --git a/mozilla/layout/base/nsLayoutAtomList.h b/mozilla/layout/base/nsLayoutAtomList.h index e351f9053c7..4195be92a7c 100644 --- a/mozilla/layout/base/nsLayoutAtomList.h +++ b/mozilla/layout/base/nsLayoutAtomList.h @@ -256,6 +256,13 @@ LAYOUT_ATOM(endsInDiacritic, "EndsInDiacritic") // PRUint32 LAYOUT_ATOM(nextBidi, "NextBidi") // nsIFrame* LAYOUT_ATOM(charType, "charType") // PRUint8 +LAYOUT_ATOM(capture, "capture") +LAYOUT_ATOM(stop, "stop") +LAYOUT_ATOM(cancel, "cancel") +LAYOUT_ATOM(onLoad, "onLoad") +LAYOUT_ATOM(always, "always") +LAYOUT_ATOM(collapsed, "collapsed") + #ifdef MOZ_SVG // Alphabetical list of SVG frame types LAYOUT_ATOM(svgCircleFrame,"SVGCircleFrame") diff --git a/mozilla/layout/forms/nsButtonFrameRenderer.cpp b/mozilla/layout/forms/nsButtonFrameRenderer.cpp index 7a57c7906e2..b2ce0e3f05a 100644 --- a/mozilla/layout/forms/nsButtonFrameRenderer.cpp +++ b/mozilla/layout/forms/nsButtonFrameRenderer.cpp @@ -88,12 +88,8 @@ PRBool nsButtonFrameRenderer::isDisabled() { // get the content - nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == - mFrame->GetContent()->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, value)) - return PR_TRUE; - - return PR_FALSE; + return mFrame->GetContent()->HasAttr(kNameSpaceID_None, + nsHTMLAtoms::disabled); } void diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 39130f13605..3e633ca79c1 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -804,19 +804,18 @@ nsComboboxControlFrame::ReflowItems(nsPresContext* aPresContext, nsCOMPtr optionElement = getter_AddRefs(GetOption(*options, i)); if (optionElement) { nsAutoString text; - rv = optionElement->GetLabel(text); - if (NS_CONTENT_ATTR_HAS_VALUE != rv || text.IsEmpty()) { - if (NS_OK == optionElement->GetText(text)) { - nscoord width; - aReflowState.rendContext->GetWidth(text, width); - if (width > maxWidth) { - maxStr = text; - maxWidth = width; - } - //maxWidth = PR_MAX(width, maxWidth); - //printf("[%d] - %d %s \n", i, width, NS_LossyConvertUCS2toASCII(text).get()); + optionElement->GetLabel(text); + if (text.IsEmpty() && + NS_SUCCEEDED(optionElement->GetText(text))) { + nscoord width; + aReflowState.rendContext->GetWidth(text, width); + if (width > maxWidth) { + maxStr = text; + maxWidth = width; } - } + //maxWidth = PR_MAX(width, maxWidth); + //printf("[%d] - %d %s \n", i, width, NS_LossyConvertUCS2toASCII(text).get()); + } } } } @@ -1636,7 +1635,9 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, NS_IMETHODIMP nsComboboxControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } nsIFrame* diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 4e2c9810902..60834f099df 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -541,7 +541,9 @@ nsFileControlFrame::GetSkipSides() const NS_IMETHODIMP nsFileControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } void @@ -549,8 +551,7 @@ nsFileControlFrame::SyncAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aWhichControls) { nsAutoString value; - nsresult rv = mContent->GetAttr(aNameSpaceID, aAttribute, value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { + if (mContent->GetAttr(aNameSpaceID, aAttribute, value)) { if (aWhichControls & SYNC_TEXT && mTextContent) { mTextContent->SetAttr(aNameSpaceID, aAttribute, value, PR_TRUE); } diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index e00cef65628..63ee15c381e 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -621,40 +621,6 @@ nsFormControlFrame::GetCID() return kButtonCID; } -NS_IMETHODIMP -nsFormControlFrame::GetMaxLength(PRInt32* aSize) -{ - *aSize = -1; - - nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); - if (content) { - const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::maxlength); - if (attr && attr->Type() == nsAttrValue::eInteger) { - *aSize = attr->GetIntegerValue(); - - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - return NS_CONTENT_ATTR_NOT_THERE; -} - -nsresult -nsFormControlFrame::GetSizeFromContent(PRInt32* aSize) const -{ - *aSize = -1; - - nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); - if (content) { - const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::size); - if (attr && attr->Type() == nsAttrValue::eInteger) { - *aSize = attr->GetIntegerValue(); - - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - return NS_CONTENT_ATTR_NOT_THERE; -} - NS_IMETHODIMP_(PRInt32) nsFormControlFrame::GetFormControlType() const { @@ -664,14 +630,18 @@ nsFormControlFrame::GetFormControlType() const NS_IMETHODIMP nsFormControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } NS_IMETHODIMP nsFormControlFrame::GetValue(nsAString* aResult) { - return nsFormControlHelper::GetValueAttr(mContent, aResult); + nsFormControlHelper::GetValueAttr(mContent, aResult); + + return NS_OK; } @@ -735,48 +705,13 @@ nsFormControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -nsresult -nsFormControlFrame::GetDefaultCheckState(PRBool *aState) -{ - nsresult res = NS_OK; - nsCOMPtr inputElement = do_QueryInterface(mContent); - if (inputElement) { - res = inputElement->GetDefaultChecked(aState); - } - return res; -} - -nsresult -nsFormControlFrame::SetDefaultCheckState(PRBool aState) -{ - nsresult res = NS_OK; - nsCOMPtr inputElement = do_QueryInterface(mContent); - if (inputElement) { - res = inputElement->SetDefaultChecked(aState); - } - return res; -} - -nsresult +void nsFormControlFrame::GetCurrentCheckState(PRBool *aState) { - nsresult res = NS_OK; nsCOMPtr inputElement = do_QueryInterface(mContent); if (inputElement) { - res = inputElement->GetChecked(aState); + inputElement->GetChecked(aState); } - return res; -} - -nsresult -nsFormControlFrame::SetCurrentCheckState(PRBool aState) -{ - nsresult res = NS_OK; - nsCOMPtr inputElement = do_QueryInterface(mContent); - if (inputElement) { - inputElement->SetChecked(aState); - } - return res; } NS_IMETHODIMP diff --git a/mozilla/layout/forms/nsFormControlFrame.h b/mozilla/layout/forms/nsFormControlFrame.h index 75b266fbfb1..ab96f60906d 100644 --- a/mozilla/layout/forms/nsFormControlFrame.h +++ b/mozilla/layout/forms/nsFormControlFrame.h @@ -185,9 +185,6 @@ public: // need to change to use it. static nscoord GetScrollbarWidth(float aPixToTwip); - virtual nsresult GetSizeFromContent(PRInt32* aSize) const; - NS_IMETHOD GetMaxLength(PRInt32* aSize); - virtual void SetClickPoint(nscoord aX, nscoord aY); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; @@ -268,38 +265,10 @@ protected: * Get the state of the checked attribute. * @param aState set to PR_TRUE if the checked attribute is set, * PR_FALSE if the checked attribute has been removed - * @returns NS_OK or NS_CONTENT_ATTR_HAS_VALUE */ - nsresult GetCurrentCheckState(PRBool* aState); + void GetCurrentCheckState(PRBool* aState); - /** - * Set the state of the checked attribute. - * @param aState set to PR_TRUE to set the attribute, - * PR_FALSE to unset the attribute - * @returns NS_OK or NS_CONTENT_ATTR_HAS_VALUE - */ - - nsresult SetCurrentCheckState(PRBool aState); - - /** - * Get the state of the defaultchecked attribute. - * @param aState set to PR_TRUE if the defaultchecked attribute is set, - * PR_FALSE if the checked attribute has been removed - * @returns NS_OK or NS_CONTENT_ATTR_HAS_VALUE - */ - - nsresult GetDefaultCheckState(PRBool* aState); - - /** - * Set the state of the checked attribute. - * @param aState set to PR_TRUE to set the checked attribute - * PR_FALSE to unset it - * @returns NS_OK - */ - - nsresult SetDefaultCheckState(PRBool aState); - nsSize mWidgetSize; PRBool mDidInit; nsPoint mLastClickPoint; diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index b3f22c80d94..30a57f92068 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -129,20 +129,7 @@ nsresult nsFormControlHelper::GetFrameFontFM(nsIFrame* aFrame, *aFontMet); } -nsresult -nsFormControlHelper::GetWrapProperty(nsIContent * aContent, nsString &aOutValue) -{ - if (aContent->IsContentOfType(nsIContent::eHTML)) { - return aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::wrap, aOutValue); - } - - aOutValue.Truncate(); - - return NS_CONTENT_ATTR_NOT_THERE; -} - - -nsresult +PRBool nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& aWrapProp) { // soft is the default; "physical" defaults to soft as well because all other @@ -152,17 +139,18 @@ nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& aWrapProp = eHTMLTextWrap_Soft; // the default nsAutoString wrap; - nsresult rv = GetWrapProperty(aContent, wrap); - - if (rv != NS_CONTENT_ATTR_NOT_THERE) { - + if (aContent->IsContentOfType(nsIContent::eHTML) && + aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::wrap, wrap)) { if (wrap.EqualsIgnoreCase(kTextControl_Wrap_Hard)) { aWrapProp = eHTMLTextWrap_Hard; } else if (wrap.EqualsIgnoreCase(kTextControl_Wrap_Off)) { aWrapProp = eHTMLTextWrap_Off; } + + return PR_TRUE; } - return rv; + + return PR_FALSE; } // @@ -331,14 +319,12 @@ nsFormControlHelper::PaintCheckMark(nsIRenderingContext& aRenderingContext, aRenderingContext.FillPolygon(checkedPolygon, checkpoints); } -nsresult +PRBool nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult) { NS_PRECONDITION(aResult, "Null pointer bad!"); - if (!aContent->IsContentOfType(nsIContent::eHTML)) - return NS_ERROR_FAILURE; - - return aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, *aResult); + return aContent->IsContentOfType(nsIContent::eHTML) && + aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, *aResult); } PRInt32 @@ -353,14 +339,12 @@ nsFormControlHelper::GetType(nsIContent* aContent) return NS_FORM_INPUT_TEXT; } -nsresult +PRBool nsFormControlHelper::GetValueAttr(nsIContent* aContent, nsAString* aResult) { NS_PRECONDITION(aResult, "Null pointer bad!"); - if (!aContent->IsContentOfType(nsIContent::eHTML)) - return NS_ERROR_FAILURE; - - return aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, *aResult); + return aContent->IsContentOfType(nsIContent::eHTML) && + aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, *aResult); } //---------------------------------------------------------------------------------- diff --git a/mozilla/layout/forms/nsFormControlHelper.h b/mozilla/layout/forms/nsFormControlHelper.h index b3050e30d45..5ae9d3238ae 100644 --- a/mozilla/layout/forms/nsFormControlHelper.h +++ b/mozilla/layout/forms/nsFormControlHelper.h @@ -98,32 +98,24 @@ public: * Get the name of the form control * @param aContent the content to get the name of * @param aResult the returned name of the form control [OUT] - * @return NS_CONTENT_ATTR_HAS_VALUE if things go well - * @return NS_CONTENT_ATTR_NO_VALUE if the name attr is present but is empty - * @return NS_CONTENT_ATTR_NOT_THERE if the name attribute is undefined - * @return NS_ERROR_FAILURE if aContent is null or is not HTML content + * @return PR_TRUE if things go well + * PR_FALSE if the name attribute is undefined */ - static nsresult GetName(nsIContent* aContent, nsAString* aResult); + static PRBool GetName(nsIContent* aContent, nsAString* aResult); /** * Get the type of the form control (if it's not obvious from the frame type) * @param aContent the content to get the name of - * @param aType the returned type of the form control [OUT] - * @return NS_CONTENT_ATTR_HAS_VALUE if things go well - * @return NS_CONTENT_ATTR_NO_VALUE if the type attr is present but is empty - * @return NS_CONTENT_ATTR_NOT_THERE if the type attribute is undefined - * @return NS_ERROR_FAILURE if aContent is null or is not HTML content + * @return the returned type of the form control [OUT] */ static PRInt32 GetType(nsIContent* aContent); /** * Get the value of the form control (if it's just living in an attr) * @param aContent the content to get the name of * @param aResult the returned value of the form control [OUT] - * @return NS_CONTENT_ATTR_HAS_VALUE if things go well - * @return NS_CONTENT_ATTR_NO_VALUE if the value attr is present but is empty - * @return NS_CONTENT_ATTR_NOT_THERE if the value attribute is undefined - * @return NS_ERROR_FAILURE if aContent is null or is not HTML content + * @return PR_TRUE if things go well + * PR_FALSE if the name attribute is undefined */ - static nsresult GetValueAttr(nsIContent* aContent, nsAString* aResult); + static PRBool GetValueAttr(nsIContent* aContent, nsAString* aResult); /** * Cause the form control to reset its value * @param aFrame the frame who owns the form control @@ -153,50 +145,12 @@ public: // wrap can be one of these three values. typedef enum { - eHTMLTextWrap_Off = 1, // the default - eHTMLTextWrap_Hard = 2, // "hard" or "physical" - eHTMLTextWrap_Soft = 3 // "soft" or "virtual" + eHTMLTextWrap_Off = 1, // "off" + eHTMLTextWrap_Hard = 2, // "hard" + eHTMLTextWrap_Soft = 3 // the default } nsHTMLTextWrap; - /** returns the value of the "wrap" property in aOutValue - * returns NS_CONTENT_ATTR_NOT_THERE if the property does not exist for this - */ - static nsresult GetWrapProperty(nsIContent * aContent, nsString &aOutValue); - - static nsresult GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& aWrapProp); - -// -//------------------------------------------------------------------------------------- -// Utility methods for managing checkboxes and radiobuttons -//------------------------------------------------------------------------------------- -// - /** - * Get the state of the checked attribute. - * @param aState set to PR_TRUE if the checked attribute is set, - * PR_FALSE if the checked attribute has been removed - * @returns NS_OK or NS_CONTENT_ATTR_HAS_VALUE - */ - - //nsresult GetCurrentCheckState(PRBool* aState); - - /** - * Set the state of the checked attribute. - * @param aState set to PR_TRUE to set the attribute, - * PR_FALSE to unset the attribute - * @returns NS_OK or NS_CONTENT_ATTR_HAS_VALUE - */ - - nsresult SetCurrentCheckState(PRBool aState); - - /** - * Get the state of the defaultchecked attribute. - * @param aState set to PR_TRUE if the defaultchecked attribute is set, - * PR_FALSE if the defaultchecked attribute has been removed - * @returns NS_OK or NS_CONTENT_ATTR_HAS_VALUE - */ - - nsresult GetDefaultCheckState(PRBool* aState); - + static PRBool GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& aWrapProp); // //------------------------------------------------------------------------------------- diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index baf4fb206ee..c8a36bdad54 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -151,23 +151,19 @@ NS_IMETHODIMP nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, nsISupportsArray& aChildList) { - nsresult result; - // Get the text from the "value" attribute. // If it is zero length, set it to a default value (localized) nsAutoString initvalue; - result = GetValue(&initvalue); + GetValue(&initvalue); nsXPIDLString value; value.Assign(initvalue); - if (result != NS_CONTENT_ATTR_HAS_VALUE && value.IsEmpty()) { + if (value.IsEmpty()) { // Generate localized label. // We can't make any assumption as to what the default would be // because the value is localized for non-english platforms, thus // it might not be the string "Reset", "Submit Query", or "Browse..." - result = GetDefaultLabel(value); - if (NS_FAILED(result)) { - return result; - } + nsresult rv = GetDefaultLabel(value); + NS_ENSURE_SUCCESS(rv, rv); } // Compress whitespace out of label if needed. @@ -204,7 +200,7 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, mTextContent->SetText(value, PR_TRUE); aChildList.AppendElement(mTextContent); } - return result; + return NS_OK; } // Create the text content used as label for the button. @@ -317,9 +313,7 @@ nsGfxButtonControlFrame::AttributeChanged(PRInt32 aNameSpaceID, if (nsHTMLAtoms::value == aAttribute) { nsAutoString value; if (mTextContent && mContent) { - if (NS_CONTENT_ATTR_HAS_VALUE != mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, value)) { - value.Truncate(); - } + mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, value); mTextContent->SetText(value, PR_TRUE); } else { rv = NS_ERROR_UNEXPECTED; diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index 0deebcedb0b..2127b3ebc45 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -195,13 +195,17 @@ nsHTMLButtonControlFrame::GetFormControlType() const NS_IMETHODIMP nsHTMLButtonControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } NS_IMETHODIMP nsHTMLButtonControlFrame::GetValue(nsAString* aResult) { - return nsFormControlHelper::GetValueAttr(mContent, aResult); + nsFormControlHelper::GetValueAttr(mContent, aResult); + + return NS_OK; } void diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index 41b101bf12b..a1f4d923a75 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -299,7 +299,9 @@ nsImageControlFrame::GetFormControlType() const NS_IMETHODIMP nsImageControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 948024a0699..cf54ef29d4d 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -747,36 +747,6 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext, bailOnHeight = PR_FALSE; #endif -#ifdef DEBUG_rodsXXX - // Lists out all the options - { - nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr options = - getter_AddRefs(GetOptions(mContent)); - if (options) { - PRUint32 numOptions; - options->GetLength(&numOptions); - printf("--- Num of Items %d ---\n", numOptions); - for (PRUint32 i=0;i optionElement = getter_AddRefs(GetOption(options, i)); - if (optionElement) { - nsAutoString text; - rv = optionElement->GetLabel(text); - if (NS_CONTENT_ATTR_HAS_VALUE != rv || text.IsEmpty()) { - if (NS_OK != optionElement->GetText(text)) { - text = "No Value"; - } - } else { - text = "No Value"; - } - printf("[%d] - %s\n", i, NS_LossyConvertUCS2toASCII(text).get()); - } - } - } - } -#endif // DEBUG_rodsXXX - - // If all the content and frames are here // then initialize it before reflow if (mIsAllContentHere && !mHasBeenInitialized) { @@ -1839,7 +1809,9 @@ nsListControlFrame::ResetList(PRBool aAllowScrolling) NS_IMETHODIMP nsListControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 4680d98f3f4..3d144f04846 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -1971,9 +1971,7 @@ nsTextControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, // Set max text field length PRInt32 maxLength; - rv = GetMaxLength(&maxLength); - if (NS_CONTENT_ATTR_NOT_THERE != rv) - { + if (GetMaxLength(&maxLength)) { textEditor->SetMaxTextLength(maxLength); } } @@ -2005,26 +2003,14 @@ nsTextControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, if (NS_FAILED(rv)) return rv; - nsAutoString resultValue; - // Check if the readonly attribute is set. - rv = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::readonly, resultValue); - - if (NS_FAILED(rv)) - return rv; - - if (NS_CONTENT_ATTR_NOT_THERE != rv) + if (mContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::readonly)) editorFlags |= nsIPlaintextEditor::eEditorReadonlyMask; // Check if the disabled attribute is set. - rv = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, resultValue); - - if (NS_FAILED(rv)) - return rv; - - if (NS_CONTENT_ATTR_NOT_THERE != rv) + if (mContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) editorFlags |= nsIPlaintextEditor::eEditorDisabledMask; // Disable the caret and selection if necessary. @@ -2218,7 +2204,9 @@ nsTextControlFrame::IsLeaf() const NS_IMETHODIMP nsTextControlFrame::GetName(nsAString* aResult) { - return nsFormControlHelper::GetName(mContent, aResult); + nsFormControlHelper::GetName(mContent, aResult); + + return NS_OK; } NS_IMETHODIMP_(PRInt32) @@ -2799,12 +2787,12 @@ nsTextControlFrame::AttributeChanged(PRInt32 aNameSpaceID, if (nsHTMLAtoms::maxlength == aAttribute) { PRInt32 maxLength; - rv = GetMaxLength(&maxLength); + PRBool maxDefined = GetMaxLength(&maxLength); nsCOMPtr textEditor = do_QueryInterface(mEditor); if (textEditor) { - if (NS_CONTENT_ATTR_NOT_THERE != rv) + if (maxDefined) { // set the maxLength attribute textEditor->SetMaxTextLength(maxLength); // if maxLength>docLength, we need to truncate the doc content @@ -2877,7 +2865,7 @@ nsTextControlFrame::AttributeChanged(PRInt32 aNameSpaceID, NS_IMETHODIMP nsTextControlFrame::GetText(nsString* aText) { - nsresult rv = NS_CONTENT_ATTR_NOT_THERE; + nsresult rv = NS_OK; if (IsSingleLineTextControl()) { // If we're going to remove newlines anyway, ignore the wrap property GetValue(*aText, PR_TRUE); @@ -2923,7 +2911,7 @@ void nsTextControlFrame::RemoveNewlines(nsString &aString) } -nsresult +PRBool nsTextControlFrame::GetMaxLength(PRInt32* aSize) { *aSize = -1; @@ -2934,10 +2922,10 @@ nsTextControlFrame::GetMaxLength(PRInt32* aSize) if (attr && attr->Type() == nsAttrValue::eInteger) { *aSize = attr->GetIntegerValue(); - return NS_CONTENT_ATTR_HAS_VALUE; + return PR_TRUE; } } - return NS_CONTENT_ATTR_NOT_THERE; + return PR_FALSE; } // this is where we propagate a content changed event @@ -3028,12 +3016,9 @@ nsTextControlFrame::GetValue(nsAString& aValue, PRBool aIgnoreWrap) if (!aIgnoreWrap) { nsFormControlHelper::nsHTMLTextWrap wrapProp; - rv = nsFormControlHelper::GetWrapPropertyEnum(mContent, wrapProp); - if (rv != NS_CONTENT_ATTR_NOT_THERE) { - if (wrapProp == nsFormControlHelper::eHTMLTextWrap_Hard) - { - flags |= nsIDocumentEncoder::OutputWrap; - } + if (nsFormControlHelper::GetWrapPropertyEnum(mContent, wrapProp) && + wrapProp == nsFormControlHelper::eHTMLTextWrap_Hard) { + flags |= nsIDocumentEncoder::OutputWrap; } } diff --git a/mozilla/layout/forms/nsTextControlFrame.h b/mozilla/layout/forms/nsTextControlFrame.h index e30be494495..5f212199191 100644 --- a/mozilla/layout/forms/nsTextControlFrame.h +++ b/mozilla/layout/forms/nsTextControlFrame.h @@ -233,9 +233,9 @@ protected: /** * Get the maxlength attribute * @param aMaxLength the value of the max length attr - * @throws NS_CONTENT_ATTR_NOT_THERE if attr not defined + * @returns PR_FALSE if attr not defined */ - nsresult GetMaxLength(PRInt32* aMaxLength); + PRBool GetMaxLength(PRInt32* aMaxLength); /** * Find out whether an attribute exists on the content or not. * @param aAtt the attribute to determine the existence of diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index f6d50b2be77..41a18d189c9 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -902,17 +902,15 @@ nsBlockReflowState::FlowAndPlaceFloat(nsFloatCache* aFloatCache, // IE makes a difference between align and he float property nsIContent* content = prevFrame->GetContent(); if (content) { - nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value)) { - // we're interested only if previous frame is align=left - // IE messes things up when "right" (overlapping frames) - if (value.LowerCaseEqualsLiteral("left")) { - keepFloatOnSameLine = PR_TRUE; - // don't advance to next line (IE quirkie behaviour) - // it breaks rule CSS2/9.5.1/1, but what the hell - // since we cannot evangelize the world - break; - } + // we're interested only if previous frame is align=left + // IE messes things up when "right" (overlapping frames) + if (content->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::align, + NS_LITERAL_STRING("left"), eIgnoreCase)) { + keepFloatOnSameLine = PR_TRUE; + // don't advance to next line (IE quirkie behaviour) + // it breaks rule CSS2/9.5.1/1, but what the hell + // since we cannot evangelize the world + break; } } } diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index d2bfebc3893..4962fd11ddf 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -1579,8 +1579,8 @@ nsGfxScrollFrameInner::ReloadChildFrames() mScrolledFrame = frame; } else { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, - nsXULAtoms::orient, value)) { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::orient, value); + if (!value.IsEmpty()) { // probably a scrollbar then if (value.LowerCaseEqualsLiteral("horizontal")) { NS_ASSERTION(!mHScrollbarBox, "Found multiple horizontal scrollbars?"); @@ -1763,7 +1763,8 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32 nscoord y = 0; nsAutoString value; - if (hcontent && NS_CONTENT_ATTR_HAS_VALUE == hcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value)) + if (hcontent && hcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, + value)) { PRInt32 error; @@ -1771,7 +1772,8 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32 x = value.ToInteger(&error); } - if (vcontent && NS_CONTENT_ATTR_HAS_VALUE == vcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value)) + if (vcontent && vcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, + value)) { PRInt32 error; @@ -2553,7 +2555,8 @@ nsGfxScrollFrameInner::GetIntegerAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 nsIContent* content = aBox->GetContent(); nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, atom, value)) + content->GetAttr(kNameSpaceID_None, atom, value); + if (!value.IsEmpty()) { PRInt32 error; diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index ce15424ce5d..288c3681223 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -1519,9 +1519,7 @@ nsImageFrame::TriggerLink(nsPresContext* aPresContext, PRBool nsImageFrame::IsServerImageMap() { - nsAutoString ismap; - return NS_CONTENT_ATTR_HAS_VALUE == - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::ismap, ismap); + return mContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::ismap); } // Translate an point that is relative to our frame diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 3fd03669963..6dc9aa2fbe7 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -1098,9 +1098,6 @@ nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const // only tags support the HIDDEN attribute if (mContent->Tag() == nsHTMLAtoms::embed) { - nsAutoString hidden; - nsresult result = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden); - // Yes, these are really the kooky ways that you could tell 4.x // not to hide the once you'd put the 'hidden' attribute // on the tag... @@ -1108,7 +1105,8 @@ nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const // HIDDEN w/ no attributes gets translated as we are hidden for // compatibility w/ 4.x and IE so we don't create a non-painting // widget in layout. See bug 188959. - if (NS_CONTENT_ATTR_NOT_THERE != result && + nsAutoString hidden; + if (mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden) && (hidden.IsEmpty() || !hidden.LowerCaseEqualsLiteral("false") && !hidden.LowerCaseEqualsLiteral("no") && @@ -1781,9 +1779,8 @@ nsObjectFrame::Instantiate(const char* aMimeType, nsIURI* aURI) nsCOMPtr baseURI = mContent->GetBaseURI(); nsAutoString codeBase; - if ((NS_CONTENT_ATTR_HAS_VALUE == - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) && - !codeBase.IsEmpty()) { + mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase); + if (!codeBase.IsEmpty()) { nsCOMPtr codeBaseURL; rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURI); if (NS_SUCCEEDED(rv)) { @@ -1801,7 +1798,8 @@ nsObjectFrame::Instantiate(const char* aMimeType, nsIURI* aURI) // if we have a clsid, we're either an internal widget, an ActiveX control, or an applet if (mContent->Tag() == nsHTMLAtoms::object && - NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::classid, classid)) { + mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::classid, classid) && + !classid.IsEmpty()) { // Find a MIME type for the class ID nsCOMPtr objContent = do_QueryInterface(GetContent(), &rv); @@ -2945,10 +2943,9 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() // to the bottom of the array if there isn't already a "src" specified. PRInt16 numRealAttrs = mNumCachedAttrs; nsAutoString data; - nsIAtom *tag = content->Tag(); - if (nsHTMLAtoms::object == tag + if (content->Tag() == nsHTMLAtoms::object && !content->HasAttr(kNameSpaceID_None, nsHTMLAtoms::src) - && NS_CONTENT_ATTR_NOT_THERE != content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data)) { + && content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data)) { mNumCachedAttrs++; } @@ -2988,16 +2985,15 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() getter_AddRefs(atom), getter_AddRefs(prefix)); nsAutoString value; - if (NS_CONTENT_ATTR_NOT_THERE != content->GetAttr(nameSpaceID, atom, value)) { - nsAutoString name; - atom->ToString(name); - - mOwner->FixUpURLS(name, value); + content->GetAttr(nameSpaceID, atom, value); + nsAutoString name; + atom->ToString(name); - mCachedAttrParamNames [c] = ToNewUTF8String(name); - mCachedAttrParamValues[c] = ToNewUTF8String(value); - c++; - } + mOwner->FixUpURLS(name, value); + + mCachedAttrParamNames [c] = ToNewUTF8String(name); + mCachedAttrParamValues[c] = ToNewUTF8String(value); + c++; } // if the conditions above were met, copy the "data" attribute to a "src" array entry diff --git a/mozilla/layout/generic/nsSpacerFrame.cpp b/mozilla/layout/generic/nsSpacerFrame.cpp index 4532c6f91cc..e20e7a42e60 100644 --- a/mozilla/layout/generic/nsSpacerFrame.cpp +++ b/mozilla/layout/generic/nsSpacerFrame.cpp @@ -171,8 +171,7 @@ SpacerFrame::GetType() { PRUint8 type = TYPE_WORD; nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) { + if (mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) { if (value.LowerCaseEqualsLiteral("line") || value.LowerCaseEqualsLiteral("vert") || value.LowerCaseEqualsLiteral("vertical")) { diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 112a2ea327f..743200b3b6f 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -615,9 +615,9 @@ nsMathMLContainerFrame::PropagateScriptStyleFor(nsIFrame* aFrame, // css rules are fixed in mathml.css and are applicable to all elements. // see if there is a scriptminsize attribute on a that wraps us - if (NS_CONTENT_ATTR_HAS_VALUE == - GetAttribute(nsnull, presentationData.mstyle, - nsMathMLAtoms::scriptminsize_, fontsize)) { + GetAttribute(nsnull, presentationData.mstyle, + nsMathMLAtoms::scriptminsize_, fontsize); + if (!fontsize.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(fontsize, cssValue)) { nsCSSUnit unit = cssValue.GetUnit(); diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index d2bd6623105..eb06dcc90c1 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -205,41 +205,39 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame, } // helper to get an attribute from the content or the surrounding hierarchy -/* static */ nsresult +/* static */ PRBool nsMathMLFrame::GetAttribute(nsIContent* aContent, nsIFrame* aMathMLmstyleFrame, nsIAtom* aAttributeAtom, nsString& aValue) { - nsresult rv = NS_CONTENT_ATTR_NOT_THERE; - // see if we can get the attribute from the content - if (aContent) { - rv = aContent->GetAttr(kNameSpaceID_None, aAttributeAtom, aValue); + if (aContent && aContent->GetAttr(kNameSpaceID_None, aAttributeAtom, + aValue)) { + return PR_TRUE; } - if (NS_CONTENT_ATTR_NOT_THERE == rv) { - // see if we can get the attribute from the mstyle frame - if (aMathMLmstyleFrame) { - nsIFrame* mstyleParent = aMathMLmstyleFrame->GetParent(); + // see if we can get the attribute from the mstyle frame + if (!aMathMLmstyleFrame) { + return PR_FALSE; + } - nsPresentationData mstyleParentData; - mstyleParentData.mstyle = nsnull; + nsIFrame* mstyleParent = aMathMLmstyleFrame->GetParent(); - if (mstyleParent) { - nsIMathMLFrame* mathMLFrame; - mstyleParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (mathMLFrame) { - mathMLFrame->GetPresentationData(mstyleParentData); - } - } + nsPresentationData mstyleParentData; + mstyleParentData.mstyle = nsnull; - // recurse all the way up into the hierarchy - rv = GetAttribute(aMathMLmstyleFrame->GetContent(), - mstyleParentData.mstyle, aAttributeAtom, aValue); + if (mstyleParent) { + nsIMathMLFrame* mathMLFrame; + mstyleParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { + mathMLFrame->GetPresentationData(mstyleParentData); } } - return rv; + + // recurse all the way up into the hierarchy + return GetAttribute(aMathMLmstyleFrame->GetContent(), + mstyleParentData.mstyle, aAttributeAtom, aValue); } /* static */ void @@ -486,8 +484,8 @@ nsMathMLFrame::ParseNamedSpaceValue(nsIFrame* aMathMLmstyleFrame, // see if there is a that has overriden the default value // GetAttribute() will recurse all the way up into the hierarchy nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == - GetAttribute(nsnull, aMathMLmstyleFrame, namedspaceAtom, value)) { + GetAttribute(nsnull, aMathMLmstyleFrame, namedspaceAtom, value); + if (!value.IsEmpty()) { if (ParseNumericValue(value, aCSSValue) && aCSSValue.IsLengthUnit()) { return PR_TRUE; diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.h b/mozilla/layout/mathml/base/src/nsMathMLFrame.h index 2a2a42479fc..64d96cba67d 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.h @@ -204,10 +204,9 @@ public: // helper to check if a content has an attribute. If content is nsnull or if // the attribute is not there, check if the attribute is on the mstyle hierarchy - // @return NS_CONTENT_ATTR_HAS_VALUE --if attribute has non-empty value, attr="value" - // NS_CONTENT_ATTR_NO_VALUE --if attribute has empty value, attr="" - // NS_CONTENT_ATTR_NOT_THERE --if attribute is not there - static nsresult + // @return PR_TRUE --if attribute exists + // PR_FALSE --if attribute doesn't exist + static PRBool GetAttribute(nsIContent* aContent, nsIFrame* aMathMLmstyleFrame, nsIAtom* aAttributeAtom, diff --git a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp index fb6f6d75974..1c5ae8e1185 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp @@ -416,12 +416,12 @@ nsMathMLTokenFrame::SetQuotes(nsPresContext* aPresContext) nsAutoString value; // lquote - if (NS_CONTENT_ATTR_NOT_THERE != GetAttribute(mContent, mPresentationData.mstyle, + if (GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::lquote_, value)) { SetQuote(aPresContext, leftFrame, value); } // rquote - if (NS_CONTENT_ATTR_NOT_THERE != GetAttribute(mContent, mPresentationData.mstyle, + if (GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::rquote_, value)) { SetQuote(aPresContext, rightFrame, value); } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 76f29bdf55e..4115980bf79 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -123,8 +123,8 @@ nsMathMLmactionFrame::Init(nsPresContext* aPresContext, nsRefPtr newStyleContext; mActionType = NS_MATHML_ACTION_TYPE_NONE; - if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::actiontype_, value)) { + aContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::actiontype_, value); + if (!value.IsEmpty()) { if (value.EqualsLiteral("toggle")) mActionType = NS_MATHML_ACTION_TYPE_TOGGLE; @@ -184,8 +184,8 @@ nsMathMLmactionFrame::GetSelectedFrame() nsAutoString value; PRInt32 selection; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::selection_, value)) { + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::selection_, value); + if (!value.IsEmpty()) { PRInt32 errorCode; selection = value.ToInteger(&errorCode); if (NS_FAILED(errorCode)) @@ -389,13 +389,11 @@ nsMathMLmactionFrame::MouseOver(nsIDOMEvent* aMouseEvent) // see if we should display a status message if (NS_MATHML_ACTION_TYPE_STATUSLINE == mActionType) { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::actiontype_, value)) { - // expected statusline prefix (11ch)... - if (11 < value.Length() && 0 == value.Find("statusline#")) { - value.Cut(0, 11); - ShowStatus(mPresContext, value); - } + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::actiontype_, value); + // expected statusline prefix (11ch)... + if (11 < value.Length() && 0 == value.Find("statusline#")) { + value.Cut(0, 11); + ShowStatus(mPresContext, value); } } return NS_OK; @@ -434,8 +432,9 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent) if (!mRestyle.IsEmpty()) { nsCOMPtr node( do_QueryInterface(mContent) ); if (node.get()) { - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::actiontype_, value)) + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::actiontype_, + value); + if (!value.IsEmpty()) node->RemoveAttribute(NS_LITERAL_STRING("actiontype")); else node->SetAttribute(NS_LITERAL_STRING("actiontype"), mRestyle); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp index 8eec16e5564..5e6ada20c0e 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp @@ -141,65 +141,56 @@ nsresult nsMathMLmfencedFrame::CreateFencesAndSeparators(nsPresContext* aPresContext) { nsresult rv; - nsAutoString value, data; + nsAutoString value; PRBool isMutable = PR_FALSE; ////////////// // see if the opening fence is there ... - rv = GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::open_, value); - if (NS_CONTENT_ATTR_HAS_VALUE == rv) { - value.Trim(" "); - data = value; + if (!GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::open_, + value)) { + value = PRUnichar('('); // default as per the MathML REC + } + else { + value.Trim(" "); } - else if (NS_CONTENT_ATTR_NOT_THERE == rv) - data = PRUnichar('('); // default as per the MathML REC - else - data.Truncate(); - if (!data.IsEmpty()) { + if (!value.IsEmpty()) { mOpenChar = new nsMathMLChar; if (!mOpenChar) return NS_ERROR_OUT_OF_MEMORY; - mOpenChar->SetData(aPresContext, data); - isMutable = nsMathMLOperators::IsMutableOperator(data); + mOpenChar->SetData(aPresContext, value); + isMutable = nsMathMLOperators::IsMutableOperator(value); ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, mOpenChar, isMutable); } ////////////// // see if the closing fence is there ... - rv = GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::close_, value); - if (NS_CONTENT_ATTR_HAS_VALUE == rv) { - value.Trim(" "); - data = value; + if(!GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::close_, value)) { + value = PRUnichar(')'); // default as per the MathML REC + } + else { + value.Trim(" "); } - else if (NS_CONTENT_ATTR_NOT_THERE == rv) - data = PRUnichar(')'); // default as per the MathML REC - else - data.Truncate(); - if (!data.IsEmpty()) { + if (!value.IsEmpty()) { mCloseChar = new nsMathMLChar; if (!mCloseChar) return NS_ERROR_OUT_OF_MEMORY; - mCloseChar->SetData(aPresContext, data); - isMutable = nsMathMLOperators::IsMutableOperator(data); + mCloseChar->SetData(aPresContext, value); + isMutable = nsMathMLOperators::IsMutableOperator(value); ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, mCloseChar, isMutable); } ////////////// // see if separators are there ... - rv = GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::separators_, value); - if (NS_CONTENT_ATTR_HAS_VALUE == rv) { - value.Trim(" "); - data = value; + if(!GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::separators_, value)) { + value = PRUnichar(','); // default as per the MathML REC + } + else { + value.Trim(" "); } - else if (NS_CONTENT_ATTR_NOT_THERE == rv) - data = PRUnichar(','); // default as per the MathML REC - else - data.Truncate(); - mSeparatorsCount = data.Length(); + mSeparatorsCount = value.Length(); if (0 < mSeparatorsCount) { PRInt32 sepCount = mFrames.GetLength() - 1; if (0 < sepCount) { @@ -208,11 +199,11 @@ nsMathMLmfencedFrame::CreateFencesAndSeparators(nsPresContext* aPresContext) nsAutoString sepChar; for (PRInt32 i = 0; i < sepCount; i++) { if (i < mSeparatorsCount) { - sepChar = data[i]; + sepChar = value[i]; isMutable = nsMathMLOperators::IsMutableOperator(sepChar); } else { - sepChar = data[mSeparatorsCount-1]; + sepChar = value[mSeparatorsCount-1]; // keep the value of isMutable that was set earlier } mSeparatorsChar[i].SetData(aPresContext, sepChar); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp index cc09eeb60cf..c1dda7bbbbe 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp @@ -101,14 +101,9 @@ PRBool nsMathMLmfracFrame::IsBevelled() { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == - GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::bevelled_, value)) { - if (value.EqualsLiteral("true")) { - return PR_TRUE; - } - } - return PR_FALSE; + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::bevelled_, + value); + return value.EqualsLiteral("true"); } NS_IMETHODIMP @@ -423,21 +418,20 @@ nsMathMLmfracFrame::Place(nsIRenderingContext& aRenderingContext, width += leftSpace + rightSpace; // see if the numalign attribute is there - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::numalign_, value)) { - if (value.EqualsLiteral("left")) - dxNum = leftSpace; - else if (value.EqualsLiteral("right")) - dxNum = width - rightSpace - sizeNum.width; - } + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::numalign_, + value); + if (value.EqualsLiteral("left")) + dxNum = leftSpace; + else if (value.EqualsLiteral("right")) + dxNum = width - rightSpace - sizeNum.width; + // see if the denomalign attribute is there - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::denomalign_, value)) { - if (value.EqualsLiteral("left")) - dxDen = leftSpace; - else if (value.EqualsLiteral("right")) - dxDen = width - rightSpace - sizeDen.width; - } + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::denomalign_, + value); + if (value.EqualsLiteral("left")) + dxDen = leftSpace; + else if (value.EqualsLiteral("right")) + dxDen = width - rightSpace - sizeDen.width; mBoundingMetrics.rightBearing = PR_MAX(dxNum + bmNum.rightBearing, dxDen + bmDen.rightBearing); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp index 1ef305acf31..adaa98a8442 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp @@ -134,16 +134,18 @@ nsMathMLmmultiscriptsFrame::ProcessAttributes() // check if the subscriptshift attribute is there nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::subscriptshift_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::subscriptshift_, value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) && cssValue.IsLengthUnit()) { mSubScriptShift = CalcLength(GetPresContext(), mStyleContext, cssValue); } } // check if the superscriptshift attribute is there - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::superscriptshift_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::superscriptshift_, value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) && cssValue.IsLengthUnit()) { mSupScriptShift = CalcLength(GetPresContext(), mStyleContext, cssValue); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp index df45136a13c..970a8f1418c 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -334,21 +334,20 @@ nsMathMLmoFrame::ProcessOperatorData() mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS; // see if the accent attribute is there - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::accent_, value)) { - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT; - } + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::accent_, + value); + if (value.EqualsLiteral("true")) + mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT; + else if (value.EqualsLiteral("false")) + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT; + // see if the movablelimits attribute is there - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::movablelimits_, value)) { - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_MOVABLELIMITS; - } + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::movablelimits_, value); + if (value.EqualsLiteral("true")) + mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS; + else if (value.EqualsLiteral("false")) + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_MOVABLELIMITS; // --------------------------------------------------------------------- // we will be called again to re-sync the rest of our state next time... @@ -398,8 +397,9 @@ nsMathMLmoFrame::ProcessOperatorData() // find our form form = NS_MATHML_OPERATOR_FORM_INFIX; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::form_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::form_, + value); + if (!value.IsEmpty()) { if (value.EqualsLiteral("prefix")) form = NS_MATHML_OPERATOR_FORM_PREFIX; else if (value.EqualsLiteral("postfix")) @@ -454,8 +454,9 @@ nsMathMLmoFrame::ProcessOperatorData() // lspace = number h-unit | namedspace nscoord leftSpace = mEmbellishData.leftSpace; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::lspace_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::lspace_, + value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) @@ -470,8 +471,9 @@ nsMathMLmoFrame::ProcessOperatorData() // rspace = number h-unit | namedspace nscoord rightSpace = mEmbellishData.rightSpace; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::rspace_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::rspace_, + value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) @@ -507,42 +509,42 @@ nsMathMLmoFrame::ProcessOperatorData() // special: accent and movablelimits are handled in ProcessEmbellishData() // don't process them here - nsAutoString kfalse, ktrue; - kfalse.AssignLiteral("false"); - ktrue.AssignLiteral("true"); - if (NS_MATHML_OPERATOR_IS_STRETCHY(mFlags)) { - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::stretchy_, value) && value == kfalse) + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::stretchy_, value); + if (value.EqualsLiteral("false")) mFlags &= ~NS_MATHML_OPERATOR_STRETCHY; } if (NS_MATHML_OPERATOR_IS_FENCE(mFlags)) { - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::fence_, value) && value == kfalse) + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::fence_, value); + if (value.EqualsLiteral("false")) mFlags &= ~NS_MATHML_OPERATOR_FENCE; } if (NS_MATHML_OPERATOR_IS_LARGEOP(mFlags)) { - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::largeop_, value) && value == kfalse) + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::largeop_, value); + if (value.EqualsLiteral("false")) mFlags &= ~NS_MATHML_OPERATOR_LARGEOP; } if (NS_MATHML_OPERATOR_IS_SEPARATOR(mFlags)) { - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::separator_, value) && value == kfalse) + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::separator_, value); + if (value.EqualsLiteral("false")) mFlags &= ~NS_MATHML_OPERATOR_SEPARATOR; } - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::symmetric_, value)) { - if (value == kfalse) - mFlags &= ~NS_MATHML_OPERATOR_SYMMETRIC; - else if (value == ktrue) - mFlags |= NS_MATHML_OPERATOR_SYMMETRIC; - } + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::symmetric_, + value); + if (value.EqualsLiteral("false")) + mFlags &= ~NS_MATHML_OPERATOR_SYMMETRIC; + else if (value.EqualsLiteral("true")) + mFlags |= NS_MATHML_OPERATOR_SYMMETRIC; // minsize = number [ v-unit | h-unit ] | namedspace mMinSize = float(NS_UNCONSTRAINEDSIZE); - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::minsize_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::minsize_, + value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) @@ -559,8 +561,9 @@ nsMathMLmoFrame::ProcessOperatorData() if ((eCSSUnit_Number == unit) || (eCSSUnit_Percent == unit)) { // see if the multiplicative inheritance should be from - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsnull, mPresentationData.mstyle, - nsMathMLAtoms::minsize_, value)) { + GetAttribute(nsnull, mPresentationData.mstyle, + nsMathMLAtoms::minsize_, value); + if (!value.IsEmpty()) { if (ParseNumericValue(value, cssValue)) { if (cssValue.IsLengthUnit()) { mMinSize *= float(CalcLength(presContext, mStyleContext, cssValue)); @@ -574,8 +577,9 @@ nsMathMLmoFrame::ProcessOperatorData() // maxsize = number [ v-unit | h-unit ] | namedspace | infinity mMaxSize = float(NS_UNCONSTRAINEDSIZE); - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::maxsize_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::maxsize_, + value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) @@ -592,8 +596,9 @@ nsMathMLmoFrame::ProcessOperatorData() if ((eCSSUnit_Number == unit) || (eCSSUnit_Percent == unit)) { // see if the multiplicative inheritance should be from - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsnull, mPresentationData.mstyle, - nsMathMLAtoms::maxsize_, value)) { + GetAttribute(nsnull, mPresentationData.mstyle, + nsMathMLAtoms::maxsize_, value); + if (!value.IsEmpty()) { if (ParseNumericValue(value, cssValue)) { if (cssValue.IsLengthUnit()) { mMaxSize *= float(CalcLength(presContext, mStyleContext, cssValue)); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp index c1230ee24ea..31b92b81b77 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp @@ -208,13 +208,11 @@ XXX The winner is the outermost in conflicting settings like these: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; // if we have an accent attribute, it overrides what the overscript said - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::accent_, value)) { - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; - } + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::accent_, value); + if (value.EqualsLiteral("true")) + mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; + else if (value.EqualsLiteral("false")) + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && diff --git a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp index 4f2e6da94ac..a3568334ebc 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp @@ -125,29 +125,29 @@ nsMathMLmpaddedFrame::ProcessAttributes() // width mWidthSign = NS_MATHML_SIGN_INVALID; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, nsnull, - nsMathMLAtoms::width_, value)) { + GetAttribute(mContent, nsnull, nsMathMLAtoms::width_, value); + if (!value.IsEmpty()) { ParseAttribute(value, mWidthSign, mWidth, mWidthPseudoUnit); } // height mHeightSign = NS_MATHML_SIGN_INVALID; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, nsnull, - nsMathMLAtoms::height_, value)) { + GetAttribute(mContent, nsnull, nsMathMLAtoms::height_, value); + if (!value.IsEmpty()) { ParseAttribute(value, mHeightSign, mHeight, mHeightPseudoUnit); } // depth mDepthSign = NS_MATHML_SIGN_INVALID; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, nsnull, - nsMathMLAtoms::depth_, value)) { + GetAttribute(mContent, nsnull, nsMathMLAtoms::depth_, value); + if (!value.IsEmpty()) { ParseAttribute(value, mDepthSign, mDepth, mDepthPseudoUnit); } // lspace mLeftSpaceSign = NS_MATHML_SIGN_INVALID; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, nsnull, - nsMathMLAtoms::lspace_, value)) { + GetAttribute(mContent, nsnull, nsMathMLAtoms::lspace_, value); + if (!value.IsEmpty()) { ParseAttribute(value, mLeftSpaceSign, mLeftSpace, mLeftSpacePseudoUnit); } } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp index 8f34fa64e39..d9d9a88138c 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp @@ -91,8 +91,9 @@ nsMathMLmspaceFrame::ProcessAttributes(nsPresContext* aPresContext) // width mWidth = 0; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::width_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::width_, + value); + if (!value.IsEmpty()) { if ((ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) && cssValue.IsLengthUnit()) { @@ -102,8 +103,9 @@ nsMathMLmspaceFrame::ProcessAttributes(nsPresContext* aPresContext) // height mHeight = 0; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::height_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::height_, + value); + if (!value.IsEmpty()) { if ((ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) && cssValue.IsLengthUnit()) { @@ -113,8 +115,9 @@ nsMathMLmspaceFrame::ProcessAttributes(nsPresContext* aPresContext) // depth mDepth = 0; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::depth_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, nsMathMLAtoms::depth_, + value); + if (!value.IsEmpty()) { if ((ParseNumericValue(value, cssValue) || ParseNamedSpaceValue(mPresentationData.mstyle, value, cssValue)) && cssValue.IsLengthUnit()) { diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index 925234008f3..17fc13b7584 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -89,21 +89,19 @@ nsMathMLmstyleFrame::InheritAutomaticData(nsIFrame* aParent) // see if the displaystyle attribute is there nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::displaystyle_, value)) { - if (value.EqualsLiteral("true")) { - mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - } - else if (value.EqualsLiteral("false")) { - mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; - } + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::displaystyle_, value); + if (value.EqualsLiteral("true")) { + mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + else if (value.EqualsLiteral("false")) { + mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; + mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; } // see if the scriptlevel attribute is there - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::scriptlevel_, value)) { + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::scriptlevel_, value); + if (!value.IsEmpty()) { PRInt32 errorCode, userValue; userValue = value.ToInteger(&errorCode); if (!errorCode) { diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp index bc2db9bf9b4..e34b4727546 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp @@ -105,8 +105,9 @@ nsMathMLmsubFrame::Place (nsIRenderingContext& aRenderingContext, // check if the subscriptshift attribute is there nscoord subScriptShift = 0; nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::subscriptshift_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::subscriptshift_, value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) && cssValue.IsLengthUnit()) { subScriptShift = CalcLength(GetPresContext(), mStyleContext, cssValue); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp index 91903c56477..72b17fbc753 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp @@ -110,8 +110,9 @@ nsMathMLmsubsupFrame::Place(nsIRenderingContext& aRenderingContext, // check if the subscriptshift attribute is there nsAutoString value; nscoord subScriptShift = 0; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::subscriptshift_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::subscriptshift_, value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) && cssValue.IsLengthUnit()) { subScriptShift = CalcLength(GetPresContext(), mStyleContext, cssValue); @@ -119,8 +120,9 @@ nsMathMLmsubsupFrame::Place(nsIRenderingContext& aRenderingContext, } // check if the superscriptshift attribute is there nscoord supScriptShift = 0; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::superscriptshift_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::superscriptshift_, value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) && cssValue.IsLengthUnit()) { supScriptShift = CalcLength(GetPresContext(), mStyleContext, cssValue); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp index 1058d68a351..e5e9285c6fc 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp @@ -105,8 +105,9 @@ nsMathMLmsupFrame::Place(nsIRenderingContext& aRenderingContext, // check if the superscriptshift attribute is there nsAutoString value; nscoord supScriptShift = 0; - if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle, - nsMathMLAtoms::superscriptshift_, value)) { + GetAttribute(mContent, mPresentationData.mstyle, + nsMathMLAtoms::superscriptshift_, value); + if (!value.IsEmpty()) { nsCSSValue cssValue; if (ParseNumericValue(value, cssValue) && cssValue.IsLengthUnit()) { supScriptShift = CalcLength(GetPresContext(), mStyleContext, cssValue); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index eee080e01c3..b68268609a0 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -141,8 +141,8 @@ GetValueAt(nsPresContext* aPresContext, if (!valueList) { // The property isn't there yet, so set it nsAutoString values; - if (NS_CONTENT_ATTR_HAS_VALUE == - aTableOrRowFrame->GetContent()->GetAttr(kNameSpaceID_None, aAttributeAtom, values)) { + aTableOrRowFrame->GetContent()->GetAttr(kNameSpaceID_None, aAttributeAtom, values); + if (!values.IsEmpty()) { valueList = new nsValueList(values); if (valueList) { propTable->SetProperty(aTableOrRowFrame, aAttributeAtom, @@ -205,8 +205,7 @@ MapAttributesInto(nsPresContext* aPresContext, // see if the rowalign attribute is not already set atom = nsMathMLAtoms::rowalign_; - rv = aCellContent->GetAttr(kNameSpaceID_None, atom, value); - if (NS_CONTENT_ATTR_NOT_THERE == rv) { + if (!aCellContent->GetAttr(kNameSpaceID_None, atom, value)) { // see if the rowalign attribute was specified on the row attr = GetValueAt(aPresContext, rowFrame, atom, rowIndex); if (!attr) { @@ -251,8 +250,7 @@ MapAttributesInto(nsPresContext* aPresContext, // see if the columnalign attribute is not already set atom = nsMathMLAtoms::columnalign_; - rv = aCellContent->GetAttr(kNameSpaceID_None, atom, value); - if (NS_CONTENT_ATTR_NOT_THERE == rv) { + if (!aCellContent->GetAttr(kNameSpaceID_None, atom, value)) { // see if the columnalign attribute was specified on the row attr = GetValueAt(aPresContext, rowFrame, atom, colIndex); if (!attr) { @@ -395,14 +393,12 @@ nsMathMLmtableOuterFrame::InheritAutomaticData(nsIFrame* aParent) // see if the displaystyle attribute is there and let it override what we inherited nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == - GetAttribute(mContent, nsnull, nsMathMLAtoms::displaystyle_, value)) { - if (value.EqualsLiteral("true")) { - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - } - else if (value.EqualsLiteral("false")) { - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; - } + GetAttribute(mContent, nsnull, nsMathMLAtoms::displaystyle_, value); + if (value.EqualsLiteral("true")) { + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + else if (value.EqualsLiteral("false")) { + mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; } return NS_OK; @@ -497,8 +493,8 @@ nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext, // XXX should we also check ? PRInt32 rowIndex = 0; eAlign tableAlign = eAlign_axis; - if (NS_CONTENT_ATTR_HAS_VALUE == - GetAttribute(mContent, nsnull, nsMathMLAtoms::align_, value)) { + GetAttribute(mContent, nsnull, nsMathMLAtoms::align_, value); + if (!value.IsEmpty()) { ParseAlignAttribute(value, tableAlign, rowIndex); } @@ -619,8 +615,8 @@ nsMathMLmtdFrame::GetRowSpan() { PRInt32 rowspan = 1; nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::rowspan_, value)) { + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::rowspan_, value); + if (!value.IsEmpty()) { PRInt32 error; rowspan = value.ToInteger(&error); if (error) @@ -634,8 +630,8 @@ nsMathMLmtdFrame::GetColSpan() { PRInt32 colspan = 1; nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::columnspan_, value)) { + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::columnspan_, value); + if (!value.IsEmpty()) { PRInt32 error; colspan = value.ToInteger(&error); if (error) diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp index a8774fb52ef..bbf818a5884 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp @@ -208,13 +208,11 @@ XXX The winner is the outermost setting in conflicting settings like these: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; // if we have an accentunder attribute, it overrides what the underscript said - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::accentunder_, value)) { - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; - } + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::accentunder_, value); + if (value.EqualsLiteral("true")) + mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; + else if (value.EqualsLiteral("false")) + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp index 068439377a6..a476f712c2f 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp @@ -212,13 +212,11 @@ nsMathMLmunderoverFrame::TransmitAutomaticData() mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; // if we have an accentunder attribute, it overrides what the underscript said - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::accentunder_, value)) { - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; - } + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::accentunder_, value); + if (value.EqualsLiteral("true")) + mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; + else if (value.EqualsLiteral("false")) + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; // The default value of accent is false, unless the overscript is embellished // and its core is an accent @@ -229,13 +227,11 @@ nsMathMLmunderoverFrame::TransmitAutomaticData() mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; // if we have an accent attribute, it overrides what the overscript said - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, - nsMathMLAtoms::accent_, value)) { - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; - } + mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::accent_, value); + if (value.EqualsLiteral("true")) + mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; + else if (value.EqualsLiteral("false")) + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index 70dcb0812da..6c294fcbbec 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -2702,14 +2702,13 @@ const nsString* RuleProcessorData::GetLang() // xml:lang has precedence over lang on HTML elements (see // XHTML1 section C.7). nsAutoString value; - nsresult attrState = content->GetAttr(kNameSpaceID_XML, - nsHTMLAtoms::lang, value); - if (attrState != NS_CONTENT_ATTR_HAS_VALUE && - content->IsContentOfType(nsIContent::eHTML)) { - attrState = content->GetAttr(kNameSpaceID_None, - nsHTMLAtoms::lang, value); + PRBool hasAttr = content->GetAttr(kNameSpaceID_XML, nsHTMLAtoms::lang, + value); + if (!hasAttr && content->IsContentOfType(nsIContent::eHTML)) { + hasAttr = content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::lang, + value); } - if (attrState == NS_CONTENT_ATTR_HAS_VALUE) { + if (hasAttr) { *mLanguage = value; break; } @@ -3189,12 +3188,10 @@ static PRBool SelectorMatches(RuleProcessorData &data, } else { nsAutoString value; #ifdef DEBUG - attrState = + PRBool hasAttr = #endif data.mContent->GetAttr(nameSpaceID, name, value); - NS_ASSERTION(NS_SUCCEEDED(attrState) && - NS_CONTENT_ATTR_NOT_THERE != attrState, - "GetAttrNameAt lied or GetAttr failed"); + NS_ASSERTION(hasAttr, "GetAttrNameAt lied"); attrSelectorMatched = AttrMatchesValue(attr, value); } @@ -3223,12 +3220,10 @@ static PRBool SelectorMatches(RuleProcessorData &data, else if (attr->mFunction != NS_ATTR_FUNC_SET) { nsAutoString value; #ifdef DEBUG - nsresult attrState = + PRBool hasAttr = #endif data.mContent->GetAttr(attr->mNameSpace, attr->mAttr, value); - NS_ASSERTION(NS_SUCCEEDED(attrState) && - NS_CONTENT_ATTR_NOT_THERE != attrState, - "HasAttr lied or GetAttr failed"); + NS_ASSERTION(hasAttr, "HasAttr lied"); result = localTrue == AttrMatchesValue(attr, value); } diff --git a/mozilla/layout/xul/base/src/nsBox.cpp b/mozilla/layout/xul/base/src/nsBox.cpp index fd2e519504d..5b82660759b 100644 --- a/mozilla/layout/xul/base/src/nsBox.cpp +++ b/mozilla/layout/xul/base/src/nsBox.cpp @@ -966,8 +966,8 @@ nsIBox::AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) nsAutoString value; PRInt32 error; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::width, value)) - { + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::width, value); + if (!value.IsEmpty()) { value.Trim("%"); aSize.width = @@ -975,8 +975,8 @@ nsIBox::AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) widthSet = PR_TRUE; } - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::height, value)) - { + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::height, value); + if (!value.IsEmpty()) { value.Trim("%"); aSize.height = presContext->IntScaledPixelsToTwips(value.ToInteger(&error)); @@ -1057,7 +1057,8 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) nsAutoString value; PRInt32 error; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::minwidth, value)) + content->GetAttr(kNameSpaceID_None, nsXULAtoms::minwidth, value); + if (!value.IsEmpty()) { value.Trim("%"); @@ -1068,7 +1069,8 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) widthSet = PR_TRUE; } - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::minheight, value)) + content->GetAttr(kNameSpaceID_None, nsXULAtoms::minheight, value); + if (!value.IsEmpty()) { value.Trim("%"); @@ -1114,8 +1116,8 @@ nsIBox::AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) nsAutoString value; PRInt32 error; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::maxwidth, value)) - { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::maxwidth, value); + if (!value.IsEmpty()) { value.Trim("%"); nscoord val = @@ -1124,8 +1126,8 @@ nsIBox::AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) widthSet = PR_TRUE; } - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::maxheight, value)) - { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::maxheight, value); + if (!value.IsEmpty()) { value.Trim("%"); nscoord val = @@ -1150,8 +1152,8 @@ nsIBox::AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex) PRInt32 error; nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::flex, value)) - { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::flex, value); + if (!value.IsEmpty()) { value.Trim("%"); aFlex = value.ToInteger(&error); flexSet = PR_TRUE; @@ -1189,7 +1191,8 @@ nsIBox::AddCSSOrdinal(nsBoxLayoutState& aState, nsIBox* aBox, PRUint32& aOrdinal PRInt32 error; nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::ordinal, value)) { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::ordinal, value); + if (!value.IsEmpty()) { aOrdinal = value.ToInteger(&error); ordinalSet = PR_TRUE; } diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index c452893b46a..e053648126e 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -245,13 +245,11 @@ void nsBoxFrame::UpdateMouseThrough() { if (mContent) { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::mousethrough, value)) { - if (value.EqualsLiteral("never")) - mMouseThrough = never; - else if (value.EqualsLiteral("always")) - mMouseThrough = always; - - } + mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::mousethrough, value); + if (value.EqualsLiteral("never")) + mMouseThrough = never; + else if (value.EqualsLiteral("always")) + mMouseThrough = always; } } @@ -351,15 +349,13 @@ nsBoxFrame::GetInitialDebug(PRBool& aDebug) if (!content) return PR_FALSE; - - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::debug, value)) { - if (value.EqualsLiteral("true")) { - aDebug = PR_TRUE; - return PR_TRUE; - } else if (value.EqualsLiteral("false")) { - aDebug = PR_FALSE; - return PR_TRUE; - } + content->GetAttr(kNameSpaceID_None, nsXULAtoms::debug, value); + if (value.EqualsLiteral("true")) { + aDebug = PR_TRUE; + return PR_TRUE; + } else if (value.EqualsLiteral("false")) { + aDebug = PR_FALSE; + return PR_TRUE; } return PR_FALSE; @@ -376,25 +372,25 @@ nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign) if (!content) return PR_FALSE; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value)) { - // XXXdwh Everything inside this if statement is deprecated code. - if (value.EqualsLiteral("left")) { - aHalign = nsBoxFrame::hAlign_Left; - return PR_TRUE; - } else if (value.EqualsLiteral("right")) { - aHalign = nsBoxFrame::hAlign_Right; - return PR_TRUE; - } + // XXXdwh Everything inside this if statement is deprecated code. + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value); + if (value.EqualsLiteral("left")) { + aHalign = nsBoxFrame::hAlign_Left; + return PR_TRUE; + } else if (value.EqualsLiteral("right")) { + aHalign = nsBoxFrame::hAlign_Right; + return PR_TRUE; } // Now that the deprecated stuff is out of the way, we move on to check the appropriate // attribute. For horizontal boxes, we are checking the PACK attribute. For vertical boxes // we are checking the ALIGN attribute. - nsresult res; if (IsHorizontal()) - res = content->GetAttr(kNameSpaceID_None, nsXULAtoms::pack, value); - else res = content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value); - if (res == NS_CONTENT_ATTR_HAS_VALUE) { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::pack, value); + else + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value); + + if (!value.IsEmpty()) { if (value.EqualsLiteral("start")) { aHalign = nsBoxFrame::hAlign_Left; return PR_TRUE; @@ -459,7 +455,7 @@ nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign) if (!content) return PR_FALSE; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::valign, value)) { + if (content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::valign, value)) { if (value.EqualsLiteral("top")) { aValign = nsBoxFrame::vAlign_Top; return PR_TRUE; @@ -478,11 +474,12 @@ nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign) // Now that the deprecated stuff is out of the way, we move on to check the appropriate // attribute. For horizontal boxes, we are checking the ALIGN attribute. For vertical boxes // we are checking the PACK attribute. - nsresult res; if (IsHorizontal()) - res = content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value); - else res = content->GetAttr(kNameSpaceID_None, nsXULAtoms::pack, value); - if (res == NS_CONTENT_ATTR_HAS_VALUE) { + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value); + else + content->GetAttr(kNameSpaceID_None, nsXULAtoms::pack, value); + + if (!value.IsEmpty()) { if (value.EqualsLiteral("start")) { aValign = nsBoxFrame::vAlign_Top; return PR_TRUE; @@ -564,12 +561,11 @@ nsBoxFrame::GetInitialOrientation(PRBool& aIsHorizontal) // Now see if we have an attribute. The attribute overrides // the style system value. - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::orient, value)) { - if (value.EqualsLiteral("vertical")) - aIsHorizontal = PR_FALSE; - else if (value.EqualsLiteral("horizontal")) - aIsHorizontal = PR_TRUE; - } + content->GetAttr(kNameSpaceID_None, nsXULAtoms::orient, value); + if (value.EqualsLiteral("vertical")) + aIsHorizontal = PR_FALSE; + else if (value.EqualsLiteral("horizontal")) + aIsHorizontal = PR_TRUE; } void @@ -597,7 +593,8 @@ nsBoxFrame::GetInitialDirection(PRBool& aIsNormal) // Now see if we have an attribute. The attribute overrides // the style system value. - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::dir, value)) { + content->GetAttr(kNameSpaceID_None, nsXULAtoms::dir, value); + if (!value.IsEmpty()) { if (value.EqualsLiteral("reverse")) aIsNormal = !aIsNormal; // Invert our direction. else if (value.EqualsLiteral("ltr")) @@ -621,12 +618,11 @@ nsBoxFrame::GetInitialEqualSize(PRBool& aEqualSize) if (!content) return PR_FALSE; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::equalsize, value)) - { - if (value.EqualsLiteral("always")) { - aEqualSize = PR_TRUE; - return PR_TRUE; - } + + if (content->AttrValueIs(kNameSpaceID_None, nsXULAtoms::equalsize, + nsLayoutAtoms::always, eCaseMatters)) { + aEqualSize = PR_TRUE; + return PR_TRUE; } return PR_FALSE; @@ -646,7 +642,8 @@ nsBoxFrame::GetInitialAutoStretch(PRBool& aStretch) return PR_FALSE; // Check the align attribute. - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value)) { + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::align, value); + if (!value.IsEmpty()) { aStretch = value.EqualsLiteral("stretch"); return PR_TRUE; } diff --git a/mozilla/layout/xul/base/src/nsDeckFrame.cpp b/mozilla/layout/xul/base/src/nsDeckFrame.cpp index c9fc24879b5..5ab2c82924e 100644 --- a/mozilla/layout/xul/base/src/nsDeckFrame.cpp +++ b/mozilla/layout/xul/base/src/nsDeckFrame.cpp @@ -179,7 +179,7 @@ nsDeckFrame::GetSelectedIndex() // get the index attribute nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::selectedIndex, value)) + if (mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::selectedIndex, value)) { PRInt32 error; diff --git a/mozilla/layout/xul/base/src/nsGrippyFrame.cpp b/mozilla/layout/xul/base/src/nsGrippyFrame.cpp index 507d6ad8ae1..1d93caa1f8a 100644 --- a/mozilla/layout/xul/base/src/nsGrippyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsGrippyFrame.cpp @@ -60,6 +60,7 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsHTMLContainerFrame.h" +#include "nsLayoutAtoms.h" // @@ -88,12 +89,14 @@ nsGrippyFrame::MouseClicked (nsPresContext* aPresContext, nsGUIEvent* aEvent) // get the splitters content node nsIContent* content = splitter->GetContent(); - nsAutoString newState(NS_LITERAL_STRING("collapsed")); - nsAutoString oldState; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::state, oldState)) - { - if (oldState.Equals(newState)) - newState.AssignLiteral("open"); + nsAutoString newState; + if (content->AttrValueIs(kNameSpaceID_None, nsXULAtoms::state, + nsLayoutAtoms::collapsed, + eCaseMatters)) { + newState.AssignLiteral("open"); + } + else { + newState.AssignLiteral("collapsed"); } content->SetAttr(kNameSpaceID_None, nsXULAtoms::state, newState, PR_TRUE); @@ -124,13 +127,9 @@ nsGrippyFrame::MouseClicked(nsPresContext* aPresContext) // get the collapse attribute. If the attribute is not set collapse // the child before otherwise collapse the child after - PRBool before = PR_TRUE; - nsString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::collapse, value)) - { - if (value=="after") - before = PR_FALSE; - } + PRBool before = + !content->AttrValueIs(kNameSpaceID_None, nsXULAtoms::collapse, + NS_LITERAL_STRING("after"), eCaseMatters); // find the child just in the box just before the splitter. If we are not currently collapsed then // then get the childs style attribute and store it. Then set the child style attribute to be display none. diff --git a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp index 31f757b5346..b45cbe56b30 100644 --- a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -137,13 +137,11 @@ void nsLeafBoxFrame::UpdateMouseThrough() { if (mContent) { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::mousethrough, value)) { - if (value.EqualsLiteral("never")) - mMouseThrough = never; - else if (value.EqualsLiteral("always")) - mMouseThrough = always; - - } + mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::mousethrough, value); + if (value.EqualsLiteral("never")) + mMouseThrough = never; + else if (value.EqualsLiteral("always")) + mMouseThrough = always; } } diff --git a/mozilla/layout/xul/base/src/nsResizerFrame.cpp b/mozilla/layout/xul/base/src/nsResizerFrame.cpp index bde3cd971ba..3b762f74645 100644 --- a/mozilla/layout/xul/base/src/nsResizerFrame.cpp +++ b/mozilla/layout/xul/base/src/nsResizerFrame.cpp @@ -308,8 +308,7 @@ nsResizerFrame::GetInitialDirection(eDirection& aDirection) if (!content) return PR_FALSE; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::dir, value)) - { + if (content->GetAttr(kNameSpaceID_None, nsXULAtoms::dir, value)) { return EvalDirection(value,aDirection); } diff --git a/mozilla/layout/xul/base/src/nsScrollbarButtonFrame.cpp b/mozilla/layout/xul/base/src/nsScrollbarButtonFrame.cpp index f62767974e2..6420d91f824 100644 --- a/mozilla/layout/xul/base/src/nsScrollbarButtonFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollbarButtonFrame.cpp @@ -165,7 +165,8 @@ nsScrollbarButtonFrame::MouseClicked() #endif nsString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) + mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value); + if (!value.IsEmpty()) { // if our class is DecrementButton subtract the current pos by increment amount // if our class is IncrementButton increment the current pos by the decrement amount diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.cpp b/mozilla/layout/xul/base/src/nsSliderFrame.cpp index 496b10ce2be..b5029937ed9 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSliderFrame.cpp @@ -201,8 +201,8 @@ PRInt32 nsSliderFrame::GetIntegerAttribute(nsIContent* content, nsIAtom* atom, PRInt32 defaultValue) { nsAutoString value; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, atom, value)) - { + content->GetAttr(kNameSpaceID_None, atom, value); + if (!value.IsEmpty()) { PRInt32 error; // convert it to an integer diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index da9289331be..eaa3f831c24 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -894,18 +894,14 @@ nsSplitterFrameInner::Reverse(nsSplitterInfo*& aChildInfos, PRInt32 aCount) nsSplitterFrameInner::CollapseDirection nsSplitterFrameInner::GetCollapseDirection() { - nsString value; - if (NS_CONTENT_ATTR_HAS_VALUE == mOuter->mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::collapse, value)) - { - if (value.EqualsLiteral("before")) - return Before; - else if (value.EqualsLiteral("after")) - return After; - else - return None; - } else { - return None; - } + nsString value; + mOuter->mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::collapse, value); + if (value.EqualsLiteral("before")) + return Before; + else if (value.EqualsLiteral("after")) + return After; + + return None; } void diff --git a/mozilla/layout/xul/base/src/nsStackLayout.cpp b/mozilla/layout/xul/base/src/nsStackLayout.cpp index 8fcb9f2dbf2..7ba2caf8faa 100644 --- a/mozilla/layout/xul/base/src/nsStackLayout.cpp +++ b/mozilla/layout/xul/base/src/nsStackLayout.cpp @@ -223,14 +223,16 @@ nsStackLayout::AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize nsAutoString value; PRInt32 error; - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::left, value)) { + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::left, value); + if (!value.IsEmpty()) { value.Trim("%"); offset.width = NSIntPixelsToTwips(value.ToInteger(&error), presContext->ScaledPixelsToTwips()); offsetSpecified = PR_TRUE; } - if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::top, value)) { + content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::top, value); + if (!value.IsEmpty()) { value.Trim("%"); offset.height = NSIntPixelsToTwips(value.ToInteger(&error), presContext->ScaledPixelsToTwips()); diff --git a/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp b/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp index 2ee1ecf731f..d6c342dfef3 100644 --- a/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp +++ b/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp @@ -646,8 +646,8 @@ nsKeygenFormProcessor::ProcessValue(nsIDOMHTMLElement *aElement, nsAutoString keyTypeValue; nsAutoString pqgValue; - res = selectElement->GetAttribute(NS_LITERAL_STRING("_moz-type"), keygenvalue); - if (NS_CONTENT_ATTR_HAS_VALUE == res && keygenvalue.EqualsLiteral("-mozilla-keygen")) { + selectElement->GetAttribute(NS_LITERAL_STRING("_moz-type"), keygenvalue); + if (keygenvalue.EqualsLiteral("-mozilla-keygen")) { res = selectElement->GetAttribute(NS_LITERAL_STRING("pqg"), pqgValue); res = selectElement->GetAttribute(NS_LITERAL_STRING("keytype"), keyTypeValue); diff --git a/mozilla/widget/src/gtk/nsNativeThemeGTK.cpp b/mozilla/widget/src/gtk/nsNativeThemeGTK.cpp index bf35490080c..222b28ecfdb 100644 --- a/mozilla/widget/src/gtk/nsNativeThemeGTK.cpp +++ b/mozilla/widget/src/gtk/nsNativeThemeGTK.cpp @@ -265,17 +265,9 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, if (aWidgetType == NS_THEME_CHECKMENUITEM || aWidgetType == NS_THEME_RADIOMENUITEM) { - if (aFrame) { - nsAutoString attr; - nsresult res = aFrame->GetContent()->GetAttr(kNameSpaceID_None, mCheckedAtom, attr); - if (res == NS_CONTENT_ATTR_NO_VALUE || - (res != NS_CONTENT_ATTR_NOT_THERE && attr.IsEmpty())) - *aWidgetFlags = FALSE; - else - *aWidgetFlags = attr.EqualsIgnoreCase("true"); - } else { - *aWidgetFlags = FALSE; - } + *aWidgetFlags = aFrame && aFrame->GetContent()-> + AttrValueIs(kNameSpaceID_None, mCheckedAtom, + NS_LITERAL_STRING("true"), eIgnoreCase); } } } diff --git a/mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp b/mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp index afd8ec707bc..3754790e5cc 100644 --- a/mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -269,17 +269,9 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, if (aWidgetType == NS_THEME_CHECKMENUITEM || aWidgetType == NS_THEME_RADIOMENUITEM) { - if (aFrame) { - nsAutoString attr; - nsresult res = aFrame->GetContent()->GetAttr(kNameSpaceID_None, mCheckedAtom, attr); - if (res == NS_CONTENT_ATTR_NO_VALUE || - (res != NS_CONTENT_ATTR_NOT_THERE && attr.IsEmpty())) - *aWidgetFlags = FALSE; - else - *aWidgetFlags = attr.EqualsIgnoreCase("true"); - } else { - *aWidgetFlags = FALSE; - } + *aWidgetFlags = aFrame && aFrame->GetContent()-> + AttrValueIs(kNameSpaceID_None, mCheckedAtom, + NS_LITERAL_STRING("true"), eIgnoreCase); } } } diff --git a/mozilla/widget/src/xpwidgets/nsNativeTheme.cpp b/mozilla/widget/src/xpwidgets/nsNativeTheme.cpp index 98e629a8755..355dca472c2 100644 --- a/mozilla/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/mozilla/widget/src/xpwidgets/nsNativeTheme.cpp @@ -135,14 +135,11 @@ nsNativeTheme::CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom) if (content->IsContentOfType(nsIContent::eHTML)) return content->HasAttr(kNameSpaceID_None, aAtom); - nsAutoString attr; - content->GetAttr(kNameSpaceID_None, aAtom, attr); - // For XML/XUL elements, an attribute must be equal to the literal // string "true" to be counted as true. An empty string should _not_ // be counted as true. - - return attr.EqualsLiteral("true"); + return content->AttrValueIs(kNameSpaceID_None, aAtom, + NS_LITERAL_STRING("true"), eCaseMatters); } PRInt32 @@ -166,9 +163,8 @@ nsNativeTheme::GetAttr(nsIFrame* aFrame, nsIAtom* aAtom, nsAString& attrValue) if (!aFrame) return PR_FALSE; - nsresult res = aFrame->GetContent()->GetAttr(kNameSpaceID_None, aAtom, attrValue); - return ((res != NS_CONTENT_ATTR_NOT_THERE) && - !(res != NS_CONTENT_ATTR_NO_VALUE && attrValue.IsEmpty())); + aFrame->GetContent()->GetAttr(kNameSpaceID_None, aAtom, attrValue); + return !attrValue.IsEmpty(); } PRBool