No Bug - Backout bug 375008 (6c59b73c8c4b) and re-enable test_focus.xul. r=distress
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 27 Feb 2013 15:53:41 +0000
changeset 123169 168340d9684b295392f11d5ebe9376e52179d70b
parent 123168 a28ab17cb0c05737acec405391f3f67d0063d5e5
child 123170 8e174d6ad4a8233c8671cece922b257d76ab9881
push id24373
push userryanvm@gmail.com
push dateThu, 28 Feb 2013 01:36:21 +0000
treeherdermozilla-central@8cb9d6981978 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdistress
bugs375008
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
No Bug - Backout bug 375008 (6c59b73c8c4b) and re-enable test_focus.xul. r=distress
content/events/src/nsEventStateManager.cpp
content/events/test/Makefile.in
content/events/test/test_focus_disabled.html
dom/tests/mochitest/chrome/Makefile.in
layout/style/forms.css
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -3126,48 +3126,18 @@ nsEventStateManager::PostHandleEvent(nsP
 
       nsCOMPtr<nsIContent> activeContent;
       if (nsEventStatus_eConsumeNoDefault != *aStatus) {
         nsCOMPtr<nsIContent> newFocus;      
         bool suppressBlur = false;
         if (mCurrentTarget) {
           mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(newFocus));
           const nsStyleUserInterface* ui = mCurrentTarget->StyleUserInterface();
+          suppressBlur = (ui->mUserFocus == NS_STYLE_USER_FOCUS_IGNORE);
           activeContent = mCurrentTarget->GetContent();
-
-          // In some cases, we do not want to even blur the current focused
-          // element. Those cases are:
-          // 1. -moz-user-focus CSS property is set to 'ignore';
-          // 2. Element with NS_EVENT_STATE_DISABLED
-          //    (aka :disabled pseudo-class for HTML element);
-          // 3. XUL control element has the disabled property set to 'true'.
-          //
-          // We can't use nsIFrame::IsFocusable() because we want to blur when
-          // we click on a visibility: none element.
-          // We can't use nsIContent::IsFocusable() because we want to blur when
-          // we click on a non-focusable element like a <div>.
-          // We have to use |aEvent->target| to not make sure we do not check an
-          // anonymous node of the targeted element.
-          suppressBlur = (ui->mUserFocus == NS_STYLE_USER_FOCUS_IGNORE);
-
-          if (!suppressBlur) {
-            nsCOMPtr<Element> element = do_QueryInterface(aEvent->target);
-            suppressBlur = element &&
-                           element->State().HasState(NS_EVENT_STATE_DISABLED);
-          }
-
-          if (!suppressBlur) {
-            nsCOMPtr<nsIDOMXULControlElement> xulControl =
-              do_QueryInterface(aEvent->target);
-            if (xulControl) {
-              bool disabled;
-              xulControl->GetDisabled(&disabled);
-              suppressBlur = disabled;
-            }
-          }
         }
 
         nsIFrame* currFrame = mCurrentTarget;
 
         // When a root content which isn't editable but has an editable HTML
         // <body> element is clicked, we should redirect the focus to the
         // the <body> element.  E.g., when an user click bottom of the editor
         // where is outside of the <body> element, the <body> should be focused
--- a/content/events/test/Makefile.in
+++ b/content/events/test/Makefile.in
@@ -96,17 +96,16 @@ MOCHITEST_FILES = \
 		test_wheel_default_action.html \
 		window_wheel_default_action.html \
 		test_bug603008.html \
 		test_bug716822.html \
 		test_bug742376.html \
 		test_dragstart.html \
 		test_bug812744.html \
 		test_addEventListenerExtraArg.html \
-		test_focus_disabled.html \
 		$(NULL)
 
 MOCHITEST_CHROME_FILES = \
 		test_bug336682_2.xul \
 		test_bug336682.js \
 		test_bug586961.xul \
 		test_bug415498.xul \
 		bug415498-doc1.html \
deleted file mode 100644
--- a/content/events/test/test_focus_disabled.html
+++ /dev/null
@@ -1,116 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=375008
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 375008</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375008">Mozilla Bug 375008</a>
-<p id="display"></p>
-<div id="content">
-  <div>
-    <input id='witness'>
-  </div>
-
-  <div id='not-focusable'>
-    <!-- Disabled elements -->
-    <button hidden disabled>foo</button>
-    <input hidden disabled>
-    <fieldset hidden disabled>foo</fieldset>
-    <select hidden disabled><option>foo</option></select>
-    <textarea hidden disabled></textarea>
-    <optgroup hidden disabled><option>foo</option></optgroup>
-    <option hidden disabled>foo</option>
-  </div>
-
-  <div id='focusable'>
-    <button hidden>foo</button>
-    <input hidden>
-    <select hidden><option>foo</option></select>
-    <textarea hidden></textarea>
-
-    <!-- Those elements are not focusable by default. -->
-    <fieldset tabindex=1 hidden>foo</fieldset>
-    <optgroup tabindex=1 hidden><option>foo</option></optgroup>
-    <option tabindex=1 hidden>foo</option>
-  </div>
-
-  <!-- Hidden elements, they have a frame but focus will go through them. -->
-  <div id='hidden' style='visibility: hidden;'>
-    <button hidden>foo</button>
-    <input hidden>
-    <fieldset hidden>foo</fieldset>
-    <select hidden><option>foo</option></select>
-    <textarea hidden></textarea>
-    <optgroup hidden><option>foo</option></optgroup>
-    <option hidden>foo</option>
-  </div>
-
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 375008 **/
-
-/*
- * This test is divided in three parts:
- * - cases where focus isn't doable but blur should not happen;
- * - cases where focus is doable;
- * - cases where focus isn't doable but blur should still happen.
- */
-
-SimpleTest.waitForExplicitFinish();
-SimpleTest.waitForFocus(function() {
-  var witness = document.getElementById('witness');
-  witness.focus();
-
-  var notFocusableElements = document.getElementById('not-focusable').children;
-  for (var i=0; i<notFocusableElements.length; ++i) {
-    var element = notFocusableElements[i];
-    element.hidden = false;
-    synthesizeMouseAtCenter(element, {});
-    is(document.activeElement, witness,
-       "[" + element.tagName + "] witness should still be focused");
-
-    // Cleanup.
-    witness.focus();
-  }
-
-  var focusableElements = document.getElementById('focusable').children;
-  for (var i=0; i<focusableElements.length; ++i) {
-    var element = focusableElements[i];
-    element.hidden = false;
-    synthesizeMouseAtCenter(element, {});
-    is(document.activeElement, element, "focus should have moved to " + element);
-
-    // Cleanup.
-    element.hidden = true;
-    witness.focus();
-  }
-
-  var hiddenElements = document.getElementById('hidden').children;
-  for (var i=0; i<hiddenElements.length; ++i) {
-    var element = hiddenElements[i];
-    element.hidden = false;
-    synthesizeMouseAtCenter(element, {});
-    is(document.activeElement, document.body,
-       "focus should have moved to the body");
-
-    // Cleanup.
-    element.hidden = true;
-    witness.focus();
-  }
-
-  SimpleTest.finish();
-});
-
-</script>
-</pre>
-</body>
-</html>
--- a/dom/tests/mochitest/chrome/Makefile.in
+++ b/dom/tests/mochitest/chrome/Makefile.in
@@ -16,16 +16,17 @@ MOCHITEST_CHROME_FILES = \
 		test_fullscreen.xul \
 		fullscreen.xul \
 		test_fullscreen_preventdefault.xul \
 		fullscreen_preventdefault.xul \
 		focus_window2.xul \
 		focus_frameset.html \
 		child_focus_frame.html \
 		test_focus_switchbinding.xul \
+		test_focus.xul \
 		window_focus.xul \
 		test_focused_link_scroll.xul \
 		test_geolocation.xul \
 		test_activation.xul \
 		window_activation.xul \
 		test_DOMWindowCreated.xul \
 		DOMWindowCreated_chrome.xul \
 		DOMWindowCreated_content.html \
--- a/layout/style/forms.css
+++ b/layout/style/forms.css
@@ -357,16 +357,17 @@ optgroup:before {
 input:disabled,
 textarea:disabled,
 option:disabled,
 optgroup:disabled,
 select:disabled:disabled /* Need the pseudo-class twice to have the specificity
                             be at least the same as select[size][multiple] above */
 {
   -moz-user-input: disabled;
+  -moz-user-focus: ignore;
   color: GrayText;
   background-color: ThreeDFace;
   cursor: inherit;
 }
 
 input:disabled > .anonymous-div,
 textarea:disabled > .anonymous-div {
   cursor: default;