diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 42147daba60b..80cfc2e46522 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -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); diff --git a/content/events/src/nsEventStateManager.h b/content/events/src/nsEventStateManager.h index 6da99a1e03d4..b6839292d8ee 100644 --- a/content/events/src/nsEventStateManager.h +++ b/content/events/src/nsEventStateManager.h @@ -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); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 2583f1ffdd22..a48557f084b3 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -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); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 3e7724cedea5..957248a72824 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -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(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(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(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(searchView->GetClientData()); + f = searchView->GetFrame(); if (f) { break; } diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 623bacb78f67..31821cbbf10e 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -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(aView->GetClientData()); } + static nsIFrame* GetFrameFor(nsIView *aView) { return aView->GetFrame(); } /** * GetScrollableFrameFor returns the scrollable frame for a scrolled frame diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index e1587dbbcc19..ad70512a0407 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2301,7 +2301,7 @@ nsPresContext::IsRootContentDocument() return true; } - nsIFrame* f = static_cast(view->GetClientData()); + nsIFrame* f = view->GetFrame(); return (f && f->PresContext()->IsChrome()); } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 6320f2a51ed5..12dd1016da07 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -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(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(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(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(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(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(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(activeShell); - nsIView* activeShellRootView = shell->GetViewManager()->GetRootView(); - frame = static_cast(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 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 vo = do_QueryInterface(shell); if (vo) { - nsIView* root = shell->GetViewManager()->GetRootView(); rv = static_cast(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(view->GetClientData()); + nsIFrame* frame = view->GetFrame(); if (!frame) return true; diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index 132d79225c9a..3849c9d6eef0 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -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. diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 62940d710cb6..b3ef2bb5109c 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -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 diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index c6e195abbc9a..985db0723469 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -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); diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index de2482616ef7..333a6b580c7d 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -107,7 +107,7 @@ GetDocumentFromView(nsIView* aView) { NS_PRECONDITION(aView, ""); - nsIFrame* f = static_cast(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(subdocView->GetClientData()); + return subdocView ? subdocView->GetFrame() : nsnull; } NS_IMETHODIMP @@ -287,9 +285,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsCOMPtr presShell = nsnull; - nsIFrame* subdocRootFrame = - static_cast(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(nextView->GetClientData()); + frame = nextView->GetFrame(); } if (frame) { nsIPresShell* ps = frame->PresContext()->PresShell(); diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 1966e80140a2..46c874572bc7 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -338,7 +338,7 @@ nsXULPopupManager::AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow) static nsMenuPopupFrame* GetPopupToMoveOrResize(nsIView* aView) { - nsIFrame *frame = static_cast(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(aView->GetClientData()); + nsIFrame *frame = aView->GetFrame(); if (!frame || frame->GetType() != nsGkAtoms::menuPopupFrame) return; diff --git a/view/public/nsIView.h b/view/public/nsIView.h index 0c1fc9575f08..6d4fe367d9d9 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -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 diff --git a/view/public/nsIViewObserver.h b/view/public/nsIViewObserver.h index 660958d09813..fb3045b2b871 100644 --- a/view/public/nsIViewObserver.h +++ b/view/public/nsIViewObserver.h @@ -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; diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 292e8a13350b..b214c68995a8 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -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); diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index c71be2405bac..721411bba813 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -955,7 +955,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, // destruction in, say, some JavaScript event handler. nsCOMPtr 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(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(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 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 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) diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 541ca8acdea8..07d1baf4577c 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -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