Re: Where does mozilla build a table of attribute for each node
Jonas Sicking <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > On Jan 28, 6:07 pm, Boris Zbarsky <[email protected]> wrote: >> [email protected] wrote: >>> Thank you. I have searched for SetAttr, but the result does not show >>> nsHTMLContentSink. >>> http://lxr.mozilla.org/mozilla1.8.0/ident?i=SetAttr >> Uh... That URI shows hits in nsHTMLContentSink. >> >>> And why not all html elements have SetAttr() function? >> You mean the implementation? It's on the superclass (nsGenericElement), >> generally speaking. Only the ones that have to do something weird with >> attributes override it. >> >> -Boris > > I am trying to override SetAttr() of the Embed Element so that if the > attribute value has a string 'false', i want to replace it with true' > > <EMBED attr="false;something something something"> > I want to replace it with in c++: > <EMBED attr="true;something something something"> > > Can you please tell me how can I over-ride the SetAttr() to achieve > that? > > The parameter 'aValue' is a const, so I can modify it: > SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix, > const nsAString& aValue, > PRBool aNotify) > > And how can I allocation memory for the new value string, replace > 'false' with 'true' and then call the parent SetAttr()? > And do I need to free the memory of the 'aValue' passed in to this > SetAttr()? Not sure if I think what you're doing sounds like a good idea. But it sounds like you want to modify the SetAttr function in nsHTMLSharedObjectElement.cpp. Note that that class is used for both embed elements and applet elements. You can then use the normal string manipulation functions to modify the string as desired: http://developer.mozilla.org/en/docs/XPCOM:Strings Good luck! / Jonas