Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #17 0x00007ffd712eeaed in nsWindow::DispatchEvent (this=0x7ffd5cb37600, aEvent=0x7fff47ee2ce0, aStatus=@0x7fff47ee2d6c)
- at /home/diogogmt/mozilla-central-diogogmt/widget/gtk2/nsWindow.cpp:575
- 563 nsresult
- 564 nsWindow::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus)
- 565 {
- 566 #ifdef DEBUG
- 567 debug_DumpEvent(stdout, aEvent->widget, aEvent,
- 568 nsCAutoString("something"), 0);
- 569 #endif
- 570
- 571 aStatus = nsEventStatus_eIgnore;
- 572
- 573 // send it to the standard callback
- 574 if (mEventCallback)
- 575 aStatus = (* mEventCallback)(aEvent);
- 576
- 577 return NS_OK;
- 578 }
- #16 0x00007ffd708e2672 in HandleEvent (aEvent=0x7fff47ee2ce0) at /home/diogogmt/mozilla-central-diogogmt/view/src/nsView.cpp:158
- 146 // Main events handler
- 147 static nsEventStatus HandleEvent(nsGUIEvent *aEvent)
- 148 {
- 149 #if 0
- 150 printf(" %d %d %d (%d,%d) \n", aEvent->widget, aEvent->message);
- 151 #endif
- 152 nsEventStatus result = nsEventStatus_eIgnore;
- 153 nsView *view = nsView::GetViewFor(aEvent->widget);
- 154
- 155 if (view)
- 156 {
- 157 nsCOMPtr<nsIViewManager> vm = view->GetViewManager();
- 158 vm->DispatchEvent(aEvent, view, &result);
- 159 }
- 160
- 161 return result;
- 162 }
- #15 0x00007ffd708e871d in nsViewManager::DispatchEvent (this=0x7ffd5cba8bf0, aEvent=0x7fff47ee2ce0, aView=0x7ffd5cb77600, aStatus=0x7fff47ee2c14)
- at /home/diogogmt/mozilla-central-diogogmt/view/src/nsViewManager.cpp:908
- 652 NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
- 653 nsIView* aView, nsEventStatus *aStatus)
- 654 {
- 655 NS_ASSERTION(!aView || static_cast<nsView*>(aView)->GetViewManager() == this,
- 656 "wrong view manager");
- 657
- 658 SAMPLE_LABEL("event", "nsViewManager::DispatchEvent");
- 659
- 660 *aStatus = nsEventStatus_eIgnore;
- 661
- 662 switch(aEvent->message)
- 663 {
- 664 case NS_SIZE:
- 665 {
- 666 if (aView)
- 667 {
- 668 // client area dimensions are set on the view
- 669 nscoord width = ((nsSizeEvent*)aEvent)->windowSize->width;
- 670 nscoord height = ((nsSizeEvent*)aEvent)->windowSize->height;
- 671
- 672 // The root view may not be set if this is the resize associated with
- 673 // window creation
- 674
- 675 if (aView == mRootView)
- 676 {
- 677 PRInt32 p2a = AppUnitsPerDevPixel();
- 678 SetWindowDimensions(NSIntPixelsToAppUnits(width, p2a),
- 679 NSIntPixelsToAppUnits(height, p2a));
- 680 *aStatus = nsEventStatus_eConsumeNoDefault;
- 681 }
- 682 else if (IsViewForPopup(aView))
- 683 {
- 684 nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
- 685 if (pm)
- 686 {
- 687 pm->PopupResized(aView->GetFrame(), nsIntSize(width, height));
- 688 *aStatus = nsEventStatus_eConsumeNoDefault;
- 689 }
- 690 }
- 691 }
- 692 }
- 693
- 694 break;
- 695
- 696 case NS_MOVE:
- 697 {
- 698 // A popup's parent view is the root view for the parent window, so when
- 699 // a popup moves, the popup's frame and view position must be updated
- 700 // to match.
- 701 if (aView && IsViewForPopup(aView))
- 702 {
- 703 nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
- 704 if (pm)
- 705 {
- 706 pm->PopupMoved(aView->GetFrame(), aEvent->refPoint);
- 707 *aStatus = nsEventStatus_eConsumeNoDefault;
- 708 }
- 709 }
- 710 break;
- 711 }
- 712
- 713 case NS_DONESIZEMOVE:
- 714 {
- 715 if (mPresShell) {
- 716 nsPresContext* presContext = mPresShell->GetPresContext();
- 717 if (presContext) {
- 718 nsEventStateManager::ClearGlobalActiveContent(nsnull);
- 719 }
- 720
- 721 }
- 722
- 723 nsIPresShell::ClearMouseCapture(nsnull);
- 724 }
- 725 break;
- 726
- 727 case NS_XUL_CLOSE:
- 728 {
- 729 // if this is a popup, make a request to hide it. Note that a popuphidden
- 730 // event listener may cancel the event and the popup will not be hidden.
- 731 nsIWidget* widget = aView->GetWidget();
- 732 if (widget) {
- 733 nsWindowType type;
- 734 widget->GetWindowType(type);
- 735 if (type == eWindowType_popup) {
- 736 nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
- 737 if (pm) {
- 738 pm->HidePopup(aView->GetFrame());
- 739 *aStatus = nsEventStatus_eConsumeNoDefault;
- 740 }
- 741 }
- 742 }
- 743 }
- 744 break;
- 745
- 746 case NS_WILL_PAINT:
- 747 {
- 748 if (!aView || !mContext)
- 749 break;
- 750
- 751 *aStatus = nsEventStatus_eConsumeNoDefault;
- 752
- 753 nsPaintEvent *event = static_cast<nsPaintEvent*>(aEvent);
- 754
- 755 NS_ASSERTION(static_cast<nsView*>(aView) ==
- 756 nsView::GetViewFor(event->widget),
- 757 "view/widget mismatch");
- 758
- 759 // If an ancestor widget was hidden and then shown, we could
- 760 // have a delayed resize to handle.
- 761 for (nsViewManager *vm = this; vm;
- 762 vm = vm->mRootView->GetParent()
- 763 ? vm->mRootView->GetParent()->GetViewManager()
- 764 : nsnull) {
- 765 if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
- 766 vm->mRootView->IsEffectivelyVisible() &&
- 767 mPresShell && mPresShell->IsVisible()) {
- 768 vm->FlushDelayedResize(true);
- 769 vm->InvalidateView(vm->mRootView);
- 770 }
- 771 }
- 772
- 773 // Flush things like reflows and plugin widget geometry updates by
- 774 // calling WillPaint on observer presShells.
- 775 nsRefPtr<nsViewManager> rootVM = RootViewManager();
- 776 if (mPresShell) {
- 777 rootVM->CallWillPaintOnObservers(event->willSendDidPaint);
- 778 }
- 779 // Flush view widget geometry updates and invalidations.
- 780 rootVM->ProcessPendingUpdates();
- 781 }
- 782 break;
- 783
- 784 case NS_PAINT:
- 785 {
- 786 if (!aView || !mContext)
- 787 break;
- 788
- 789 *aStatus = nsEventStatus_eConsumeNoDefault;
- 790 nsPaintEvent *event = static_cast<nsPaintEvent*>(aEvent);
- 791 nsView* view = static_cast<nsView*>(aView);
- 792 NS_ASSERTION(view == nsView::GetViewFor(event->widget),
- 793 "view/widget mismatch");
- 794 NS_ASSERTION(IsPaintingAllowed(),
- 795 "shouldn't be receiving paint events while painting is "
- 796 "disallowed!");
- 797
- 798 if (!event->didSendWillPaint) {
- 799 // Send NS_WILL_PAINT event ourselves.
- 800 nsPaintEvent willPaintEvent(true, NS_WILL_PAINT, event->widget);
- 801 willPaintEvent.willSendDidPaint = event->willSendDidPaint;
- 802 DispatchEvent(&willPaintEvent, view, aStatus);
- 803
- 804 // Get the view pointer again since NS_WILL_PAINT might have
- 805 // destroyed it during CallWillPaintOnObservers (bug 378273).
- 806 view = nsView::GetViewFor(event->widget);
- 807 }
- 808
- 809 if (!view || event->region.IsEmpty())
- 810 break;
- 811
- 812 // Paint.
- 813 Refresh(view, event->widget, event->region, event->willSendDidPaint);
- 814
- 815 break;
- 816 }
- 817
- 818 case NS_DID_PAINT: {
- 819 nsRefPtr<nsViewManager> rootVM = RootViewManager();
- 820 rootVM->CallDidPaintOnObserver();
- 821 break;
- 822 }
- 823
- 824 case NS_CREATE:
- 825 case NS_DESTROY:
- 826 case NS_SETZLEVEL:
- 827 /* Don't pass these events through. Passing them through
- 828 causes performance problems on pages with lots of views/frames
- 829 @see bug 112861 */
- 830 *aStatus = nsEventStatus_eConsumeNoDefault;
- 831 break;
- 832
- 833 case NS_DISPLAYCHANGED:
- 834
- 835 //Destroy the cached backbuffer to force a new backbuffer
- 836 //be constructed with the appropriate display depth.
- 837 //@see bugzilla bug 6061
- 838 *aStatus = nsEventStatus_eConsumeDoDefault;
- 839 break;
- 840
- 841 case NS_SYSCOLORCHANGED:
- 842 {
- 843 if (mPresShell) {
- 844 // Hold a refcount to the presshell. The continued existence of the observer will
- 845 // delay deletion of this view hierarchy should the event want to cause its
- 846 // destruction in, say, some JavaScript event handler.
- 847 nsCOMPtr<nsIPresShell> presShell = mPresShell;
- 848 presShell->HandleEvent(aView->GetFrame(), aEvent, false, aStatus);
- 849 }
- 850 }
- 851 break;
- 852
- 853 default:
- 854 {
- 855 if ((NS_IS_MOUSE_EVENT(aEvent) &&
- 856 // Ignore mouse events that we synthesize.
- 857 static_cast<nsMouseEvent*>(aEvent)->reason ==
- 858 nsMouseEvent::eReal &&
- 859 // Ignore mouse exit and enter (we'll get moves if the user
- 860 // is really moving the mouse) since we get them when we
- 861 // create and destroy widgets.
- 862 aEvent->message != NS_MOUSE_EXIT &&
- 863 aEvent->message != NS_MOUSE_ENTER) ||
- 864 NS_IS_KEY_EVENT(aEvent) ||
- 865 NS_IS_IME_EVENT(aEvent) ||
- 866 aEvent->message == NS_PLUGIN_INPUT_EVENT) {
- 867 gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow());
- 868 }
- 869
- 870 if (aEvent->message == NS_DEACTIVATE) {
- 871 // if a window is deactivated, clear the mouse capture regardless
- 872 // of what is capturing
- 873 nsIPresShell::ClearMouseCapture(nsnull);
- 874 }
- 875
- 876 // Find the view whose coordinates system we're in.
- 877 nsIView* view = aView;
- 878 bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
- 879 if (dispatchUsingCoordinates) {
- 880 // Will dispatch using coordinates. Pretty bogus but it's consistent
- 881 // with what presshell does.
- 882 view = GetDisplayRootFor(view);
- 883 }
- 884
- 885 // If the view has no frame, look for a view that does.
- 886 nsIFrame* frame = view->GetFrame();
- 887 if (!frame &&
- 888 (dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) ||
- 889 NS_IS_IME_RELATED_EVENT(aEvent) ||
- 890 NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) ||
- 891 aEvent->message == NS_PLUGIN_ACTIVATE ||
- 892 aEvent->message == NS_PLUGIN_FOCUS)) {
- 893 while (view && !view->GetFrame()) {
- 894 view = view->GetParent();
- 895 }
- 896
- 897 if (view) {
- 898 frame = view->GetFrame();
- 899 }
- 900 }
- 901
- 902 if (nsnull != frame) {
- 903 // Hold a refcount to the presshell. The continued existence of the
- 904 // presshell will delay deletion of this view hierarchy should the event
- 905 // want to cause its destruction in, say, some JavaScript event handler.
- 906 nsCOMPtr<nsIPresShell> shell = view->GetViewManager()->GetPresShell();
- 907 if (shell) {
- 908 shell->HandleEvent(frame, aEvent, false, aStatus);
- 909 }
- 910 }
- 911
- 912 break;
- 913 }
- 914 }
- 915
- 916 return NS_OK;
- 917 }
- #14 0x00007ffd7021c9ca in PresShell::HandleEvent (this=0x7ffd5cb5a000, aFrame=0x7ffd5d52bc38, aEvent=0x7fff47ee2ce0, aDontRetargetEvents=false,
- aEventStatus=0x7fff47ee2c14) at /home/diogogmt/mozilla-central-diogogmt/layout/base/nsPresShell.cpp:6151
- 5800 nsresult
- 5801 PresShell::HandleEvent(nsIFrame *aFrame,
- 5802 nsGUIEvent* aEvent,
- 5803 bool aDontRetargetEvents,
- 5804 nsEventStatus* aEventStatus)
- 5805 {
- 5806 NS_ASSERTION(aFrame, "null frame");
- 5807
- 5808 if (mIsDestroying ||
- 5809 (sDisableNonTestMouseEvents && NS_IS_MOUSE_EVENT(aEvent) &&
- 5810 !(aEvent->flags & NS_EVENT_FLAG_SYNTHETIC_TEST_EVENT))) {
- 5811 return NS_OK;
- 5812 }
- 5813
- 5814 RecordMouseLocation(aEvent);
- 5815
- 5816 #ifdef ACCESSIBILITY
- 5817 if (aEvent->eventStructType == NS_ACCESSIBLE_EVENT) {
- 5818 NS_TIME_FUNCTION_MIN(1.0);
- 5819
- 5820 // Accessibility events come through OS requests and not from scripts,
- 5821 // so it is safe to handle here
- 5822 return HandleEventInternal(aEvent, aEventStatus);
- 5823 }
- 5824 #endif
- 5825
- 5826 if (!nsContentUtils::IsSafeToRunScript())
- 5827 return NS_OK;
- 5828
- 5829 NS_TIME_FUNCTION_MIN(1.0);
- 5830
- 5831 nsIContent* capturingContent =
- 5832 NS_IS_MOUSE_EVENT(aEvent) ? GetCapturingContent() : nsnull;
- 5833
- 5834 nsCOMPtr<nsIDocument> retargetEventDoc;
- 5835 if (!aDontRetargetEvents) {
- 5836 // key and IME related events should not cross top level window boundary.
- 5837 // Basically, such input events should be fired only on focused widget.
- 5838 // However, some IMEs might need to clean up composition after focused
- 5839 // window is deactivated. And also some tests on MozMill want to test key
- 5840 // handling on deactivated window because MozMill window can be activated
- 5841 // during tests. So, there is no merit the events should be redirected to
- 5842 // active window. So, the events should be handled on the last focused
- 5843 // content in the last focused DOM window in same top level window.
- 5844 // Note, if no DOM window has been focused yet, we can discard the events.
- 5845 if (NS_IsEventTargetedAtFocusedWindow(aEvent)) {
- 5846 nsCOMPtr<nsPIDOMWindow> window = GetFocusedDOMWindowInOurWindow();
- 5847 // No DOM window in same top level window has not been focused yet,
- 5848 // discard the events.
- 5849 if (!window) {
- 5850 return NS_OK;
- 5851 }
- 5852
- 5853 retargetEventDoc = do_QueryInterface(window->GetExtantDocument());
- 5854 if (!retargetEventDoc)
- 5855 return NS_OK;
- 5856 } else if (capturingContent) {
- 5857 // if the mouse is being captured then retarget the mouse event at the
- 5858 // document that is being captured.
- 5859 retargetEventDoc = capturingContent->GetCurrentDoc();
- 5860 }
- 5861
- 5862 if (retargetEventDoc) {
- 5863 nsCOMPtr<nsIPresShell> presShell = retargetEventDoc->GetShell();
- 5864 if (!presShell)
- 5865 return NS_OK;
- 5866
- 5867 if (presShell != this) {
- 5868 nsIFrame* frame = presShell->GetRootFrame();
- 5869 if (!frame) {
- 5870 if (aEvent->message == NS_QUERY_TEXT_CONTENT ||
- 5871 NS_IS_CONTENT_COMMAND_EVENT(aEvent)) {
- 5872 return NS_OK;
- 5873 }
- 5874
- 5875 nsIView* view = presShell->GetViewManager()->GetRootView();
- 5876 while (view && !view->GetFrame()) {
- 5877 view = view->GetParent();
- 5878 }
- 5879
- 5880 if (view) {
- 5881 frame = view->GetFrame();
- 5882 }
- 5883 }
- 5884
- 5885 if (!frame)
- 5886 return NS_OK;
- 5887
- 5888 nsCOMPtr<nsIPresShell> shell = frame->PresContext()->GetPresShell();
- 5889 return shell->HandleEvent(frame, aEvent, true, aEventStatus);
- 5890 }
- 5891 }
- 5892 }
- 5893
- 5894 // Check for a theme change up front, since the frame type is irrelevant
- 5895 if (aEvent->message == NS_THEMECHANGED && mPresContext) {
- 5896 mPresContext->ThemeChanged();
- 5897 return NS_OK;
- 5898 }
- 5899
- 5900 if (aEvent->message == NS_UISTATECHANGED && mDocument) {
- 5901 nsPIDOMWindow* win = mDocument->GetWindow();
- 5902 if (win) {
- 5903 nsUIStateChangeEvent* event = (nsUIStateChangeEvent*)aEvent;
- 5904 win->SetKeyboardIndicators(event->showAccelerators, event->showFocusRings);
- 5905 }
- 5906 return NS_OK;
- 5907 }
- 5908
- 5909 // Check for a system color change up front, since the frame type is
- 5910 // irrelevant
- 5911 if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext &&
- 5912 aFrame == FrameManager()->GetRootFrame()) {
- 5913 *aEventStatus = nsEventStatus_eConsumeDoDefault;
- 5914 mPresContext->SysColorChanged();
- 5915 return NS_OK;
- 5916 }
- 5917
- 5918 if (aEvent->eventStructType == NS_KEY_EVENT &&
- 5919 mDocument && mDocument->EventHandlingSuppressed()) {
- 5920 if (aEvent->message == NS_KEY_DOWN) {
- 5921 mNoDelayedKeyEvents = true;
- 5922 } else if (!mNoDelayedKeyEvents) {
- 5923 nsDelayedEvent* event =
- 5924 new nsDelayedKeyEvent(static_cast<nsKeyEvent*>(aEvent));
- 5925 if (!mDelayedEvents.AppendElement(event)) {
- 5926 delete event;
- 5927 }
- 5928 }
- 5929 return NS_OK;
- 5930 }
- 5931
- 5932 nsIFrame* frame = aFrame;
- 5933 bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
- 5934 if (dispatchUsingCoordinates) {
- 5935 NS_WARN_IF_FALSE(frame, "Nothing to handle this event!");
- 5936 if (!frame)
- 5937 return NS_OK;
- 5938
- 5939 nsPresContext* framePresContext = frame->PresContext();
- 5940 nsPresContext* rootPresContext = framePresContext->GetRootPresContext();
- 5941 NS_ASSERTION(rootPresContext == mPresContext->GetRootPresContext(),
- 5942 "How did we end up outside the connected prescontext/viewmanager hierarchy?");
- 5943 // If we aren't starting our event dispatch from the root frame of the root prescontext,
- 5944 // then someone must be capturing the mouse. In that case we don't want to search the popup
- 5945 // list.
- 5946 if (framePresContext == rootPresContext &&
- 5947 frame == FrameManager()->GetRootFrame()) {
- 5948 nsIFrame* popupFrame =
- 5949 nsLayoutUtils::GetPopupFrameForEventCoordinates(rootPresContext, aEvent);
- 5950 // If the popupFrame is an ancestor of the 'frame', the frame should
- 5951 // handle the event, otherwise, the popup should handle it.
- 5952 if (popupFrame &&
- 5953 !nsContentUtils::ContentIsCrossDocDescendantOf(
- 5954 framePresContext->GetPresShell()->GetDocument(),
- 5955 popupFrame->GetContent())) {
- 5956 frame = popupFrame;
- 5957 }
- 5958 }
- 5959
- 5960 bool captureRetarget = false;
- 5961 if (capturingContent) {
- 5962 // If a capture is active, determine if the docshell is visible. If not,
- 5963 // clear the capture and target the mouse event normally instead. This
- 5964 // would occur if the mouse button is held down while a tab change occurs.
- 5965 // If the docshell is visible, look for a scrolling container.
- 5966 bool vis;
- 5967 nsCOMPtr<nsISupports> supports = mPresContext->GetContainer();
- 5968 nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supports));
- 5969 if (baseWin && NS_SUCCEEDED(baseWin->GetVisibility(&vis)) && vis) {
- 5970 captureRetarget = gCaptureInfo.mRetargetToElement;
- 5971 if (!captureRetarget) {
- 5972 // A check was already done above to ensure that capturingContent is
- 5973 // in this presshell.
- 5974 NS_ASSERTION(capturingContent->GetCurrentDoc() == GetDocument(),
- 5975 "Unexpected document");
- 5976 nsIFrame* captureFrame = capturingContent->GetPrimaryFrame();
- 5977 if (captureFrame) {
- 5978 if (capturingContent->Tag() == nsGkAtoms::select &&
- 5979 capturingContent->IsHTML()) {
- 5980 // a dropdown <select> has a child in its selectPopupList and we should
- 5981 // capture on that instead.
- 5982 nsIFrame* childFrame = captureFrame->GetChildList(nsIFrame::kSelectPopupList).FirstChild();
- 5983 if (childFrame) {
- 5984 captureFrame = childFrame;
- 5985 }
- 5986 }
- 5987
- 5988 // scrollable frames should use the scrolling container as
- 5989 // the root instead of the document
- 5990 nsIScrollableFrame* scrollFrame = do_QueryFrame(captureFrame);
- 5991 if (scrollFrame) {
- 5992 frame = scrollFrame->GetScrolledFrame();
- 5993 }
- 5994 }
- 5995 }
- 5996 }
- 5997 else {
- 5998 ClearMouseCapture(nsnull);
- 5999 capturingContent = nsnull;
- 6000 }
- 6001 }
- 6002
- 6003 bool isWindowLevelMouseExit = (aEvent->message == NS_MOUSE_EXIT) &&
- 6004 (static_cast<nsMouseEvent*>(aEvent)->exit == nsMouseEvent::eTopLevel);
- 6005
- 6006 // Get the frame at the event point. However, don't do this if we're
- 6007 // capturing and retargeting the event because the captured frame will
- 6008 // be used instead below. Also keep using the root frame if we're dealing
- 6009 // with a window-level mouse exit event since we want to start sending
- 6010 // mouse out events at the root EventStateManager.
- 6011 if (!captureRetarget && !isWindowLevelMouseExit) {
- 6012 #ifdef MOZ_TOUCH
- 6013 nsPoint eventPoint;
- 6014 if (aEvent->message == NS_TOUCH_START) {
- 6015 // Add any new touches to the queue
- 6016 nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
- 6017 // if there is only one touch in this touchstart event, assume that it is
- 6018 // the start of a new touch session and evict any old touches in the
- 6019 // queue
- 6020 if (touchEvent->touches.Length() == 1) {
- 6021 nsTArray<nsCOMPtr<nsIDOMTouch> > touches;
- 6022 gCaptureTouchList.Enumerate(&AppendToTouchList, (void *)&touches);
- 6023 for (PRUint32 i = 0; i < touches.Length(); ++i) {
- 6024 EvictTouchPoint(touches[i]);
- 6025 }
- 6026 }
- 6027 for (PRUint32 i = 0; i < touchEvent->touches.Length(); ++i) {
- 6028 nsIDOMTouch *touch = touchEvent->touches[i];
- 6029 nsDOMTouch *domtouch = static_cast<nsDOMTouch*>(touch);
- 6030 touch->mMessage = aEvent->message;
- 6031
- 6032 PRInt32 id = 0;
- 6033 touch->GetIdentifier(&id);
- 6034 if (!gCaptureTouchList.Get(id, nsnull)) {
- 6035 // This event is a new touch. Mark it as a changedTouch and
- 6036 // add it to the queue.
- 6037 touch->mChanged = true;
- 6038 gCaptureTouchList.Put(id, touch);
- 6039
- 6040 eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, touch->mRefPoint, frame);
- 6041 } else {
- 6042 // This touch is an old touch, we need to ensure that is not
- 6043 // marked as changed and set its target correctly
- 6044 touch->mChanged = false;
- 6045 PRInt32 id;
- 6046 touch->GetIdentifier(&id);
- 6047
- 6048 nsCOMPtr<nsIDOMTouch> oldTouch;
- 6049 gCaptureTouchList.Get(id, getter_AddRefs(oldTouch));
- 6050 if (oldTouch) {
- 6051 nsCOMPtr<nsPIDOMEventTarget> targetPtr;
- 6052 oldTouch->GetTarget(getter_AddRefs(targetPtr));
- 6053 domtouch->SetTarget(targetPtr);
- 6054 gCaptureTouchList.Put(id, touch);
- 6055 }
- 6056 }
- 6057 }
- 6058 } else {
- 6059 eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
- 6060 }
- 6061 #else
- 6062 nsPoint eventPoint
- 6063 = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
- 6064 #endif
- 6065 {
- 6066 bool ignoreRootScrollFrame = false;
- 6067 if (aEvent->eventStructType == NS_MOUSE_EVENT) {
- 6068 ignoreRootScrollFrame = static_cast<nsMouseEvent*>(aEvent)->ignoreRootScrollFrame;
- 6069 }
- 6070 nsIFrame* target = nsLayoutUtils::GetFrameForPoint(frame, eventPoint,
- 6071 false, ignoreRootScrollFrame);
- 6072 if (target) {
- 6073 frame = target;
- 6074 }
- 6075 }
- 6076 }
- 6077
- 6078 // if a node is capturing the mouse, check if the event needs to be
- 6079 // retargeted at the capturing content instead. This will be the case when
- 6080 // capture retargeting is being used, no frame was found or the frame's
- 6081 // content is not a descendant of the capturing content.
- 6082 if (capturingContent &&
- 6083 (gCaptureInfo.mRetargetToElement || !frame->GetContent() ||
- 6084 !nsContentUtils::ContentIsCrossDocDescendantOf(frame->GetContent(),
- 6085 capturingContent))) {
- 6086 // A check was already done above to ensure that capturingContent is
- 6087 // in this presshell.
- 6088 NS_ASSERTION(capturingContent->GetCurrentDoc() == GetDocument(),
- 6089 "Unexpected document");
- 6090 nsIFrame* capturingFrame = capturingContent->GetPrimaryFrame();
- 6091 if (capturingFrame) {
- 6092 frame = capturingFrame;
- 6093 }
- 6094 }
- 6095
- 6096 // Suppress mouse event if it's being targeted at an element inside
- 6097 // a document which needs events suppressed
- 6098 if (aEvent->eventStructType == NS_MOUSE_EVENT &&
- 6099 frame->PresContext()->Document()->EventHandlingSuppressed()) {
- 6100 if (aEvent->message == NS_MOUSE_BUTTON_DOWN) {
- 6101 mNoDelayedMouseEvents = true;
- 6102 } else if (!mNoDelayedMouseEvents && aEvent->message == NS_MOUSE_BUTTON_UP) {
- 6103 nsDelayedEvent* event =
- 6104 new nsDelayedMouseEvent(static_cast<nsMouseEvent*>(aEvent));
- 6105 if (!mDelayedEvents.AppendElement(event)) {
- 6106 delete event;
- 6107 }
- 6108 }
- 6109
- 6110 return NS_OK;
- 6111 }
- 6112
- 6113 PresShell* shell =
- 6114 static_cast<PresShell*>(frame->PresContext()->PresShell());
- 6115
- 6116 // Check if we have an active EventStateManager which isn't the6117 // EventStateManager of the current PresContext.
- 6118 // If that is the case, and mouse is over some ancestor document,
- 6119 // forward event handling to the active document.
- 6120 // This way content can get mouse events even when
- 6121 // mouse is over the chrome or outside the window.
- 6122 //
- 6123 // Note, currently for backwards compatibility we don't forward mouse events
- 6124 // to the active document when mouse is over some subdocument.
- 6125 nsEventStateManager* activeESM =
- 6126 nsEventStateManager::GetActiveEventStateManager();
- 6127 if (activeESM && NS_IS_MOUSE_EVENT(aEvent) &&
- 6128 activeESM != shell->GetPresContext()->EventStateManager() &&
- 6129 static_cast<nsEventStateManager*>(activeESM)->GetPresContext()) {
- 6130 nsIPresShell* activeShell =
- 6131 static_cast<nsEventStateManager*>(activeESM)->GetPresContext()->GetPresShell();
- 6132 if (activeShell &&
- 6133 nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(),
- 6134 shell->GetDocument())) {
- 6135 shell = static_cast<PresShell*>(activeShell);
- 6136 frame = shell->GetRootFrame();
- 6137 }
- 6138 }
- 6139
- 6140 if (shell != this) {
- 6141 // Handle the event in the correct shell.
- 6142 // Prevent deletion until we're done with event handling (bug 336582).
- 6143 nsCOMPtr<nsIPresShell> kungFuDeathGrip(shell);
- 6144 // We pass the subshell's root frame as the frame to start from. This is
- 6145 // the only correct alternative; if the event was captured then it
- 6146 // must have been captured by us or some ancestor shell and we
- 6147 // now ask the subshell to dispatch it normally.
- 6148 return shell->HandlePositionedEvent(frame, aEvent, aEventStatus);
- 6149 }
- 6150
- 6151 return HandlePositionedEvent(frame, aEvent, aEventStatus);
- 6152 }
- 6153
- 6154 nsresult rv = NS_OK;
- 6155
- 6156 if (frame) {
- 6157 PushCurrentEventInfo(nsnull, nsnull);
- 6158
- 6159 // key and IME related events go to the focused frame in this DOM window.
- 6160 if (NS_IsEventTargetedAtFocusedContent(aEvent)) {
- 6161 mCurrentEventContent = nsnull;
- 6162
- 6163 nsCOMPtr<nsPIDOMWindow> window =
- 6164 do_QueryInterface(mDocument->GetWindow());
- 6165 nsCOMPtr<nsPIDOMWindow> focusedWindow;
- 6166 nsCOMPtr<nsIContent> eventTarget =
- 6167 nsFocusManager::GetFocusedDescendant(window, false,
- 6168 getter_AddRefs(focusedWindow));
- 6169
- 6160 if (NS_IsEventTargetedAtFocusedContent(aEvent)) {
- 6161 mCurrentEventContent = nsnull;
- 6162
- 6163 nsCOMPtr<nsPIDOMWindow> window =
- 6164 do_QueryInterface(mDocument->GetWindow());
- 6165 nsCOMPtr<nsPIDOMWindow> focusedWindow;
- 6166 nsCOMPtr<nsIContent> eventTarget =
- 6167 nsFocusManager::GetFocusedDescendant(window, false,
- 6168 getter_AddRefs(focusedWindow));
- 6169
- 6170 // otherwise, if there is no focused content or the focused content has
- 6171 // no frame, just use the root content. This ensures that key events
- 6172 // still get sent to the window properly if nothing is focused or if a
- 6173 // frame goes away while it is focused.
- 6174 if (!eventTarget || !eventTarget->GetPrimaryFrame()) {
- 6175 nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
- 6176 if (htmlDoc) {
- 6177 nsCOMPtr<nsIDOMHTMLElement> body;
- 6178 htmlDoc->GetBody(getter_AddRefs(body));
- 6179 eventTarget = do_QueryInterface(body);
- 6180 if (!eventTarget) {
- 6181 eventTarget = mDocument->GetRootElement();
- 6182 }
- 6183 } else {
- 6184 eventTarget = mDocument->GetRootElement();
- 6185 }
- 6186 }
- 6187
- 6188 if (aEvent->message == NS_KEY_DOWN) {
- 6189 NS_IF_RELEASE(gKeyDownTarget);
- 6190 NS_IF_ADDREF(gKeyDownTarget = eventTarget);
- 6191 }
- 6192 else if ((aEvent->message == NS_KEY_PRESS || aEvent->message == NS_KEY_UP) &&
- 6193 gKeyDownTarget) {
- 6194 // If a different element is now focused for the keypress/keyup event
- 6195 // than what was focused during the keydown event, check if the new
- 6196 // focused element is not in a chrome document any more, and if so,
- 6197 // retarget the event back at the keydown target. This prevents a
- 6198 // content area from grabbing the focus from chrome in-between key
- 6199 // events.
- 6200 if (eventTarget &&
- 6201 nsContentUtils::IsChromeDoc(gKeyDownTarget->GetCurrentDoc()) !=
- 6202 nsContentUtils::IsChromeDoc(eventTarget->GetCurrentDoc())) {
- 6203 eventTarget = gKeyDownTarget;
- 6204 }
- 6205
- 6206 if (aEvent->message == NS_KEY_UP) {
- 6207 NS_RELEASE(gKeyDownTarget);
- 6208 }
- 6209 }
- 6210
- 6211 mCurrentEventFrame = nsnull;
- 6212 nsIDocument* targetDoc = eventTarget ? eventTarget->OwnerDoc() : nsnull;
- 6213 if (targetDoc && targetDoc != mDocument) {
- 6214 PopCurrentEventInfo();
- 6215 nsCOMPtr<nsIPresShell> shell = targetDoc->GetShell();
- 6216 if (shell) {
- 6217 rv = static_cast<PresShell*>(shell.get())->
- 6218 HandleRetargetedEvent(aEvent, aEventStatus, eventTarget);
- 6219 }
- 6220 return rv;
- 6221 } else {
- 6222 mCurrentEventContent = eventTarget;
- 6223 }
- 6224
- 6225 if (!mCurrentEventContent || !GetCurrentEventFrame() ||
- 6226 InZombieDocument(mCurrentEventContent)) {
- 6227 rv = RetargetEventToParent(aEvent, aEventStatus);
- 6228 PopCurrentEventInfo();
- 6229 return rv;
- 6230 }
- 6231 } else {
- 6232 mCurrentEventFrame = frame;
- 6233 }
- 6234 if (GetCurrentEventFrame()) {
- 6235 rv = HandleEventInternal(aEvent, aEventStatus);
- 6236 }
- 6237
- 6238 #ifdef NS_DEBUG
- 6239 ShowEventTargetDebug();
- 6240 #endif
- 6241 PopCurrentEventInfo();
- 6242 } else {
- 6243 // Activation events need to be dispatched even if no frame was found, since
- 6244 // we don't want the focus to be out of sync.
- 6245
- 6246 if (!NS_EVENT_NEEDS_FRAME(aEvent)) {
- 6247 mCurrentEventFrame = nsnull;
- 6248 return HandleEventInternal(aEvent, aEventStatus);
- 6249 }
- 6250 else if (NS_IS_KEY_EVENT(aEvent)) {
- 6251 // Keypress events in new blank tabs should not be completely thrown away.
- 6252 // Retarget them -- the parent chrome shell might make use of them.
- 6253 return RetargetEventToParent(aEvent, aEventStatus);
- 6254 }
- 6255 }
- 6256
- 6257 return rv;
- 6258 }
- #0 nsEventDispatcher::CreateEvent (aPresContext=0x7ffd59908800, aEvent=0x7fff47ee20d0, aEventType=..., aDOMEvent=0x7fff47ee1ee0)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventDispatcher.cpp:768
- #1 0x00007ffd706a5e19 in nsEventListenerManager::HandleEventInternal (this=0x7ffd5d914040, aPresContext=0x7ffd59908800, aEvent=0x7fff47ee20d0, aDOMEvent=
- 0x7fff47ee1ee0, aCurrentTarget=0x7ffd5d913ce0, aFlags=514, aEventStatus=0x7fff47ee1ee8, aPusher=0x7fff47ee1f10)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventListenerManager.cpp:788
- #2 0x00007ffd706d457a in nsEventListenerManager::HandleEvent (this=0x7ffd5d914040, aPresContext=0x7ffd59908800, aEvent=0x7fff47ee20d0, aDOMEvent=
- 0x7fff47ee1ee0, aCurrentTarget=0x7ffd5d913ce0, aFlags=514, aEventStatus=0x7fff47ee1ee8, aPusher=0x7fff47ee1f10)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventListenerManager.h:169
- #3 0x00007ffd706d4aaa in nsEventTargetChainItem::HandleEvent (this=0x7ffd5d51f0e0, aVisitor=..., aFlags=514, aMayHaveNewListenerManagers=false, aPusher=
- 0x7fff47ee1f10) at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventDispatcher.cpp:215
- #4 0x00007ffd706d50c5 in nsEventTargetChainItem::HandleEventTargetChain (this=0x7ffd5d51f070, aVisitor=..., aFlags=518, aCallback=0x7fff47ee2150,
- aMayHaveNewListenerManagers=false, aPusher=0x7fff47ee1f10) at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventDispatcher.cpp:370
- #5 0x00007ffd706d51f1 in nsEventTargetChainItem::HandleEventTargetChain (this=0x7ffd5d51f070, aVisitor=..., aFlags=6, aCallback=0x7fff47ee2150,
- aMayHaveNewListenerManagers=false, aPusher=0x7fff47ee1f10) at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventDispatcher.cpp:402
- #6 0x00007ffd706d62f2 in nsEventDispatcher::Dispatch (aTarget=0x7ffd594fc310, aPresContext=0x7ffd59908800, aEvent=0x7fff47ee20d0, aDOMEvent=0x0,
- aEventStatus=0x7fff47ee217c, aCallback=0x7fff47ee2150, aTargets=0x0)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventDispatcher.cpp:689
- #7 0x00007ffd706b4011 in nsEventStateManager::DispatchMouseEvent (this=0x7ffd635aa080, aEvent=0x7fff47ee2ce0, aMessage=332, aTargetContent=0x7ffd594fc310,
- aRelatedContent=0x0) at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventStateManager.cpp:3872
- #8 0x00007ffd706b45bd in nsEventStateManager::NotifyMouseOut (this=0x7ffd635aa080, aEvent=0x7fff47ee2ce0, aMovingInto=0x0)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventStateManager.cpp:3983
- #9 0x00007ffd706b44ad in nsEventStateManager::NotifyMouseOut (this=0x7ffd5d59da00, aEvent=0x7fff47ee2ce0, aMovingInto=0x0)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventStateManager.cpp:3955
- #10 0x00007ffd706b4c6a in nsEventStateManager::GenerateMouseEnterExit (this=0x7ffd5d59da00, aEvent=0x7fff47ee2ce0)
- at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventStateManager.cpp:4105
- #11 0x00007ffd706abf47 in nsEventStateManager::PreHandleEvent (this=0x7ffd5d59da00, aPresContext=0x7ffd5cb0c800, aEvent=0x7fff47ee2ce0, aTargetFrame=
- 0x7ffd5d52bc38, aStatus=0x7fff47ee2c14) at /home/diogogmt/mozilla-central-diogogmt/content/events/src/nsEventStateManager.cpp:1155
- #12 0x00007ffd7021dcfc in PresShell::HandleEventInternal (this=0x7ffd5cb5a000, aEvent=0x7fff47ee2ce0, aStatus=0x7fff47ee2c14)
- at /home/diogogmt/mozilla-central-diogogmt/layout/base/nsPresShell.cpp:6633
- #13 0x00007ffd7021d4aa in PresShell::HandlePositionedEvent (this=0x7ffd5cb5a000, aTargetFrame=0x7ffd5d52bc38, aEvent=0x7fff47ee2ce0, aEventStatus=
- 0x7fff47ee2c14) at /home/diogogmt/mozilla-central-diogogmt/layout/base/nsPresShell.cpp:6321
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement