Thank you, great reply! It works like a charm :) Cheers, Emil
"Olivier Danes" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > > Hi, > > to get sytle information from elements nodes, here is how I make it (don't > know if a simpler way exist) : > > 1. QI the nsIDOMDocument to get the nsIDOMDocumentView > 2. get the nsIDOMAbstractView by calling > nsIDOMDocumentView::GetDefaultView() > 3. QI the nsIDOMAbstractView to get the nsIDOMViewCSS > 4. QI the nsIDOMNode you want to get the sytle to get the nsIDOMElement it > refers to > 5. get the nsIDOMCSSStyleDeclaration by calling the > nsIDOMViewCSS::GetComputedStyle() method > 6. call the nsIDOMCSSStyleDeclaration::GetPropertyValue() to get the sytle > information you want ! > > Olivier > > Here is my code snippet > > nsCOMPtr<nsIDOMDocument> doc = 0; > nsCOMPtr<nsIDOMDocumentView> dv = 0; > nsCOMPtr<nsIDOMViewCSS> view = 0; > nsCOMPtr<nsIDOMElement> element; > nsIDOMCSSStyleDeclaration *style; > nsString prop_value; > nsresult rv; > > rv = NS_STATIC_CAST(nsIDOMNode *, > N)->GetOwnerDocument(getter_AddRefs(doc)); > if( NS_SUCCEEDED(rv) && doc ) { > nsCOMPtr<nsIDOMDocumentView> dom_view = > do_QueryInterface(doc, &rv); > if( NS_SUCCEEDED(rv) && dom_view ) { > nsCOMPtr<nsIDOMAbstractView> abtract_view = 0; > rv = > dom_view->GetDefaultView(getter_AddRefs(abtract_view)); > if( NS_SUCCEEDED(rv) && abtract_view ) { > view = do_QueryInterface(abtract_view, > &rv); > element = > do_QueryInterface(NS_STATIC_CAST(nsIDOMNode *, N)); > if( NS_SUCCEEDED(rv) && view && element ) > { > rv = > view->GetComputedStyle(element, EmptyString(), &style); > if( NS_SUCCEEDED(rv) && style ) { > for(unsigned int i=0; > i<count; ++i) { > rv = > style->GetPropertyValue( > > NS_ConvertASCIItoUTF16(properties[i].c_str()), > > prop_value); > if( > NS_SUCCEEDED(rv) ) { > > values[i] = NS_ConvertUTF16toUTF8(prop_value).get(); > } > } > return OK; > } > } > } > } > } > > > Emil Wikström wrote: >> Hi all, >> >> How can I get DOM layout information from my embedded browser? >> >> I need stuff like with, height & offsets from document and elements. >> >> Thx >> /Emil >> >> _______________________________________________ dev-embedding mailing list [email protected] https://lists.mozilla.org/listinfo/dev-embedding
