Re: How get nsIView from a nsGenericElement
hap497 <[email protected]> Mon, 26 Apr 2010 11:57:25 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <e536e29c-8409-4d6d-a540-33e8b1612967@a27g2000prj.googlegroups.com> |
On Apr 26, 8:59 am, Smaug <[email protected]> wrote: > On 4/26/10 6:43 PM, hap497 wrote: > > > > > > > On Apr 25, 8:00 pm, Boris Zbarsky<[email protected]> wrote: > >> On 4/25/10 9:32 PM, hap497 wrote: > > >>> If I have a pointer to nsGenericElement, how can I get a nsIView of > >>> the element? > > >> Just based on the element, you can't. There may not be a view, or there > >> may be more than one. > > >> What are you actually trying to do? > > >> -Boris > > > I am trying to emulate an user click event on html element like > > anchor. So I am trying to call nsPresShell's HandleEvent method > > HandleEvent(nsIView* aView, nsGUIEvent* aEvent, > > nsEventStatus* aEventStatus); > >http://mxr.mozilla.org/mozilla1.9.1/source/layout/base/nsPresShell.cp... > > > Since my input is an nsGenericElement (an anchor), I need to get a > > nsIView to call this HandleEvent. > > > Thank you. > > Could you perhaps use trunk or 1.9.2 builds? > nsDOMWindowUtils::DispatchDOMEventViaPresShell might be useful for you. > It doesn't dispatch the event using PresShell::HandleEvent but > PresShell::HandleEventWithTarget. > > -Olli I see a method HandleEventWithTarget in 1.9.1, are they the same? http://mxr.mozilla.org/mozilla1.9.1/source/layout/base/nsPresShell.cpp#867 And how can I get nsIFrame from an nsGenericElement? I looked for it in http://mxr.mozilla.org/mozilla1.9.1/source/content/base/src/nsGenericElement.h There are 2 methods: GetPrimaryFrame(); and GetStyledFrame(); Which one should I use? Thank you.