Bug 703260, part 1, remove view from eventstatemanager and presshell event handling, r=smaug,sr=roc

This commit is contained in:
Neil Deakin 2011-11-21 12:53:20 -05:00
parent 92135fd903
commit b15e9b4338
17 changed files with 102 additions and 162 deletions

View File

@ -68,8 +68,6 @@
#include "nsIDOMXULControlElement.h"
#include "nsINameSpaceManager.h"
#include "nsIBaseWindow.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsISelection.h"
#include "nsFrameSelection.h"
#include "nsIPrivateDOMEvent.h"
@ -1030,8 +1028,7 @@ nsresult
nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView)
nsEventStatus* aStatus)
{
NS_ENSURE_ARG_POINTER(aStatus);
NS_ENSURE_ARG(aPresContext);
@ -3029,8 +3026,7 @@ nsresult
nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView)
nsEventStatus* aStatus)
{
NS_ENSURE_ARG(aPresContext);
NS_ENSURE_ARG_POINTER(aStatus);

View File

@ -106,8 +106,7 @@ public:
nsresult PreHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView);
nsEventStatus* aStatus);
/* The PostHandleEvent method should contain all system processing which
* should occur conditionally based on DOM or frame processing. It should
@ -117,8 +116,7 @@ public:
nsresult PostHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView);
nsEventStatus* aStatus);
void NotifyDestroyPresContext(nsPresContext* aPresContext);
void SetPresContext(nsPresContext* aPresContext);

View File

@ -489,7 +489,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
return NS_ERROR_FAILURE;
status = nsEventStatus_eIgnore;
return vo->HandleEvent(view, &event, false, &status);
return vo->HandleEvent(view->GetFrame(), &event, false, &status);
}
return widget->DispatchEvent(&event, status);
}

View File

@ -510,9 +510,7 @@ nsLayoutUtils::GetCrossDocParentFrame(const nsIFrame* aFrame,
*aExtraOffset += v->GetPosition();
}
v = v->GetParent(); // subdocumentframe's view
if (!v)
return nsnull;
return static_cast<nsIFrame*>(v->GetClientData());
return v ? v->GetFrame() : nsnull;
}
// static
@ -753,16 +751,16 @@ nsIFrame* nsLayoutUtils::GetLastSibling(nsIFrame* aFrame) {
// static
nsIView*
nsLayoutUtils::FindSiblingViewFor(nsIView* aParentView, nsIFrame* aFrame) {
nsIFrame* parentViewFrame = static_cast<nsIFrame*>(aParentView->GetClientData());
nsIFrame* parentViewFrame = aParentView->GetFrame();
nsIContent* parentViewContent = parentViewFrame ? parentViewFrame->GetContent() : nsnull;
for (nsIView* insertBefore = aParentView->GetFirstChild(); insertBefore;
insertBefore = insertBefore->GetNextSibling()) {
nsIFrame* f = static_cast<nsIFrame*>(insertBefore->GetClientData());
nsIFrame* f = insertBefore->GetFrame();
if (!f) {
// this view could be some anonymous view attached to a meaningful parent
for (nsIView* searchView = insertBefore->GetParent(); searchView;
searchView = searchView->GetParent()) {
f = static_cast<nsIFrame*>(searchView->GetClientData());
f = searchView->GetFrame();
if (f) {
break;
}

View File

@ -342,8 +342,7 @@ public:
* @param aView is the view to return the root frame for
* @return the root frame for the view
*/
static nsIFrame* GetFrameFor(nsIView *aView)
{ return static_cast<nsIFrame*>(aView->GetClientData()); }
static nsIFrame* GetFrameFor(nsIView *aView) { return aView->GetFrame(); }
/**
* GetScrollableFrameFor returns the scrollable frame for a scrolled frame

View File

@ -2301,7 +2301,7 @@ nsPresContext::IsRootContentDocument()
return true;
}
nsIFrame* f = static_cast<nsIFrame*>(view->GetClientData());
nsIFrame* f = view->GetFrame();
return (f && f->PresContext()->IsChrome());
}

View File

@ -72,7 +72,8 @@
#include "nsINameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816)
#include "nsIServiceManager.h"
#include "nsFrame.h"
#include "nsIViewManager.h"
#include "nsViewManager.h"
#include "nsView.h"
#include "nsCRTGlue.h"
#include "prlog.h"
#include "prmem.h"
@ -5262,7 +5263,7 @@ static nsIView* FindFloatingViewContaining(nsIView* aView, nsPoint aPt)
// No need to look into descendants.
return nsnull;
nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* frame = aView->GetFrame();
if (frame) {
if (!frame->IsVisibleConsideringAncestors(nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY) ||
!frame->PresContext()->PresShell()->IsActive()) {
@ -5299,7 +5300,7 @@ static nsIView* FindViewContaining(nsIView* aView, nsPoint aPt)
return nsnull;
}
nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* frame = aView->GetFrame();
if (frame) {
if (!frame->IsVisibleConsideringAncestors(nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY) ||
!frame->PresContext()->PresShell()->IsActive()) {
@ -5374,7 +5375,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
viewAPD = APD;
} else {
pointVM = view->GetViewManager();
nsIFrame* frame = static_cast<nsIFrame*>(view->GetClientData());
nsIFrame* frame = view->GetFrame();
NS_ASSERTION(frame, "floating views can't be anonymous");
viewAPD = frame->PresContext()->AppUnitsPerDevPixel();
refpoint = mMouseLocation.ConvertAppUnits(APD, viewAPD);
@ -5424,8 +5425,7 @@ PresShell::Paint(nsIView* aViewToPaint,
nsPresContext* presContext = GetPresContext();
AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint);
nsIFrame* frame = aPaintDefaultBackground
? nsnull : static_cast<nsIFrame*>(aViewToPaint->GetClientData());
nsIFrame* frame = aPaintDefaultBackground ? nsnull : aViewToPaint->GetFrame();
bool isRetainingManager;
LayerManager* layerManager =
@ -5651,10 +5651,8 @@ PresShell::RetargetEventToParent(nsGUIEvent* aEvent,
return NS_ERROR_FAILURE;
}
// Fake the event as though it'ss from the parent pres shell's root view.
nsIView *parentRootView = parentPresShell->GetViewManager()->GetRootView();
return parentViewObserver->HandleEvent(parentRootView, aEvent, true, aEventStatus);
// Fake the event as though it's from the parent pres shell's root frame.
return parentViewObserver->HandleEvent(parentPresShell->GetRootFrame(), aEvent, true, aEventStatus);
}
void
@ -5727,12 +5725,12 @@ PresShell::RecordMouseLocation(nsGUIEvent* aEvent)
}
NS_IMETHODIMP
PresShell::HandleEvent(nsIView *aView,
PresShell::HandleEvent(nsIFrame *aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus)
{
NS_ASSERTION(aView, "null view");
NS_ASSERTION(aFrame, "null frame");
if (mIsDestroying ||
(sDisableNonTestMouseEvents && NS_IS_MOUSE_EVENT(aEvent) &&
@ -5748,7 +5746,7 @@ PresShell::HandleEvent(nsIView *aView,
// Accessibility events come through OS requests and not from scripts,
// so it is safe to handle here
return HandleEventInternal(aEvent, aView, aEventStatus);
return HandleEventInternal(aEvent, aEventStatus);
}
#endif
@ -5798,8 +5796,7 @@ PresShell::HandleEvent(nsIView *aView,
if (!viewObserver)
return NS_ERROR_FAILURE;
nsIView* view = presShell->GetViewManager()->GetRootView();
return viewObserver->HandleEvent(view, aEvent, true, aEventStatus);
return viewObserver->HandleEvent(presShell->GetRootFrame(), aEvent, true, aEventStatus);
}
}
}
@ -5821,20 +5818,10 @@ PresShell::HandleEvent(nsIView *aView,
// Check for a system color change up front, since the frame type is
// irrelevant
if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext) {
nsIViewManager* vm = GetViewManager();
if (vm) {
// Only dispatch system color change when the message originates from
// from the root views widget. This is necessary to prevent us from
// dispatching the SysColorChanged notification for each child window
// which may be redundant.
nsIView* view = vm->GetRootView();
if (view == aView) {
*aEventStatus = nsEventStatus_eConsumeDoDefault;
mPresContext->SysColorChanged();
return NS_OK;
}
}
if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext &&
aFrame == FrameManager()->GetRootFrame()) {
*aEventStatus = nsEventStatus_eConsumeDoDefault;
mPresContext->SysColorChanged();
return NS_OK;
}
@ -5852,28 +5839,8 @@ PresShell::HandleEvent(nsIView *aView,
return NS_OK;
}
nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* frame = aFrame;
bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
// if this event has no frame, we need to retarget it at a parent
// view that has a frame.
if (!frame &&
(dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) ||
NS_IS_IME_RELATED_EVENT(aEvent) ||
NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) ||
aEvent->message == NS_PLUGIN_ACTIVATE ||
aEvent->message == NS_PLUGIN_FOCUS)) {
nsIView* targetView = aView;
while (targetView && !targetView->GetClientData()) {
targetView = targetView->GetParent();
}
if (targetView) {
aView = targetView;
frame = static_cast<nsIFrame*>(aView->GetClientData());
}
}
if (dispatchUsingCoordinates) {
NS_WARN_IF_FALSE(frame, "Nothing to handle this event!");
if (!frame)
@ -5982,7 +5949,6 @@ PresShell::HandleEvent(nsIView *aView,
nsIFrame* capturingFrame = capturingContent->GetPrimaryFrame();
if (capturingFrame) {
frame = capturingFrame;
aView = frame->GetClosestView();
}
}
@ -6026,8 +5992,7 @@ PresShell::HandleEvent(nsIView *aView,
nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(),
shell->GetDocument())) {
shell = static_cast<PresShell*>(activeShell);
nsIView* activeShellRootView = shell->GetViewManager()->GetRootView();
frame = static_cast<nsIFrame*>(activeShellRootView->GetClientData());
frame = shell->GetRootFrame();
}
}
@ -6035,16 +6000,14 @@ PresShell::HandleEvent(nsIView *aView,
// Handle the event in the correct shell.
// Prevent deletion until we're done with event handling (bug 336582).
nsCOMPtr<nsIPresShell> kungFuDeathGrip(shell);
nsIView* subshellRootView = shell->GetViewManager()->GetRootView();
// We pass the subshell's root view as the view to start from. This is
// We pass the subshell's root frame as the frame to start from. This is
// the only correct alternative; if the event was captured then it
// must have been captured by us or some ancestor shell and we
// now ask the subshell to dispatch it normally.
return shell->HandlePositionedEvent(subshellRootView, frame,
aEvent, aEventStatus);
return shell->HandlePositionedEvent(frame, aEvent, aEventStatus);
}
return HandlePositionedEvent(aView, frame, aEvent, aEventStatus);
return HandlePositionedEvent(frame, aEvent, aEventStatus);
}
nsresult rv = NS_OK;
@ -6111,9 +6074,7 @@ PresShell::HandleEvent(nsIView *aView,
nsIPresShell* shell = targetDoc->GetShell();
nsCOMPtr<nsIViewObserver> vo = do_QueryInterface(shell);
if (vo) {
nsIView* root = shell->GetViewManager()->GetRootView();
rv = static_cast<PresShell*>(shell)->HandleRetargetedEvent(aEvent,
root,
aEventStatus,
eventTarget);
}
@ -6132,7 +6093,7 @@ PresShell::HandleEvent(nsIView *aView,
mCurrentEventFrame = frame;
}
if (GetCurrentEventFrame()) {
rv = HandleEventInternal(aEvent, aView, aEventStatus);
rv = HandleEventInternal(aEvent, aEventStatus);
}
#ifdef NS_DEBUG
@ -6145,7 +6106,7 @@ PresShell::HandleEvent(nsIView *aView,
if (!NS_EVENT_NEEDS_FRAME(aEvent)) {
mCurrentEventFrame = nsnull;
return HandleEventInternal(aEvent, aView, aEventStatus);
return HandleEventInternal(aEvent, aEventStatus);
}
else if (NS_IS_KEY_EVENT(aEvent)) {
// Keypress events in new blank tabs should not be completely thrown away.
@ -6176,8 +6137,7 @@ PresShell::ShowEventTargetDebug()
#endif
nsresult
PresShell::HandlePositionedEvent(nsIView* aView,
nsIFrame* aTargetFrame,
PresShell::HandlePositionedEvent(nsIFrame* aTargetFrame,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
@ -6219,7 +6179,7 @@ PresShell::HandlePositionedEvent(nsIView* aView,
}
if (GetCurrentEventFrame()) {
rv = HandleEventInternal(aEvent, aView, aEventStatus);
rv = HandleEventInternal(aEvent, aEventStatus);
}
#ifdef NS_DEBUG
@ -6234,7 +6194,7 @@ PresShell::HandleEventWithTarget(nsEvent* aEvent, nsIFrame* aFrame,
nsIContent* aContent, nsEventStatus* aStatus)
{
PushCurrentEventInfo(aFrame, aContent);
nsresult rv = HandleEventInternal(aEvent, nsnull, aStatus);
nsresult rv = HandleEventInternal(aEvent, aStatus);
PopCurrentEventInfo();
return rv;
}
@ -6323,8 +6283,7 @@ IsFullScreenAndRestrictedKeyEvent(nsIContent* aTarget, const nsEvent* aEvent)
}
nsresult
PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
nsEventStatus* aStatus)
PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
{
NS_TIME_FUNCTION_MIN(1.0);
@ -6443,11 +6402,9 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
// bug 329430
aEvent->target = nsnull;
nsWeakView weakView(aView);
// 1. Give event to event manager for pre event state changes and
// generation of synthetic events.
rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame,
aStatus, aView);
rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus);
// 2. Give event to the DOM for third party and JS use.
if (GetCurrentEventFrame() && NS_SUCCEEDED(rv)) {
@ -6486,8 +6443,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
// generation of synthetic events.
if (!mIsDestroying && NS_SUCCEEDED(rv)) {
rv = manager->PostHandleEvent(mPresContext, aEvent,
GetCurrentEventFrame(), aStatus,
weakView.GetView());
GetCurrentEventFrame(), aStatus);
}
}
@ -6972,7 +6928,7 @@ PresShell::IsVisible()
if (!view)
return true;
nsIFrame* frame = static_cast<nsIFrame*>(view->GetClientData());
nsIFrame* frame = view->GetFrame();
if (!frame)
return true;

View File

@ -320,7 +320,7 @@ public:
const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground,
bool aWillSendDidPaint);
NS_IMETHOD HandleEvent(nsIView* aView,
NS_IMETHOD HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus);
@ -605,14 +605,13 @@ protected:
}
}
nsresult HandleRetargetedEvent(nsEvent* aEvent, nsIView* aView,
nsEventStatus* aStatus, nsIContent* aTarget)
nsresult HandleRetargetedEvent(nsEvent* aEvent, nsEventStatus* aStatus, nsIContent* aTarget)
{
PushCurrentEventInfo(nsnull, nsnull);
mCurrentEventContent = aTarget;
nsresult rv = NS_OK;
if (GetCurrentEventFrame()) {
rv = HandleEventInternal(aEvent, aView, aStatus);
rv = HandleEventInternal(aEvent, aStatus);
}
PopCurrentEventInfo();
return rv;
@ -801,10 +800,8 @@ protected:
private:
void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
void PopCurrentEventInfo();
nsresult HandleEventInternal(nsEvent* aEvent, nsIView* aView,
nsEventStatus *aStatus);
nsresult HandlePositionedEvent(nsIView* aView,
nsIFrame* aTargetFrame,
nsresult HandleEventInternal(nsEvent* aEvent, nsEventStatus *aStatus);
nsresult HandlePositionedEvent(nsIFrame* aTargetFrame,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
// This returns the focused DOM window under our top level window.

View File

@ -245,7 +245,7 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
// Prevent event dispatch during destruction
if (HasView()) {
GetView()->SetClientData(nsnull);
GetView()->SetFrame(nsnull);
}
// Delete the primary child list

View File

@ -575,7 +575,7 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
if (view) {
// Break association between view and frame
view->SetClientData(nsnull);
view->SetFrame(nsnull);
// Destroy the view
view->Destroy();
@ -4049,7 +4049,7 @@ nsresult
nsIFrame::SetView(nsIView* aView)
{
if (aView) {
aView->SetClientData(this);
aView->SetFrame(this);
// Set a property on the frame
Properties().Set(ViewProperty(), aView);

View File

@ -107,7 +107,7 @@ GetDocumentFromView(nsIView* aView)
{
NS_PRECONDITION(aView, "");
nsIFrame* f = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* f = aView->GetFrame();
nsIPresShell* ps = f ? f->PresContext()->PresShell() : nsnull;
return ps ? ps->GetDocument() : nsnull;
}
@ -250,9 +250,7 @@ nsSubDocumentFrame::GetSubdocumentRootFrame()
if (!mInnerView)
return nsnull;
nsIView* subdocView = mInnerView->GetFirstChild();
if (!subdocView)
return nsnull;
return static_cast<nsIFrame*>(subdocView->GetClientData());
return subdocView ? subdocView->GetFrame() : nsnull;
}
NS_IMETHODIMP
@ -287,9 +285,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsCOMPtr<nsIPresShell> presShell = nsnull;
nsIFrame* subdocRootFrame =
static_cast<nsIFrame*>(subdocView->GetClientData());
nsIFrame* subdocRootFrame = subdocView->GetFrame();
if (subdocRootFrame) {
presShell = subdocRootFrame->PresContext()->PresShell();
}
@ -303,7 +299,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIView* nextView = subdocView->GetNextSibling();
nsIFrame* frame = nsnull;
if (nextView) {
frame = static_cast<nsIFrame*>(nextView->GetClientData());
frame = nextView->GetFrame();
}
if (frame) {
nsIPresShell* ps = frame->PresContext()->PresShell();

View File

@ -338,7 +338,7 @@ nsXULPopupManager::AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow)
static
nsMenuPopupFrame* GetPopupToMoveOrResize(nsIView* aView)
{
nsIFrame *frame = static_cast<nsIFrame *>(aView->GetClientData());
nsIFrame *frame = aView->GetFrame();
if (!frame || frame->GetType() != nsGkAtoms::menuPopupFrame)
return nsnull;
@ -1000,7 +1000,7 @@ nsXULPopupManager::HidePopupCallback(nsIContent* aPopup,
void
nsXULPopupManager::HidePopup(nsIView* aView)
{
nsIFrame *frame = static_cast<nsIFrame *>(aView->GetClientData());
nsIFrame *frame = aView->GetFrame();
if (!frame || frame->GetType() != nsGkAtoms::menuPopupFrame)
return;

View File

@ -45,6 +45,7 @@
#include "nsNativeWidget.h"
#include "nsIWidget.h"
#include "nsWidgetInitData.h"
#include "nsIFrame.h"
class nsIViewManager;
class nsViewManager;
@ -62,8 +63,8 @@ enum nsViewVisibility {
};
#define NS_IVIEW_IID \
{ 0x7caf32d2, 0xd82a, 0x4b9f, \
{ 0x84, 0xc1, 0xbd, 0x20, 0xeb, 0x5c, 0x78, 0x55 } }
{ 0xda62efbf, 0x0711, 0x4b79, \
{ 0x87, 0x85, 0x9e, 0xec, 0xed, 0xf5, 0xb0, 0x32 } }
// Public view flags
@ -251,16 +252,14 @@ public:
}
/**
* Set the view's link to client owned data.
* @param aData - data to associate with view. nsnull to disassociate
* Set the view's frame.
*/
void SetClientData(void *aData) { mClientData = aData; }
void SetFrame(nsIFrame* aRootFrame) { mFrame = aRootFrame; }
/**
* Query the view for it's link to client owned data.
* @result data associated with view or nsnull if there is none.
* Retrieve the view's frame.
*/
void* GetClientData() const { return mClientData; }
nsIFrame* GetFrame() const { return mFrame; }
/**
* Get the nearest widget in this view or a parent of this view and
@ -399,7 +398,7 @@ protected:
nsIWidget *mWindow;
nsView *mNextSibling;
nsView *mFirstChild;
void *mClientData;
nsIFrame *mFrame;
PRInt32 mZIndex;
nsViewVisibility mVis;
// position relative our parent view origin but in our appunits

View File

@ -50,8 +50,8 @@ class nsRegion;
class nsIntRegion;
#define NS_IVIEWOBSERVER_IID \
{ 0xac6eec35, 0x65d2, 0x4fe8, \
{ 0xa1, 0x37, 0x1a, 0xc3, 0xf6, 0x51, 0x52, 0x56 } }
{ 0x0d7ea18f, 0xc154, 0x4e25, \
{ 0x81, 0x0c, 0x5d, 0x60, 0x31, 0xd0, 0xac, 0xc3 } }
class nsIViewObserver : public nsISupports
{
@ -87,9 +87,8 @@ public:
bool aWillSendDidPaint) = 0;
/* called when the observer needs to handle an event
* @param aView - where to start processing the event; the root view,
* or the view that's currently capturing this sort of event; must be a view
* for this presshell
* @param aFrame - the frame of where to start processing the event;
* must be a frame for this presshell
* @param aEvent - event notification
* @param aEventStatus - out parameter for event handling
* status
@ -97,7 +96,7 @@ public:
* handle the event
* @return error status
*/
NS_IMETHOD HandleEvent(nsIView* aView,
NS_IMETHOD HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus) = 0;

View File

@ -983,8 +983,8 @@ void nsIView::List(FILE* out, PRInt32 aIndent) const
nsRect brect = GetBounds();
fprintf(out, "{%d,%d,%d,%d}",
brect.x, brect.y, brect.width, brect.height);
fprintf(out, " z=%d vis=%d clientData=%p <\n",
mZIndex, mVis, mClientData);
fprintf(out, " z=%d vis=%d frame=%p <\n",
mZIndex, mVis, mFrame);
for (nsView* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
NS_ASSERTION(kid->GetParent() == this, "incorrect parent");
kid->List(out, aIndent + 1);

View File

@ -955,7 +955,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
// destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIViewObserver> obs = GetViewObserver();
if (obs) {
obs->HandleEvent(aView, aEvent, false, aStatus);
obs->HandleEvent(aView->GetFrame(), aEvent, false, aStatus);
}
}
break;
@ -986,18 +986,40 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
}
}
//Find the view whose coordinates system we're in.
nsView* baseView = static_cast<nsView*>(aView);
nsView* view = baseView;
if (NS_IsEventUsingCoordinates(aEvent)) {
// will dispatch using coordinates. Pretty bogus but it's consistent
// Find the view whose coordinates system we're in.
nsIView* view = aView;
bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
if (dispatchUsingCoordinates) {
// Will dispatch using coordinates. Pretty bogus but it's consistent
// with what presshell does.
view = static_cast<nsView*>(GetDisplayRootFor(baseView));
view = GetDisplayRootFor(view);
}
// If the view has no frame, look for a view that does.
nsIFrame* frame = view->GetFrame();
if (!frame &&
(dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) ||
NS_IS_IME_RELATED_EVENT(aEvent) ||
NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) ||
aEvent->message == NS_PLUGIN_ACTIVATE ||
aEvent->message == NS_PLUGIN_FOCUS)) {
while (view && !view->GetFrame()) {
view = view->GetParent();
}
if (view) {
frame = view->GetFrame();
}
}
if (nsnull != view) {
*aStatus = HandleEvent(view, aEvent);
if (nsnull != frame) {
// Hold a refcount to the presshell. The continued existence of the
// presshell will delay deletion of this view hierarchy should the event
// want to cause its destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIViewObserver> obs = view->GetViewManager()->GetViewObserver();
if (obs) {
obs->HandleEvent(frame, aEvent, false, aStatus);
}
}
break;
@ -1007,24 +1029,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
return NS_OK;
}
nsEventStatus nsViewManager::HandleEvent(nsView* aView, nsGUIEvent* aEvent)
{
#if 0
printf(" %d %d %d %d (%d,%d) \n", this, event->widget, event->widgetSupports,
event->message, event->point.x, event->point.y);
#endif
// Hold a refcount to the observer. The continued existence of the observer will
// delay deletion of this view hierarchy should the event want to cause its
// destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIViewObserver> obs = aView->GetViewManager()->GetViewObserver();
nsEventStatus status = nsEventStatus_eIgnore;
if (obs) {
obs->HandleEvent(aView, aEvent, false, &status);
}
return status;
}
// Recursively reparent widgets if necessary
void nsViewManager::ReparentChildWidgets(nsIView* aView, nsIWidget *aNewWidget)

View File

@ -244,8 +244,6 @@ public: // NOT in nsIViewManager, so private to the view module
nsViewManager* RootViewManager() const { return mRootViewManager; }
bool IsRootVM() const { return this == RootViewManager(); }
nsEventStatus HandleEvent(nsView* aView, nsGUIEvent* aEvent);
bool IsRefreshEnabled() { return RootViewManager()->mUpdateBatchCnt == 0; }
// Call this when you need to let the viewmanager know that it now has