Discussion:
How get nsIView from a nsGenericElement
hap497
2010-04-26 01:32:59 UTC
Permalink
Hi,

If I have a pointer to nsGenericElement, how can I get a nsIView of
the element?
I have looked at nsGenericElement.h , but I can't find any method
which does it?
http://mxr.mozilla.org/mozilla1.9.1/source/content/base/src/nsGenericElement.h

Thank you.
Boris Zbarsky
2010-04-26 03:00:43 UTC
Permalink
Post by hap497
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
hap497
2010-04-26 15:43:14 UTC
Permalink
Post by hap497
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.cpp#908

Since my input is an nsGenericElement (an anchor), I need to get a
nsIView to call this HandleEvent.

Thank you.
Smaug
2010-04-26 15:59:12 UTC
Permalink
Post by hap497
Post by Boris Zbarsky
Post by hap497
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.cpp#908
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
hap497
2010-04-26 18:57:25 UTC
Permalink
Post by Smaug
Post by hap497
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.

Loading...