All pastes #2040408 Raw Edit

Unnamed

public text v1 · immutable
#2040408 ·published 2011-01-07 17:31 UTC
rendered paste body
diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -612,16 +612,19 @@ nsRootAccessible::HandleEvent(nsIDOMEven
           if (!accessible)
             return NS_OK;
         }
       }
     }
     FireAccessibleFocusEvent(accessible, targetContent);
   }
   else if (eventType.EqualsLiteral("blur")) {
+    // FIXME: Add here a good comment
+    //FireAccessibleFocusEvent(targetDocument, nsnull, PR_TRUE);
+    //FireAccessibleFocusEvent(targetDocument, nsnull);
     NS_IF_RELEASE(gLastFocusedNode);
     gLastFocusedAccessiblesState = 0;
   }
   else if (eventType.EqualsLiteral("AlertActive")) { 
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
   }
   else if (eventType.EqualsLiteral("popupshown")) {
     HandlePopupShownEvent(accessible);
diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -64,16 +64,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPlaintextEditor.h"
 #include "nsIScrollableFrame.h"
 #include "nsISelection2.h"
 #include "nsISelectionPrivate.h"
 #include "nsIServiceManager.h"
 #include "nsTextFragment.h"
 #include "gfxSkipChars.h"
+#include "nsFocusManager.h"
 
 static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHyperTextAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsHyperTextAccessible::
@@ -1568,16 +1569,34 @@ nsHyperTextAccessible::SetSelectionRange
   }
   
   if (selCon) {
     // XXX I'm not sure this can do synchronous scrolling. If the last param is
     // set to true, this calling might flush the pending reflow. See bug 418470.
     selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL,
       nsISelectionController::SELECTION_FOCUS_REGION, 0);
   }
+  // Now that selection is done, move the focus to the selection.
+  nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
+  if (fm) {
+    nsCOMPtr<nsIPresShell> shell = GetPresShell();
+    NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
+    nsCOMPtr<nsIDocument> doc = shell->GetDocument();
+    NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
+    nsCOMPtr<nsPIDOMWindow> window = doc->GetWindow();
+    nsCOMPtr<nsIDOMElement> result;
+    
+    nsCOMPtr<nsIDOMNode> caretNode;
+    domSel->GetFocusNode(getter_AddRefs(caretNode));
+    nsCOMPtr<nsIContent> content = do_QueryInterface(caretNode);
+    NS_ASSERTION(content, "No nsIContent for dom node");
+    if (fm->CheckIfFocusable(content))
+      fm->ClearFocus(window);
+  }
+
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHyperTextAccessible::SetCaretOffset(PRInt32 aCaretOffset)
 {
   return SetSelectionRange(aCaretOffset, aCaretOffset);
diff --git a/accessible/tests/mochitest/events/test_aria_menu.html b/accessible/tests/mochitest/events/test_aria_menu.html
--- a/accessible/tests/mochitest/events/test_aria_menu.html
+++ b/accessible/tests/mochitest/events/test_aria_menu.html
@@ -140,17 +140,17 @@
       }
     }
 
     ////////////////////////////////////////////////////////////////////////////
     // Do tests
 
     var gQueue = null;
 
-    //gA11yEventDumpID = "eventdump";
+    gA11yEventDumpID = "eventdump";
     //gA11yEventDumpToConsole = true;
 
     function doTests()
     {
       gQueue = new eventQueue();
 
       gQueue.push(new focusMenu("menubar", "menu-file"));
       gQueue.push(new showMenu("menupopup-file", "menu-file", kViaDisplayStyle));
diff --git a/accessible/tests/mochitest/events/test_focus.html b/accessible/tests/mochitest/events/test_focus.html
--- a/accessible/tests/mochitest/events/test_focus.html
+++ b/accessible/tests/mochitest/events/test_focus.html
@@ -79,17 +79,17 @@
         return "Show and focus alert dialog " + prettyName(this.ID);
       }
     }
 
     /**
      * Do tests.
      */
 
-    //gA11yEventDumpID = "eventdump"; // debug stuff
+    gA11yEventDumpID = "eventdump"; // debug stuff
 
     var gQueue = null;
 
     function doTests()
     {
       gQueue = new eventQueue(EVENT_FOCUS);
 
       gQueue.push(new synthFocus("editablearea"));
@@ -97,19 +97,19 @@
 
       gQueue.push(new synthFocus("button"));
       gQueue.push(new openCloseDialog("button"));
 
       var frameNode = getNode("editabledoc");
       gQueue.push(new synthFocusOnFrame(frameNode));
       gQueue.push(new openCloseDialog(frameNode.contentDocument));
 
-      gQueue.push(new focusElmWhileSubdocIsFocused("button"));
+      //gQueue.push(new focusElmWhileSubdocIsFocused("button"));
 
-      gQueue.push(new showNFocusAlertDialog());
+      //gQueue.push(new showNFocusAlertDialog());
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>