From a62fed42a43decaec75f2ee2d375f148451f797f Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Tue, 30 Nov 1999 00:53:41 +0000 Subject: [PATCH] Tree scrolling improvements. Avoid string twiddling in CreateAnonymousTreeCellFrames. r=hyatt git-svn-id: svn://10.0.0.236/trunk@54659 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 50 +++++++++---------- .../html/style/src/nsCSSFrameConstructor.cpp | 50 +++++++++---------- 2 files changed, 46 insertions(+), 54 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 168e5d9d04f..27149b1ba9d 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -3544,75 +3544,71 @@ nsCSSFrameConstructor::CreateAnonymousTreeCellFrames(nsIPresContext* aPresConte nsCOMPtr nsdoc(do_QueryInterface(doc)); nsCOMPtr document(do_QueryInterface(doc)); - nsString xulNamespace = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - nsString htmlNamespace = "http://www.w3.org/TR/REC-html40"; - nsCOMPtr classAtom = dont_AddRef(NS_NewAtom("class")); - + nsAutoString xulNamespace = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; nsCOMPtr node; nsCOMPtr content; nsAutoString indent; - nsCOMPtr parentNode = do_QueryInterface(aParent); - parentNode->GetAttribute("indent", indent); + aParent->GetAttribute(kNameSpaceID_None, nsXULAtoms::indent, indent); nsCOMPtr boxElement; nsCOMPtr dummy; if (indent == "true") { // We have to make a box to hold everything. - nsdoc->CreateElementWithNameSpace("box", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("box"), xulNamespace, getter_AddRefs(node)); content = do_QueryInterface(node); anonymousItems->AppendElement(content); - content->SetAttribute(kNameSpaceID_None, classAtom, "tree-icon", PR_FALSE); + content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, nsAutoString("tree-icon"), PR_FALSE); boxElement = do_QueryInterface(content); // Make the indentation. - nsdoc->CreateElementWithNameSpace("treeindentation", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("treeindentation"), xulNamespace, getter_AddRefs(node)); boxElement->AppendChild(node, getter_AddRefs(dummy)); - nsCOMPtr treeRow; - nsCOMPtr treeItem; - parentNode->GetParentNode(getter_AddRefs(treeRow)); - treeRow->GetParentNode(getter_AddRefs(treeItem)); + nsCOMPtr treeRow; + aParent->GetParent(*getter_AddRefs(treeRow)); + + nsCOMPtr treeItem; + treeRow->GetParent(*getter_AddRefs(treeItem)); nsAutoString container; - nsCOMPtr treeItemNode = do_QueryInterface(treeItem); - treeItemNode->GetAttribute("container", container); + treeItem->GetAttribute(kNameSpaceID_None, nsXULAtoms::container, container); // Always make a twisty but disable it for non-containers. - nsdoc->CreateElementWithNameSpace("titledbutton", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("titledbutton"), xulNamespace, getter_AddRefs(node)); content = do_QueryInterface(node); - content->SetAttribute(kNameSpaceID_None, classAtom, "twisty", PR_FALSE); + content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, nsAutoString("twisty"), PR_FALSE); if (container != "true") - content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, "true", PR_FALSE); - else content->SetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, "true", PR_FALSE); + content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, nsAutoString("true"), PR_FALSE); + else content->SetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, nsAutoString("true"), PR_FALSE); boxElement->AppendChild(node, getter_AddRefs(dummy)); } - nsString classDesc = "tree-button"; + nsAutoString classDesc = "tree-button"; - nsdoc->CreateElementWithNameSpace("titledbutton", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("titledbutton"), xulNamespace, getter_AddRefs(node)); buttonContent = do_QueryInterface(node); - buttonContent->SetAttribute(kNameSpaceID_None, classAtom, classDesc, PR_FALSE); - nsAutoString value; + buttonContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, classDesc, PR_FALSE); - parentNode->GetAttribute("value", value); + nsAutoString value; + aParent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value); if (value != "") buttonContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value, PR_FALSE); nsAutoString crop; - parentNode->GetAttribute("crop", crop); + aParent->GetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop); if (crop == "") crop = "right"; buttonContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop, PR_FALSE); nsAutoString align; - parentNode->GetAttribute("align", align); + aParent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, align); if (align == "") align = "left"; buttonContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, align, PR_FALSE); if (boxElement) { - buttonContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "1", PR_FALSE); + buttonContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, nsAutoString("1"), PR_FALSE); boxElement->AppendChild(node, getter_AddRefs(dummy)); } else anonymousItems->AppendElement(buttonContent); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 168e5d9d04f..27149b1ba9d 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -3544,75 +3544,71 @@ nsCSSFrameConstructor::CreateAnonymousTreeCellFrames(nsIPresContext* aPresConte nsCOMPtr nsdoc(do_QueryInterface(doc)); nsCOMPtr document(do_QueryInterface(doc)); - nsString xulNamespace = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - nsString htmlNamespace = "http://www.w3.org/TR/REC-html40"; - nsCOMPtr classAtom = dont_AddRef(NS_NewAtom("class")); - + nsAutoString xulNamespace = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; nsCOMPtr node; nsCOMPtr content; nsAutoString indent; - nsCOMPtr parentNode = do_QueryInterface(aParent); - parentNode->GetAttribute("indent", indent); + aParent->GetAttribute(kNameSpaceID_None, nsXULAtoms::indent, indent); nsCOMPtr boxElement; nsCOMPtr dummy; if (indent == "true") { // We have to make a box to hold everything. - nsdoc->CreateElementWithNameSpace("box", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("box"), xulNamespace, getter_AddRefs(node)); content = do_QueryInterface(node); anonymousItems->AppendElement(content); - content->SetAttribute(kNameSpaceID_None, classAtom, "tree-icon", PR_FALSE); + content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, nsAutoString("tree-icon"), PR_FALSE); boxElement = do_QueryInterface(content); // Make the indentation. - nsdoc->CreateElementWithNameSpace("treeindentation", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("treeindentation"), xulNamespace, getter_AddRefs(node)); boxElement->AppendChild(node, getter_AddRefs(dummy)); - nsCOMPtr treeRow; - nsCOMPtr treeItem; - parentNode->GetParentNode(getter_AddRefs(treeRow)); - treeRow->GetParentNode(getter_AddRefs(treeItem)); + nsCOMPtr treeRow; + aParent->GetParent(*getter_AddRefs(treeRow)); + + nsCOMPtr treeItem; + treeRow->GetParent(*getter_AddRefs(treeItem)); nsAutoString container; - nsCOMPtr treeItemNode = do_QueryInterface(treeItem); - treeItemNode->GetAttribute("container", container); + treeItem->GetAttribute(kNameSpaceID_None, nsXULAtoms::container, container); // Always make a twisty but disable it for non-containers. - nsdoc->CreateElementWithNameSpace("titledbutton", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("titledbutton"), xulNamespace, getter_AddRefs(node)); content = do_QueryInterface(node); - content->SetAttribute(kNameSpaceID_None, classAtom, "twisty", PR_FALSE); + content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, nsAutoString("twisty"), PR_FALSE); if (container != "true") - content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, "true", PR_FALSE); - else content->SetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, "true", PR_FALSE); + content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, nsAutoString("true"), PR_FALSE); + else content->SetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, nsAutoString("true"), PR_FALSE); boxElement->AppendChild(node, getter_AddRefs(dummy)); } - nsString classDesc = "tree-button"; + nsAutoString classDesc = "tree-button"; - nsdoc->CreateElementWithNameSpace("titledbutton", xulNamespace, getter_AddRefs(node)); + nsdoc->CreateElementWithNameSpace(nsAutoString("titledbutton"), xulNamespace, getter_AddRefs(node)); buttonContent = do_QueryInterface(node); - buttonContent->SetAttribute(kNameSpaceID_None, classAtom, classDesc, PR_FALSE); - nsAutoString value; + buttonContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, classDesc, PR_FALSE); - parentNode->GetAttribute("value", value); + nsAutoString value; + aParent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value); if (value != "") buttonContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value, PR_FALSE); nsAutoString crop; - parentNode->GetAttribute("crop", crop); + aParent->GetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop); if (crop == "") crop = "right"; buttonContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop, PR_FALSE); nsAutoString align; - parentNode->GetAttribute("align", align); + aParent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, align); if (align == "") align = "left"; buttonContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, align, PR_FALSE); if (boxElement) { - buttonContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "1", PR_FALSE); + buttonContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, nsAutoString("1"), PR_FALSE); boxElement->AppendChild(node, getter_AddRefs(dummy)); } else anonymousItems->AppendElement(buttonContent);