Bug 1607223 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(In reply to Edgar Chen [:edgar] from comment #0)
> While debugging bug 1604140, I found this issue in the frame traversal logic around https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3356-3569.

What happens here is that: when we traverse to the first element inside the shadow dom, the `currentContent` points to the element and `oldTopLevelScopeOwner` is nullptr, so we do https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3362 which sets `currentTopLevelScopeOwner` to the shadow host. And then we run into the if-block in https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3431-3448, but do nothing, because the tabindex of shadow host doesn't match with the index we are looking for.

And then we unexpected check the `currentContent` again, which is wrong, because we have already checked the whole scope in the above if-block https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3431-3448. And we mean to check the `currentContent` only when it is in top-level-scope, https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3366-3380 will do the filter job.
(In reply to Edgar Chen [:edgar] from comment #0)
> While debugging bug 1604140, I found this issue in the frame traversal logic around https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3356-3569.

What happens here is that: when we traverse to the first element inside the shadow dom, the `currentContent` points to the element and `oldTopLevelScopeOwner` is nullptr, so we do https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3362 which sets `currentTopLevelScopeOwner` to the shadow host. And then we run into the if-block in https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3431-3448, but do nothing, because the tabindex of shadow host doesn't match with the index we are looking for.

And then we unexpected check the `currentContent` again, which is wrong, because we have already checked the whole scope in the above if-block https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3431-3448. And we mean to check the `currentContent` only when it is in top-level-scope, https://searchfox.org/mozilla-central/rev/9b99e1d9c6cf83539674cb016c7373f549ba59ca/dom/base/nsFocusManager.cpp#3366-3380 should do the filter job.

Back to Bug 1607223 Comment 1