Hi,
I want to make processing after document loading is complete, so I add
myBrowserProgressListener progress listener to gBrowser:
gBrowser.addProgressListener(myBrowserProgressListener,
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
where the myBrowserProgressListener implements the nsIWebProgressListener
interface:
var myBrowserProgressListener =
{
QueryInterface: function(aIID)
{...}
onStateChange: function(aProgress, aRequest, aFlag, aStatus)
{
...
if(aFlag & STATE_STOP && aFlag & STATE_IS_WINDOW)
{
myxpcom.OnDocumentComplete(aProgress, tabID);
}
}
...
}
and on the C++ side:
NS_IMETHODIMP nsMyXPCOM::OnDocumentComplete(nsIWebProgress *prog, const
nsAString & tabID)
{
nsCOMPtr<nsIDOMWindow> domWindow = NULL;
nsresult rv = prog->GetDOMWindow(getter_AddRefs(domWindow));
if(NS_SUCCEEDED(rv) && domWindow)
{
...
nsCOMPtr<nsIDOMCSSStyleDeclaration> spComputedStyle = NULL;
rv = spDomView->GetComputedStyle(domElement, EmptyString(),
getter_AddRefs(spComputedStyle));
if(NS_SUCCEEDED(rv) && spComputedStyle)
{
...
strPropertyName.AssignLiteral("font-size");
strPropertyValue.AssignLiteral("16px");
nsresult rv = spComputedStyle.setProperty(strPropertyName,
strPropertyValue, EmptyString());
...
}
}
...
}
The "rv" has value 0x80530007 and it means that the error
NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR happens.
I suppose that the reason is that the nsIWebProgress's DOMWindow attribute
is readonly.
Could you please suggest the right way to change some property of the given
element (nsIDOMElement)?
Are there other ways to observe that a document is loaded beside of adding
nsIWebProgressListener?
Thank you in advance!
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout