diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-26 11:53:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-27 10:28:52 +0100 |
commit | 980c859480be431311ba803c5251694160dcb3d5 (patch) | |
tree | 57766be2cf7a0867e90148a3cb4ee32fc925d0d2 /vcl | |
parent | 2fcc04722d72dbadf8d3decd7a5014ec39b93d27 (diff) |
tdf#108642 load accessibility children faster
Reduces the cost of repeatedly iterating over the page objects, by
adding a new XAccessibleContext3 interface to return accesibility
children in one call.
This takes the load time from 5.6s to 3.2s.
Change-Id: Ifcc20fa7e7ab8ad50417073882c8c3a2405d1eaa
Reviewed-on: https://gerrit.libreoffice.org/83850
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/a11y/gtk3atklistener.cxx | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/vcl/unx/gtk3/a11y/gtk3atklistener.cxx b/vcl/unx/gtk3/a11y/gtk3atklistener.cxx index 600403773b92..8606b7bde5ab 100644 --- a/vcl/unx/gtk3/a11y/gtk3atklistener.cxx +++ b/vcl/unx/gtk3/a11y/gtk3atklistener.cxx @@ -29,10 +29,12 @@ #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleContext3.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include "atklistener.hxx" #include "atkwrapper.hxx" +#include <comphelper/sequence.hxx> #include <vcl/svapp.hxx> #include <sal/log.hxx> @@ -129,30 +131,38 @@ void AtkListener::updateChildList( css::uno::Reference<css::accessibility::XAccessibleContext> const & pContext) { - m_aChildList.clear(); - - uno::Reference< accessibility::XAccessibleStateSet > xStateSet = pContext->getAccessibleStateSet(); - if( xStateSet.is() - && !xStateSet->contains(accessibility::AccessibleStateType::DEFUNC) - && !xStateSet->contains(accessibility::AccessibleStateType::MANAGES_DESCENDANTS) ) - { - sal_Int32 nChildren = pContext->getAccessibleChildCount(); - m_aChildList.resize(nChildren); - for(sal_Int32 n = 0; n < nChildren; n++) - { - try - { - m_aChildList[n] = pContext->getAccessibleChild(n); - } - catch (lang::IndexOutOfBoundsException const&) - { - sal_Int32 nChildren2 = pContext->getAccessibleChildCount(); - assert(nChildren2 <= n && "consistency?"); - m_aChildList.resize(std::min(nChildren2, n)); - break; - } - } - } + m_aChildList.clear(); + + uno::Reference< accessibility::XAccessibleStateSet > xStateSet = pContext->getAccessibleStateSet(); + if( xStateSet.is() + && !xStateSet->contains(accessibility::AccessibleStateType::DEFUNC) + && !xStateSet->contains(accessibility::AccessibleStateType::MANAGES_DESCENDANTS) ) + { + css::uno::Reference<css::accessibility::XAccessibleContext3> xContext3(pContext, css::uno::UNO_QUERY); + if (xContext3.is()) + { + m_aChildList = comphelper::sequenceToContainer<std::vector<css::uno::Reference< css::accessibility::XAccessible >>>(xContext3->getAccessibleChildren()); + } + else + { + sal_Int32 nChildren = pContext->getAccessibleChildCount(); + m_aChildList.resize(nChildren); + for(sal_Int32 n = 0; n < nChildren; n++) + { + try + { + m_aChildList[n] = pContext->getAccessibleChild(n); + } + catch (lang::IndexOutOfBoundsException const&) + { + sal_Int32 nChildren2 = pContext->getAccessibleChildCount(); + assert(nChildren2 <= n && "consistency?"); + m_aChildList.resize(std::min(nChildren2, n)); + break; + } + } + } + } } /*****************************************************************************/ |