Bug 458418: onclick event doesn't fire on empty fixed position elements. r+sr=roc.
authorUri Bernstein <uriber@gmail.com>
Thu, 09 Oct 2008 12:35:56 +0200
changeset 20201 5ab2c2b2f3a06887ff4dc475b75c0ec6c3d7d17c
parent 20200 729436f1f0d3f929891bc1f9cd5b2b367d5a3713
child 20202 9929cf926c6295d9bc338b2e4cbc718303d1eaab
push idunknown
push userunknown
push dateunknown
bugs458418
milestone1.9.1b2pre
Bug 458418: onclick event doesn't fire on empty fixed position elements. r+sr=roc.
layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1903,33 +1903,37 @@ nsFrame::HandlePress(nsPresContext* aPre
   // check for select: none
   if (!selectable)
     return NS_OK;
 
   // When implementing NS_STYLE_USER_SELECT_ELEMENT, NS_STYLE_USER_SELECT_ELEMENTS and
   // NS_STYLE_USER_SELECT_TOGGLE, need to change this logic
   PRBool useFrameSelection = (selectStyle == NS_STYLE_USER_SELECT_TEXT);
 
-  nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
-  ContentOffsets offsets = GetContentOffsetsFromPoint(pt);
-
-  if (!IsMouseCaptured(aPresContext) && offsets.content) {
-    nsIFrame* capturingFrame = shell->GetPrimaryFrameFor(offsets.content);
-    if (capturingFrame)
-      capturingFrame->CaptureMouse(aPresContext, PR_TRUE);
-  }
-
   // XXX This is screwy; it really should use the selection frame, not the
   // event frame
   const nsFrameSelection* frameselection = nsnull;
   if (useFrameSelection)
     frameselection = GetConstFrameSelection();
   else
     frameselection = shell->ConstFrameSelection();
 
+  nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
+  ContentOffsets offsets = GetContentOffsetsFromPoint(pt);
+  
+  if (!IsMouseCaptured(aPresContext) && offsets.content) {
+    PRInt32 offset;
+    nsIFrame* capturingFrame = frameselection->
+      GetFrameForNodeOffset(offsets.content, offsets.offset, 
+                            nsFrameSelection::HINT(offsets.associateWithNext),
+                            &offset);
+    if (capturingFrame)
+      capturingFrame->CaptureMouse(aPresContext, PR_TRUE);
+  }
+    
   if (frameselection->GetDisplaySelection() == nsISelectionController::SELECTION_OFF)
     return NS_OK;//nothing to do we cannot affect selection from here
 
   nsMouseEvent *me = (nsMouseEvent *)aEvent;
 
 #ifdef XP_MACOSX
   if (me->isControl)
     return NS_OK;//short ciruit. hard coded for mac due to time restraints.