From ca47f5992a81672cba3a7c4397bc33fd4c3eef75 Mon Sep 17 00:00:00 2001 From: "leon.sha%sun.com" Date: Mon, 24 Apr 2006 05:40:11 +0000 Subject: [PATCH] Bug 333896 Convert GetAttr calls to AttrValueIs and FindAttrValueIn. Patch by alfred.peng@sun.com. roc: review+ roc: superreview+ git-svn-id: svn://10.0.0.236/trunk@195238 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/base/nsAccessibilityAtomList.h | 10 ++ mozilla/accessible/src/base/nsAccessible.cpp | 34 ++-- .../accessible/src/base/nsDocAccessible.cpp | 10 +- .../src/html/nsHTMLFormControlAccessible.cpp | 5 +- mozilla/content/base/src/nsGkAtomList.h | 25 +++ .../html/content/src/nsHTMLInputElement.cpp | 15 +- .../html/content/src/nsHTMLLinkElement.cpp | 14 +- mozilla/content/xbl/src/nsXBLBinding.cpp | 9 +- .../content/xbl/src/nsXBLPrototypeBinding.cpp | 5 +- .../content/xbl/src/nsXBLPrototypeHandler.cpp | 6 +- .../content/xml/content/src/nsXMLElement.cpp | 35 ++-- .../xul/document/src/nsXULDocument.cpp | 7 +- .../xul/templates/src/nsXULContentBuilder.cpp | 6 +- .../templates/src/nsXULTemplateBuilder.cpp | 16 +- .../src/nsXULTemplateQueryProcessorRDF.cpp | 27 ++- .../xul/templates/src/nsXULTreeBuilder.cpp | 34 ++-- .../typeaheadfind/src/nsTypeAheadFind.cpp | 6 +- mozilla/layout/base/nsCSSFrameConstructor.cpp | 10 +- mozilla/layout/forms/nsFormControlHelper.cpp | 25 ++- mozilla/layout/generic/nsGfxScrollFrame.cpp | 5 +- mozilla/layout/generic/nsImageMap.cpp | 49 ++--- mozilla/layout/generic/nsSpacerFrame.cpp | 17 +- mozilla/layout/mathml/base/src/Makefile.in | 5 +- .../mathml/base/src/nsMathMLTokenFrame.cpp | 6 +- .../mathml/base/src/nsMathMLmactionFrame.cpp | 8 +- .../mathml/base/src/nsMathMLmoverFrame.cpp | 14 +- .../mathml/base/src/nsMathMLmstyleFrame.cpp | 23 ++- .../mathml/base/src/nsMathMLmtableFrame.cpp | 5 +- .../mathml/base/src/nsMathMLmunderFrame.cpp | 14 +- .../base/src/nsMathMLmunderoverFrame.cpp | 25 +-- .../layout/xul/base/src/nsButtonBoxFrame.cpp | 5 +- .../layout/xul/base/src/nsImageBoxFrame.cpp | 22 ++- .../layout/xul/base/src/nsLeafBoxFrame.cpp | 14 +- .../xul/base/src/nsListBoxBodyFrame.cpp | 6 +- .../layout/xul/base/src/nsListBoxLayout.cpp | 11 +- .../layout/xul/base/src/nsListItemFrame.cpp | 5 +- .../layout/xul/base/src/nsMenuBarFrame.cpp | 7 +- mozilla/layout/xul/base/src/nsMenuFrame.cpp | 169 +++++++++--------- .../layout/xul/base/src/nsMenuPopupFrame.cpp | 27 ++- .../layout/xul/base/src/nsPopupSetFrame.cpp | 11 +- .../layout/xul/base/src/nsSplitterFrame.cpp | 50 +++--- .../layout/xul/base/src/nsTextBoxFrame.cpp | 25 ++- .../xul/base/src/tree/src/nsTreeColumns.cpp | 43 +++-- .../base/src/tree/src/nsTreeContentView.cpp | 19 +- .../typeaheadfind/src/nsTypeAheadFind.cpp | 6 +- 45 files changed, 460 insertions(+), 430 deletions(-) diff --git a/mozilla/accessible/src/base/nsAccessibilityAtomList.h b/mozilla/accessible/src/base/nsAccessibilityAtomList.h index 2ab88daaabf..2e6bafed111 100755 --- a/mozilla/accessible/src/base/nsAccessibilityAtomList.h +++ b/mozilla/accessible/src/base/nsAccessibilityAtomList.h @@ -55,6 +55,16 @@ ******/ + // Alphabetical list of generic atoms +ACCESSIBILITY_ATOM(_empty, "") +ACCESSIBILITY_ATOM(button, "button") +ACCESSIBILITY_ATOM(_false, "false") +ACCESSIBILITY_ATOM(image, "image") +ACCESSIBILITY_ATOM(password, "password") +ACCESSIBILITY_ATOM(reset, "reset") +ACCESSIBILITY_ATOM(submit, "submit") +ACCESSIBILITY_ATOM(_true, "true") + // Header info ACCESSIBILITY_ATOM(headerContentLanguage, "content-language") diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 482dfbcbb53..6a7ea14c8d5 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -137,11 +137,12 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr) // to support nsIAccessibleSelectable // If either attribute (role or multiselect) change, then we'll // destroy this accessible so that we can follow COM identity rules. - nsAutoString multiSelect; - content->GetAttr(kNameSpaceID_WAIProperties, - nsAccessibilityAtoms::multiselect, - multiSelect); - if (!multiSelect.IsEmpty() && !multiSelect.EqualsLiteral("false")) { + static nsIContent::AttrValuesArray strings[] = + {&nsAccessibilityAtoms::_empty, &nsAccessibilityAtoms::_false, nsnull}; + if (content->FindAttrValueIn(kNameSpaceID_None, + nsAccessibilityAtoms::multiselect, + strings, eCaseMatters) == + nsIContent::ATTR_VALUE_NO_MATCH) { *aInstancePtr = NS_STATIC_CAST(nsIAccessibleSelectable*, this); NS_ADDREF_THIS(); } @@ -747,9 +748,10 @@ NS_IMETHODIMP nsAccessible::GetState(PRUint32 *aState) isDisabled = content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::disabled); } else { - nsAutoString disabled; - content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::disabled, disabled); - isDisabled = disabled.EqualsLiteral("true"); + isDisabled = content->AttrValueIs(kNameSpaceID_None, + nsAccessibilityAtoms::disabled, + nsAccessibilityAtoms::_true, + eCaseMatters); } if (isDisabled) { *aState |= STATE_UNAVAILABLE; @@ -1275,12 +1277,11 @@ nsresult nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsA } if (tag == nsAccessibilityAtoms::input) { - nsAutoString inputType; - aContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, inputType); - if (inputType.LowerCaseEqualsLiteral("button") || - inputType.LowerCaseEqualsLiteral("submit") || - inputType.LowerCaseEqualsLiteral("reset") || - inputType.LowerCaseEqualsLiteral("image")) { + static nsIContent::AttrValuesArray strings[] = + {&nsAccessibilityAtoms::button, &nsAccessibilityAtoms::submit, + &nsAccessibilityAtoms::reset, &nsAccessibilityAtoms::image, nsnull}; + if (aContent->FindAttrValueIn(kNameSpaceID_None, nsAccessibilityAtoms::type, + strings, eIgnoreCase) >= 0) { return AppendNameFromAccessibleFor(aContent, aFlatString); } } @@ -1453,9 +1454,8 @@ nsIContent *nsAccessible::GetContentPointingTo(const nsAString *aId, { if (!aTagType || aLookContent->Tag() == aTagType) { if (aForAttrib) { - nsAutoString labelIsFor; - aLookContent->GetAttr(aForAttribNameSpace, aForAttrib, labelIsFor); - if (labelIsFor.Equals(*aId)) { + if (aLookContent->AttrValueIs(aForAttribNameSpace, aForAttrib, + *aId, eCaseMatters)) { return aLookContent; } } diff --git a/mozilla/accessible/src/base/nsDocAccessible.cpp b/mozilla/accessible/src/base/nsDocAccessible.cpp index cf57f747a25..8e76a7b7813 100644 --- a/mozilla/accessible/src/base/nsDocAccessible.cpp +++ b/mozilla/accessible/src/base/nsDocAccessible.cpp @@ -789,10 +789,12 @@ nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, NS_ASSERTION(multiSelectDOMNode, "A new accessible without a DOM node!"); FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN, multiSelectDOMNode, nsnull, PR_TRUE); - nsAutoString attrValue; - aContent->GetAttr(aNameSpaceID, - nsAccessibilityAtoms::selected, attrValue); - if (attrValue.IsEmpty() || attrValue.EqualsLiteral("false")) { + static nsIContent::AttrValuesArray strings[] = + {&nsAccessibilityAtoms::_empty, &nsAccessibilityAtoms::_false, nsnull}; + if (aContent->FindAttrValueIn(kNameSpaceID_None, + nsAccessibilityAtoms::selected, + strings, eCaseMatters) != + nsIContent::ATTR_VALUE_NO_MATCH) { eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE; } else { diff --git a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp index accb44f762c..7ea78a0a847 100644 --- a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -330,9 +330,8 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetState(PRUint32 *aState) } nsFormControlAccessible::GetState(aState); - nsAutoString typeString; - content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, typeString); - if (typeString.LowerCaseEqualsLiteral("password")) { + if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, + nsAccessibilityAtoms::password, eIgnoreCase)) { *aState |= STATE_PROTECTED; } if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) { diff --git a/mozilla/content/base/src/nsGkAtomList.h b/mozilla/content/base/src/nsGkAtomList.h index c33cee2d64d..b76918d2a2e 100755 --- a/mozilla/content/base/src/nsGkAtomList.h +++ b/mozilla/content/base/src/nsGkAtomList.h @@ -78,6 +78,9 @@ GK_ATOM(acceptcharset, "accept-charset") GK_ATOM(accesskey, "accesskey") GK_ATOM(action, "action") GK_ATOM(actuate, "actuate") +GK_ATOM(after, "after") +GK_ATOM(after_end, "after_end") +GK_ATOM(after_start, "after_start") GK_ATOM(align, "align") GK_ATOM(alink, "alink") GK_ATOM(all, "all") @@ -102,6 +105,7 @@ GK_ATOM(attributeSet, "attribute-set") GK_ATOM(aural, "aural") GK_ATOM(_auto, "auto") GK_ATOM(autocheck, "autocheck") +GK_ATOM(autocomplete, "autocomplete") GK_ATOM(autorepeatbutton, "autorepeatbutton") GK_ATOM(axis, "axis") GK_ATOM(b, "b") @@ -111,12 +115,16 @@ GK_ATOM(basefont, "basefont") GK_ATOM(baseLevel, "BaseLevel") // PRUint8 GK_ATOM(baseline, "baseline") GK_ATOM(bdo, "bdo") +GK_ATOM(before, "before") +GK_ATOM(before_end, "before_end") +GK_ATOM(before_start, "before_start") GK_ATOM(below, "below") GK_ATOM(bgcolor, "bgcolor") GK_ATOM(big, "big") GK_ATOM(binding, "binding") GK_ATOM(bindings, "bindings") GK_ATOM(blankrow, "blankrow") +GK_ATOM(block, "block") GK_ATOM(blockquote, "blockquote") GK_ATOM(blur, "blur") GK_ATOM(body, "body") @@ -263,6 +271,7 @@ GK_ATOM(dragenter, "dragenter") GK_ATOM(dragevent, "dragevent") GK_ATOM(dragexit, "dragexit") GK_ATOM(draggesture, "draggesture") +GK_ATOM(dragging, "dragging") GK_ATOM(dragover, "dragover") GK_ATOM(dragSession, "dragSession") GK_ATOM(dropAfter, "dropAfter") @@ -283,6 +292,8 @@ GK_ATOM(empty, "empty") GK_ATOM(encoding, "encoding") GK_ATOM(enctype, "enctype") GK_ATOM(end, "end") +GK_ATOM(end_after, "end_after") +GK_ATOM(end_before, "end_before") GK_ATOM(endsInDiacritic, "EndsInDiacritic") // PRUint32 GK_ATOM(equalsize, "equalsize") GK_ATOM(error, "error") @@ -295,6 +306,7 @@ GK_ATOM(extensionElementPrefixes, "extension-element-prefixes") GK_ATOM(face, "face") GK_ATOM(fallback, "fallback") GK_ATOM(_false, "false") +GK_ATOM(farthest, "farthest") GK_ATOM(field, "field") GK_ATOM(fieldset, "fieldset") GK_ATOM(fixed, "fixed") @@ -328,6 +340,7 @@ GK_ATOM(grippy, "grippy") GK_ATOM(group, "group") GK_ATOM(groupingSeparator, "grouping-separator") GK_ATOM(groupingSize, "grouping-size") +GK_ATOM(grow, "grow") GK_ATOM(gutter, "gutter") GK_ATOM(h1, "h1") GK_ATOM(h2, "h2") @@ -338,6 +351,7 @@ GK_ATOM(h6, "h6") GK_ATOM(handheld, "handheld") GK_ATOM(handler, "handler") GK_ATOM(handlers, "handlers") +GK_ATOM(HARD, "HARD") GK_ATOM(hbox, "hbox") GK_ATOM(head, "head") GK_ATOM(headers, "headers") @@ -468,6 +482,7 @@ GK_ATOM(NaN, "NaN") GK_ATOM(nativescrollbar, "nativescrollbar") GK_ATOM(negate, "negate") GK_ATOM(never, "never") +GK_ATOM(_new, "new") GK_ATOM(nextBidi, "NextBidi") GK_ATOM(no, "no") GK_ATOM(node, "node") @@ -487,6 +502,7 @@ GK_ATOM(object, "object") GK_ATOM(observer, "observer") GK_ATOM(observes, "observes") GK_ATOM(odd, "odd") +GK_ATOM(OFF, "OFF") GK_ATOM(ol, "ol") GK_ATOM(omitXmlDeclaration, "omit-xml-declaration") GK_ATOM(onabort, "onabort") @@ -563,6 +579,7 @@ GK_ATOM(overflowList, "Overflow-list") GK_ATOM(overflowchanged, "overflowchanged") GK_ATOM(overflowOutOfFlowList, "OverflowOutOfFlow-list") GK_ATOM(overlay, "overlay") +GK_ATOM(overlap, "overlap") GK_ATOM(p, "p") GK_ATOM(pack, "pack") GK_ATOM(page, "page") @@ -625,6 +642,7 @@ GK_ATOM(refresh, "refresh") GK_ATOM(rel, "rel") GK_ATOM(removeelement, "removeelement") GK_ATOM(repeat, "repeat") +GK_ATOM(replace, "replace") GK_ATOM(reset, "reset") GK_ATOM(resizeafter, "resizeafter") GK_ATOM(resizebefore, "resizebefore") @@ -694,6 +712,8 @@ GK_ATOM(stack, "stack") GK_ATOM(standalone, "standalone") GK_ATOM(standby, "standby") GK_ATOM(start, "start") +GK_ATOM(start_after, "start_after") +GK_ATOM(start_before, "start_before") GK_ATOM(startsWith, "starts-with") GK_ATOM(state, "state") GK_ATOM(statedatasource, "statedatasource") @@ -772,6 +792,7 @@ GK_ATOM(type, "type") GK_ATOM(u, "u") GK_ATOM(ul, "ul") GK_ATOM(underflow, "underflow") +GK_ATOM(undetermined, "undetermined") GK_ATOM(unload, "unload") GK_ATOM(unparsedEntityUri, "unparsed-entity-uri") GK_ATOM(upperFirst, "upper-first") @@ -791,6 +812,7 @@ GK_ATOM(vcard_name, "vcard_name") GK_ATOM(vendor, "vendor") GK_ATOM(vendorUrl, "vendor-url") GK_ATOM(version, "version") +GK_ATOM(vert, "vert") GK_ATOM(vertical, "vertical") GK_ATOM(visibility, "visibility") GK_ATOM(vlink, "vlink") @@ -826,6 +848,7 @@ GK_ATOM(animateColor, "animateColor") GK_ATOM(animateMotion, "animateMotion") GK_ATOM(animateTransform, "animateTransform") GK_ATOM(baseline_shift, "baseline-shift") +GK_ATOM(circ, "circ") GK_ATOM(circle, "circle") GK_ATOM(clip_path, "clip-path") GK_ATOM(clip_rule, "clip-rule") @@ -954,6 +977,7 @@ GK_ATOM(patternUnits, "patternUnits") GK_ATOM(pc, "pc") GK_ATOM(pointer_events, "pointer-events") GK_ATOM(points, "points") +GK_ATOM(poly, "poly") GK_ATOM(polygon, "polygon") GK_ATOM(polyline, "polyline") GK_ATOM(preserveAspectRatio, "preserveAspectRatio") @@ -964,6 +988,7 @@ GK_ATOM(r, "r") GK_ATOM(rad, "rad") GK_ATOM(radialGradient, "radialGradient") GK_ATOM(rect, "rect") +GK_ATOM(rectangle, "rectangle") GK_ATOM(reflect, "reflect") GK_ATOM(refX, "refX") GK_ATOM(refY, "refY") diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index cdbf4e20360..8a5b3aab2fb 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -267,11 +267,8 @@ protected: void SelectAll(nsPresContext* aPresContext); PRBool IsImage() const { - nsAutoString tmp; - - GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, tmp); - - return tmp.LowerCaseEqualsLiteral("image"); + return AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::type, + nsHTMLAtoms::image, eIgnoreCase); } /** @@ -1617,10 +1614,10 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) nsCOMPtr maybeButton = do_QueryInterface(aVisitor.mEvent->originalTarget); if (maybeButton) { - nsAutoString type; - maybeButton->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, - type); - isButton = type.EqualsLiteral("button"); + isButton = maybeButton->AttrValueIs(kNameSpaceID_None, + nsHTMLAtoms::type, + nsHTMLAtoms::button, + eCaseMatters); } } diff --git a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp index 081e92a94a4..35702b5ef1f 100644 --- a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp @@ -253,19 +253,19 @@ nsHTMLLinkElement::CreateAndDispatchEvent(nsIDocument* aDoc, if (!aDoc) return; - nsAutoString rel; - nsAutoString rev; - GetAttr(kNameSpaceID_None, nsHTMLAtoms::rel, rel); - GetAttr(kNameSpaceID_None, nsHTMLAtoms::rev, rev); - // In the unlikely case that both rev is specified *and* rel=stylesheet, // this code will cause the event to fire, on the principle that maybe the // page really does want to specify that it's author is a stylesheet. Since // this should never actually happen and the performance hit is minimal, // doing the "right" thing costs virtually nothing here, even if it doesn't // make much sense. - if (rev.IsEmpty() && - (rel.IsEmpty() || rel.LowerCaseEqualsLiteral("stylesheet"))) + static nsIContent::AttrValuesArray strings[] = + {&nsHTMLAtoms::_empty, &nsHTMLAtoms::stylesheet, nsnull}; + + if (!nsContentUtils::HasNonEmptyAttr(this, kNameSpaceID_None, + nsHTMLAtoms::rev) && + FindAttrValueIn(kNameSpaceID_None, nsHTMLAtoms::rel, + strings, eIgnoreCase) != ATTR_VALUE_NO_MATCH) return; nsContentUtils::DispatchTrustedEvent(aDoc, diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index b0e591d68ab..f5763b5e84f 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -452,9 +452,8 @@ nsXBLBinding::GenerateAnonymousContent() #ifdef DEBUG // See if there's an includes attribute. - nsAutoString includes; - content->GetAttr(kNameSpaceID_None, nsXBLAtoms::includes, includes); - if (!includes.IsEmpty()) { + if (nsContentUtils::HasNonEmptyAttr(content, kNameSpaceID_None, + nsXBLAtoms::includes)) { nsCAutoString id; mPrototypeBinding->GetID(id); nsCAutoString message("An XBL Binding with an id of "); @@ -622,9 +621,7 @@ nsXBLBinding::GenerateAnonymousContent() nsIAtom* name = attrName->LocalName(); if (name != nsXBLAtoms::includes) { - nsAutoString value; - mBoundElement->GetAttr(namespaceID, name, value); - if (value.IsEmpty()) { + if (!nsContentUtils::HasNonEmptyAttr(mBoundElement, namespaceID, name)) { nsAutoString value2; content->GetAttr(namespaceID, name, value2); mBoundElement->SetAttr(namespaceID, name, attrName->GetPrefix(), diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index 731a5f99712..3639584e134 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -335,9 +335,8 @@ void nsXBLPrototypeBinding::SetBindingElement(nsIContent* aElement) { mBinding = aElement; - nsAutoString inheritStyle; - mBinding->GetAttr(kNameSpaceID_None, nsXBLAtoms::inheritstyle, inheritStyle); - if (inheritStyle.EqualsLiteral("false")) + if (mBinding->AttrValueIs(kNameSpaceID_None, nsXBLAtoms::inheritstyle, + nsXBLAtoms::_false, eCaseMatters)) mInheritStyle = PR_FALSE; } diff --git a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp index 73053770e63..feb58357c37 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -331,10 +331,8 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, } if (content->HasAttr(kNameSpaceID_XLink, nsHTMLAtoms::type)) { - nsAutoString type; - content->GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::type, type); - - isLink = type.EqualsLiteral("simple"); + isLink = content->AttrValueIs(kNameSpaceID_XLink, nsHTMLAtoms::type, + nsHTMLAtoms::simple, eCaseMatters); if (isLink) { break; diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index 4da67f5c69b..a768b778933 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -70,6 +70,9 @@ #include "nsEventDispatcher.h" #include "nsContentErrors.h" +static nsIContent::AttrValuesArray strings[] = + {&nsLayoutAtoms::_new, &nsLayoutAtoms::replace, &nsLayoutAtoms::embed, nsnull}; + nsresult NS_NewXMLElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo) { @@ -196,7 +199,6 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell) if (mIsLink) { do { // actuate="onLoad" ? - nsAutoString value; if (AttrValueIs(kNameSpaceID_XLink, nsLayoutAtoms::actuate, nsLayoutAtoms::onLoad, eCaseMatters)) { @@ -218,24 +220,26 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell) // show= ? nsLinkVerb verb = eLinkVerb_Undefined; // basically means same as replace - GetAttr(kNameSpaceID_XLink, nsLayoutAtoms::show, value); + PRBool stop = PR_FALSE; // XXX Should probably do this using atoms - if (value.EqualsLiteral("new")) { + switch (FindAttrValueIn(kNameSpaceID_XLink, nsLayoutAtoms::show, + strings, eCaseMatters)) { // We should just act like an HTML link with target="_blank" and if // someone diverts or blocks those, that's fine with us. We don't // care. - verb = eLinkVerb_New; - } else if (value.EqualsLiteral("replace")) { + case 0: verb = eLinkVerb_New; break; // We want to actually stop processing the current document now. // We do this by returning the correct value so that the one // that called us knows to stop processing. - verb = eLinkVerb_Replace; - } else if (value.EqualsLiteral("embed")) { + case 1: verb = eLinkVerb_Replace; break; // XXX TODO - break; + case 2: stop = PR_TRUE; break; } + if (stop) + break; + // Get our URI nsCOMPtr uri = nsContentUtils::GetXLinkURI(this); if (!uri) @@ -283,7 +287,7 @@ nsXMLElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) inputEvent->isAlt || inputEvent->isShift) { break; // let the click go through so we can handle it in JS/XUL } - nsAutoString show, href; + nsAutoString href; nsLinkVerb verb = eLinkVerb_Undefined; // basically means same as replace nsCOMPtr uri = nsContentUtils::GetXLinkURI(this); if (!uri) { @@ -291,15 +295,12 @@ nsXMLElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) break; } - GetAttr(kNameSpaceID_XLink, nsLayoutAtoms::show, show); - // XXX Should probably do this using atoms - if (show.EqualsLiteral("new")) { - verb = eLinkVerb_New; - } else if (show.EqualsLiteral("replace")) { - verb = eLinkVerb_Replace; - } else if (show.EqualsLiteral("embed")) { - verb = eLinkVerb_Embed; + switch (FindAttrValueIn(kNameSpaceID_XLink, nsLayoutAtoms::show, + strings, eCaseMatters)) { + case 0: verb = eLinkVerb_New; break; + case 1: verb = eLinkVerb_Replace; break; + case 2: verb = eLinkVerb_Embed; break; } nsAutoString target; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 82dfa059975..3b332c63228 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -3733,10 +3733,6 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode, // node in the document with the same id as currContent that // also has aTargetNode as its parent. - nsAutoString documentParentID; - aTargetNode->GetAttr(kNameSpaceID_None, nsXULAtoms::id, - documentParentID); - nsCOMPtr nodeParent; rv = nodeInDocument->GetParentNode(getter_AddRefs(nodeParent)); if (NS_FAILED(rv)) return rv; @@ -3744,7 +3740,8 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode, nsAutoString parentID; elementParent->GetAttribute(NS_LITERAL_STRING("id"), parentID); - if (parentID.Equals(documentParentID)) { + if (aTargetNode->AttrValueIs(kNameSpaceID_None, nsXULAtoms::id, + parentID, eCaseMatters)) { // The element matches. "Go Deep!" nsCOMPtr childDocumentContent(do_QueryInterface(nodeInDocument)); rv = Merge(childDocumentContent, currContent, aNotify); diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index 31c5fd5395f..e76e6abaa93 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1756,10 +1756,8 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument, if ((aContent->GetNameSpaceID() == kNameSpaceID_XUL) && (aAttribute == nsXULAtoms::open)) { // We're on a XUL tag, and an ``open'' attribute changed. - nsAutoString open; - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::open, open); - - if (open.EqualsLiteral("true")) + if (aContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::open, + nsXULAtoms::_true, eCaseMatters)) OpenContainer(aContent); else CloseContainer(aContent); diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index 086af9de063..1c9b7db2434 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -963,15 +963,13 @@ nsXULTemplateBuilder::LoadDataSources(nsIDocument* doc) } // check for magical attributes. XXX move to ``flags''? - nsAutoString coalesce; - mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::coalesceduplicatearcs, coalesce); - if (coalesce.EqualsLiteral("false")) - mCompDB->SetCoalesceDuplicateArcs(PR_FALSE); - - nsAutoString allowneg; - mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::allownegativeassertions, allowneg); - if (allowneg.EqualsLiteral("false")) - mCompDB->SetAllowNegativeAssertions(PR_FALSE); + if (mRoot->AttrValueIs(kNameSpaceID_None, nsXULAtoms::coalesceduplicatearcs, + nsXULAtoms::_false, eCaseMatters)) + mCompDB->SetCoalesceDuplicateArcs(PR_FALSE); + + if (mRoot->AttrValueIs(kNameSpaceID_None, nsXULAtoms::allownegativeassertions, + nsXULAtoms::_false, eCaseMatters)) + mCompDB->SetAllowNegativeAssertions(PR_FALSE); // Grab the doc's principal... nsIPrincipal *docPrincipal = doc->GetNodePrincipal(); diff --git a/mozilla/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp b/mozilla/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp index 5656bf8042c..2506aba4f60 100755 --- a/mozilla/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp @@ -1393,26 +1393,23 @@ nsXULTemplateQueryProcessorRDF::CompileSimpleQuery(nsRDFQuery* aQuery, nsRDFConInstanceTestNode::Test iscontainer = nsRDFConInstanceTestNode::eDontCare; - nsAutoString value; - aQueryElement->GetAttr(kNameSpaceID_None, nsXULAtoms::iscontainer, value); - - if (value.EqualsLiteral("true")) { - iscontainer = nsRDFConInstanceTestNode::eTrue; - } - else if (value.EqualsLiteral("false")) { - iscontainer = nsRDFConInstanceTestNode::eFalse; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::_true, &nsXULAtoms::_false, nsnull}; + switch (aQueryElement->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::iscontainer, + strings, eCaseMatters)) { + case 0: iscontainer = nsRDFConInstanceTestNode::eTrue; break; + case 1: iscontainer = nsRDFConInstanceTestNode::eFalse; break; } nsRDFConInstanceTestNode::Test isempty = nsRDFConInstanceTestNode::eDontCare; - aQueryElement->GetAttr(kNameSpaceID_None, nsXULAtoms::isempty, value); - - if (value.EqualsLiteral("true")) { - isempty = nsRDFConInstanceTestNode::eTrue; - } - else if (value.EqualsLiteral("false")) { - isempty = nsRDFConInstanceTestNode::eFalse; + switch (aQueryElement->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::isempty, + strings, eCaseMatters)) { + case 0: isempty = nsRDFConInstanceTestNode::eTrue; break; + case 1: isempty = nsRDFConInstanceTestNode::eFalse; break; } testnode = new nsRDFConInstanceTestNode(prevnode, diff --git a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp index 060754276db..1c69a15fa66 100644 --- a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -421,9 +421,8 @@ nsXULTreeBuilder::Sort(nsIDOMElement* aElement) if (! header) return NS_ERROR_FAILURE; - nsAutoString sortLocked; - header->GetAttr(kNameSpaceID_None, nsXULAtoms::sortLocked, sortLocked); - if (sortLocked.EqualsLiteral("true")) + if (header->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortLocked, + nsXULAtoms::_true, eCaseMatters)) return NS_OK; nsAutoString sort; @@ -1331,22 +1330,22 @@ nsXULTreeBuilder::EnsureSortVariables() if (child->NodeInfo()->Equals(nsXULAtoms::treecol, kNameSpaceID_XUL)) { - nsAutoString sortActive; - child->GetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, sortActive); - if (sortActive.EqualsLiteral("true")) { + if (child->AttrValueIs(kNameSpaceID_None, nsXULAtoms::sortActive, + nsXULAtoms::_true, eCaseMatters)) { nsAutoString sort; child->GetAttr(kNameSpaceID_None, nsXULAtoms::sort, sort); if (! sort.IsEmpty()) { mSortVariable = do_GetAtom(sort); - nsAutoString sortDirection; - child->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, sortDirection); - if (sortDirection.EqualsLiteral("ascending")) - mSortDirection = eDirection_Ascending; - else if (sortDirection.EqualsLiteral("descending")) - mSortDirection = eDirection_Descending; - else - mSortDirection = eDirection_Natural; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::ascending, &nsXULAtoms::descending, nsnull}; + switch (child->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::sortDirection, + strings, eCaseMatters)) { + case 0: mSortDirection = eDirection_Ascending; break; + case 1: mSortDirection = eDirection_Descending; break; + default: mSortDirection = eDirection_Natural; break; + } } break; } @@ -1480,9 +1479,10 @@ nsXULTreeBuilder::GetTemplateActionCellFor(PRInt32 aRow, if (child->NodeInfo()->Equals(nsXULAtoms::treecell, kNameSpaceID_XUL)) { - nsAutoString ref; - child->GetAttr(kNameSpaceID_None, nsXULAtoms::ref, ref); - if (!ref.IsEmpty() && ref.Equals(colID)) { + if (colID[0] != 0 && + child->AttrValueIs(kNameSpaceID_None, nsXULAtoms::ref, + nsDependentString(colID), + eCaseMatters)) { *aResult = child; break; } diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 4fcb2d46d23..0027ed48428 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -1639,9 +1639,9 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, // Any xml element can be an xlink *aIsInsideLink = startContent->HasAttr(kNameSpaceID_XLink, hrefAtom); if (*aIsInsideLink) { - nsAutoString xlinkType; - startContent->GetAttr(kNameSpaceID_XLink, typeAtom, xlinkType); - if (!xlinkType.EqualsLiteral("simple")) { + if (!startContent->AttrValueIs(kNameSpaceID_XLink, typeAtom, + NS_LITERAL_STRING("simple"), + eCaseMatters)) { *aIsInsideLink = PR_FALSE; // Xlink must be type="simple" } diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index c28c322fe3c..6cb2ef6ac25 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -6430,9 +6430,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, newFrame = NS_NewMenuPopupFrame(mPresShell, aStyleContext); if (aTag == nsXULAtoms::tooltip) { - nsAutoString defaultTooltip; - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::_default, defaultTooltip); - if (defaultTooltip.LowerCaseEqualsLiteral("true")) { + if (aContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::_default, + nsXULAtoms::_true, eIgnoreCase)) { // Locate the root frame and tell it about the tooltip. nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame(); if (rootFrame) @@ -6608,10 +6607,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, #ifdef MOZ_XUL // register tooltip support if needed - nsAutoString value; if (aTag == nsXULAtoms::treechildren || // trees always need titletips - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext, value) || - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltip, value)) + aContent->HasAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext) || + aContent->HasAttr(kNameSpaceID_None, nsXULAtoms::tooltip)) { nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame(); if (rootFrame) diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 93de5133a31..7879fab82ef 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -73,13 +73,6 @@ static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); // done I10N -// For figuring out the "WRAP" property -// See GetWrapPropertyEnum for details -#define kTextControl_Wrap_Soft "SOFT" -#define kTextControl_Wrap_Hard "HARD" -#define kTextControl_Wrap_Off "OFF" - - nsFormControlHelper::nsFormControlHelper() { MOZ_COUNT_CTOR(nsFormControlHelper); @@ -133,17 +126,19 @@ nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& aWrapProp = eHTMLTextWrap_Soft; // the default nsAutoString wrap; - 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; + if (aContent->IsContentOfType(nsIContent::eHTML)) { + static nsIContent::AttrValuesArray strings[] = + {&nsHTMLAtoms::HARD, &nsHTMLAtoms::OFF, nsnull}; + + switch (aContent->FindAttrValueIn(kNameSpaceID_None, nsHTMLAtoms::wrap, + strings, eIgnoreCase)) { + case 0: aWrapProp = eHTMLTextWrap_Hard; break; + case 1: aWrapProp = eHTMLTextWrap_Off; break; } - + return PR_TRUE; } - + return PR_FALSE; } diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 8b4b37d3c6f..8c6c772ede0 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -2528,13 +2528,10 @@ nsGfxScrollFrameInner::SetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord a nsIContent *content = aBox->GetContent(); - nsAutoString oldValue; - content->GetAttr(kNameSpaceID_None, aAtom, oldValue); - nsAutoString newValue; newValue.AppendInt(aSize); - if (oldValue == newValue) + if (content->AttrValueIs(kNameSpaceID_None, aAtom, newValue, eCaseMatters)) return PR_FALSE; content->SetAttr(kNameSpaceID_None, aAtom, newValue, aReflow); diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index b1e56424973..eb1829eafbf 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -862,30 +862,37 @@ nsImageMap::UpdateAreas() nsresult nsImageMap::AddArea(nsIContent* aArea) { - nsAutoString shape, coords; - aArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::shape, shape); + nsAutoString coords; + static nsIContent::AttrValuesArray strings[] = + {&nsHTMLAtoms::_empty, &nsHTMLAtoms::rect, &nsHTMLAtoms::rectangle, + &nsHTMLAtoms::poly, &nsHTMLAtoms::polygon, &nsHTMLAtoms::circle, + &nsHTMLAtoms::circ, &nsHTMLAtoms::_default, nsnull}; + aArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::coords, coords); Area* area; - if (shape.IsEmpty() || - shape.LowerCaseEqualsLiteral("rect") || - shape.LowerCaseEqualsLiteral("rectangle")) { - area = new RectArea(aArea); - } - else if (shape.LowerCaseEqualsLiteral("poly") || - shape.LowerCaseEqualsLiteral("polygon")) { - area = new PolyArea(aArea); - } - else if (shape.LowerCaseEqualsLiteral("circle") || - shape.LowerCaseEqualsLiteral("circ")) { - area = new CircleArea(aArea); - } - else if (shape.LowerCaseEqualsLiteral("default")) { - area = new DefaultArea(aArea); - } - else { - // Unknown area type; bail - return NS_OK; + switch (aArea->FindAttrValueIn(kNameSpaceID_None, nsHTMLAtoms::shape, + strings, eIgnoreCase)) { + case nsIContent::ATTR_MISSING: + case 0: + case 1: + case 2: + area = new RectArea(aArea); + break; + case 3: + case 4: + area = new PolyArea(aArea); + break; + case 5: + case 6: + area = new CircleArea(aArea); + break; + case 7: + area = new DefaultArea(aArea); + break; + default: + // Unknown area type; bail + return NS_OK; } if (!area) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/generic/nsSpacerFrame.cpp b/mozilla/layout/generic/nsSpacerFrame.cpp index 47c05c1df6e..d4e1886e0b5 100644 --- a/mozilla/layout/generic/nsSpacerFrame.cpp +++ b/mozilla/layout/generic/nsSpacerFrame.cpp @@ -160,16 +160,17 @@ PRUint8 SpacerFrame::GetType() { PRUint8 type = TYPE_WORD; - nsAutoString value; - if (mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) { - if (value.LowerCaseEqualsLiteral("line") || - value.LowerCaseEqualsLiteral("vert") || - value.LowerCaseEqualsLiteral("vertical")) { + static nsIContent::AttrValuesArray strings[] = + {&nsHTMLAtoms::line, &nsHTMLAtoms::vert, &nsHTMLAtoms::vertical, + &nsHTMLAtoms::block, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsHTMLAtoms::type, + strings, eIgnoreCase)) { + case 0: + case 1: + case 2: return TYPE_LINE; - } - if (value.LowerCaseEqualsLiteral("block")) { + case 3: return TYPE_IMAGE; - } } return type; } diff --git a/mozilla/layout/mathml/base/src/Makefile.in b/mozilla/layout/mathml/base/src/Makefile.in index 9b473b873f1..2d5b9f21025 100644 --- a/mozilla/layout/mathml/base/src/Makefile.in +++ b/mozilla/layout/mathml/base/src/Makefile.in @@ -56,7 +56,7 @@ REQUIRES = xpcom \ content \ gfx \ widget \ - view \ + view \ webshell \ locale \ intl \ @@ -66,13 +66,14 @@ REQUIRES = xpcom \ webbrwsr \ windowwatcher \ pref \ + js \ $(NULL) LOCAL_INCLUDES = \ -I$(srcdir)/../../../style \ -I$(srcdir)/../../../base \ -I$(srcdir)/../../../generic \ - -I$(srcdir)/../../../tables \ + -I$(srcdir)/../../../tables \ -I$(srcdir)/../../content/src \ -I$(srcdir)/../../../xul/base/src \ $(NULL) diff --git a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp index 0f483e3d6af..68b7153f6b1 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp @@ -72,11 +72,9 @@ nsMathMLTokenFrame::GetType() const } // for , distinguish between italic and upright... - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::MOZfontstyle, value); - // treat invariant the same as italic to inherit its inter-space properties - return value.EqualsLiteral("normal") + return mContent->AttrValueIs(kNameSpaceID_None, nsMathMLAtoms::MOZfontstyle, + nsMathMLAtoms::normal, eCaseMatters) ? nsMathMLAtoms::uprightIdentifierMathMLFrame : nsMathMLAtoms::italicIdentifierMathMLFrame; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 770a8ab3302..16f588c5e0a 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -62,6 +62,7 @@ #include "nsAutoPtr.h" #include "nsStyleSet.h" #include "nsDisplayList.h" +#include "nsContentUtils.h" // // -- bind actions to a subexpression - implementation @@ -391,10 +392,10 @@ nsMathMLmactionFrame::MouseOut(nsIDOMEvent* aMouseEvent) NS_IMETHODIMP nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent) { - nsAutoString value; if (NS_MATHML_ACTION_TYPE_TOGGLE == mActionType) { if (mChildCount > 1) { PRInt32 selection = (mSelection == mChildCount)? 1 : mSelection + 1; + nsAutoString value; char cbuf[10]; PR_snprintf(cbuf, sizeof(cbuf), "%d", selection); value.AssignASCII(cbuf); @@ -409,9 +410,8 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent) if (!mRestyle.IsEmpty()) { nsCOMPtr node( do_QueryInterface(mContent) ); if (node.get()) { - mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::actiontype_, - value); - if (!value.IsEmpty()) + if (nsContentUtils::HasNonEmptyAttr(mContent, kNameSpaceID_None, + nsMathMLAtoms::actiontype_)) node->RemoveAttribute(NS_LITERAL_STRING("actiontype")); else node->SetAttribute(NS_LITERAL_STRING("actiontype"), mRestyle); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp index e1775562a4f..57d185e5c99 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp @@ -183,8 +183,6 @@ XXX The winner is the outermost in conflicting settings like these: mPresentationData.baseFrame = baseFrame; GetEmbellishDataFrom(baseFrame, mEmbellishData); - nsAutoString value; - // The default value of accent is false, unless the overscript is embellished // and its core is an accent nsEmbellishData embellishData; @@ -195,11 +193,13 @@ 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 - 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; + static nsIContent::AttrValuesArray strings[] = + {&nsMathMLAtoms::_true, &nsMathMLAtoms::_false, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsMathMLAtoms::accent_, + strings, eCaseMatters)) { + case 0: mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; break; + case 1: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; break; + } // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index 2b303c2b992..299079f8bf3 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -75,18 +75,23 @@ nsMathMLmstyleFrame::InheritAutomaticData(nsIFrame* aParent) mPresentationData.mstyle = this; // see if the displaystyle attribute is there - nsAutoString 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; + static nsIContent::AttrValuesArray strings[] = + {&nsMathMLAtoms::_true, &nsMathMLAtoms::_false, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsMathMLAtoms::displaystyle_, + strings, eCaseMatters)) { + case 0: + mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + break; + + case 1: + mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; + mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; + break; } // see if the scriptlevel attribute is there + nsAutoString value; mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::scriptlevel_, value); if (!value.IsEmpty()) { PRInt32 errorCode, userValue; diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index d4590909fac..4c5a7830b12 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -195,7 +195,6 @@ MapAttributesInto(nsPresContext* aPresContext, nsIAtom* atom; PRUnichar* attr; - nsAutoString value; PRBool hasChanged = PR_FALSE; NS_NAMED_LITERAL_STRING(trueStr, "true"); @@ -205,7 +204,7 @@ MapAttributesInto(nsPresContext* aPresContext, // see if the rowalign attribute is not already set atom = nsMathMLAtoms::rowalign_; - if (!aCellContent->GetAttr(kNameSpaceID_None, atom, value)) { + if (!aCellContent->HasAttr(kNameSpaceID_None, atom)) { // see if the rowalign attribute was specified on the row attr = GetValueAt(aPresContext, rowFrame, atom, rowIndex); if (!attr) { @@ -250,7 +249,7 @@ MapAttributesInto(nsPresContext* aPresContext, // see if the columnalign attribute is not already set atom = nsMathMLAtoms::columnalign_; - if (!aCellContent->GetAttr(kNameSpaceID_None, atom, value)) { + if (!aCellContent->HasAttr(kNameSpaceID_None, atom)) { // see if the columnalign attribute was specified on the row attr = GetValueAt(aPresContext, rowFrame, atom, colIndex); if (!attr) { diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp index 7b1ba2e761e..6ec89811bdf 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp @@ -183,8 +183,6 @@ XXX The winner is the outermost setting in conflicting settings like these: mPresentationData.baseFrame = baseFrame; GetEmbellishDataFrom(baseFrame, mEmbellishData); - nsAutoString value; - // The default value of accentunder is false, unless the underscript is embellished // and its core is an accent nsEmbellishData embellishData; @@ -195,11 +193,13 @@ XXX The winner is the outermost setting in conflicting settings like these: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; // if we have an accentunder attribute, it overrides what the underscript said - mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::accentunder_, value); - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; + static nsIContent::AttrValuesArray strings[] = + {&nsMathMLAtoms::_true, &nsMathMLAtoms::_false, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsMathMLAtoms::accentunder_, + strings, eCaseMatters)) { + case 0: mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; break; + case 1: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; break; + } // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp index df2c200bb80..ca386d4e690 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp @@ -187,8 +187,6 @@ nsMathMLmunderoverFrame::TransmitAutomaticData() mPresentationData.baseFrame = baseFrame; GetEmbellishDataFrom(baseFrame, mEmbellishData); - nsAutoString value; - // The default value of accentunder is false, unless the underscript is embellished // and its core is an accent nsEmbellishData embellishData; @@ -198,12 +196,15 @@ nsMathMLmunderoverFrame::TransmitAutomaticData() else mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; + static nsIContent::AttrValuesArray strings[] = + {&nsMathMLAtoms::_true, &nsMathMLAtoms::_false, nsnull}; + // if we have an accentunder attribute, it overrides what the underscript said - mContent->GetAttr(kNameSpaceID_None, nsMathMLAtoms::accentunder_, value); - if (value.EqualsLiteral("true")) - mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; - else if (value.EqualsLiteral("false")) - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsMathMLAtoms::accentunder_, + strings, eCaseMatters)) { + case 0: mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; break; + case 1: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; break; + } // The default value of accent is false, unless the overscript is embellished // and its core is an accent @@ -214,11 +215,11 @@ nsMathMLmunderoverFrame::TransmitAutomaticData() mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; // if we have an accent attribute, it overrides what the overscript said - 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; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsMathMLAtoms::accent_, + strings, eCaseMatters)) { + case 0: mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; break; + case 1: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; break; + } // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && diff --git a/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp b/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp index f4484bdbafa..f66bf28497b 100644 --- a/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp @@ -145,9 +145,8 @@ void nsButtonBoxFrame::DoMouseClick(nsGUIEvent* aEvent, PRBool aTrustEvent) { // Don't execute if we're disabled. - nsAutoString disabled; - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled); - if (disabled.EqualsLiteral("true")) + if (mContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::disabled, + nsHTMLAtoms::_true, eCaseMatters)) return; // Execute the oncommand event handler. diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index 887c1e0318b..87b8bc2c3cb 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -376,14 +376,20 @@ nsImageBoxFrame::UpdateImage() void nsImageBoxFrame::UpdateLoadFlags() { - nsAutoString loadPolicy; - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::validate, loadPolicy); - if (loadPolicy.EqualsLiteral("always")) - mLoadFlags = nsIRequest::VALIDATE_ALWAYS; - else if (loadPolicy.EqualsLiteral("never")) - mLoadFlags = nsIRequest::VALIDATE_NEVER|nsIRequest::LOAD_FROM_CACHE; - else - mLoadFlags = nsIRequest::LOAD_NORMAL; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::always, &nsXULAtoms::never, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsXULAtoms::validate, + strings, eCaseMatters)) { + case 0: + mLoadFlags = nsIRequest::VALIDATE_ALWAYS; + break; + case 1: + mLoadFlags = nsIRequest::VALIDATE_NEVER|nsIRequest::LOAD_FROM_CACHE; + break; + default: + mLoadFlags = nsIRequest::LOAD_NORMAL; + break; + } } class nsDisplayXULImage : public nsDisplayItem { diff --git a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp index edcfa28a624..aa4a2675e5c 100644 --- a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -136,12 +136,14 @@ nsLeafBoxFrame::AttributeChanged(PRInt32 aNameSpaceID, void nsLeafBoxFrame::UpdateMouseThrough() { if (mContent) { - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::mousethrough, value); - if (value.EqualsLiteral("never")) - mMouseThrough = never; - else if (value.EqualsLiteral("always")) - mMouseThrough = always; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::never, &nsXULAtoms::always, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::mousethrough, + strings, eCaseMatters)) { + case 0: mMouseThrough = never; break; + case 1: mMouseThrough = always; break; + } } } diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index 1817c01e08b..f5c59928f83 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -72,6 +72,7 @@ #include "nsINodeInfo.h" #include "nsLayoutUtils.h" #include "nsPIListBoxObject.h" +#include "nsContentUtils.h" /////////////// nsListScrollSmoother ////////////////// @@ -371,9 +372,8 @@ nsSize nsListBoxBodyFrame::GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) { nsSize result(0, 0); - nsAutoString sizeMode; - GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sizemode, sizeMode); - if (!sizeMode.IsEmpty()) { + if (nsContentUtils::HasNonEmptyAttr(GetContent(), kNameSpaceID_None, + nsXULAtoms::sizemode)) { GetPrefSize(aBoxLayoutState, result); result.height = 0; nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this); diff --git a/mozilla/layout/xul/base/src/nsListBoxLayout.cpp b/mozilla/layout/xul/base/src/nsListBoxLayout.cpp index 36e9ef68ece..4e05697817f 100644 --- a/mozilla/layout/xul/base/src/nsListBoxLayout.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxLayout.cpp @@ -47,6 +47,7 @@ #include "nsIReflowCallback.h" #include "nsINameSpaceManager.h" #include "nsXULAtoms.h" +#include "nsContentUtils.h" nsListBoxLayout::nsListBoxLayout(nsIPresShell* aPresShell) : nsGridRowGroupLayout(aPresShell) @@ -71,9 +72,8 @@ nsListBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, ns nscoord remainder = m == 0 ? 0 : rowheight - m; aSize.height += remainder; } - nsAutoString sizeMode; - frame->GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sizemode, sizeMode); - if (!sizeMode.IsEmpty()) { + if (nsContentUtils::HasNonEmptyAttr(frame->GetContent(), kNameSpaceID_None, + nsXULAtoms::sizemode)) { nscoord width = frame->ComputeIntrinsicWidth(aBoxLayoutState); if (width > aSize.width) aSize.width = width; @@ -98,9 +98,8 @@ nsListBoxLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsS nscoord remainder = m == 0 ? 0 : rowheight - m; aSize.height += remainder; } - nsAutoString sizeMode; - frame->GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sizemode, sizeMode); - if (!sizeMode.IsEmpty()) { + if (nsContentUtils::HasNonEmptyAttr(frame->GetContent(), kNameSpaceID_None, + nsXULAtoms::sizemode)) { nscoord width = frame->ComputeIntrinsicWidth(aBoxLayoutState); if (width > aSize.width) aSize.width = width; diff --git a/mozilla/layout/xul/base/src/nsListItemFrame.cpp b/mozilla/layout/xul/base/src/nsListItemFrame.cpp index 9b600a00be2..bec85b0e551 100644 --- a/mozilla/layout/xul/base/src/nsListItemFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListItemFrame.cpp @@ -89,9 +89,8 @@ nsListItemFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { if (aBuilder->IsForEventDelivery()) { - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value); - if (!value.EqualsLiteral("true")) + if (!mContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::allowevents, + nsXULAtoms::_true, eCaseMatters)) return NS_OK; } diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp index 909c8c5b113..fc05e64b200 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp @@ -761,11 +761,8 @@ nsMenuBarFrame::IsValidItem(nsIContent* aContent) PRBool nsMenuBarFrame::IsDisabled(nsIContent* aContent) { - nsString disabled; - aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled); - if (disabled.EqualsLiteral("true")) - return PR_TRUE; - return PR_FALSE; + return aContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::disabled, + nsHTMLAtoms::_true, eCaseMatters); } void diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index eed7970d9bf..ac7b2ecffe4 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -605,11 +605,10 @@ PRBool nsMenuFrame::IsGenerated() // Generate the menu if it hasn't been generated already. This // takes it from display: none to display: block and gives us // a menu forevermore. - if (child) { - nsString genVal; - child->GetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, genVal); - if (genVal.IsEmpty()) - return PR_FALSE; + if (child && + !nsContentUtils::HasNonEmptyAttr(child, kNameSpaceID_None, + nsXULAtoms::menugenerated)) { + return PR_FALSE; } return PR_TRUE; @@ -624,12 +623,11 @@ nsMenuFrame::MarkAsGenerated() // Generate the menu if it hasn't been generated already. This // takes it from display: none to display: block and gives us // a menu forevermore. - if (child) { - nsAutoString genVal; - child->GetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, genVal); - if (genVal.IsEmpty()) { - child->SetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, NS_LITERAL_STRING("true"), PR_TRUE); - } + if (child && + !nsContentUtils::HasNonEmptyAttr(child, kNameSpaceID_None, + nsXULAtoms::menugenerated)) { + child->SetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, + NS_LITERAL_STRING("true"), PR_TRUE); } return NS_OK; @@ -641,11 +639,10 @@ nsMenuFrame::UngenerateMenu() nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); - if (child) { - nsAutoString genVal; - child->GetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, genVal); - if (!genVal.IsEmpty()) - child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, PR_TRUE); + if (child && + nsContentUtils::HasNonEmptyAttr(child, kNameSpaceID_None, + nsXULAtoms::menugenerated)) { + child->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, PR_TRUE); } return NS_OK; @@ -1113,46 +1110,53 @@ nsMenuFrame::SetDebug(nsBoxLayoutState& aState, nsIFrame* aList, PRBool aDebug) static void ConvertPosition(nsIContent* aPopupElt, nsString& aAnchor, nsString& aAlign) { - nsAutoString position; - aPopupElt->GetAttr(kNameSpaceID_None, nsXULAtoms::position, position); - if (position.IsEmpty()) - return; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::_empty, &nsXULAtoms::before_start, &nsXULAtoms::before_end, + &nsXULAtoms::after_start, &nsXULAtoms::after_end, &nsXULAtoms::start_before, + &nsXULAtoms::start_after, &nsXULAtoms::end_before, &nsXULAtoms::end_after, + &nsXULAtoms::overlap, nsnull}; - if (position.EqualsLiteral("before_start")) { - aAnchor.AssignLiteral("topleft"); - aAlign.AssignLiteral("bottomleft"); - } - else if (position.EqualsLiteral("before_end")) { - aAnchor.AssignLiteral("topright"); - aAlign.AssignLiteral("bottomright"); - } - else if (position.EqualsLiteral("after_start")) { - aAnchor.AssignLiteral("bottomleft"); - aAlign.AssignLiteral("topleft"); - } - else if (position.EqualsLiteral("after_end")) { - aAnchor.AssignLiteral("bottomright"); - aAlign.AssignLiteral("topright"); - } - else if (position.EqualsLiteral("start_before")) { - aAnchor.AssignLiteral("topleft"); - aAlign.AssignLiteral("topright"); - } - else if (position.EqualsLiteral("start_after")) { - aAnchor.AssignLiteral("bottomleft"); - aAlign.AssignLiteral("bottomright"); - } - else if (position.EqualsLiteral("end_before")) { - aAnchor.AssignLiteral("topright"); - aAlign.AssignLiteral("topleft"); - } - else if (position.EqualsLiteral("end_after")) { - aAnchor.AssignLiteral("bottomright"); - aAlign.AssignLiteral("bottomleft"); - } - else if (position.EqualsLiteral("overlap")) { - aAnchor.AssignLiteral("topleft"); - aAlign.AssignLiteral("topleft"); + switch (aPopupElt->FindAttrValueIn(kNameSpaceID_None, nsXULAtoms::position, + strings, eCaseMatters)) { + case nsIContent::ATTR_MISSING: + case 0: + return; + case 1: + aAnchor.AssignLiteral("topleft"); + aAlign.AssignLiteral("bottomleft"); + break; + case 2: + aAnchor.AssignLiteral("topright"); + aAlign.AssignLiteral("bottomright"); + break; + case 3: + aAnchor.AssignLiteral("bottomleft"); + aAlign.AssignLiteral("topleft"); + break; + case 4: + aAnchor.AssignLiteral("bottomright"); + aAlign.AssignLiteral("topright"); + break; + case 5: + aAnchor.AssignLiteral("topleft"); + aAlign.AssignLiteral("topright"); + break; + case 6: + aAnchor.AssignLiteral("bottomleft"); + aAlign.AssignLiteral("bottomright"); + break; + case 7: + aAnchor.AssignLiteral("topright"); + aAlign.AssignLiteral("topleft"); + break; + case 8: + aAnchor.AssignLiteral("bottomright"); + aAlign.AssignLiteral("bottomleft"); + break; + case 9: + aAnchor.AssignLiteral("topleft"); + aAlign.AssignLiteral("topleft"); + break; } } @@ -1311,9 +1315,8 @@ nsMenuFrame::Notify(nsITimer* aTimer) mMenuParent->GetIsContextMenu(parentIsContextMenu); if (ctxMenu == nsnull || parentIsContextMenu) { - nsAutoString active; - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, active); - if (active.Equals(NS_LITERAL_STRING("true"))) { + if (mContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::menuactive, + nsXULAtoms::_true, eCaseMatters)) { // We're still the active menu. Make sure all submenus/timers are closed // before opening this one mMenuParent->KillPendingTimers(); @@ -1332,29 +1335,29 @@ nsMenuFrame::Notify(nsITimer* aTimer) PRBool nsMenuFrame::IsDisabled() { - nsAutoString disabled; - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled); - if (disabled.EqualsLiteral("true")) - return PR_TRUE; - return PR_FALSE; + return mContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::disabled, + nsHTMLAtoms::_true, eCaseMatters); } void nsMenuFrame::UpdateMenuType(nsPresContext* aPresContext) { - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value); - if (value.EqualsLiteral("checkbox")) - mType = eMenuType_Checkbox; - else if (value.EqualsLiteral("radio")) { - mType = eMenuType_Radio; - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, mGroupName); - } - else { - if (mType != eMenuType_Normal) - mContent->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, - PR_TRUE); - mType = eMenuType_Normal; + static nsIContent::AttrValuesArray strings[] = + {&nsHTMLAtoms::checkbox, &nsHTMLAtoms::radio, nsnull}; + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsHTMLAtoms::type, + strings, eCaseMatters)) { + case 0: mType = eMenuType_Checkbox; break; + case 1: + mType = eMenuType_Radio; + mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, mGroupName); + break; + + default: + if (mType != eMenuType_Normal) + mContent->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, + PR_TRUE); + mType = eMenuType_Normal; + break; } UpdateMenuSpecialState(aPresContext); } @@ -1362,12 +1365,9 @@ nsMenuFrame::UpdateMenuType(nsPresContext* aPresContext) /* update checked-ness for type="checkbox" and type="radio" */ void nsMenuFrame::UpdateMenuSpecialState(nsPresContext* aPresContext) { - nsAutoString value; - PRBool newChecked; - - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, - value); - newChecked = (value.EqualsLiteral("true")); + PRBool newChecked = + mContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::checked, + nsHTMLAtoms::_true, eCaseMatters); if (newChecked == mChecked) { /* checked state didn't change */ @@ -1586,9 +1586,8 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent) { // flip "checked" state if we're a checkbox menu, or an un-checked radio menu if (mType == eMenuType_Checkbox || (mType == eMenuType_Radio && !mChecked)) { - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::autocheck, value); - if (!value.EqualsLiteral("false")) { + if (!mContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::autocheck, + nsHTMLAtoms::_false, eCaseMatters)) { if (mChecked) { mContent->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, PR_TRUE); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 564fc795dab..07a1d845001 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -1120,11 +1120,10 @@ nsMenuPopupFrame::SyncViewWithFrame(nsPresContext* aPresContext, SetBounds(state, nsRect(mRect.x, mRect.y, parentRect.width, mRect.height)); } - nsAutoString shouldDisplay, menuActive; - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, menuActive); - if (!menuActive.EqualsLiteral("true")) { - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, shouldDisplay); - if ( shouldDisplay.EqualsLiteral("true") ) + if (!mContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::menuactive, + nsXULAtoms::_true, eCaseMatters) && + mContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, + nsXULAtoms::_true, eCaseMatters)) { mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, NS_LITERAL_STRING("true"), PR_TRUE); } @@ -1291,9 +1290,8 @@ NS_IMETHODIMP nsMenuPopupFrame::ConsumeOutsideClicks(PRBool& aConsumeOutsideClic } if (parentTag == nsXULAtoms::textbox) { // Don't consume outside clicks for autocomplete widget - nsAutoString typeString; - parentContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, typeString); - if (typeString.EqualsLiteral("autocomplete")) + if (parentContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::type, + nsHTMLAtoms::autocomplete, eCaseMatters)) aConsumeOutsideClicks = PR_FALSE; } } @@ -1569,7 +1567,7 @@ nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, PRBool& doActi // See if it's a menu item. if (IsValidItem(current)) { - nsAutoString activeKey, textKey; + nsAutoString textKey; // Get the shortcut attribute. current->GetAttr(kNameSpaceID_None, nsXULAtoms::accesskey, textKey); if (textKey.IsEmpty()) { // No shortcut, try first letter @@ -1610,8 +1608,8 @@ nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, PRBool& doActi } // Get the active status - current->GetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, activeKey); - if (activeKey.EqualsLiteral("true")) { + if (current->AttrValueIs(kNameSpaceID_None, nsXULAtoms::menuactive, + nsXULAtoms::_true, eCaseMatters)) { foundActive = PR_TRUE; if (stringLength > 1) { // If there is more than one char typed, the current item has highest priority, @@ -1937,11 +1935,8 @@ nsMenuPopupFrame::IsValidItem(nsIContent* aContent) PRBool nsMenuPopupFrame::IsDisabled(nsIContent* aContent) { - nsString disabled; - aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled); - if (disabled.EqualsLiteral("true")) - return PR_TRUE; - return PR_FALSE; + return aContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::disabled, + nsHTMLAtoms::_true, eCaseMatters); } NS_IMETHODIMP diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp index f0abccdec3f..0381f54f046 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp @@ -454,10 +454,8 @@ nsPopupSetFrame::MarkAsGenerated(nsIContent* aPopupContent) { // Set our attribute, but only if we aren't already generated. // Retrieve the menugenerated attribute. - nsAutoString value; - aPopupContent->GetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, - value); - if (!value.EqualsLiteral("true")) { + if (!aPopupContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::menugenerated, + nsXULAtoms::_true, eCaseMatters)) { // Generate this element. aPopupContent->SetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, NS_LITERAL_STRING("true"), PR_TRUE); @@ -480,9 +478,8 @@ nsPopupSetFrame::OpenPopup(nsPopupFrameList* aEntry, PRBool aActivateFlag) // Tooltips don't get keyboard navigation if (childPopup && !nsMenuDismissalListener::sInstance) { // First check and make sure this popup wants keyboard navigation - nsAutoString property; - aEntry->mPopupContent->GetAttr(kNameSpaceID_None, nsXULAtoms::ignorekeys, property); - if (!property.EqualsLiteral("true")) + if (!aEntry->mPopupContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::ignorekeys, + nsXULAtoms::_true, eCaseMatters)) childPopup->InstallKeyboardNavigator(); } diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index d6892831a84..e3a0832d34e 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -77,6 +77,7 @@ #include "nsStyleSet.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" +#include "nsContentUtils.h" // was used in nsSplitterFrame::Init but now commented out //static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -199,26 +200,28 @@ nsSplitterFrameInner::~nsSplitterFrameInner() nsSplitterFrameInner::ResizeType nsSplitterFrameInner::GetResizeAfter() { - nsString value; - mOuter->GetContent()->GetAttr(kNameSpaceID_None, - nsXULAtoms::resizeafter, value); - if (value.EqualsLiteral("farthest")) - return Farthest; - if (value.EqualsLiteral("grow")) - return Grow; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::farthest, &nsXULAtoms::grow, nsnull}; + switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::resizeafter, + strings, eCaseMatters)) { + case 0: return Farthest; + case 1: return Grow; + } return Closest; } nsSplitterFrameInner::State nsSplitterFrameInner::GetState() { - nsString value; - mOuter->GetContent()->GetAttr(kNameSpaceID_None, - nsXULAtoms::state, value); - if (value.EqualsLiteral("dragging")) - return Dragging; - if (value.EqualsLiteral("collapsed")) - return Collapsed; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::dragging, &nsXULAtoms::collapsed, nsnull}; + switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::state, + strings, eCaseMatters)) { + case 0: return Dragging; + case 1: return Collapsed; + } return Open; } @@ -332,9 +335,8 @@ nsSplitterFrame::Init(nsIContent* aContent, PRBool isHorizontal; aParent->GetOrientation(isHorizontal); if (!isHorizontal) { - nsAutoString str; - aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::orient, str); - if (str.IsEmpty()) { + if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None, + nsXULAtoms::orient)) { aContent->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("vertical"), PR_FALSE); nsStyleContext* parentStyleContext = aParent->GetStyleContext(); @@ -885,12 +887,14 @@ nsSplitterFrameInner::Reverse(nsSplitterInfo*& aChildInfos, PRInt32 aCount) nsSplitterFrameInner::CollapseDirection nsSplitterFrameInner::GetCollapseDirection() { - nsString value; - mOuter->mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::collapse, value); - if (value.EqualsLiteral("before")) - return Before; - else if (value.EqualsLiteral("after")) - return After; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::before, &nsXULAtoms::after, nsnull}; + switch (mOuter->mContent->FindAttrValueIn(kNameSpaceID_None, + nsXULAtoms::collapse, + strings, eCaseMatters)) { + case 0: return Before; + case 1: return After; + } return None; } diff --git a/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp b/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp index aec823951fb..a2ad1229f1f 100644 --- a/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp @@ -216,20 +216,27 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom* aAttribute, aRedraw = PR_FALSE; if (aAttribute == nsnull || aAttribute == nsXULAtoms::crop) { - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::crop, value); + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::left, &nsXULAtoms::start, &nsXULAtoms::center, + &nsXULAtoms::right, &nsXULAtoms::end, nsnull}; CroppingStyle cropType; - - if (value.EqualsASCII(CROP_LEFT) || - value.EqualsASCII(CROP_START)) + switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsXULAtoms::crop, + strings, eCaseMatters)) { + case 0: + case 1: cropType = CropLeft; - else if (value.EqualsASCII(CROP_CENTER)) + break; + case 2: cropType = CropCenter; - else if (value.EqualsASCII(CROP_RIGHT) || - value.EqualsASCII(CROP_END)) + break; + case 3: + case 4: cropType = CropRight; - else + break; + default: cropType = CropNone; + break; + } if (cropType != mCropType) { aResize = PR_TRUE; diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp index c27a5fd2bb8..6c916b69c3d 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp @@ -48,6 +48,7 @@ #include "nsStyleContext.h" #include "nsIDOMClassInfo.h" #include "nsINodeInfo.h" +#include "nsContentUtils.h" // Column class that caches all the info about our column. nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, nsIFrame* aFrame) @@ -225,22 +226,28 @@ nsTreeColumn::CacheAttributes() // Figure out our column type. Default type is text. mType = nsITreeColumn::TYPE_TEXT; - nsAutoString type; - content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type); - if (type.EqualsLiteral("checkbox")) - mType = nsITreeColumn::TYPE_CHECKBOX; - else if (type.EqualsLiteral("progressmeter")) - mType = nsITreeColumn::TYPE_PROGRESSMETER; + static nsIContent::AttrValuesArray typestrings[] = + {&nsHTMLAtoms::checkbox, &nsHTMLAtoms::progressmeter, nsnull}; + switch (content->FindAttrValueIn(kNameSpaceID_None, nsHTMLAtoms::type, + typestrings, eCaseMatters)) { + case 0: mType = nsITreeColumn::TYPE_CHECKBOX; break; + case 1: mType = nsITreeColumn::TYPE_PROGRESSMETER; break; + } // Fetch the crop style. mCropStyle = 0; - nsAutoString crop; - content->GetAttr(kNameSpaceID_None, nsXULAtoms::crop, crop); - if (crop.EqualsLiteral("center")) - mCropStyle = 1; - else if (crop.EqualsLiteral("left") || - crop.EqualsLiteral("start")) - mCropStyle = 2; + static nsIContent::AttrValuesArray cropstrings[] = + {&nsXULAtoms::center, &nsXULAtoms::left, &nsXULAtoms::start, nsnull}; + switch (content->FindAttrValueIn(kNameSpaceID_None, nsXULAtoms::crop, + cropstrings, eCaseMatters)) { + case 0: + mCropStyle = 1; + break; + case 1: + case 2: + mCropStyle = 2; + break; + } } @@ -323,9 +330,8 @@ nsTreeColumns::GetSortedColumn(nsITreeColumn** _retval) EnsureColumns(); *_retval = nsnull; for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) { - nsAutoString attr; - currCol->GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, attr); - if (!attr.IsEmpty()) { + if (nsContentUtils::HasNonEmptyAttr(currCol->GetContent(), kNameSpaceID_None, + nsXULAtoms::sortDirection)) { NS_ADDREF(*_retval = currCol); return NS_OK; } @@ -359,9 +365,8 @@ nsTreeColumns::GetKeyColumn(nsITreeColumn** _retval) if (!first) first = currCol; - nsAutoString attr; - content->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, attr); - if (!attr.IsEmpty()) { + if (nsContentUtils::HasNonEmptyAttr(content, kNameSpaceID_None, + nsXULAtoms::sortDirection)) { // Use sorted column as the key. sorted = currCol; break; diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp index 3e58c8c87f9..09c41fc503a 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp @@ -451,12 +451,13 @@ nsTreeContentView::GetProgressMode(PRInt32 aRow, nsITreeColumn* aCol, PRInt32* _ if (realRow) { nsIContent* cell = GetCell(realRow, aCol); if (cell) { - nsAutoString state; - cell->GetAttr(kNameSpaceID_None, nsXULAtoms::mode, state); - if (state.EqualsLiteral("normal")) - *_retval = nsITreeView::PROGRESS_NORMAL; - else if (state.EqualsLiteral("undetermined")) - *_retval = nsITreeView::PROGRESS_UNDETERMINED; + static nsIContent::AttrValuesArray strings[] = + {&nsXULAtoms::normal, &nsXULAtoms::undetermined, nsnull}; + switch (cell->FindAttrValueIn(kNameSpaceID_None, nsXULAtoms::mode, + strings, eCaseMatters)) { + case 0: *_retval = nsITreeView::PROGRESS_NORMAL; break; + case 1: *_retval = nsITreeView::PROGRESS_UNDETERMINED; break; + } } } @@ -1462,9 +1463,9 @@ nsTreeContentView::GetCell(nsIContent* aContainer, nsITreeColumn* aCol) nsCOMPtr cell = *iter; if (cell->Tag() == nsXULAtoms::treecell) { - nsAutoString ref; - cell->GetAttr(kNameSpaceID_None, nsXULAtoms::ref, ref); - if (!ref.IsEmpty() && ref.Equals(colID)) { + if (colID[0] != 0 && cell->AttrValueIs(kNameSpaceID_None, nsXULAtoms::ref, + nsDependentString(colID), + eCaseMatters)) { result = cell; break; } diff --git a/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp index d173859d1fe..626bd051589 100755 --- a/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp @@ -736,9 +736,9 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, // Any xml element can be an xlink *aIsInsideLink = startContent->HasAttr(kNameSpaceID_XLink, hrefAtom); if (*aIsInsideLink) { - nsAutoString xlinkType; - startContent->GetAttr(kNameSpaceID_XLink, typeAtom, xlinkType); - if (!xlinkType.Equals(NS_LITERAL_STRING("simple"))) { + if (!startContent->AttrValueIs(kNameSpaceID_XLink, typeAtom, + NS_LITERAL_STRING("simple"), + eCaseMatters)) { *aIsInsideLink = PR_FALSE; // Xlink must be type="simple" }