Bug 1496242 - Part III, nsFocusManager should account for UA Widget when deciding to traverse into NAC r=smaug
authorTimothy Guan-tin Chien <timdream@gmail.com>
Mon, 29 Oct 2018 19:51:17 +0000
changeset 444230 4ec5f59ab7236bce89f734ccdea1ec4c7f5fd95d
parent 444229 66df568f60f633bb8e361be0a256cb4490330bf8
child 444327 6655fa7cff4800390e15d164968923da168ce7c8
push id72267
push usertchien@mozilla.com
push dateSat, 03 Nov 2018 05:35:18 +0000
treeherderautoland@4ec5f59ab723 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1496242, 1430692
milestone65.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
Bug 1496242 - Part III, nsFocusManager should account for UA Widget when deciding to traverse into NAC r=smaug In bug 1430692, a special case was added in nsFocusManager::GetNextTabbableContentInScope() that traverse into the element when the primany frame implements nsIAnonymousContentCreator, assuming there will be NAC to focus within. This is not the case when UA Widget is turned on, where the focusable inner inputs will be put in the UA Widget Shadow DOM. The change here account this fact. Depends on D9057 Differential Revision: https://phabricator.services.mozilla.com/D9303
dom/base/nsFocusManager.cpp
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -3308,20 +3308,28 @@ nsFocusManager::GetNextTabbableContentIn
         frame->IsFocusable(&tabIndex, 0);
       }
       if (tabIndex < 0 || !(aIgnoreTabIndex || tabIndex == aCurrentTabIndex)) {
         // If the element has native anonymous content, we may need to
         // focus some NAC element, even if the element itself isn't focusable.
         // This happens for example with <input type="date">.
         // So, try to find NAC and then traverse the frame tree to find elements
         // to focus.
+        // Yet, even if the frame is a nsIAnonymousContentCreator, don't
+        // traverse into the element again when the element is in a UA Widget,
+        // because there isn't any NAC to focus.
         nsIFrame* possibleAnonOwnerFrame = iterContent->GetPrimaryFrame();
         nsIAnonymousContentCreator* anonCreator =
           do_QueryFrame(possibleAnonOwnerFrame);
-        if (anonCreator && !iterContent->IsInNativeAnonymousSubtree()) {
+        bool isIterContentInUAWidgetShadow =
+          iterContent->GetContainingShadow() &&
+          iterContent->GetContainingShadow()->IsUAWidget();
+        if (anonCreator &&
+            !isIterContentInUAWidgetShadow &&
+            !iterContent->IsInNativeAnonymousSubtree()) {
           nsIFrame* frame = nullptr;
           // Find the first or last frame in tree order so that
           // we can scope frame traversing to NAC.
           if (aForward) {
             frame = possibleAnonOwnerFrame->PrincipalChildList().FirstChild();
           } else {
             frame = possibleAnonOwnerFrame->PrincipalChildList().LastChild();
             nsIFrame* last = frame;