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
This commit is contained in:
cvshook%sicking.cc 2005-10-28 11:25:24 +00:00
parent 2d2caede4d
commit b26f9f52fb
117 changed files with 894 additions and 1478 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -569,9 +569,8 @@ nsObjectLoadingContent::ObjectURIChanged(const nsAString& aURI,
nsCOMPtr<nsIURI> baseURI = thisContent->GetBaseURI();
nsCOMPtr<nsIURI> 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;

View File

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

View File

@ -288,36 +288,21 @@ PRBool
nsScriptLoader::IsScriptEventHandler(nsIScriptElement *aScriptElement)
{
nsCOMPtr<nsIContent> 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.*".

View File

@ -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<nsIDocument> doc = do_QueryInterface(aCurrentTarget);
if (!doc) {
nsCOMPtr<nsIContent> 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<nsIDocument> doc = do_QueryInterface(aCurrentTarget);
if (!doc) {
nsCOMPtr<nsIContent> 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;
}
}
}

View File

@ -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<nsIURI> 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<nsIContent> observer;
if (!hasObserver) {

View File

@ -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<nsIURI> baseURI = GetBaseURI();
nsCOMPtr<nsIURI> 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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<nsIDOMHTMLTableRowElement> row;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), value);
if (NS_SUCCEEDED(rv)) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -864,10 +864,7 @@ nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
nsCOMPtr<nsIAtom> 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<nsIContent> 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<nsIRDFNode> 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<nsIDOMElement> 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(&notify);
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<nsIDOMElement> nodeInDocument;
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
if (!id.IsEmpty()) {
nsCOMPtr<nsIDOMDocument> 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<nsIDOMNode> 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<nsIDOMDocument> domDocument(
do_QueryInterface(aParent->GetDocument()));
nsCOMPtr<nsIDOMElement> 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

View File

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

View File

@ -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<nsIDocument> 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<nsIDOMElement> domelement = do_QueryInterface(aElement);

View File

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

View File

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

View File

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

View File

@ -76,7 +76,9 @@ protected:
nsCOMPtr<nsIAtom> mTextAreaAtom;
nsCOMPtr<nsIAtom> mSelectAreaAtom;
nsCOMPtr<nsIAtom> mMapAtom;
nsCOMPtr<nsIAtom> mCiteAtom;
nsCOMPtr<nsIAtom> mTrueAtom;
nsCOMPtr<nsIAtom> mMozSignatureAtom;
};
#define NS_COMPOSERTXTSRVFILTER_CID \

View File

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

View File

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

View File

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

View File

@ -1521,7 +1521,6 @@ nsXFormsUtils::GetElementById(nsIDOMDocument *aDoc,
PRUint32 i;
PRUint16 type;
nsAutoString idVal;
nsCOMPtr<nsIDOMNode> 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<nsIContent> 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;
}

View File

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

View File

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

View File

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

View File

@ -804,19 +804,18 @@ nsComboboxControlFrame::ReflowItems(nsPresContext* aPresContext,
nsCOMPtr<nsIDOMHTMLOptionElement> 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*

View File

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

View File

@ -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<nsIDOMHTMLInputElement> inputElement = do_QueryInterface(mContent);
if (inputElement) {
res = inputElement->GetDefaultChecked(aState);
}
return res;
}
nsresult
nsFormControlFrame::SetDefaultCheckState(PRBool aState)
{
nsresult res = NS_OK;
nsCOMPtr<nsIDOMHTMLInputElement> inputElement = do_QueryInterface(mContent);
if (inputElement) {
res = inputElement->SetDefaultChecked(aState);
}
return res;
}
nsresult
void
nsFormControlFrame::GetCurrentCheckState(PRBool *aState)
{
nsresult res = NS_OK;
nsCOMPtr<nsIDOMHTMLInputElement> 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<nsIDOMHTMLInputElement> inputElement = do_QueryInterface(mContent);
if (inputElement) {
inputElement->SetChecked(aState);
}
return res;
}
NS_IMETHODIMP

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<nsIDOMHTMLOptionsCollection> options =
getter_AddRefs(GetOptions(mContent));
if (options) {
PRUint32 numOptions;
options->GetLength(&numOptions);
printf("--- Num of Items %d ---\n", numOptions);
for (PRUint32 i=0;i<numOptions;i++) {
nsCOMPtr<nsIDOMHTMLOptionElement> 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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1098,9 +1098,6 @@ nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const
// only <embed> 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 <embed> 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<nsIURI> 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<nsIURI> 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<nsIObjectLoadingContent> 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

View File

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

View File

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

View File

@ -205,41 +205,39 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
}
// helper to get an attribute from the content or the surrounding <mstyle> 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 <mstyle> 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 <mstyle> hierarchy
return GetAttribute(aMathMLmstyleFrame->GetContent(),
mstyleParentData.mstyle, aAttributeAtom, aValue);
}
/* static */ void
@ -486,8 +484,8 @@ nsMathMLFrame::ParseNamedSpaceValue(nsIFrame* aMathMLmstyleFrame,
// see if there is a <mstyle> that has overriden the default value
// GetAttribute() will recurse all the way up into the <mstyle> 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;

View File

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

View File

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

View File

@ -123,8 +123,8 @@ nsMathMLmactionFrame::Init(nsPresContext* aPresContext,
nsRefPtr<nsStyleContext> 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<nsIDOMElement> 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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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