Re: Setting attributes via DOM does not take effect

"[email protected]" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Organization http://groups.google.com
Message-ID <4a026f9f-7d21-464d-b204-8a5ed06e5e95@e10g2000prf.googlegroups.com>
On Jan 9, 11:19 am, Boris Zbarsky <[email protected]> wrote:

I followed the documents you pointed out and Mozilla Dev center's
DOM:style page. I was able to access the stylesheet via the API.
However, when I went further to access cssRules on the stylesheet, I
got an error of 0x80004005. Here is the code snippet I have (in Java):

		nsIDOMWindow domWindow = webBrowser.getContentDOMWindow();

		nsIDOMDocument document = domWindow.getDocument();

		// Query nsIDOMDocumentStyle interface out of the regular
nsIDOMDocument.
		nsIDOMDocumentStyle documentStyle = (nsIDOMDocumentStyle)
document.queryInterface(nsIDOMDocumentStyle.NS_IDOMDOCUMENTSTYLE_IID);

		nsIDOMStyleSheetList styleList = documentStyle.getStyleSheets();

		nsIDOMStyleSheet styleSheet = styleList.item(0);

		// Query nsIDOMCSSStyleSheet interface out of nsIDOMStyleSheet
		nsIDOMCSSStyleSheet cssStyleSheet = (nsIDOMCSSStyleSheet)
styleSheet.queryInterface(nsIDOMCSSStyleSheet.NS_IDOMCSSSTYLESHEET_IID);

		// Every thing is fine until this point. Following call throw a
0x80004005 error.
		nsIDOMCSSRuleList ruleList = cssStyleSheet.getCssRules();

		nsIDOMCSSRule rule = ruleList.item(0);

		// rule will then be queried into nsIDOMCSSStyleRule and the
nsIDOMCSSStyleDeclaration property can be obtained to operate on the
actual css text.
		......


I can't figure out why the call failed. Is it not implemented? I went
through similar logic in JavaScript
(document.styleSheets[0].cssRules[0].style.color) on the same page and
it gave me the correct result. Do you see any problem in my logic? I
really appreciate your help.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.