Make updateKeyboardFocus a bit more efficient

master
Andrey Kleshchev 2024-09-10 19:26:16 +03:00
parent f90712b983
commit d6eafa1bdb
1 changed files with 13 additions and 3 deletions

View File

@ -3888,7 +3888,9 @@ void LLViewerWindow::updateKeyboardFocus()
LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
if (cur_focus)
{
if (!cur_focus->isInVisibleChain() || !cur_focus->isInEnabledChain())
bool is_in_visible_chain = cur_focus->isInVisibleChain();
bool is_in_enabled_chain = cur_focus->isInEnabledChain();
if (!is_in_visible_chain || !is_in_enabled_chain)
{
// don't release focus, just reassign so that if being given
// to a sibling won't call onFocusLost on all the ancestors
@ -3899,11 +3901,19 @@ void LLViewerWindow::updateKeyboardFocus()
bool new_focus_found = false;
while(parent)
{
if (!is_in_visible_chain)
{
is_in_visible_chain = parent->isInVisibleChain();
}
if (!is_in_enabled_chain)
{
is_in_enabled_chain = parent->isInEnabledChain();
}
if (parent->isCtrl()
&& (parent->hasTabStop() || parent == focus_root)
&& !parent->getIsChrome()
&& parent->isInVisibleChain()
&& parent->isInEnabledChain())
&& is_in_visible_chain
&& is_in_enabled_chain)
{
if (!parent->focusFirstItem())
{