Boris Zbarsky wrote:
Niky Williams wrote:
I realize by doing it this way in a timer thread, and not within the actual Gecko event loop, that it's probably not exactly thread safe...

It's not at all threadsafe.

but I don't believe it would be causing this issue

It sure could.

> Is there a possible leak with nsIDOMCSSStyleDeclaration::GetPropertyValue
()

Also possible, but I haven't run into it before.

What does your actual code look like?

-Boris


Code is below. I came across something just recently. Using the nsIDOMNSDocument::GetBoxObjectFor (), I could possibly get and set the same things I'm needing.

bool GetDOMElementBounds (char szElementID[], nsIWebBrowserChrome *pwbc, nsIDOMElement **ppde, int &iLeft, int &iTop, int &iWidth, int &iHeight)
{
        //Temp vars
        nsCOMPtr<nsIWebBrowser> pCOM_wb;
        nsCOMPtr<nsIDOMWindow> pCOM_dw;
        nsCOMPtr<nsIDOMDocument> pCOM_dd;
        nsCOMPtr<nsIDOMElement> pCOM_de;
        nsString sElementID;    


        nsCOMPtr<nsIDOMDocument> pCOM_ddElement;
        nsCOMPtr<nsIDOMDocumentView> pCOM_ddv;
        nsCOMPtr<nsIDOMAbstractView> pCOM_dav;
        nsCOMPtr<nsIDOMViewCSS> pCOM_dvc;
        nsCOMPtr<nsIDOMCSSStyleDeclaration> pCOM_dcsd;
                
        nsString sValue;
        char szValue[128];
        char *p = NULL;

        //For conversion
        sElementID.AssignWithConversion (szElementID);

        //Getting the browser
        ScData.pCOM_wbcScreens->GetWebBrowser (getter_AddRefs (pCOM_wb));
        if (!pCOM_wb)
        {
                return (false);
        }

        //Getting the DOM window now
        pCOM_wb->GetContentDOMWindow (getter_AddRefs (pCOM_dw));
        if (!pCOM_dw)
        {
                return (false);
        }

        //Now the document
        pCOM_dw->GetDocument (getter_AddRefs (pCOM_dd));
        if (!pCOM_dd)
        {
                return (false);
        }

        //Now the scroller and the scroller message
        pCOM_dd->GetElementById (sElementID, getter_AddRefs (pCOM_de));      
        if (!pCOM_de)
        {
                return (false);
        }

        //Setting the return value here
        *ppde = pCOM_de;
        (*ppde)->AddRef ();          

        //Getting owner document
        pCOM_de->GetOwnerDocument (getter_AddRefs (pCOM_ddElement));
        //Making sure we got this
        if (!pCOM_dd)
        {
                return (false);
        }

        //Getting the view here
        pCOM_ddv = do_QueryInterface (pCOM_ddElement);
        //Making sure we got this
        if (!pCOM_ddv)
        {
                return (false);
        }

        //Getting DOM view
        pCOM_ddv->GetDefaultView (getter_AddRefs (pCOM_dav));
        //Making sure we got this
        if (!pCOM_dav)
        {
                return (false);
        }

        //Getting the view CSS
        pCOM_dvc = do_QueryInterface (pCOM_dav);
        //Making sure we got this
        if (!pCOM_dvc)
        {
                return (false);
        }

        //Getting css style
pCOM_dvc->GetComputedStyle (pCOM_de, EmptyString (), getter_AddRefs (pCOM_dcsd));
        if (!pCOM_dcsd)
        {
                return (false);
        }
                
        //Getting various attributes    
        //********IF I COMMENT THIS AND BELOW, NO MEM LEAK ISSUES*******
        pCOM_dcsd->GetPropertyValue (nsString (L"left"), sValue);  
        wcstombs (szValue, sValue.get (), sValue.Length () + 1);
        (p = strstr (szValue, "px")) != NULL ? p[0] = NULL : false;           
        iLeft = CString (szValue).Numeric ();

        pCOM_dcsd->GetPropertyValue (nsString (L"top"), sValue);
        wcstombs (szValue, sValue.get (), sValue.Length () + 1);
        (p = strstr (szValue, "px")) != NULL ? p[0] = NULL : false;   
        iTop = CString (szValue).Numeric ();

        pCOM_dcsd->GetPropertyValue (nsString (L"width"), sValue);
        wcstombs (szValue, sValue.get (), sValue.Length () + 1);
        (p = strstr (szValue, "px")) != NULL ? p[0] = NULL : false;   
        iWidth = CString (szValue).Numeric ();

        pCOM_dcsd->GetPropertyValue (nsString (L"height"), sValue);
        wcstombs (szValue, sValue.get (), sValue.Length () + 1);
        (p = strstr (szValue, "px")) != NULL ? p[0] = NULL : false;   
        iHeight = CString (szValue).Numeric ();

        return (true);
}
_______________________________________________
mozilla-embedding mailing list
mozilla-embedding@mozilla.org
http://mail.mozilla.org/listinfo/mozilla-embedding

Reply via email to