Boris Zbarsky wrote:
> PM wrote:
>
>> Problem is that the style isn’t applied immediately.
>
> Which Gecko version? This should work with Gecko 1.9, but not with
> Gecko 1.8.x. See <https://bugzilla.mozilla.org/show_bug.cgi?id=335689>.
>
I work with Gecko 1.8.x
I solved problem this way, I’m not sure if is it correct, but it works:
nsresult LoadStyleSheet(nsIDocument* doc, nsCString aSpec )
{
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
nsresult rv;
nsCOMPtr<nsIURI> aSheetURI;
nsCOMPtr<nsIIOService> ios = do_GetService(NS_IOSERVICE_CONTRACTID);
rv = ios->NewURI(aSpec,nsnull, nsnull, getter_AddRefs(aSheetURI));
nsCOMPtr<nsICSSLoader> cssLoader = do_CreateInstance(kCSSLoaderCID);
nsCOMPtr<nsICSSStyleSheet> aCSSStyleSheet;
rv = cssLoader->LoadAgentSheet(aSheetURI,
getter_AddRefs(aCSSStyleSheet));
NS_ENSURE_SUCCESS(rv, rv);
doc->BeginUpdate(UPDATE_STYLE);
doc->AddStyleSheet(aCSSStyleSheet);
doc->EndUpdate(UPDATE_STYLE);
return rv;
}
>> Does it exist any article or example how to create style dynamically
>> by javascript or c++ and register it?
>
> You can use a data: URI, no?
>
> -Boris
Sorry, what is „data: URI“? I’ve been developing with Mozilla just 2
months. Is any article about it or example where is it used?
PM
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout