[Libreoffice-commits] core.git: editeng/source include/editeng svx/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 7 15:52:25 UTC 2021
editeng/source/accessibility/AccessibleParaManager.cxx | 11 ++++++
include/editeng/AccessibleParaManager.hxx | 1
svx/source/accessibility/AccessibleTextHelper.cxx | 29 +++--------------
3 files changed, 18 insertions(+), 23 deletions(-)
New commits:
commit 4c76bcb5f35527283c6070fc8e3911a35734eba1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jul 6 20:53:06 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 7 17:51:52 2021 +0200
tdf#132740 avoid some WeakReference cost in accessibility
reduces time by 20% for me
Change-Id: Ife78248fd36099298eb2401b362f16a1ae3c0434
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118534
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/accessibility/AccessibleParaManager.cxx b/editeng/source/accessibility/AccessibleParaManager.cxx
index 2fb3006da7b7..12aff3e2df63 100644
--- a/editeng/source/accessibility/AccessibleParaManager.cxx
+++ b/editeng/source/accessibility/AccessibleParaManager.cxx
@@ -144,6 +144,17 @@ namespace accessibility
}
}
+ bool AccessibleParaManager::HasCreatedChild( sal_Int32 nParagraphIndex ) const
+ {
+ if( 0 <= nParagraphIndex && maChildren.size() > o3tl::make_unsigned(nParagraphIndex) )
+ {
+ auto const & rChild = maChildren[ nParagraphIndex ];
+ return rChild.second.Width != 0 || rChild.second.Height != 0;
+ }
+ else
+ return false;
+ }
+
AccessibleParaManager::Child AccessibleParaManager::CreateChild( sal_Int32 nChild,
const uno::Reference< XAccessible >& xFrontEnd,
SvxEditSourceAdapter& rEditSource,
diff --git a/include/editeng/AccessibleParaManager.hxx b/include/editeng/AccessibleParaManager.hxx
index d496be8afb28..5330e1100893 100644
--- a/include/editeng/AccessibleParaManager.hxx
+++ b/include/editeng/AccessibleParaManager.hxx
@@ -138,6 +138,7 @@ namespace accessibility
sal_Int32 nParagraphIndex );
WeakChild GetChild( sal_Int32 nParagraphIndex ) const;
+ bool HasCreatedChild( sal_Int32 nParagraphIndex ) const;
// forwarder to all paragraphs
/// Make all children active and editable (or off)
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index f8ff9013e929..9fbd897ea519 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -761,9 +761,7 @@ namespace accessibility
if (mxFrontEnd.is() && bBroadcastEvents)
{
// child not yet created?
- ::accessibility::AccessibleParaManager::WeakChild aChild( maParaManager.GetChild(nCurrPara) );
- if( aChild.second.Width == 0 &&
- aChild.second.Height == 0 )
+ if (!maParaManager.HasCreatedChild(nCurrPara))
{
GotPropertyEvent( uno::makeAny( maParaManager.CreateChild( nCurrPara - mnFirstVisibleChild,
mxFrontEnd, GetEditSource(), nCurrPara ).first ),
@@ -787,15 +785,12 @@ namespace accessibility
}
}
- namespace {
-
- // functor for checking changes in paragraph bounding boxes (no stand-alone function, maybe not inlined)
- class AccessibleTextHelper_UpdateChildBounds
+ void AccessibleTextHelper_Impl::UpdateBoundRect()
{
- public:
- explicit AccessibleTextHelper_UpdateChildBounds() {}
- ::accessibility::AccessibleParaManager::WeakChild operator()( const ::accessibility::AccessibleParaManager::WeakChild& rChild )
+ // send BOUNDRECT_CHANGED to affected children
+ for(auto it = maParaManager.begin(); it != maParaManager.end(); ++it)
{
+ ::accessibility::AccessibleParaManager::WeakChild& rChild = *it;
// retrieve hard reference from weak one
auto aHardRef( rChild.first.get() );
@@ -813,22 +808,10 @@ namespace accessibility
aHardRef->FireEvent( AccessibleEventId::BOUNDRECT_CHANGED );
// update internal bounds
- return ::accessibility::AccessibleParaManager::WeakChild( rChild.first, aNewRect );
+ rChild = ::accessibility::AccessibleParaManager::WeakChild( rChild.first, aNewRect );
}
}
-
- // identity transform
- return rChild;
}
- };
-
- }
-
- void AccessibleTextHelper_Impl::UpdateBoundRect()
- {
- // send BOUNDRECT_CHANGED to affected children
- AccessibleTextHelper_UpdateChildBounds aFunctor;
- ::std::transform( maParaManager.begin(), maParaManager.end(), maParaManager.begin(), aFunctor );
}
#ifdef DBG_UTIL
More information about the Libreoffice-commits
mailing list